]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/capsicum-test/GNUmakefile
compiler-rt: re-exec with ASLR disabled when necessary
[FreeBSD/FreeBSD.git] / contrib / capsicum-test / GNUmakefile
1 OS:=$(shell uname)
2
3 # Set ARCH to 32 or x32 for i386/x32 ABIs
4 ARCH?=64
5 ARCHFLAG=-m$(ARCH)
6
7 ifeq ($(OS),FreeBSD)
8 EXTRA_LIBS=-lprocstat
9 endif
10
11 ifeq ($(OS),Linux)
12 PROCESSOR:=$(shell uname -p)
13
14 ifneq ($(wildcard /usr/lib/$(PROCESSOR)-linux-gnu),)
15 # Can use standard Debian location for static libraries.
16 PLATFORM_LIBDIR=/usr/lib/$(PROCESSOR)-linux-gnu
17 else
18 # Attempt to determine library location from gcc configuration.
19 PLATFORM_LIBDIR=$(shell gcc -v 2>&1 | grep "Configured with:" | sed 's/.*--libdir=\(\/usr\/[^ ]*\).*/\1/g')
20 endif
21
22 # Override for explicitly specified ARCHFLAG.
23 # Use locally compiled libcaprights in this case, on the
24 # assumption that any installed version is 64-bit.
25 ifeq ($(ARCHFLAG),-m32)
26 PROCESSOR=i386
27 PLATFORM_LIBDIR=/usr/lib32
28 LIBCAPRIGHTS=./libcaprights.a
29 endif
30 ifeq ($(ARCHFLAG),-mx32)
31 PROCESSOR=x32
32 PLATFORM_LIBDIR=/usr/libx32
33 LIBCAPRIGHTS=./libcaprights.a
34 endif
35
36 # Detect presence of libsctp in normal Debian location
37 ifneq ($(wildcard $(PLATFORM_LIBDIR)/libsctp.a),)
38 LIBSCTP=-lsctp
39 CXXFLAGS=-DHAVE_SCTP
40 endif
41
42 ifneq ($(LIBCAPRIGHTS),)
43 # Build local libcaprights.a (assuming ./configure
44 # has already been done in libcaprights/)
45 LOCAL_LIBS=$(LIBCAPRIGHTS)
46 LIBCAPRIGHTS_OBJS=libcaprights/capsicum.o libcaprights/linux-bpf-capmode.o libcaprights/procdesc.o libcaprights/signal.o
47 LOCAL_CLEAN=$(LOCAL_LIBS) $(LIBCAPRIGHTS_OBJS)
48 else
49 # Detect installed libcaprights static library.
50 ifneq ($(wildcard $(PLATFORM_LIBDIR)/libcaprights.a),)
51 LIBCAPRIGHTS=$(PLATFORM_LIBDIR)/libcaprights.a
52 else
53 ifneq ($(wildcard /usr/lib/libcaprights.a),)
54 LIBCAPRIGHTS=/usr/lib/libcaprights.a
55 endif
56 endif
57 endif
58
59 endif
60
61 # Extra test programs for arch-transition tests
62 EXTRA_PROGS = mini-me.32 mini-me.64
63 ifneq ($(wildcard /usr/include/gnu/stubs-x32.h),)
64 EXTRA_PROGS += mini-me.x32
65 endif
66
67 # Chain on to the master makefile
68 include makefile
69
70 ./libcaprights.a: $(LIBCAPRIGHTS_OBJS)
71         ar cr $@ $^
72
73 # Small static programs of known architectures
74 # These may require additional packages to be installed; for example, for Debian:
75 #  - libc6-dev-i386 provides 32-bit headers for a 64-bit system
76 #  - libc6-dev-x32 provides headers for the x32 ABI.
77 mini-me.32: mini-me.c
78         $(CC) $(CFLAGS) -m32 -static -o $@ $<
79 mini-me.x32: mini-me.c
80         $(CC) $(CFLAGS) -mx32 -static -o $@ $<
81 mini-me.64: mini-me.c
82         $(CC) $(CFLAGS) -m64 -static -o $@ $<