Skip to contentSkip to conversation

config: put CFLAGS/LDLIBS in config.mk

PATCH New Stephen Hemminger 1 participant 1 message Aug 11, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 config: put CFLAGS/LDLIBS in config.mk

This renames Config to config.mk and includes more Make input. Now configure generates all the required CFLAGS and LDLIBS for the optional libraries.

Also, use pkg-config to test for libelf, rather than using a test program. This makes it consistent with other libraries.

---
 .gitignore       |  1 -
 Makefile         |  8 +++---
 README           |  5 ++--
 bridge/Makefile  | 11 +-------
 configure        | 81 ++++++++++++++++++++++++++++----------------------------
 devlink/Makefile |  3 ++-
 genl/Makefile    |  7 +----
 ip/Makefile      | 15 +----------
 lib/Makefile     | 14 +---------
 misc/Makefile    | 16 +----------
 netem/Makefile   |  7 +----
 tc/Makefile      | 15 +----------
 tipc/Makefile    |  5 ++--
 13 files changed, 59 insertions(+), 129 deletions(-)
.gitignore +0 -1
index c3b8d386450b..308aec6ba80b 100644
@@ -1,6 +1,5 @@
 static-syms.h
 config.*
-Config
 *.o
 *.a
 *.so
Makefile +4 -4
index 1f88f7f56691..b0ea6794285c 100644
@@ -54,12 +54,12 @@ SUBDIRS=lib ip tc bridge misc netem genl tipc devlink man
 LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a
 LDLIBS += $(LIBNETLINK)
 
-all: Config
+all: config.mk
 	@set -e; \
 	for i in $(SUBDIRS); \
 	do echo; echo $$i; $(MAKE) $(MFLAGS) -C $$i; done
 
-Config:
+config.mk:
 	sh configure $(KERNEL_INCLUDE)
 
 install: all
@@ -88,9 +88,9 @@ clean:
 	do $(MAKE) $(MFLAGS) -C $$i clean; done
 
 clobber:
-	touch Config
+	touch config.mk
 	$(MAKE) $(MFLAGS) clean
-	rm -f Config cscope.*
+	rm -f config.mk cscope.*
 
 distclean: clobber
 
README +3 -2
index c7a5118dd6d0..386fbaf6cf7d 100644
@@ -21,8 +21,9 @@ database routines.  Often this is in the db-devel package.
 
 2. make
 
-The makefile will automatically build a Config file which
-contains whether or not ATM is available, etc.
+The makefile will automatically build a config.mk file which
+contains definitions of libraries that may or may not be available
+on the system such as: ATM, ELF, MNL, and SELINUX.
 
 3. To make documentation, cd to doc/ directory , then
    look at start of Makefile and set correct values for
bridge/Makefile +1 -10
index fa448ea2e4fa..b2ae0a4ed04d 100644
@@ -1,15 +1,6 @@
 BROBJ = bridge.o fdb.o monitor.o link.o mdb.o vlan.o
 
-include ../Config
-
-ifeq ($(IP_CONFIG_SETNS),y)
-	CFLAGS += -DHAVE_SETNS
-endif
-
-ifeq ($(HAVE_MNL),y)
-	CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
-	LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
-endif
+include ../config.mk
 
 all: bridge
 
configure +41 -40

224 lines not on this page · raw message

devlink/Makefile +2 -1
index 7256c28708eb..3b2067d6658c 100644
@@ -1,4 +1,5 @@
-include ../Config
+include ../config.mk
+
 ifeq ($(HAVE_MNL),y)
 
 DEVLINKOBJ = devlink.o mnlg.o
genl/Makefile +1 -6
index f0efe1ac6647..de1635e498ad 100644
@@ -1,6 +1,6 @@
 GENLOBJ=genl.o
 
-include ../Config
+include ../config.mk
 SHARED_LIBS ?= y
 
 CFLAGS += -fno-strict-aliasing
@@ -17,11 +17,6 @@ LDFLAGS += -Wl,-export-dynamic
 LDLIBS  += -lm -ldl
 endif
 
-ifeq ($(HAVE_MNL),y)
-	CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
-	LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
-endif
-
 all: genl
 
 genl: $(GENLOBJ) $(LIBNETLINK) $(LIBUTIL) $(GENLLIB)
ip/Makefile +1 -14
index a754c04d2dbb..5a1c7ad2d264 100644
@@ -13,20 +13,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
 
 RTMONOBJ=rtmon.o
 
