build-system: fixes for cross-compilation
Avoid the libcap buildsys forcing CC/CFLAGS/LDFLAGS/AR/RANLIB
Signed-off-by: Gustavo Zacarias <[email protected]>
[[email protected]: dont chmod +x the shared lib]
Signed-off-by: "Yann E. MORIN" <[email protected]>
[Retrieved (and slightly updated to avoid hardcoding PAM_CAP to no) from
https://git.buildroot.net/buildroot/tree/package/libcap/0001-build-system-fixes-for-cross-compilation.patch]
Signed-off-by: Fabrice Fontaine <[email protected]>
Signed-off-by: Andrew G. Morgan <[email protected]>
diff --git a/Make.Rules b/Make.Rules
index 03ae700..b85ddee 100644
--- a/Make.Rules
+++ b/Make.Rules
@@ -54,20 +54,20 @@
KERNEL_HEADERS := $(topdir)/libcap/include/uapi
IPATH += -fPIC -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include
-CC := $(CROSS_COMPILE)gcc
+CC ?= $(CROSS_COMPILE)gcc
DEFINES := -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
-CFLAGS := -O2 $(DEFINES)
-BUILD_CC := $(CC)
-BUILD_CFLAGS := -O2 $(DEFINES) $(IPATH)
-AR := $(CROSS_COMPILE)ar
-RANLIB := $(CROSS_COMPILE)ranlib
+CFLAGS ?= -O2 $(DEFINES)
+BUILD_CC ?= $(CC)
+BUILD_CFLAGS ?= -O2 $(DEFINES) $(IPATH)
+AR ?= $(CROSS_COMPILE)ar
+RANLIB ?= $(CROSS_COMPILE)ranlib
DEBUG = -g #-DDEBUG
WARNINGS=-Wall -Wwrite-strings \
-Wpointer-arith -Wcast-qual -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes \
-Wnested-externs -Winline -Wshadow
LD=$(CC) -Wl,-x -shared
-LDFLAGS := #-g
+LDFLAGS ?= #-g
LIBCAPLIB := -L$(topdir)/libcap -lcap
LIBPSXLIB := -L$(topdir)/libcap -lpsx -lpthread
@@ -77,7 +77,7 @@
INCS=$(topdir)/libcap/include/sys/capability.h
LDFLAGS += -L$(topdir)/libcap
CFLAGS += -Dlinux $(WARNINGS) $(DEBUG)
-PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
+PAM_CAP ?= $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
INDENT := $(shell if [ -n "$$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi)
DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo yes; fi)