[PATCH libaio 11/11] build: Honour user build flags
authorGuillem Jover <guillem@hadrons.org>
Sun, 12 Apr 2020 02:01:27 +0000 (04:01 +0200)
committerGuillem Jover <guillem@debian.org>
Thu, 24 Dec 2020 14:41:17 +0000 (14:41 +0000)
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 if the user flags are
passed.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Gbp-Pq: Name 0011-build-Honour-user-build-flags.patch

harness/Makefile
src/Makefile

index 84e03a62e3bec65ab560fb1652348c435a4f338d..42aa49a4b8445ac4da529c8c1aa6bb6caf3ffa5f 100644 (file)
@@ -6,8 +6,11 @@ PROGS:=$(PARTPROGS) $(EXTRAPROGS)
 HARNESS_SRCS:=main.c
 # io_queue.c
 
-CFLAGS+=-Wall -I../src -g -O2
+MK_CPPFLAGS := -I../src $(CPPFLAGS)
+CFLAGS = -Wall -g -O2
 #-lpthread -lrt
+MK_CFLAGS = $(CFLAGS)
+MK_LDFLAGS = main.c $(LIBAIO) -lpthread $(LDFLAGS)
 
 # Change this on the build line to run tests against the installed libraries:
 # make LIBAIO=-laio partcheck
@@ -16,7 +19,7 @@ LIBAIO?=../src/libaio.a
 all: $(PROGS)
 
 $(PROGS): %.p: %.t $(HARNESS_SRCS)
-       $(CC) $(CFLAGS) -DTEST_NAME=\"$<\" -o $@ main.c $(LIBAIO) -lpthread
+       $(CC) $(MK_CPPFLAGS) $(MK_CFLAGS) -DTEST_NAME=\"$<\" -o $@ $(MK_LDFLAGS)
 
 clean:
        rm -f $(PROGS) *.o runtests.out rofile wofile rwfile
index a53c43c8fef0f8638f5c4f757a2b5f89d32e32be..f6215f930fdac553153bb60798328e893d54dd2a 100644 (file)
@@ -3,12 +3,12 @@ prefix=/usr
 includedir=$(prefix)/include
 libdir=$(prefix)/lib
 
-CFLAGS ?= -g -fomit-frame-pointer -O2
-CFLAGS += -Wall -I. -fPIC
-SO_CFLAGS=-shared $(CFLAGS)
-L_CFLAGS=$(CFLAGS)
-LINK_FLAGS=
-LINK_FLAGS+=$(LDFLAGS)
+MK_CPPFLAGS = -I.
+MK_CFLAGS = -fPIC $(CFLAGS)
+CFLAGS = -Wall -g -fomit-frame-pointer -O2
+SO_CFLAGS = -shared $(MK_CFLAGS)
+L_CFLAGS = $(MK_CFLAGS)
+MK_LDFLAGS = $(LDFLAGS)
 ENABLE_SHARED ?= 1
 
 soname=libaio.so.1
@@ -43,10 +43,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
@@ -56,7 +56,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