Honour user build flags
authorGuillem Jover <guillem@debian.org>
Tue, 31 May 2016 18:38:08 +0000 (19:38 +0100)
committerGuillem Jover <guillem@debian.org>
Tue, 31 May 2016 18:38:08 +0000 (19:38 +0100)
Origin: vendor
Forwarded: no
Last-Update: 2014-10-09

CPPFLAGS, CFLAGS and LDFLAGS are user flags, which we need to preserve, any
required flag that the build system needs, has to be set in some other flag
so that the build will succeed even of the user flags are passed.

Gbp-Pq: Name 05_build-flags.patch

harness/Makefile
src/Makefile

index 6f1f3a143c1dc8b3eea0c4e022ab6908484e8968..59a05484142a73cc0921d5d7c978879e61a8f41e 100644 (file)
@@ -6,13 +6,16 @@ PROGS:=$(PARTPROGS) $(EXTRAPROGS)
 HARNESS_SRCS:=main.c
 # io_queue.c
 
-CFLAGS+=-Wall -I../src -g -O
+MK_CPPFLAGS:=-I../src
+CFLAGS=-Wall -g -O
 #-lpthread -lrt
+MK_CFLAGS=$(CFLAGS)
+MK_LDFLAGS=main.c ../src/libaio.a $(LDFLAGS)
 
 all: $(PROGS)
 
 $(PROGS): %.p: %.t $(HARNESS_SRCS)
-       $(CC) $(CFLAGS) -DTEST_NAME=\"$<\" -o $@ main.c ../src/libaio.a
+       $(CC) $(MK_CPPFLAGS) $(MK_CFLAGS) -DTEST_NAME=\"$<\" -o $@ $(MK_LDFLAGS)
 
 clean:
        rm -f $(PROGS) *.o runtests.out rofile wofile rwfile
index 383699147a7e7c4e1d9d0d96edf2a28b6001747c..05d7226fc82b7ebed0e1295c2cd348b9f69134fd 100644 (file)
@@ -4,12 +4,12 @@ includedir=$(prefix)/include
 libdir=$(prefix)/lib
 libdevdir=$(prefix)/lib
 
-CFLAGS ?= -g -fomit-frame-pointer -O2
-CFLAGS += -nostdlib -nostartfiles -Wall -I. -fPIC
-SO_CFLAGS=-shared $(CFLAGS)
-L_CFLAGS=$(CFLAGS)
-LINK_FLAGS=-Wl,--as-needed -lgcc -lc
-LINK_FLAGS+=$(LDFLAGS)
+MK_CPPFLAGS=-I.
+MK_CFLAGS=-nostdlib -nostartfiles -fomit-frame-pointer -fPIC $(CFLAGS)
+CFLAGS=-Wall -g -O2
+SO_CFLAGS=-shared $(MK_CFLAGS)
+L_CFLAGS=$(MK_CFLAGS)
+MK_LDFLAGS=-Wl,--as-needed -lgcc -lc $(LDFLAGS)
 
 soname=libaio.so.1
 minor=0
@@ -39,10 +39,10 @@ libaio_sobjs := $(patsubst %.c,%.os,$(libaio_srcs))
 $(libaio_objs) $(libaio_sobjs): libaio.h vsys_def.h
 
 %.os: %.c
-       $(CC) $(SO_CFLAGS) -c -o $@ $<
+       $(CC) $(MK_CPPFLAGS) $(SO_CFLAGS) -c -o $@ $<
 
 %.ol: %.c
-       $(CC) $(L_CFLAGS) -c -o $@ $<
+       $(CC) $(MK_CPPFLAGS) $(L_CFLAGS) -c -o $@ $<
 
 AR ?= ar
 RANLIB ?= ranlib
@@ -52,7 +52,7 @@ libaio.a: $(libaio_objs)
        $(RANLIB) libaio.a
 
 $(libname): $(libaio_sobjs) libaio.map
-       $(CC) $(SO_CFLAGS) -Wl,--version-script=libaio.map -Wl,-soname=$(soname) -o $@ $(libaio_sobjs) $(LINK_FLAGS)
+       $(CC) $(SO_CFLAGS) -Wl,--version-script=libaio.map -Wl,-soname=$(soname) -o $@ $(libaio_sobjs) $(MK_LDFLAGS)
 
 install: $(all_targets)
        install -D -m 644 libaio.h $(DESTDIR)$(includedir)/libaio.h