blob: 37b764e8545ec9a391ad98f1a1ad9306c0be682d [file] [log] [blame]
Brad Bishopc1d34332019-09-09 14:56:00 -04001From e9b49664e969fd5cad1abef7b8b59e1fb8d02a47 Mon Sep 17 00:00:00 2001
2From: Lee Duncan <lduncan@suse.com>
3Date: Mon, 12 Nov 2018 13:10:04 -0800
4Subject: [PATCH] Use pkg-config in Makefiles for newer libraries.
5
6These two recently-added libraries can be in different
7locations on different distros, so use pkg-config to
8added the appropriate actions in the make files.
9
10Upstream-Status: Backport[https://github.com/open-iscsi/open-iscsi/commit/
11623a81123c494f5c69dc6616bd72e838862e2f1f#diff-c4bf6688222ad28c9719cfaf88c16329]
12
13Signed-off-by: Changqing Li <changqing.li@windriver.com>
14---
15 libopeniscsiusr/Makefile | 8 +++++++-
16 usr/Makefile | 11 ++++++++---
17 2 files changed, 15 insertions(+), 4 deletions(-)
18
19diff --git a/libopeniscsiusr/Makefile b/libopeniscsiusr/Makefile
20index bf7c96c..a045a45 100644
21--- a/libopeniscsiusr/Makefile
22+++ b/libopeniscsiusr/Makefile
23@@ -23,6 +23,8 @@ endif
24 INCLUDE_DIR ?= $(prefix)/include
25 PKGCONF_DIR ?= $(LIB_DIR)/pkgconfig
26
27+PKG_CONFIG = /usr/bin/pkg-config
28+
29 LIBISCSI_USR_DIR=$(TOPDIR)/libopeniscsiusr
30
31 LIBISCSI_USR_VERSION_MAJOR=0
32@@ -43,13 +45,17 @@ OBJS = context.o misc.o session.o sysfs.o iface.o idbm.o node.o default.o
33
34 CFLAGS ?= -O2 -g
35 CFLAGS += -Wall -Werror -Wextra -fvisibility=hidden -fPIC
36+CFLAGS += $(shell $(PKG_CONFIG) --cflags libkmod)
37+
38+LDFLAGS += $(shell $(PKG_CONFIG) --libs libkmod)
39
40 LIBADD =
41
42 all: $(LIBS) $(LIBS_MAJOR) $(TESTS) doc
43
44 $(LIBS): $(OBJS)
45- $(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname=$@ -o $@ $(OBJS) $(LIBADD)
46+ @echo CFLAGS= $(CFLAGS)
47+ $(CC) $(CFLAGS) -shared -Wl,-soname=$@ -o $@ $(OBJS) $(LDFLAGS) $(LIBADD)
48 ln -sf $@ $(DEVLIB)
49
50 $(LIBS_MAJOR): $(LIBS)
51diff --git a/usr/Makefile b/usr/Makefile
52index f9445ad..f1c35aa 100644
53--- a/usr/Makefile
54+++ b/usr/Makefile
55@@ -32,11 +32,16 @@ IPC_OBJ=ioctl.o
56 endif
57 endif
58
59+PKG_CONFIG = /usr/bin/pkg-config
60+
61 CFLAGS ?= -O2 -g
62 WARNFLAGS ?= -Wall -Wstrict-prototypes
63 CFLAGS += $(WARNFLAGS) -I../include -I. -D_GNU_SOURCE \
64 -I$(TOPDIR)/libopeniscsiusr
65+CFLAGS += $(shell $(PKG_CONFIG) --cflags libkmod)
66 ISCSI_LIB = -L$(TOPDIR)/libopeniscsiusr -lopeniscsiusr
67+LDFLAGS += $(shell $(PKG_CONFIG) --libs libkmod)
68+LDFLAGS += $(shell $(PKG_CONFIG) --libs libsystemd)
69 PROGRAMS = iscsid iscsiadm iscsistart
70
71 # libc compat files
72@@ -60,14 +65,14 @@ all: $(PROGRAMS)
73
74 iscsid: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(DISCOVERY_SRCS) \
75 iscsid.o session_mgmt.o discoveryd.o mntcheck.o
76- $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -lisns -lcrypto -lrt -lmount $(ISCSI_LIB)
77+ $(CC) $(CFLAGS) $^ -o $@ -lisns -lcrypto -lrt -lmount $(LDFLAGS) $(ISCSI_LIB)
78
79 iscsiadm: $(ISCSI_LIB_SRCS) $(DISCOVERY_SRCS) iscsiadm.o session_mgmt.o mntcheck.o
80- $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -lisns -lcrypto -lmount $(ISCSI_LIB)
81+ $(CC) $(CFLAGS) $^ -o $@ -lisns -lcrypto -lmount $(LDFLAGS) $(ISCSI_LIB)
82
83 iscsistart: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(FW_BOOT_SRCS) \
84 iscsistart.o statics.o
85- $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -lrt $(ISCSI_LIB)
86+ $(CC) $(CFLAGS) $^ -o $@ -lrt $(LDFLAGS) $(ISCSI_LIB)
87 clean:
88 rm -f *.o $(PROGRAMS) .depend $(LIBSYS)
89
90--
912.7.4
92