aboutsummaryrefslogtreecommitdiff
blob: 17158c74492ecb5a2da1442b55ca1a13ae60b889 (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
AUTOMAKE_OPTIONS	= dist-bzip2 no-dist-gzip
EXTRA_DIST		= sandbox.bashrc canonicalize.c libctest.c
CLEANFILES		= symbols.h

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

dist_pkgdata_DATA	= sandbox.bashrc

lib_LTLIBRARIES 	= libsandbox.la
nodist_EXTRA_libsandbox_la_SOURCES = symbols.h
libsandbox_la_SOURCES 	= libsandbox.c sandbox_futils.c localdecls.h
libsandbox_la_LDFLAGS 	= -Wc,-nostdlib -Wc,-nodefaultlibs -lc -ldl
# 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

bin_PROGRAMS		= sandbox
sandbox_SOURCES		= sandbox.c sandbox.h sandbox_futils.c getcwd.c
sandbox_CFLAGS		= -DOUTSIDE_LIBSANDBOX

libsandbox.c: symbols.h

# Basically generates symbols.h from the function names in symbols.in.
# Not sure if we can count on the latest version the only symbol
# countaining '@@' ...
symbols.h: symbols.in
	@echo "Generating $@"; \
	if [ ! -e "$(libdir)/$(LIBC_VERSION)" ]; then\
		echo -e "\n*** Cannot find $(libdir)/$(LIBC_VERSION)!\n"; \
		exit 1; \
	fi; \
	echo "#ifndef __symbol_h" > $@; \
	echo -e "#define __symbol_h\n" >> $@; \
	for x in `cat $^`; do \
		sym=`readelf -s "$(libdir)/$(LIBC_VERSION)" 2>/dev/null | \
			awk '{ print $$8 }' | \
			grep "^$${x}@@" | \
			cut -d'@' -f3`; \
		echo "#define symname_$${x} \"$${x}\"" >> $@; \
		if [ -n "$${sym}" ]; then \
			echo "#define symver_$${x} \"$${sym}\"" >> $@; \
		else \
			echo "#define symver_$${x} NULL" >> $@; \
		fi; \
	done; \
	echo -e "\n#endif /* __symbol_h */" >> $@