Skip to contentSkip to conversation

ipvsadm: detect LIBS and CFLAGS for libnl versions

PATCH In review Jesper Dangaard Brouer 4 participants 5 messages Aug 9, 2013 – Aug 13, 2013

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

PATCH 1/1 ipvsadm: detect LIBS and CFLAGS for libnl versions

Automated detecting of LIBS and CFLAGS for different versions of libnl via using pkg-config, in the Makefiles. This should make it easier to compile on different distributions.

Detecting in prioritized order from the most recent version, and only the first detected lib is used. Thus, supporting several libnl version being installed on the same system.

Only tested with libnl-1 and libnl-3.0, but also adding support for libnl-2.0.

---
 Makefile         |    8 +++++++-
 libipvs/Makefile |    7 +++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
Makefile +7 -1
index 6e36d79..4cd59f5 100644
@@ -65,7 +65,13 @@ RPMBUILD = $(shell				\
 OBJS		= ipvsadm.o config_stream.o dynamic_array.o
 LIBS		= -lpopt
 ifneq (0,$(HAVE_NL))
-LIBS		+= -lnl
+LIBS		+= $(shell \
+		if which pkg-config > /dev/null 2>&1; then \
+		  if   pkg-config --libs libnl-genl-3.0  2> /dev/null; then :;\
+		  elif pkg-config --libs libnl-2.0       2> /dev/null; then :;\
+		  elif pkg-config --libs libnl-1         2> /dev/null; then :;\
+		  fi; \
+		else echo "-ln"; fi)
 endif
 DEFINES		= -DVERSION=\"$(VERSION)\" -DSCHEDULERS=\"$(SCHEDULERS)\" \
 		  -DPE_LIST=\"$(PE_LIST)\" $(POPT_DEFINE)
libipvs/Makefile +7 -0
index eafc3e5..f845c8b 100644
@@ -4,6 +4,13 @@ CC		= gcc
 CFLAGS		= -Wall -Wunused -Wstrict-prototypes -g -fPIC
 ifneq (0,$(HAVE_NL))
 CFLAGS		+= -DLIBIPVS_USE_NL
+CFLAGS		+= $(shell \
+		if which pkg-config > /dev/null 2>&1; then \
+		  if   pkg-config --cflags libnl-3.0  2> /dev/null; then :; \
+		  elif pkg-config --cflags libnl-2.0  2> /dev/null; then :; \
+		  elif pkg-config --cflags libnl-1    2> /dev/null; then :; \
+		  fi; \
+		fi)
 endif
 
 INCLUDE		+= $(shell if [ -f ../../ip_vs.h ]; then	\
#1 lore raw
Quoted 23 lines · Jesper Dangaard Brouer

Automated detecting of LIBS and CFLAGS for different versions of libnl via using pkg-config, in the Makefiles. This should make it easier to compile on different distributions.

Detecting in prioritized order from the most recent version, and only the first detected lib is used. Thus, supporting several libnl version being installed on the same system.

Only tested with libnl-1 and libnl-3.0, but also adding support for libnl-2.0.

---
  Makefile         |    8 +++++++-
  libipvs/Makefile |    7 +++++++
  2 files changed, 14 insertions(+), 1 deletion(-)
Makefile +0 -0
index 6e36d79..4cd59f5 100644
@@ -65,7 +65,13 @@ RPMBUILD = $(shell				\
  OBJS		= ipvsadm.o config_stream.o dynamic_array.o

Makefile RPMBUILD = $(shell \ · line 74

Quoted 10 lines
Makefile +7 -1
  LIBS		= -lpopt
  ifneq (0,$(HAVE_NL))
-LIBS		+= -lnl
+LIBS		+= $(shell \
+		if which pkg-config > /dev/null 2>&1; then \
+		  if   pkg-config --libs libnl-genl-3.0  2> /dev/null; then :;\
+		  elif pkg-config --libs libnl-2.0       2> /dev/null; then :;\
+		  elif pkg-config --libs libnl-1         2> /dev/null; then :;\
+		  fi; \
+		else echo "-ln"; fi)

-lnl

Otherwise looks good. Thanks Jesper!

Quoted 22 lines
Makefile +0 -0
  endif
  DEFINES		= -DVERSION=\"$(VERSION)\" -DSCHEDULERS=\"$(SCHEDULERS)\" \
  		  -DPE_LIST=\"$(PE_LIST)\" $(POPT_DEFINE)
libipvs/Makefile +7 -0
index eafc3e5..f845c8b 100644
@@ -4,6 +4,13 @@ CC		= gcc
  CFLAGS		= -Wall -Wunused -Wstrict-prototypes -g -fPIC
  ifneq (0,$(HAVE_NL))
  CFLAGS		+= -DLIBIPVS_USE_NL
+CFLAGS		+= $(shell \
+		if which pkg-config > /dev/null 2>&1; then \
+		  if   pkg-config --cflags libnl-3.0  2> /dev/null; then :; \
+		  elif pkg-config --cflags libnl-2.0  2> /dev/null; then :; \
+		  elif pkg-config --cflags libnl-1    2> /dev/null; then :; \
+		  fi; \
+		fi)
  endif
 
  INCLUDE		+= $(shell if [ -f ../../ip_vs.h ]; then	\
#2 lore raw

PATCH v2 1/1 ipvsadm: detect LIBS and CFLAGS for libnl versions

Automated detecting of LIBS and CFLAGS for different versions of libnl via using pkg-config, in the Makefiles. This should make it easier to compile on different distributions.

Detecting in prioritized order from the most recent version, and only the first detected lib is used. Thus, supporting several libnl version being installed on the same system.

Only tested with libnl-1 and libnl-3.0, but also adding support for libnl-2.0.

---
V2: Fix small bug noticed by Daniel, fall-through libs case missed a "l"

 Makefile         |    8 +++++++-
 libipvs/Makefile |    7 +++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
Makefile +7 -1
index 6e36d79..91a2991 100644
@@ -65,7 +65,13 @@ RPMBUILD = $(shell				\
 OBJS		= ipvsadm.o config_stream.o dynamic_array.o
 LIBS		= -lpopt
 ifneq (0,$(HAVE_NL))
-LIBS		+= -lnl
+LIBS		+= $(shell \
+		if which pkg-config > /dev/null 2>&1; then \
+		  if   pkg-config --libs libnl-genl-3.0  2> /dev/null; then :;\
+		  elif pkg-config --libs libnl-2.0       2> /dev/null; then :;\
+		  elif pkg-config --libs libnl-1         2> /dev/null; then :;\
+		  fi; \
+		else echo "-lnl"; fi)
 endif
 DEFINES		= -DVERSION=\"$(VERSION)\" -DSCHEDULERS=\"$(SCHEDULERS)\" \
 		  -DPE_LIST=\"$(PE_LIST)\" $(POPT_DEFINE)
libipvs/Makefile +7 -0
index eafc3e5..f845c8b 100644
@@ -4,6 +4,13 @@ CC		= gcc
 CFLAGS		= -Wall -Wunused -Wstrict-prototypes -g -fPIC
 ifneq (0,$(HAVE_NL))
 CFLAGS		+= -DLIBIPVS_USE_NL
+CFLAGS		+= $(shell \
+		if which pkg-config > /dev/null 2>&1; then \
+		  if   pkg-config --cflags libnl-3.0  2> /dev/null; then :; \
+		  elif pkg-config --cflags libnl-2.0  2> /dev/null; then :; \
+		  elif pkg-config --cflags libnl-1    2> /dev/null; then :; \
+		  fi; \
+		fi)
 endif
 
 INCLUDE		+= $(shell if [ -f ../../ip_vs.h ]; then	\
Acked-by on v2 1/1
#3 lore raw
Quoted 11 lines · Jesper Dangaard Brouer

Automated detecting of LIBS and CFLAGS for different versions of libnl via using pkg-config, in the Makefiles. This should make it easier to compile on different distributions.

Detecting in prioritized order from the most recent version, and only the first detected lib is used. Thus, supporting several libnl version being installed on the same system.

Only tested with libnl-1 and libnl-3.0, but also adding support for libnl-2.0.

Quoted 7 lines

---
V2: Fix small bug noticed by Daniel, fall-through libs case missed a "l"

  Makefile         |    8 +++++++-
  libipvs/Makefile |    7 +++++++
  2 files changed, 14 insertions(+), 1 deletion(-)
maintainer
#4 lore raw
Quoted 16 lines · Daniel Borkmann
Quoted 15 lines · Jesper Dangaard Brouer

Automated detecting of LIBS and CFLAGS for different versions of libnl via using pkg-config, in the Makefiles. This should make it easier to compile on different distributions.

Detecting in prioritized order from the most recent version, and only the first detected lib is used. Thus, supporting several libnl version being installed on the same system.

Only tested with libnl-1 and libnl-3.0, but also adding support for libnl-2.0.

---
V2: Fix small bug noticed by Daniel, fall-through libs case missed a "l"

Quoted 5 lines
Quoted 3 lines
 Makefile         |    8 +++++++-
 libipvs/Makefile |    7 +++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

Thanks, I will queue this up.