summaryrefslogtreecommitdiff
path: root/meta-openembedded/meta-networking/recipes-daemons/iscsi-initiator-utils/files/0001-Use-pkg-config-in-Makefiles-for-newer-libraries.patch
blob: 37b764e8545ec9a391ad98f1a1ad9306c0be682d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
From e9b49664e969fd5cad1abef7b8b59e1fb8d02a47 Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Mon, 12 Nov 2018 13:10:04 -0800
Subject: [PATCH] Use pkg-config in Makefiles for newer libraries.

These two recently-added libraries can be in different
locations on different distros, so use pkg-config to
added the appropriate actions in the make files.

Upstream-Status: Backport[https://github.com/open-iscsi/open-iscsi/commit/
623a81123c494f5c69dc6616bd72e838862e2f1f#diff-c4bf6688222ad28c9719cfaf88c16329]

Signed-off-by: Changqing Li <changqing.li@windriver.com>
---
 libopeniscsiusr/Makefile |  8 +++++++-
 usr/Makefile             | 11 ++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/libopeniscsiusr/Makefile b/libopeniscsiusr/Makefile
index bf7c96c..a045a45 100644
--- a/libopeniscsiusr/Makefile
+++ b/libopeniscsiusr/Makefile
@@ -23,6 +23,8 @@ endif
 INCLUDE_DIR ?= $(prefix)/include
 PKGCONF_DIR ?= $(LIB_DIR)/pkgconfig
 
+PKG_CONFIG = /usr/bin/pkg-config
+
 LIBISCSI_USR_DIR=$(TOPDIR)/libopeniscsiusr
 
 LIBISCSI_USR_VERSION_MAJOR=0
@@ -43,13 +45,17 @@ OBJS = context.o misc.o session.o sysfs.o iface.o idbm.o node.o default.o
 
 CFLAGS ?= -O2 -g
 CFLAGS += -Wall -Werror -Wextra -fvisibility=hidden -fPIC
+CFLAGS += $(shell $(PKG_CONFIG) --cflags libkmod)
+
+LDFLAGS += $(shell $(PKG_CONFIG) --libs libkmod)
 
 LIBADD =
 
 all: $(LIBS) $(LIBS_MAJOR) $(TESTS) doc
 
 $(LIBS): $(OBJS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname=$@ -o $@ $(OBJS) $(LIBADD)
+	@echo CFLAGS= $(CFLAGS)
+	$(CC) $(CFLAGS) -shared -Wl,-soname=$@ -o $@ $(OBJS) $(LDFLAGS) $(LIBADD)
 	ln -sf $@ $(DEVLIB)
 
 $(LIBS_MAJOR): $(LIBS)
diff --git a/usr/Makefile b/usr/Makefile
index f9445ad..f1c35aa 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -32,11 +32,16 @@ IPC_OBJ=ioctl.o
 endif
 endif
 
+PKG_CONFIG = /usr/bin/pkg-config
+
 CFLAGS ?= -O2 -g
 WARNFLAGS ?= -Wall -Wstrict-prototypes
 CFLAGS += $(WARNFLAGS) -I../include -I. -D_GNU_SOURCE \
 	  -I$(TOPDIR)/libopeniscsiusr
+CFLAGS += $(shell $(PKG_CONFIG) --cflags libkmod)
 ISCSI_LIB = -L$(TOPDIR)/libopeniscsiusr -lopeniscsiusr
+LDFLAGS += $(shell $(PKG_CONFIG) --libs libkmod)
+LDFLAGS += $(shell $(PKG_CONFIG) --libs libsystemd)
 PROGRAMS = iscsid iscsiadm iscsistart
 
 # libc compat files
@@ -60,14 +65,14 @@ all: $(PROGRAMS)
 
 iscsid: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(DISCOVERY_SRCS) \
 	iscsid.o session_mgmt.o discoveryd.o mntcheck.o
-	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@  -lisns -lcrypto -lrt -lmount $(ISCSI_LIB)
+	$(CC) $(CFLAGS) $^ -o $@  -lisns -lcrypto -lrt -lmount $(LDFLAGS) $(ISCSI_LIB)
 
 iscsiadm: $(ISCSI_LIB_SRCS) $(DISCOVERY_SRCS) iscsiadm.o session_mgmt.o mntcheck.o
-	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -lisns -lcrypto -lmount $(ISCSI_LIB)
+	$(CC) $(CFLAGS) $^ -o $@ -lisns -lcrypto -lmount $(LDFLAGS) $(ISCSI_LIB)
 
 iscsistart: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(FW_BOOT_SRCS) \
 		iscsistart.o statics.o
-	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -lrt $(ISCSI_LIB)
+	$(CC) $(CFLAGS) $^ -o $@ -lrt $(LDFLAGS) $(ISCSI_LIB)
 clean:
 	rm -f *.o $(PROGRAMS) .depend $(LIBSYS)
 
-- 
2.7.4