Skip to contentSkip to conversation

Makefile improvement and fixes

PATCH Applied Diego 'Flameeyes' Pettenò 2 participants 7 messages Dec 1, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Makefile improvement and fixes

I've been asked by a colleague Gentoo developer (Tony Vroon) to look at a build failure with parallel make[1] in crda, and I decided to take a closer look to the Makefile.

With these patches applied, --as-needed build works, as well as parallel make, the dependencies are properly handle so that changing a file will only rebuild the correct one, and it's as parallel as feasible with no recursive make.

HTH,
Diego

[1] http://bugs.gentoo.org/show_bug.cgi?id=3D249181

---

Diego E. 'Flameeyes' Petten=C3=B2 (5):
Ignore built files.
Don't use recursive make for verify target. Make it possible to switch gcrypt/openssl via knob. Fix dependencies for parallel make and others. Fix building with --as-needed LD flag.

 .gitignore |    2 ++
 Makefile   |   33 +++++++++++++++++++++------------
 2 files changed, 23 insertions(+), 12 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw

PATCH 1/5 Fix building with --as-needed LD flag.

=46rom: Diego E. 'Flameeyes' Petten=C3=B2 <[email protected]>

When using GNU ld --as-needed option, you need to ensure that the order of parameters to the linker is formally correct, with libraries coming after the object files. For this reason, don't use LDFLAGS for passing the libraries, and make sure that LDLIBS goes at the end of the line.

---

 Makefile |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
Makefile +0 -0
index 91c4329..25a92fe 100644
@@ -7,9 +7,9 @@ PUBKEY_DIR=3Dpubkeys

=20
CFLAGS +=3D -Wall -g
#CFLAGS +=3D -DUSE_OPENSSL pkg-config --cflags openssl
-#LDFLAGS +=3D pkg-config --libs openssl
+#LDLIBS +=3D pkg-config --libs openssl
CFLAGS +=3D -DUSE_GCRYPT
-LDFLAGS +=3D -lgcrypt
+LDLIBS +=3D -lgcrypt
=20
MKDIR ?=3D mkdir -p
INSTALL ?=3D install
@@ -35,15 +35,15 @@ keys-%.c: utils/key2pub.py $(PUBKEY_DIR)/$(wildcard=
*.pem)
=20
crda: keys-ssl.c keys-gcrypt.c reglib.o crda.o
$(NQ) ' LD ' $@
- $(Q)$(CC) $(CFLAGS) $(LDFLAGS) pkg-config --libs libnl-1 -o $@ regl=
ib.o crda.o
+ $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o crda.o `pkg-config --li=
bs libnl-1` $(LDLIBS)
=20
regdbdump: keys-ssl.c keys-gcrypt.c reglib.o regdbdump.o
$(NQ) ' LD ' $@
- $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o regdbdump.o
+ $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o regdbdump.o $(LDLIBS)
=20
intersect: keys-ssl.c keys-gcrypt.c reglib.o intersect.o
$(NQ) ' LD ' $@
- $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o intersect.o
+ $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o intersect.o $(LDLIBS)
=20
verify: $(REG_BIN) regdbdump
$(NQ) ' CHK $(REG_BIN)'

--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

PATCH 2/5 Fix dependencies for parallel make and others.

In reply to Diego 'Flameeyes' Pettenò

=46rom: Diego E. 'Flameeyes' Petten=C3=B2 <[email protected]>

Since the keys .c files are included by reglib.c, it's not the final output to depend on them but rather reglib.o.

This not only fixes proper regeneration of reglib.o when the pem files are changed, but also allows proper parallel make of the package.

---

 Makefile |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
Makefile +0 -0
index 25a92fe..ec06534 100644
@@ -33,15 +33,17 @@ keys-%.c: utils/key2pub.py $(PUBKEY_DIR)/$(wildcard=
 *.pem)
 	$(NQ) '  CC  ' $@
 	$(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<

=20
-crda: keys-ssl.c keys-gcrypt.c reglib.o crda.o
+reglib.o: keys-ssl.c keys-gcrypt.c
+
+crda: reglib.o crda.o
$(NQ) ' LD ' $@
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o crda.o `pkg-config --li=
bs libnl-1` $(LDLIBS)
=20
-regdbdump: keys-ssl.c keys-gcrypt.c reglib.o regdbdump.o +regdbdump: reglib.o regdbdump.o
$(NQ) ' LD ' $@
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o regdbdump.o $(LDLIBS)
=20
-intersect: keys-ssl.c keys-gcrypt.c reglib.o intersect.o +intersect: reglib.o intersect.o
$(NQ) ' LD ' $@
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o intersect.o $(LDLIBS)
=20

--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

PATCH 3/5 Make it possible to switch gcrypt/openssl via knob.

In reply to Diego 'Flameeyes' Pettenò

=46rom: Diego E. 'Flameeyes' Petten=C3=B2 <[email protected]>

By building with "make USE_OPENSSL=3D1", OpenSSL will be used in libcrypt's stead. This also allows for properly depend just on the keys-*.c source file that is actually going to be used.

Note that the all target is moved up so that it still hits as default target.

---

 Makefile |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)
