0011-build-Honour-user-build-flags.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. From b8f802cee62430d4951990f578bcd27eba27476e Mon Sep 17 00:00:00 2001
  2. From: Guillem Jover <guillem@hadrons.org>
  3. Date: Sun, 12 Apr 2020 04:01:27 +0200
  4. Subject: [PATCH libaio 11/11] build: Honour user build flags
  5. CPPFLAGS, CFLAGS and LDFLAGS are user flags, which we need to preserve.
  6. Any required flag that the build system needs, has to be set in some
  7. other flag so that the build will succeed even if the user flags are
  8. passed.
  9. Signed-off-by: Guillem Jover <guillem@hadrons.org>
  10. ---
  11. harness/Makefile | 7 +++++--
  12. src/Makefile | 18 +++++++++---------
  13. 2 files changed, 14 insertions(+), 11 deletions(-)
  14. diff --git a/harness/Makefile b/harness/Makefile
  15. index 84e03a6..42aa49a 100644
  16. --- a/harness/Makefile
  17. +++ b/harness/Makefile
  18. @@ -6,8 +6,11 @@ PROGS:=$(PARTPROGS) $(EXTRAPROGS)
  19. HARNESS_SRCS:=main.c
  20. # io_queue.c
  21. -CFLAGS+=-Wall -I../src -g -O2
  22. +MK_CPPFLAGS := -I../src $(CPPFLAGS)
  23. +CFLAGS = -Wall -g -O2
  24. #-lpthread -lrt
  25. +MK_CFLAGS = $(CFLAGS)
  26. +MK_LDFLAGS = main.c $(LIBAIO) -lpthread $(LDFLAGS)
  27. # Change this on the build line to run tests against the installed libraries:
  28. # make LIBAIO=-laio partcheck
  29. @@ -16,7 +19,7 @@ LIBAIO?=../src/libaio.a
  30. all: $(PROGS)
  31. $(PROGS): %.p: %.t $(HARNESS_SRCS)
  32. - $(CC) $(CFLAGS) -DTEST_NAME=\"$<\" -o $@ main.c $(LIBAIO) -lpthread
  33. + $(CC) $(MK_CPPFLAGS) $(MK_CFLAGS) -DTEST_NAME=\"$<\" -o $@ $(MK_LDFLAGS)
  34. clean:
  35. rm -f $(PROGS) *.o runtests.out rofile wofile rwfile
  36. diff --git a/src/Makefile b/src/Makefile
  37. index a53c43c..f6215f9 100644
  38. --- a/src/Makefile
  39. +++ b/src/Makefile
  40. @@ -3,12 +3,12 @@ prefix=/usr
  41. includedir=$(prefix)/include
  42. libdir=$(prefix)/lib
  43. -CFLAGS ?= -g -fomit-frame-pointer -O2
  44. -CFLAGS += -Wall -I. -fPIC
  45. -SO_CFLAGS=-shared $(CFLAGS)
  46. -L_CFLAGS=$(CFLAGS)
  47. -LINK_FLAGS=
  48. -LINK_FLAGS+=$(LDFLAGS)
  49. +MK_CPPFLAGS = -I.
  50. +MK_CFLAGS = -fPIC $(CFLAGS)
  51. +CFLAGS = -Wall -g -fomit-frame-pointer -O2
  52. +SO_CFLAGS = -shared $(MK_CFLAGS)
  53. +L_CFLAGS = $(MK_CFLAGS)
  54. +MK_LDFLAGS = $(LDFLAGS)
  55. ENABLE_SHARED ?= 1
  56. soname=libaio.so.1
  57. @@ -43,10 +43,10 @@ libaio_sobjs := $(patsubst %.c,%.os,$(libaio_srcs))
  58. $(libaio_objs) $(libaio_sobjs): libaio.h vsys_def.h
  59. %.os: %.c
  60. - $(CC) $(SO_CFLAGS) -c -o $@ $<
  61. + $(CC) $(MK_CPPFLAGS) $(SO_CFLAGS) -c -o $@ $<
  62. %.ol: %.c
  63. - $(CC) $(L_CFLAGS) -c -o $@ $<
  64. + $(CC) $(MK_CPPFLAGS) $(L_CFLAGS) -c -o $@ $<
  65. AR ?= ar
  66. RANLIB ?= ranlib
  67. @@ -56,7 +56,7 @@ libaio.a: $(libaio_objs)
  68. $(RANLIB) libaio.a
  69. $(libname): $(libaio_sobjs) libaio.map
  70. - $(CC) $(SO_CFLAGS) -Wl,--version-script=libaio.map -Wl,-soname=$(soname) -o $@ $(libaio_sobjs) $(LINK_FLAGS)
  71. + $(CC) $(SO_CFLAGS) -Wl,--version-script=libaio.map -Wl,-soname=$(soname) -o $@ $(libaio_sobjs) $(MK_LDFLAGS)
  72. install: $(all_targets)
  73. install -D -m 644 libaio.h $(DESTDIR)$(includedir)/libaio.h
  74. --
  75. 2.26.0.292.g33ef6b2f38