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

lib_LTLIBRARIES = libsandbox.la
bin_PROGRAMS = sandbox

AM_CPPFLAGS = \
	-D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT  \
        -DLIBSANDBOX_PATH=\"$(libdir)\"         \
        -DSANDBOX_BASHRC_PATH=\"$(pkgdatadir)\" \
	-I$(top_srcdir)

LOCAL_INCLUDES = $(top_srcdir)/localdecls.h

# We need -fexceptions here, else we do not catch exceptions
# (nptl/tst-cancelx4.c in glibc among others fails for wrapped functions).
libsandbox_la_CFLAGS = -fexceptions
# Do not add -nostdlib or -nostartfiles, as then our constructor
# and destructor will not be executed ...
libsandbox_la_LIBADD = -lc -ldl
libsandbox_la_LDFLAGS = \
	-nodefaultlibs \
	-Wl,--version-script,libsandbox.map
libsandbox_la_SOURCES = \
	libsandbox.c \
	$(LOCAL_INCLUDES)

sandbox_CFLAGS = -DOUTSIDE_LIBSANDBOX
sandbox_SOURCES = \
	sandbox.c        \
	sandbox.h        \
	sandbox_futils.c \
	getcwd.c         \
	$(LOCAL_INCLUDES)

libsandbox.c: libsandbox.map symbols.h

SYMBOLS_FILE = $(srcdir)/symbols.in
SYMBOLS_LIST = $(shell $(EGREP) -v '^\#' $(SYMBOLS_FILE))
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)
	@echo "Generating $@"; \
	if [ ! -e "$(LIBC_PATH)" ]; then\
		echo -e "\n*** Cannot find LIBC_PATH '$(LIBC_PATH)' !\n"; \
		exit 1; \
	fi; \
	export SYMBOLS="$(SYMBOLS_LIST)"; \
	if ! $(READELF) -s $(LIBC_PATH) | \
		$(AWK) -f $(GEN_VERSION_MAP_SCRIPT) > $@ ; \
	then \
		echo "\n*** Failed to generate '$@' !\n"; \
		exit 1; \
	fi

symbols.h: $(SYMBOLS_FILE) $(GEN_HEADER_SCRIPT)
	@echo "Generating $@"; \
	if [ ! -e "$(LIBC_PATH)" ]; then\
		echo -e "\n*** Cannot find LIBC_PATH '$(LIBC_PATH)' !\n"; \
		exit 1; \
	fi; \
	export SYMBOLS="$(SYMBOLS_LIST)"; \
	if ! $(READELF) -s $(LIBC_PATH) | \
		$(AWK) -f $(GEN_HEADER_SCRIPT) > $@ ; \
	then \
		echo "\n*** Failed to generate '$@' !\n"; \
		exit 1; \
	fi

EXTRA_DIST = canonicalize.c $(SYMBOLS_FILE)

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