Makefile +0 -0
index ec06534..4ac8495 100644
@@ -6,11 +6,24 @@ REG_BIN?=3D/usr/lib/crda/regulatory.bin
 PUBKEY_DIR=3Dpubkeys

=20
CFLAGS +=3D -Wall -g
-#CFLAGS +=3D -DUSE_OPENSSL pkg-config --cflags openssl -#LDLIBS +=3D pkg-config --libs openssl
+
+all: crda intersect
+ $(Q)$(MAKE) --no-print-directory -f Makefile verify
+
+ifeq ($(USE_OPENSSL),1)
+CFLAGS +=3D -DUSE_OPENSSL pkg-config --cflags openssl
+LDLIBS +=3D pkg-config --libs openssl
+
+reglib.o: keys-ssl.c
+
+else
CFLAGS +=3D -DUSE_GCRYPT
LDLIBS +=3D -lgcrypt
=20
+reglib.o: keys-gcrypt.c
+
+endif
+
MKDIR ?=3D mkdir -p
INSTALL ?=3D install
=20
@@ -22,9 +35,6 @@ Q=3D@
NQ=3D@echo
endif
=20
-all: crda intersect
- $(Q)$(MAKE) --no-print-directory -f Makefile verify
-
keys-%.c: utils/key2pub.py $(PUBKEY_DIR)/$(wildcard *.pem)
$(NQ) ' GEN ' $@
$(Q)./utils/key2pub.py --$* $(PUBKEY_DIR)/*.pem > $@
@@ -33,8 +43,6 @@ keys-%.c: utils/key2pub.py $(PUBKEY_DIR)/$(wildcard *= =2Epem)
$(NQ) ' CC ' $@
$(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
=20
-reglib.o: keys-ssl.c keys-gcrypt.c
-
crda: reglib.o crda.o
$(NQ) ' LD ' $@
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o crda.o `pkg-config --li=
bs libnl-1` $(LDLIBS)

--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

PATCH 4/5 Don't use recursive make for verify target.

In reply to Diego 'Flameeyes' Pettenò

=46rom: Diego E. 'Flameeyes' Petten=C3=B2 <[email protected]>

This makes the build more parallel since regdbdump.o build and link can happen in parallel with the keys generation and the build of the rest of the units.

---

 Makefile |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
Makefile +0 -0
index 4ac8495..a8c0a45 100644
@@ -7,8 +7,7 @@ PUBKEY_DIR=3Dpubkeys

=20
CFLAGS +=3D -Wall -g
=20
-all: crda intersect
- $(Q)$(MAKE) --no-print-directory -f Makefile verify
+all: crda intersect verify
=20
ifeq ($(USE_OPENSSL),1)
CFLAGS +=3D -DUSE_OPENSSL pkg-config --cflags openssl

--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

PATCH 5/5 Ignore built files.

In reply to Diego 'Flameeyes' Pettenò

=46rom: Diego E. 'Flameeyes' Petten=C3=B2 <[email protected]>

---

 .gitignore |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
.gitignore +2 -0
index cc39545..8ee749e 100644
@@ -3,6 +3,8 @@ regulatory.sqlite
 regulatory.bin
 crda
 dump
+intersect
+regdbdump
 *.o
 *.pyc
 keys-*.c

--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to Diego 'Flameeyes' Pettenò

On Mon, Dec 01, 2008 at 02:30:44AM -0800, Diego 'Flameeyes' Petten=F2 w= rote:

Quoted 8 lines

=20
=20
I've been asked by a colleague Gentoo developer (Tony Vroon) to look at a build failure with parallel make[1] in crda, and I decided to take a closer look to the Makefile.
=20
With these patches applied, --as-needed build works, as well as parallel make, the dependencies are properly handle so that changing =

a

Quoted 2 lines

file will only rebuild the correct one, and it's as parallel as feasible with no recursive make.

Thanks applied.

Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html