blob: b6fbf6d8994b8a774df42ce6279efb309a691bcc [file] [log] [blame]
Andrew Morgan2c9c0532007-07-10 20:50:21 -07001#
Andrew Morgan2c9c0532007-07-10 20:50:21 -07002## Optional prefixes:
3#
4
5# common 'packaging' directoty
6
Mike Frysinger76f6f0a2008-02-16 16:52:31 -05007FAKEROOT=$(DESTDIR)
Andrew Morgan2c9c0532007-07-10 20:50:21 -07008
9# Autoconf-style prefixes are activated when $(prefix) is defined.
Andrew G Morgan93308182013-12-24 10:08:05 -080010# Otherwise binaries and libraries are installed in /{lib,sbin}/,
Andrew Morgan2c9c0532007-07-10 20:50:21 -070011# header files in /usr/include/ and documentation in /usr/man/man?/.
Andrew G. Morgan85748f42010-08-08 17:42:11 -070012# These choices are motivated by the fact that getcap and setcap are
13# administrative operations that could be needed to recover a system.
Andrew Morgan2c9c0532007-07-10 20:50:21 -070014
Andrew Morgan5216fff2007-07-10 22:38:22 -070015ifndef lib
Andrew G Morgan93308182013-12-24 10:08:05 -080016lib=$(shell ldd /usr/bin/ld|egrep "ld-linux|ld.so"|cut -d/ -f2)
Andrew Morgan5216fff2007-07-10 22:38:22 -070017endif
18
Andrew Morgan2c9c0532007-07-10 20:50:21 -070019ifdef prefix
20exec_prefix=$(prefix)
21lib_prefix=$(exec_prefix)
22inc_prefix=$(lib_prefix)
Andrew Morgan5216fff2007-07-10 22:38:22 -070023man_prefix=$(prefix)/share
Andrew Morgan2c9c0532007-07-10 20:50:21 -070024else
25prefix=/usr
26exec_prefix=
27lib_prefix=$(exec_prefix)
28inc_prefix=$(prefix)
Andrew Morgan5216fff2007-07-10 22:38:22 -070029man_prefix=$(prefix)/share
Andrew Morgan2c9c0532007-07-10 20:50:21 -070030endif
31
32# Target directories
33
Benedikt Morbach0ee94212014-05-20 23:30:53 +020034MANDIR=$(man_prefix)/man
35SBINDIR=$(exec_prefix)/sbin
36INCDIR=$(inc_prefix)/include
37LIBDIR=$(lib_prefix)/$(lib)
38PKGCONFIGDIR=$(prefix)/$(lib)/pkgconfig
Andrew G. Morgan1a61e6f2019-12-07 17:23:41 -080039GOPKGDIR=$(prefix)/share/gocode/src
Andrew Morgan2c9c0532007-07-10 20:50:21 -070040
Andrew Morgan370a70f2007-07-17 21:50:12 -070041# common defines for libcap
42LIBTITLE=libcap
Andrew Morganf782a972007-11-07 22:14:24 -080043VERSION=2
Andrew G. Morganb6b7c492019-12-07 09:34:53 -080044MINOR=28
Andrew Morgan2c9c0532007-07-10 20:50:21 -070045#
46
47# Compilation specifics
48
Andrew G Morganc3290662014-01-01 17:56:31 -080049KERNEL_HEADERS := $(topdir)/libcap/include/uapi
50IPATH += -fPIC -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include
Andrew G. Morgan8bdd0ef2008-09-10 19:50:50 -070051
Andrew G. Morgan953e7f12008-06-02 22:02:01 -070052CC := gcc
Andrew G. Morganf464aa72011-06-12 18:44:37 -070053CFLAGS := -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
Andrew G. Morgan953e7f12008-06-02 22:02:01 -070054BUILD_CC := $(CC)
Andrew G. Morgan8bdd0ef2008-09-10 19:50:50 -070055BUILD_CFLAGS := $(CFLAGS) $(IPATH)
Andrew G. Morgan953e7f12008-06-02 22:02:01 -070056AR := ar
57RANLIB := ranlib
58DEBUG = -g #-DDEBUG
Torsten Werner7ebd7c52009-09-30 21:23:15 +020059WARNINGS=-Wall -Wwrite-strings \
Andrew Morgan2c9c0532007-07-10 20:50:21 -070060 -Wpointer-arith -Wcast-qual -Wcast-align \
Andrew Morgan5216fff2007-07-10 22:38:22 -070061 -Wstrict-prototypes -Wmissing-prototypes \
62 -Wnested-externs -Winline -Wshadow
Andrew Morgancd45c572007-08-13 23:16:50 -070063LD=$(CC) -Wl,-x -shared
Andrew G. Morgan953e7f12008-06-02 22:02:01 -070064LDFLAGS := #-g
Andrew G. Morgane9f55d92019-12-02 20:48:13 -080065LIBCAPLIB := -L$(topdir)/libcap -lcap
66LIBPSXLIB := -L$(topdir)/libcap -lpsx -lpthread
67
Matthieu Crapet3c228702014-03-28 14:11:15 +010068BUILD_GPERF := $(shell which gperf >/dev/null 2>/dev/null && echo yes)
Andrew Morgan2c9c0532007-07-10 20:50:21 -070069
Andrew Morgan54f055e2007-07-21 22:18:02 -070070SYSTEM_HEADERS = /usr/include
Andrew Morgan2c9c0532007-07-10 20:50:21 -070071INCS=$(topdir)/libcap/include/sys/capability.h
Andrew G. Morgan953e7f12008-06-02 22:02:01 -070072LDFLAGS += -L$(topdir)/libcap
Torsten Werner7ebd7c52009-09-30 21:23:15 +020073CFLAGS += -Dlinux $(WARNINGS) $(DEBUG)
Andrew G. Morgan953e7f12008-06-02 22:02:01 -070074PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
Matthieu Crapet3c228702014-03-28 14:11:15 +010075INDENT := $(shell if [ -n "$$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi)
Andrew G. Morgan0a42b492008-10-19 19:37:28 -070076DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo yes; fi)
77
Andrew G. Morgan0615d992019-05-19 14:57:20 -070078GOLANG := $(shell if [ -n "$(shell go version 2>/dev/null)" ]; then echo yes ; else echo no ; fi)
79ifeq ($(GOLANG),yes)
80GOROOT := $(shell go env GOROOT)
Andrew G. Morgan2d2b7022019-11-16 09:14:22 -080081GOCGO := $(shell if [ "$(shell go env CGO_ENABLED)" = 1 ]; then echo yes ; else echo no ; fi)
Andrew G. Morgan0615d992019-05-19 14:57:20 -070082GOOSARCH := $(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
Andrew G. Morganb2b267e2019-11-30 18:33:42 -080083CGO_CFLAGS := -I$(topdir)/libcap/include
84CGO_LDFLAGS := -L$(topdir)/libcap
85CGO_LDFLAGS_ALLOW := -Wl,-wrap,.+
Andrew G. Morgane305dd22019-12-07 08:04:58 -080086CGO_REQUIRED=$(shell $(topdir)/go/cgo-required.sh)
Andrew G. Morgan0615d992019-05-19 14:57:20 -070087endif
88
Andrew G. Morgan85748f42010-08-08 17:42:11 -070089# When installing setcap, set its inheritable bit to be able to place
90# capabilities on files. It can be used in conjunction with pam_cap
91# (associated with su and certain users say) to make it useful for
92# specially blessed users. If you wish to drop this install feature,
93# use this command when running install
94#
95# make RAISE_SETFCAP=no install
96#
Andrew G. Morgan85f38a52016-01-30 15:45:28 -080097RAISE_SETFCAP := yes
Andrew G. Morgan85748f42010-08-08 17:42:11 -070098
Andrew Morgan2c9c0532007-07-10 20:50:21 -070099# Global cleanup stuff
100
101LOCALCLEAN=rm -f *~ core
102DISTCLEAN=@find . \( -name '*.orig' -o -name '*.rej' \) | xargs rm -f