aboutsummaryrefslogtreecommitdiff
blob: 97d886476250a656aeb10593983ef9e3268680d2 (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
AUTOMAKE_OPTIONS = foreign

lib_LTLIBRARIES = libsandbox.la

AM_CPPFLAGS = \
	$(SANDBOX_DEFINES) \
	-DPIC -fPIC

INCLUDES = \
	-I$(top_srcdir) \
	-I$(top_srcdir)/libsbutil \
	-I$(top_srcdir)/libsbutil/include

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:
#	$(top_builddir)/libsbutil/libsbutil.la
libsandbox_la_LIBSBLIB = $(top_builddir)/libsbutil/.libs/libsbutil.a
libsandbox_la_LIBADD = \
	-lc $(LIBDL) \
	$(libsandbox_la_LIBSBLIB)
# Do not add -nostdlib or -nostartfiles, as then our constructor
# and destructor will not be executed ...
libsandbox_la_LDFLAGS = \
	-no-undefined \
	-nodefaultlibs \
	-avoid-version \
	$(LDFLAG_VER),libsandbox.map
libsandbox_la_SOURCES = \
	libsandbox.h \
	libsandbox.c \
	memory.c     \
	wrappers.h   \
	wrappers.c   \
	canonicalize.c

libsandbox.c: libsandbox.map sb_nr.h
wrappers.c: symbols.h

SYMBOLS_FILE = $(srcdir)/symbols.h.in
SYMBOLS_LIST = $(shell $(SED) -n '/^[^\#]/p' $(SYMBOLS_FILE))
SYMBOLS_WRAPPERS = $(wildcard  $(srcdir)/wrapper-funcs/*.[ch])
GEN_VERSION_MAP_SCRIPT = $(top_srcdir)/scripts/gen_symbol_version_map.awk
GEN_HEADER_SCRIPT = $(top_srcdir)/scripts/gen_symbol_header.awk

libsandbox.map: $(SYMBOLS_FILE) $(GEN_VERSION_MAP_SCRIPT)
	$(READELF) -s $(LIBC_PATH) | \
		LC_ALL=C $(AWK) -v SYMBOLS_LIST="$(SYMBOLS_LIST)" -f $(GEN_VERSION_MAP_SCRIPT) > $@

symbols.h: $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(GEN_HEADER_SCRIPT)
	$(READELF) -s $(LIBC_PATH) | \
		LC_ALL=C $(AWK) -v SYMBOLS_LIST="$(SYMBOLS_LIST)" -f $(GEN_HEADER_SCRIPT) > $@

SB_NR_FILE = $(srcdir)/sb_nr.h.in
sb_nr.h: symbols.h $(SB_NR_FILE)
	$(EGREP) -h '^\#define SB_' $^ > $@

EXTRA_DIST = $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(SB_NR_FILE)

CLEANFILES = libsandbox.map sb_nr.h symbols.h
DISTCLEANFILES = $(CLEANFILES)