Skip to contentSkip to conversation

cleanup build flags a bit

PATCH In review Mike Frysinger 2 participants 3 messages Feb 8, 2009 – Mar 3, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cleanup build flags a bit

Make sure we respect LDFLAGS, use LDLIBS for libs and not LDFLAGS (so the link ordering is correct), and allow people to set AR/RANLIB to the right cross-toolchain.

---
 Makefile |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
Makefile +9 -6
index 52a7363..544cb54 100755
@@ -48,8 +48,8 @@ numactl: numactl.o util.o shm.o bitops.o libnuma.so
 
 migratepages: migratepages.c util.o bitops.o libnuma.so
 
+migspeed: LDLIBS += -lrt
 migspeed: migspeed.o util.o libnuma.so
-	${CC} migspeed.c -o migspeed util.o libnuma.so -lrt
 
 util.o: util.c
 
@@ -57,7 +57,7 @@ memhog: util.o memhog.o libnuma.so
 
 numactl.o: numactl.c
 
-numademo: override LDFLAGS += -lm
+numademo: LDLIBS += -lm
 # GNU make 3.80 appends BENCH_CFLAGS twice. Bug? It's harmless though.
 numademo: CFLAGS += -DHAVE_STREAM_LIB -DHAVE_MT -DHAVE_CLEAR_CACHE ${BENCH_CFLAGS}
 stream_lib.o: CFLAGS += ${BENCH_CFLAGS}
@@ -72,24 +72,27 @@ numademo.o: numademo.c libnuma.so
 
 numamon: numamon.o
 
+stream: LDLIBS += -lm
 stream: stream_lib.o stream_main.o  libnuma.so util.o
-	${CC} -o stream ${CFLAGS} stream_lib.o stream_main.o util.o -L. -lnuma -lm
+	${CC} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDLIBS}
 
 stream_main.o: stream_main.c
 
 libnuma.so.1: versions.ldscript
 
 libnuma.so.1: libnuma.o syscall.o distance.o
-	${CC} -shared -Wl,-soname=libnuma.so.1 -Wl,--version-script,versions.ldscript -Wl,-init,numa_init -o libnuma.so.1 $(filter-out versions.ldscript,$^)
+	${CC} ${LDFLAGS} -shared -Wl,-soname=libnuma.so.1 -Wl,--version-script,versions.ldscript -Wl,-init,numa_init -o libnuma.so.1 $(filter-out versions.ldscript,$^)
 
 libnuma.so: libnuma.so.1
 	ln -sf libnuma.so.1 libnuma.so
 
 libnuma.o : CFLAGS += -fPIC
 
+AR ?= ar
+RANLIB ?= ranlib
 libnuma.a: libnuma.o syscall.o distance.o
-	ar rc $@ $^
-	ranlib $@
+	$(AR) rc $@ $^
+	$(RANLIB) $@
 
 distance.o : CFLAGS += -fPIC
 
Signature · 1 line
1.6.1.2
#1 lore raw

Hi Mike,

Thanks much for the patch.

It has sat in my inbox long enough (sorry). I tested it along with Amit's patches this morning.
The standard tests pass on ia64 (8 nodes).

The patch is in the numactl-2.0.3-rc2.tar.gz tarball at ftp://oss.sgi.com/www/projects/libnuma/download/

Any other review and testing is welcome.

-Cliff

Quoted 71 lines · Mike Frysinger

Make sure we respect LDFLAGS, use LDLIBS for libs and not LDFLAGS (so the link ordering is correct), and allow people to set AR/RANLIB to the right cross-toolchain.

---
 Makefile |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
Makefile +9 -6
index 52a7363..544cb54 100755
@@ -48,8 +48,8 @@ numactl: numactl.o util.o shm.o bitops.o libnuma.so
 
 migratepages: migratepages.c util.o bitops.o libnuma.so
 
+migspeed: LDLIBS += -lrt
 migspeed: migspeed.o util.o libnuma.so
-	${CC} migspeed.c -o migspeed util.o libnuma.so -lrt
 
 util.o: util.c
 
@@ -57,7 +57,7 @@ memhog: util.o memhog.o libnuma.so
 
 numactl.o: numactl.c
 
-numademo: override LDFLAGS += -lm
+numademo: LDLIBS += -lm
 # GNU make 3.80 appends BENCH_CFLAGS twice. Bug? It's harmless though.
 numademo: CFLAGS += -DHAVE_STREAM_LIB -DHAVE_MT -DHAVE_CLEAR_CACHE ${BENCH_CFLAGS}
 stream_lib.o: CFLAGS += ${BENCH_CFLAGS}
@@ -72,24 +72,27 @@ numademo.o: numademo.c libnuma.so
 
 numamon: numamon.o
 
+stream: LDLIBS += -lm
 stream: stream_lib.o stream_main.o  libnuma.so util.o
-	${CC} -o stream ${CFLAGS} stream_lib.o stream_main.o util.o -L. -lnuma -lm
+	${CC} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDLIBS}
 
 stream_main.o: stream_main.c
 
 libnuma.so.1: versions.ldscript
 
 libnuma.so.1: libnuma.o syscall.o distance.o
-	${CC} -shared -Wl,-soname=libnuma.so.1 -Wl,--version-script,versions.ldscript -Wl,-init,numa_init -o libnuma.so.1 $(filter-out versions.ldscript,$^)
+	${CC} ${LDFLAGS} -shared -Wl,-soname=libnuma.so.1 -Wl,--version-script,versions.ldscript -Wl,-init,numa_init -o libnuma.so.1 $(filter-out versions.ldscript,$^)
 
 libnuma.so: libnuma.so.1
 	ln -sf libnuma.so.1 libnuma.so
 
 libnuma.o : CFLAGS += -fPIC
 
+AR ?= ar
+RANLIB ?= ranlib
 libnuma.a: libnuma.o syscall.o distance.o
-	ar rc $@ $^
-	ranlib $@
+	$(AR) rc $@ $^
+	$(RANLIB) $@
 
 distance.o : CFLAGS += -fPIC
 
Signature · 6 lines
1.6.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 4 lines
Cliff Wickman
Silicon Graphics, Inc.
[email protected]
(651) 683-3824
#2 lore raw
Quoted 4 lines · On Monday 02 March 2009 08:56:41 Cliff Wickman wrote:

The patch is in the numactl-2.0.3-rc2.tar.gz tarball at ftp://oss.sgi.com/www/projects/libnuma/download/

Any other review and testing is welcome.

the install target creates a man2 dir but doesnt use it

the package comes with a bunch of man8 pages but doesnt install them. migratepages.8 and migspeed.8 and numastat.8 ...

it'd be nice if the install target supported $(DESTDIR) ... atm it can be mostly faked by only setting prefix when installing ...

the optional install of numa examples is a little odd ... why not just always install them ?

HTH
-mike