-include ../Config
-
-ifeq ($(IP_CONFIG_SETNS),y)
-	CFLAGS += -DHAVE_SETNS
-endif
-
-ifeq ($(HAVE_ELF),y)
-	CFLAGS += -DHAVE_ELF
-	LDLIBS += -lelf
-endif
-ifeq ($(HAVE_MNL),y)
-	CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
-	LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
-endif
+include ../config.mk
 
 ALLOBJ=$(IPOBJ) $(RTMONOBJ)
 SCRIPTS=ifcfg rtpr routel routef
lib/Makefile +1 -13
index b7b1d5685b94..5e9f72facd36 100644
@@ -1,16 +1,4 @@
-include ../Config
-
-ifeq ($(IP_CONFIG_SETNS),y)
-	CFLAGS += -DHAVE_SETNS
-endif
-
-ifeq ($(HAVE_ELF),y)
-	CFLAGS += -DHAVE_ELF
-endif
-
-ifeq ($(HAVE_MNL),y)
-	CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
-endif
+include ../config.mk
 
 CFLAGS += -fPIC
 
misc/Makefile +1 -15
index fa90308e4848..d02616e3482a 100644
@@ -3,26 +3,12 @@ LNSTATOBJ=lnstat.o lnstat_util.o
 
 TARGETS=ss nstat ifstat rtacct lnstat
 
-include ../Config
+include ../config.mk
 
 ifeq ($(HAVE_BERKELEY_DB),y)
 	TARGETS += arpd
 endif
 
-ifeq ($(HAVE_SELINUX),y)
-	LDLIBS += $(shell $(PKG_CONFIG) --libs libselinux)
-	CFLAGS += $(shell $(PKG_CONFIG) --cflags libselinux) -DHAVE_SELINUX
-endif
-
-ifeq ($(IP_CONFIG_SETNS),y)
-	CFLAGS += -DHAVE_SETNS
-endif
-
-ifeq ($(HAVE_MNL),y)
-	CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
-	LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
-endif
-
 all: $(TARGETS)
 
 ss: $(SSOBJ)
netem/Makefile +1 -6
index 2499f086f24d..434185273f64 100644
@@ -1,4 +1,4 @@
-include ../Config
+include ../config.mk
 
 DISTGEN = maketable normal pareto paretonormal
 DISTDATA = normal.dist pareto.dist paretonormal.dist experimental.dist
@@ -7,11 +7,6 @@ HOSTCC ?= $(CC)
 CCOPTS  = $(CBUILD_CFLAGS)
 LDLIBS += -lm
 
-ifeq ($(HAVE_MNL),y)
-	CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
-	LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
-endif
-
 all: $(DISTGEN) $(DISTDATA)
 
 $(DISTGEN):
tc/Makefile +1 -14
index a9b4b8e60dac..777de5e6da76 100644
@@ -2,11 +2,7 @@ TCOBJ= tc.o tc_qdisc.o tc_class.o tc_filter.o tc_util.o tc_monitor.o \
        tc_exec.o m_police.o m_estimator.o m_action.o m_ematch.o \
        emp_ematch.yacc.o emp_ematch.lex.o
 
-include ../Config
-
-ifeq ($(IP_CONFIG_SETNS),y)
-	CFLAGS += -DHAVE_SETNS
-endif
+include ../config.mk
 
 SHARED_LIBS ?= y
 
@@ -102,15 +98,6 @@ endif
 TCOBJ += $(TCMODULES)
 LDLIBS += -L. -lm
 
-ifeq ($(HAVE_ELF),y)
-	CFLAGS += -DHAVE_ELF
-	LDLIBS += -lelf
-endif
-ifeq ($(HAVE_MNL),y)
-	CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
-	LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
-endif
-
 ifeq ($(SHARED_LIBS),y)
 LDLIBS += -ldl
 LDFLAGS += -Wl,-export-dynamic
tipc/Makefile +2 -3
index 87e3cac3756f..2212beb06534 100644
@@ -1,4 +1,5 @@
-include ../Config
+include ../config.mk
+
 ifeq ($(HAVE_MNL),y)
 
 TIPCOBJ=bearer.o \
@@ -8,8 +9,6 @@ TIPCOBJ=bearer.o \
     node.o socket.o \
     peer.o tipc.o
 
-include ../Config
-
 TARGETS=tipc
 CFLAGS += $(shell $(PKG_CONFIG) libmnl --cflags)
 LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
Signature · 1 line
2.11.0