All of lore.kernel.org
 help / color / mirror / Atom feed
* [dm-devel] [PATCH 1/2] multipath-tools: move CPPFLAGS before CFLAGS
@ 2022-05-10  9:35 mwilck
  2022-05-10  9:35 ` [dm-devel] [PATCH 2/2] multipath-tools: cleanly separate CPPFLAGS and CFLAGS mwilck
  2022-05-10 10:31 ` [dm-devel] [PATCH 1/2] multipath-tools: move CPPFLAGS before CFLAGS Martin Liška
  0 siblings, 2 replies; 4+ messages in thread
From: mwilck @ 2022-05-10  9:35 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski, Martin Liška
  Cc: dm-devel, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

Distributions may want to override -D_FORTIFY_SOURCE in the generic
OPTFLAGS variable. That requires that the autodected setting is
evaluated before OPTFLAGS on the compiler command line.
This way, distributions can use OPTFLAGS="-U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=3 ..." without causing compilation errors.
(Note that the "-U" is required).

Move CPPFLAGS before CFLAGS in the compiler command line. Moreover, make sure
CPPFLAGS is referenced in all compilation steps.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 Makefile.inc          | 2 +-
 libmultipath/Makefile | 6 +++---
 multipathd/Makefile   | 2 +-
 tests/Makefile        | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Makefile.inc b/Makefile.inc
index b915c06..7422666 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -191,7 +191,7 @@ check_var = $(shell \
 
 %.o:	%.c
 	@echo building $@ because of $?
-	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
 
 %.abi:  %.so.0
 	abidw $< >$@
diff --git a/libmultipath/Makefile b/libmultipath/Makefile
index a56dd1e..2fc3f3b 100644
--- a/libmultipath/Makefile
+++ b/libmultipath/Makefile
@@ -70,12 +70,12 @@ OBJS := $(OBJS-O) $(OBJS-U)
 all:	$(DEVLIB)
 
 nvme-lib.o: nvme-lib.c nvme-ioctl.c nvme-ioctl.h
-	$(CC) $(CFLAGS) -Wno-unused-function -c -o $@ $<
+	$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused-function -c -o $@ $<
 
 # there are lots of "unused parameters" in dict.c
 # because not all handler / snprint methods need all parameters
 dict.o:	dict.c
-	$(CC) $(CFLAGS) -Wno-unused-parameter -c -o $@ $<
+	$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused-parameter -c -o $@ $<
 
 make_static = $(shell sed '/^static/!s/^\([a-z]\{1,\} \)/static \1/' <$1 >$2)
 
@@ -112,7 +112,7 @@ abi:    $(LIBS:%.so.$(SONAME)=%-nv.abi)
 # This rule is invoked from tests/Makefile, overriding configdir and plugindir
 %-test.o: %.c
 	@echo building $@ because of $?
-	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
 
 test-lib:	../tests/$(LIBS)
 
diff --git a/multipathd/Makefile b/multipathd/Makefile
index 9a49144..1449080 100644
--- a/multipathd/Makefile
+++ b/multipathd/Makefile
@@ -52,7 +52,7 @@ $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so
 	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(EXEC) $(LIBDEPS)
 
 cli_handlers.o:	cli_handlers.c
-	$(CC) $(CFLAGS) -Wno-unused-parameter -c -o $@ $<
+	$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused-parameter -c -o $@ $<
 
 install:
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
diff --git a/tests/Makefile b/tests/Makefile
index 0b39c30..a069e37 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -72,7 +72,7 @@ endif
 strbuf-test_OBJDEPS := ../libmultipath/strbuf.o
 
 %.o: %.c
-	$(CC) $(CFLAGS) $($*-test_FLAGS) -c -o $@ $<
+	$(CC) $(CPPFLAGS) $(CFLAGS) $($*-test_FLAGS) -c -o $@ $<
 
 lib/libchecktur.so:
 	mkdir -p lib
-- 
2.36.0

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-11  8:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-10  9:35 [dm-devel] [PATCH 1/2] multipath-tools: move CPPFLAGS before CFLAGS mwilck
2022-05-10  9:35 ` [dm-devel] [PATCH 2/2] multipath-tools: cleanly separate CPPFLAGS and CFLAGS mwilck
2022-05-10 10:31   ` Martin Liška
2022-05-10 10:31 ` [dm-devel] [PATCH 1/2] multipath-tools: move CPPFLAGS before CFLAGS Martin Liška

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.