3 # Set ARCH to 32 or x32 for i386/x32 ABIs
8 PROCESSOR:=$(shell uname -p)
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
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')
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)
23 PLATFORM_LIBDIR=/usr/lib32
24 LIBCAPRIGHTS=./libcaprights.a
26 ifeq ($(ARCHFLAG),-mx32)
28 PLATFORM_LIBDIR=/usr/libx32
29 LIBCAPRIGHTS=./libcaprights.a
32 # Detect presence of libsctp in normal Debian location
33 ifneq ($(wildcard $(PLATFORM_LIBDIR)/libsctp.a),)
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)
45 # Detect installed libcaprights static library.
46 ifneq ($(wildcard $(PLATFORM_LIBDIR)/libcaprights.a),)
47 LIBCAPRIGHTS=$(PLATFORM_LIBDIR)/libcaprights.a
49 ifneq ($(wildcard /usr/lib/libcaprights.a),)
50 LIBCAPRIGHTS=/usr/lib/libcaprights.a
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
63 # Chain on to the master makefile
66 ./libcaprights.a: $(LIBCAPRIGHTS_OBJS)
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.
74 $(CC) $(CFLAGS) -m32 -static -o $@ $<
75 mini-me.x32: mini-me.c
76 $(CC) $(CFLAGS) -mx32 -static -o $@ $<
78 $(CC) $(CFLAGS) -m64 -static -o $@ $<