3 # Set ARCH to 32 or x32 for i386/x32 ABIs
12 PROCESSOR:=$(shell uname -p)
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
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')
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)
27 PLATFORM_LIBDIR=/usr/lib32
28 LIBCAPRIGHTS=./libcaprights.a
30 ifeq ($(ARCHFLAG),-mx32)
32 PLATFORM_LIBDIR=/usr/libx32
33 LIBCAPRIGHTS=./libcaprights.a
36 # Detect presence of libsctp in normal Debian location
37 ifneq ($(wildcard $(PLATFORM_LIBDIR)/libsctp.a),)
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)
49 # Detect installed libcaprights static library.
50 ifneq ($(wildcard $(PLATFORM_LIBDIR)/libcaprights.a),)
51 LIBCAPRIGHTS=$(PLATFORM_LIBDIR)/libcaprights.a
53 ifneq ($(wildcard /usr/lib/libcaprights.a),)
54 LIBCAPRIGHTS=/usr/lib/libcaprights.a
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
67 # Chain on to the master makefile
70 ./libcaprights.a: $(LIBCAPRIGHTS_OBJS)
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.
78 $(CC) $(CFLAGS) -m32 -static -o $@ $<
79 mini-me.x32: mini-me.c
80 $(CC) $(CFLAGS) -mx32 -static -o $@ $<
82 $(CC) $(CFLAGS) -m64 -static -o $@ $<