1From b27c253bfb78fa3c5f416e6caee101098a4b58cc Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 12 Jul 2017 18:09:46 -0700
4Subject: [PATCH] build: Adjust CFLAGS/LDFLAGS to append values passed from env
5
6For musl we have to pass additional arguments via cflags and ldflags
7to link in librirpc, make room for those changes to take effect
8
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10
11---
12Upstream-Status: Pending
13
14 scripts/build |  2 +-
15 src/Makefile  | 14 +++++++-------
16 2 files changed, 8 insertions(+), 8 deletions(-)
17
18diff --git a/scripts/build b/scripts/build
19index 34a1371..3786741 100755
20--- a/scripts/build
21+++ b/scripts/build
22@@ -18,7 +18,7 @@ done
23
24 trap 'rm -f ${BASE}$$.s ${BASE}$$.c ${BASE}$$.o ${BASE}$$; exit 1' 1 2 15
25
26-LDLIBS=-lm
27+LDLIBS="$LDLIBS -lm"
28
29 # check for HP-UX's ANSI compiler
30 echo "main(int ac, char *av[]) { int i; }" > ${BASE}$$.c
31diff --git a/src/Makefile b/src/Makefile
32index d9efd54..96467d7 100644
33--- a/src/Makefile
34+++ b/src/Makefile
35@@ -112,8 +112,8 @@ LIBOBJS= $O/lib_tcp.o $O/lib_udp.o $O/lib_unix.o $O/lib_timing.o 	\
36 	$O/lib_sched.o
37
38 lmbench: $(UTILS)
39-	@env CFLAGS=-O MAKE="$(MAKE)" MAKEFLAGS="$(MAKEFLAGS)" CC="$(CC)" OS="$(OS)" ../scripts/build all
40-	-@env CFLAGS=-O MAKE="$(MAKE)" MAKEFLAGS="k$(MAKEFLAGS)" CC="$(CC)" OS="$(OS)" ../scripts/build opt
41+	@env CFLAGS+=-O MAKE="$(MAKE)" MAKEFLAGS="$(MAKEFLAGS)" CC="$(CC)" OS="$(OS)" ../scripts/build all
42+	-@env CFLAGS+=-O MAKE="$(MAKE)" MAKEFLAGS="k$(MAKEFLAGS)" CC="$(CC)" OS="$(OS)" ../scripts/build opt
43
44 results: lmbench
45 	@env OS="${OS}" ../scripts/config-run
46@@ -137,7 +137,7 @@ os: lmbench
47 	@env OS="${OS}" BENCHMARK_HARDWARE=NO  BENCHMARK_OS=YES ../scripts/results
48
49 install: lmbench
50-	@env CFLAGS=-O MAKE="$(MAKE)"  MAKEFLAGS="$(MAKEFLAGS)" CC="${CC}" OS="${OS}" ../scripts/build install-target
51+	@env CFLAGS+=-O MAKE="$(MAKE)"  MAKEFLAGS="$(MAKEFLAGS)" CC="${CC}" OS="${OS}" ../scripts/build install-target
52
53 install-target:
54 	if [ ! -d $(BASE) ]; then mkdir $(BASE); fi
55@@ -155,16 +155,16 @@ all: $(EXES) $O/lmbench
56 opt: $(OPT_EXES)
57 asm: $(ASMS)
58 $(ASMS):
59-	$(CC) -S $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ `basename $@ .s`.c
60+	$(CC) -S $(CFLAGS) $(CPPFLAGS) -o $@ `basename $@ .s`.c $(LDFLAGS)
61
62 Wall:
63-	@env CFLAGS="-g -O -Wall" MAKE="$(MAKE)" MAKEFLAGS="$(MAKEFLAGS)" CC="${CC}" OS="${OS}" ../scripts/build all opt
64+	@env CFLAGS+="-g -O -Wall" MAKE="$(MAKE)" MAKEFLAGS="$(MAKEFLAGS)" CC="${CC}" OS="${OS}" ../scripts/build all opt
65
66 debug:
67-	@env CFLAGS="-g -O -DDEBUG" MAKE="$(MAKE)" MAKEFLAGS="$(MAKEFLAGS)" CC="${CC}" OS="${OS}" ../scripts/build all opt
68+	@env CFLAGS+="-g -O -DDEBUG" MAKE="$(MAKE)" MAKEFLAGS="$(MAKEFLAGS)" CC="${CC}" OS="${OS}" ../scripts/build all opt
69
70 assembler:
71-	@env CFLAGS=-O MAKE="$(MAKE)" MAKEFLAGS="$(MAKEFLAGS)" CC="${CC}" OS="${OS}" ../scripts/build asm
72+	@env CFLAGS+=-O MAKE="$(MAKE)" MAKEFLAGS="$(MAKEFLAGS)" CC="${CC}" OS="${OS}" ../scripts/build asm
73
74
75 tag:
76