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