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(-)
On Mon, Dec 01, 2008 at 02:30:44AM -0800, Diego 'Flameeyes' Petten=F2 w=
rote:
>=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
> file will only rebuild the correct one, and it's as parallel as
> feasible with no recursive make.
Thanks applied.
Luis
=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.
Signed-off-by: Diego E. 'Flameeyes' Petten=C3=B2 <[email protected]>
---
Makefile | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 91c4329..25a92fe 100644
--- a/Makefile
+++ b/Makefile
@@ -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)'
=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.
Signed-off-by: Diego E. 'Flameeyes' Petten=C3=B2 <[email protected]>
---
Makefile | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 25a92fe..ec06534 100644
--- a/Makefile
+++ b/Makefile
@@ -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
=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.
Signed-off-by: Diego E. 'Flameeyes' Petten=C3=B2 <[email protected]>
---
Makefile | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 4ac8495..a8c0a45 100644
--- a/Makefile
+++ b/Makefile
@@ -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`
=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.
Signed-off-by: Diego E. 'Flameeyes' Petten=C3=B2 <[email protected]>
---
Makefile | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index ec06534..4ac8495 100644
--- a/Makefile
+++ b/Makefile
@@ -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)
=46rom: Diego E. 'Flameeyes' Petten=C3=B2 <[email protected]>
Signed-off-by: Diego E. 'Flameeyes' Petten=C3=B2 <[email protected]>
---
.gitignore | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index cc39545..8ee749e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,8 @@ regulatory.sqlite
regulatory.bin
crda
dump
+intersect
+regdbdump
*.o
*.pyc
keys-*.c