Skip to contentSkip to conversation

iw Makefile patch to allow compilation using --as-needed

PATCH Applied Mike Auty 2 participants 2 messages Dec 12, 2008 Kbuild

lore
Share & tools
lore

Mike Auty

author
#0 lore raw

Hiya,
I've got a patch for the iw program to allow it to compile properly
with the --as-needed linker flag. This flag requires that files and libraries are listed in a particular order, with required libraries listed after the functions that call them.
The original Makefile for iw adds the libraries to the LDFLAGS
variable, which is processed before the OBJS are listed (so the libraries are removed). This patch adds a LIBS variable and applies it after the OBJS variable.
For more information on as-needed, please see
http://www.gentoo.org/proj/en/qa/asneeded.xml. If you have any problems or issues with the patch, please let me know, thanks... 5:)

	Mike  5:)
Makefile +2 -2
index df59b51..8a97bae 100644
@@ -12,7 +12,7 @@ CC ?= "gcc"
 
 CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration `pkg-config --cflags libnl-1`
 CFLAGS += -O2 -g
-LDFLAGS += `pkg-config --libs libnl-1`
+LIBS += `pkg-config --libs libnl-1`
 NLVERSION = 1.0
 
 OBJS = iw.o info.o phy.o interface.o station.o util.o mpath.o reg.o mesh.o genl.o
@@ -42,7 +42,7 @@ version.h: version.sh
 
 iw:	$(OBJS)
 	@$(NQ) ' CC  ' iw
-	$(Q)$(CC) $(LDFLAGS) $(OBJS) -o iw
+	$(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o iw
 
 check:
 	$(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
#1 lore raw
Quoted 12 lines · Mike Auty

Hiya,
I've got a patch for the iw program to allow it to compile properly
with the --as-needed linker flag. This flag requires that files and libraries are listed in a particular order, with required libraries listed after the functions that call them.
The original Makefile for iw adds the libraries to the LDFLAGS
variable, which is processed before the OBJS are listed (so the libraries are removed). This patch adds a LIBS variable and applies it after the OBJS variable.
For more information on as-needed, please see
http://www.gentoo.org/proj/en/qa/asneeded.xml. If you have any problems or issues with the patch, please let me know, thanks... 5:)

Quoted 1 line
	Mike  5:)

Applied, thanks.

johannes