blob: dd78a76175c915f9cb49821dc1c352ad477b3858 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
lib_LTLIBRARIES += %D%/libsandbox.la
%C%_libsandbox_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
-I%D% \
-I$(top_srcdir)/%D% \
-I$(top_srcdir)/libsbutil \
-I$(top_srcdir)/libsbutil/include
%C%_libsandbox_la_CFLAGS = $(CFLAG_EXCEPTIONS)
# Could use the following to libsandbox_la_LIBADD, but then libtool links it
# with --whole-archive, and libsandbox.so increase with a few KB in size:
# libsbutil/libsbutil.la
libsbutil/.libs/libsbutil.a: libsbutil/libsbutil.la
%C%_libsandbox_la_LIBSBLIB = libsbutil/.libs/libsbutil.a
%C%_libsandbox_la_LIBADD = \
-lc $(LIBDL) \
$(%C%_libsandbox_la_LIBSBLIB)
# Do not add -nostdlib or -nostartfiles, as then our constructor
# and destructor will not be executed ...
%C%_libsandbox_la_LDFLAGS = \
-no-undefined \
-avoid-version \
$(LDFLAG_VER),%D%/libsandbox.map
%C%_libsandbox_la_SOURCES = \
%D%/libsandbox.h \
%D%/libsandbox.c \
%D%/lock.c \
%D%/memory.c \
%D%/pre_check_at.c \
%D%/pre_check_mkdirat.c \
%D%/pre_check_openat64.c \
%D%/pre_check_openat.c \
%D%/pre_check_unlinkat.c \
%D%/trace.c \
%D%/wrappers.h \
%D%/wrappers.c \
%D%/canonicalize.c
install-exec-hook:
rm -f $(DESTDIR)$(libdir)/libsandbox.la
# Since we removed the .la file, libtool uninstall doesn't work,
# so we have to manually uninstall libsandbox.so ourselves.
uninstall-hook:
rm -f $(DESTDIR)$(libdir)/libsandbox.so
%D%/libsandbox.c: %D%/libsandbox.map %D%/sb_nr.h
%D%/trace.c: %D%/trace_syscalls.h %D%/sb_nr.h $(TRACE_FILES)
%D%/wrappers.c: %D%/symbols.h
TRACE_FILES = $(wildcard $(top_srcdir)/%D%/trace/*.[ch] $(top_srcdir)/%D%/trace/*/*.[ch])
SCRIPT_DIR = $(top_srcdir)/scripts
SYMBOLS_FILE = $(top_srcdir)/%D%/symbols.h.in
SYMBOLS_WRAPPERS = $(wildcard $(top_srcdir)/%D%/wrapper-funcs/*.[ch])
GEN_VERSION_MAP_SCRIPT = $(SCRIPT_DIR)/gen_symbol_version_map.awk
GEN_HEADER_SCRIPT = $(SCRIPT_DIR)/gen_symbol_header.awk
GEN_TRACE_SCRIPT = $(SCRIPT_DIR)/gen_trace_header.awk
SB_AWK = LC_ALL=C $(AWK) -v SYMBOLS_FILE="$(SYMBOLS_FILE)" -v srcdir="$(top_srcdir)/%D%" -f
%D%/libsandbox.map: $(SYMBOLS_FILE) $(GEN_VERSION_MAP_SCRIPT)
@$(MKDIR_P) %D%
$(AM_V_GEN)$(READELF) -sW $(LIBC_PATH) | $(SB_AWK) $(GEN_VERSION_MAP_SCRIPT) > $@
%D%/symbols.h: $(SYMBOLS_FILE) $(GEN_HEADER_SCRIPT)
@$(MKDIR_P) %D%
$(AM_V_GEN)$(READELF) -sW $(LIBC_PATH) | $(SB_AWK) $(GEN_HEADER_SCRIPT) > $@
SB_NR_FILE = %D%/sb_nr.h.in
%D%/sb_nr.h: %D%/symbols.h $(SB_NR_FILE)
@$(MKDIR_P) %D%
$(AM_V_GEN)$(EGREP) -h '^\#define SB_' $^ > $@
TRACE_MAKE_HEADER = \
$(SB_AWK) $(GEN_TRACE_SCRIPT) -v MODE=gen | \
$(COMPILE) -E -P -include $(top_srcdir)/headers.h - $$f | \
$(SB_AWK) $(GEN_TRACE_SCRIPT) -v syscall_prefix=$$t > $$header
%D%/trace_syscalls.h: $(SYMBOLS_FILE) $(GEN_TRACE_SCRIPT) $(SB_PERSONALITIES_HEADERS)
@$(MKDIR_P) %D%
if SB_PERSONALITIES
$(AM_V_GEN)touch $@
else
$(AM_V_GEN)t= f= header=$@; $(TRACE_MAKE_HEADER)
endif
$(SB_PERSONALITIES_HEADERS): $(SYMBOLS_FILE) $(GEN_TRACE_SCRIPT)
@$(MKDIR_P) %D%
$(AM_V_GEN)for pers in $(SB_PERSONALITIES_SETTINGS) ; do \
t=_$${pers%:*}; \
f=$${pers#*:}; \
header="%D%/trace_syscalls$${t}.h"; \
if [ "$$header" = "$@" ]; then \
$(TRACE_MAKE_HEADER) || exit $$?; \
break; \
fi; \
done
EXTRA_DIST += $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(SB_NR_FILE) $(TRACE_FILES)
CLEANFILES += \
%D%/libsandbox.map \
%D%/sb_nr.h \
%D%/symbols.h \
%D%/trace_syscalls*.h
|