* [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
* [dm-devel] [PATCH 2/2] multipath-tools: cleanly separate CPPFLAGS and CFLAGS 2022-05-10 9:35 [dm-devel] [PATCH 1/2] multipath-tools: move CPPFLAGS before CFLAGS mwilck @ 2022-05-10 9:35 ` 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 1 sibling, 1 reply; 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> Move all preprocessor-related options (-D, -I) into CPPFLAGS. This is cleaner, and has the side effect of creating a better-readable output from "make". Signed-off-by: Martin Wilck <mwilck@suse.com> --- Makefile.inc | 4 ++-- kpartx/Makefile | 5 +++-- libdmmp/Makefile | 4 ++-- libdmmp/test/Makefile | 2 +- libmpathvalid/Makefile | 3 ++- libmultipath/Makefile | 19 ++++++++++--------- libmultipath/checkers/Makefile | 3 ++- libmultipath/foreign/Makefile | 3 ++- libmultipath/prioritizers/Makefile | 5 +++-- mpathpersist/Makefile | 3 ++- multipath/Makefile | 3 ++- multipathd/Makefile | 23 ++++++++++++----------- tests/Makefile | 4 ++-- 13 files changed, 45 insertions(+), 36 deletions(-) diff --git a/Makefile.inc b/Makefile.inc index 7422666..bcd2212 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -140,10 +140,10 @@ OPTFLAGS := -O2 -g $(STACKPROT) --param=ssp-buffer-size=4 WARNFLAGS := -Werror -Wall -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implicit-int \ -Werror=implicit-function-declaration -Werror=format-security \ $(WNOCLOBBERED) -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) -CPPFLAGS := $(FORTIFY_OPT) -CFLAGS := --std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe \ +CPPFLAGS := $(FORTIFY_OPT) \ -DBIN_DIR=\"$(bindir)\" -DMULTIPATH_DIR=\"$(plugindir)\" -DRUN_DIR=\"${RUN}\" \ -DCONFIG_DIR=\"$(configdir)\" -DEXTRAVERSION=\"$(EXTRAVERSION)\" -MMD -MP +CFLAGS := --std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe BIN_CFLAGS = -fPIE -DPIE LIB_CFLAGS = -fPIC SHARED_FLAGS = -shared diff --git a/kpartx/Makefile b/kpartx/Makefile index e9900fb..742d3bc 100644 --- a/kpartx/Makefile +++ b/kpartx/Makefile @@ -3,13 +3,14 @@ # include ../Makefile.inc -CFLAGS += $(BIN_CFLAGS) -I. -I$(multipathdir) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +CPPFLAGS += -I. -I$(multipathdir) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +CFLAGS += $(BIN_CFLAGS) LDFLAGS += $(BIN_LDFLAGS) LIBDEPS += -ldevmapper ifneq ($(call check_func,dm_task_set_cookie,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) - CFLAGS += -DLIBDM_API_COOKIE + CPPFLAGS += -DLIBDM_API_COOKIE endif OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o dasd.o sun.o \ diff --git a/libdmmp/Makefile b/libdmmp/Makefile index 00fc852..2e99b3e 100644 --- a/libdmmp/Makefile +++ b/libdmmp/Makefile @@ -15,8 +15,8 @@ HEADERS = libdmmp/libdmmp.h OBJS = libdmmp.o libdmmp_mp.o libdmmp_pg.o libdmmp_path.o libdmmp_misc.o -CFLAGS += $(LIB_CFLAGS) -fvisibility=hidden -I$(libdmmpdir) -I$(mpathcmddir) \ - $(shell $(PKGCONFIG) --cflags json-c) +CPPFLAGS += -I$(libdmmpdir) -I$(mpathcmddir) $(shell $(PKGCONFIG) --cflags json-c) +CFLAGS += $(LIB_CFLAGS) -fvisibility=hidden LIBDEPS += $(shell $(PKGCONFIG) --libs json-c) -L$(mpathcmddir) -lmpathcmd -lpthread diff --git a/libdmmp/test/Makefile b/libdmmp/test/Makefile index 20b3945..76b24d6 100644 --- a/libdmmp/test/Makefile +++ b/libdmmp/test/Makefile @@ -9,7 +9,7 @@ _mpathcmddir=../$(mpathcmddir) TEST_EXEC = libdmmp_test SPD_TEST_EXEC = libdmmp_speed_test -CFLAGS += -I$(_libdmmpdir) +CPPFLAGS += -I$(_libdmmpdir) LDFLAGS += -L$(_libdmmpdir) -ldmmp all: $(TEST_EXEC) $(SPD_TEST_EXEC) diff --git a/libmpathvalid/Makefile b/libmpathvalid/Makefile index fefeb2a..0a51925 100644 --- a/libmpathvalid/Makefile +++ b/libmpathvalid/Makefile @@ -5,7 +5,8 @@ DEVLIB = libmpathvalid.so LIBS = $(DEVLIB).$(SONAME) VERSION_SCRIPT := libmpathvalid.version -CFLAGS += $(LIB_CFLAGS) -I$(multipathdir) -I$(mpathcmddir) +CPPFLAGS += -I$(multipathdir) -I$(mpathcmddir) +CFLAGS += $(LIB_CFLAGS) LIBDEPS += -lpthread -ldevmapper -ldl -L$(multipathdir) \ -lmultipath -L$(mpathcmddir) -lmpathcmd -ludev diff --git a/libmultipath/Makefile b/libmultipath/Makefile index 2fc3f3b..fb03200 100644 --- a/libmultipath/Makefile +++ b/libmultipath/Makefile @@ -8,12 +8,13 @@ DEVLIB = libmultipath.so LIBS = $(DEVLIB).$(SONAME) VERSION_SCRIPT := libmultipath.version -CFLAGS += $(LIB_CFLAGS) -I$(mpathcmddir) -I$(mpathpersistdir) -I$(nvmedir) +CPPFLAGS += -I$(mpathcmddir) -I$(mpathpersistdir) -I$(nvmedir) +CFLAGS += $(LIB_CFLAGS) LIBDEPS += -lpthread -ldl -ldevmapper -ludev -L$(mpathcmddir) -lmpathcmd -lurcu -laio ifdef SYSTEMD - CFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) + CPPFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) ifeq ($(shell test $(SYSTEMD) -gt 209 && echo 1), 1) LIBDEPS += -lsystemd else @@ -22,31 +23,31 @@ ifdef SYSTEMD endif ifneq ($(call check_func,dm_task_no_flush,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) - CFLAGS += -DLIBDM_API_FLUSH -D_GNU_SOURCE + CPPFLAGS += -DLIBDM_API_FLUSH -D_GNU_SOURCE endif ifneq ($(call check_func,dm_task_get_errno,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) - CFLAGS += -DLIBDM_API_GET_ERRNO + CPPFLAGS += -DLIBDM_API_GET_ERRNO endif ifneq ($(call check_func,dm_task_set_cookie,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) - CFLAGS += -DLIBDM_API_COOKIE + CPPFLAGS += -DLIBDM_API_COOKIE endif ifneq ($(call check_func,udev_monitor_set_receive_buffer_size,$(LIBUDEV_INCDIR)/libudev.h),0) - CFLAGS += -DLIBUDEV_API_RECVBUF + CPPFLAGS += -DLIBUDEV_API_RECVBUF endif ifneq ($(call check_func,dm_task_deferred_remove,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) - CFLAGS += -DLIBDM_API_DEFERRED + CPPFLAGS += -DLIBDM_API_DEFERRED endif ifneq ($(call check_func,dm_hold_control_dev,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) - CFLAGS += -DLIBDM_API_HOLD_CONTROL + CPPFLAGS += -DLIBDM_API_HOLD_CONTROL endif ifneq ($(call check_var,ELS_DTAG_LNK_INTEGRITY,$(LINUX_HEADERS_INCDIR)/scsi/fc/fc_els.h),0) - CFLAGS += -DFPIN_EVENT_HANDLER + CPPFLAGS += -DFPIN_EVENT_HANDLER endif # object files referencing MULTIPATH_DIR or CONFIG_DIR diff --git a/libmultipath/checkers/Makefile b/libmultipath/checkers/Makefile index 8e0ed5e..8d8e45e 100644 --- a/libmultipath/checkers/Makefile +++ b/libmultipath/checkers/Makefile @@ -3,7 +3,8 @@ # include ../../Makefile.inc -CFLAGS += $(LIB_CFLAGS) -I.. +CPPFLAGS += -I.. +CFLAGS += $(LIB_CFLAGS) LDFLAGS += -L.. -lmultipath LIBDEPS = -lmultipath -laio -lpthread -lrt diff --git a/libmultipath/foreign/Makefile b/libmultipath/foreign/Makefile index f447a1c..42cea4d 100644 --- a/libmultipath/foreign/Makefile +++ b/libmultipath/foreign/Makefile @@ -4,7 +4,8 @@ TOPDIR=../.. include ../../Makefile.inc -CFLAGS += $(LIB_CFLAGS) -I.. -I$(nvmedir) +CPPFLAGS += -I.. -I$(nvmedir) +CFLAGS += $(LIB_CFLAGS) LDFLAGS += -L.. LIBDEPS = -lmultipath -ludev -lpthread -lrt diff --git a/libmultipath/prioritizers/Makefile b/libmultipath/prioritizers/Makefile index 16c6397..a5ab5e1 100644 --- a/libmultipath/prioritizers/Makefile +++ b/libmultipath/prioritizers/Makefile @@ -3,7 +3,8 @@ # include ../../Makefile.inc -CFLAGS += $(LIB_CFLAGS) -I.. +CPPFLAGS += -I.. +CFLAGS += $(LIB_CFLAGS) LDFLAGS += -L.. LIBDEPS = -lmultipath -lm -lpthread -lrt @@ -25,7 +26,7 @@ LIBS = \ ifneq ($(call check_file,$(LINUX_HEADERS_INCDIR)/linux/nvme_ioctl.h),0) LIBS += libprioana.so - CFLAGS += -I../nvme + CPPFLAGS += -I../nvme endif all: $(LIBS) diff --git a/mpathpersist/Makefile b/mpathpersist/Makefile index eb26970..2e4d483 100644 --- a/mpathpersist/Makefile +++ b/mpathpersist/Makefile @@ -1,6 +1,7 @@ include ../Makefile.inc -CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathpersistdir) +CPPFLAGS += -I$(multipathdir) -I$(mpathpersistdir) +CFLAGS += $(BIN_CFLAGS) LDFLAGS += $(BIN_LDFLAGS) LIBDEPS += -L$(mpathpersistdir) -lmpathpersist -L$(multipathdir) -lmultipath \ diff --git a/multipath/Makefile b/multipath/Makefile index c930499..bcb0453 100644 --- a/multipath/Makefile +++ b/multipath/Makefile @@ -3,7 +3,8 @@ # include ../Makefile.inc -CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathcmddir) +CPPFLAGS += -I$(multipathdir) -I$(mpathcmddir) +CFLAGS += $(BIN_CFLAGS) LDFLAGS += $(BIN_LDFLAGS) LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathcmddir) -lmpathcmd \ -lpthread -ldevmapper -ldl -ludev diff --git a/multipathd/Makefile b/multipathd/Makefile index 1449080..c937cd5 100644 --- a/multipathd/Makefile +++ b/multipathd/Makefile @@ -1,30 +1,31 @@ include ../Makefile.inc ifneq ($(call check_func,dm_task_get_errno,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) - CFLAGS += -DLIBDM_API_GET_ERRNO + CPPFLAGS += -DLIBDM_API_GET_ERRNO endif ifneq ($(call check_var,ELS_DTAG_LNK_INTEGRITY,$(LINUX_HEADERS_INCDIR)/scsi/fc/fc_els.h),0) - CFLAGS += -DFPIN_EVENT_HANDLER + CPPFLAGS += -DFPIN_EVENT_HANDLER FPIN_SUPPORT = 1 endif # # debugging stuff # -#CFLAGS += -DLCKDBG -#CFLAGS += -D_DEBUG_ -#CFLAGS += -DLOGDBG -CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathpersistdir) \ - -I$(mpathcmddir) -I$(thirdpartydir) +#CPPFLAGS += -DLCKDBG +#CPPFLAGS += -D_DEBUG_ +#CPPFLAGS += -DLOGDBG + +CPPFLAGS += -I$(multipathdir) -I$(mpathpersistdir) -I$(mpathcmddir) -I$(thirdpartydir) \ + $(shell $(PKGCONFIG) --modversion liburcu 2>/dev/null | \ + awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') +CFLAGS += $(BIN_CFLAGS) LDFLAGS += $(BIN_LDFLAGS) LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathpersistdir) -lmpathpersist \ -L$(mpathcmddir) -lmpathcmd -ludev -ldl -lurcu -lpthread \ -ldevmapper -lreadline -CFLAGS += $(shell $(PKGCONFIG) --modversion liburcu 2>/dev/null | \ - awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') ifdef SYSTEMD - CFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) + CPPFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) ifeq ($(shell test $(SYSTEMD) -gt 209 && echo 1), 1) LIBDEPS += -lsystemd else @@ -32,7 +33,7 @@ ifdef SYSTEMD endif endif ifeq ($(ENABLE_DMEVENTS_POLL),0) - CFLAGS += -DNO_DMEVENTS_POLL + CPPFLAGS += -DNO_DMEVENTS_POLL endif OBJS = main.o pidfile.o uxlsnr.o uxclnt.o cli.o cli_handlers.o waiter.o \ diff --git a/tests/Makefile b/tests/Makefile index a069e37..d20ef23 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -11,8 +11,8 @@ TEST_MISSING_INITIALIZERS = $(shell \ || echo -Wno-missing-field-initializers) W_MISSING_INITIALIZERS := $(call TEST_MISSING_INITIALIZERS) -CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathcmddir) \ - -Wno-unused-parameter $(W_MISSING_INITIALIZERS) -DTESTCONFDIR=\"$(TESTDIR)/conf.d\" +CPPFLAGS += -I$(multipathdir) -I$(mpathcmddir) -DTESTCONFDIR=\"$(TESTDIR)/conf.d\" +CFLAGS += $(BIN_CFLAGS) -Wno-unused-parameter $(W_MISSING_INITIALIZERS) LIBDEPS += -L. -L$(mpathcmddir) -lmultipath -lmpathcmd -lcmocka TESTS := uevent parser util dmevents hwtable blacklist unaligned vpd pgpolicy \ -- 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
* Re: [dm-devel] [PATCH 2/2] multipath-tools: cleanly separate CPPFLAGS and CFLAGS 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 0 siblings, 0 replies; 4+ messages in thread From: Martin Liška @ 2022-05-10 10:31 UTC (permalink / raw) To: mwilck, Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel On 5/10/22 11:35, mwilck@suse.com wrote: > From: Martin Wilck <mwilck@suse.com> > > Move all preprocessor-related options (-D, -I) into CPPFLAGS. This is > cleaner, and has the side effect of creating a better-readable output from > "make". > > Signed-off-by: Martin Wilck <mwilck@suse.com> Reviewed-by: Martin Liska <mliska@suse.cz> > --- > Makefile.inc | 4 ++-- > kpartx/Makefile | 5 +++-- > libdmmp/Makefile | 4 ++-- > libdmmp/test/Makefile | 2 +- > libmpathvalid/Makefile | 3 ++- > libmultipath/Makefile | 19 ++++++++++--------- > libmultipath/checkers/Makefile | 3 ++- > libmultipath/foreign/Makefile | 3 ++- > libmultipath/prioritizers/Makefile | 5 +++-- > mpathpersist/Makefile | 3 ++- > multipath/Makefile | 3 ++- > multipathd/Makefile | 23 ++++++++++++----------- > tests/Makefile | 4 ++-- > 13 files changed, 45 insertions(+), 36 deletions(-) > > diff --git a/Makefile.inc b/Makefile.inc > index 7422666..bcd2212 100644 > --- a/Makefile.inc > +++ b/Makefile.inc > @@ -140,10 +140,10 @@ OPTFLAGS := -O2 -g $(STACKPROT) --param=ssp-buffer-size=4 > WARNFLAGS := -Werror -Wall -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implicit-int \ > -Werror=implicit-function-declaration -Werror=format-security \ > $(WNOCLOBBERED) -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) > -CPPFLAGS := $(FORTIFY_OPT) > -CFLAGS := --std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe \ > +CPPFLAGS := $(FORTIFY_OPT) \ > -DBIN_DIR=\"$(bindir)\" -DMULTIPATH_DIR=\"$(plugindir)\" -DRUN_DIR=\"${RUN}\" \ > -DCONFIG_DIR=\"$(configdir)\" -DEXTRAVERSION=\"$(EXTRAVERSION)\" -MMD -MP > +CFLAGS := --std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe > BIN_CFLAGS = -fPIE -DPIE > LIB_CFLAGS = -fPIC > SHARED_FLAGS = -shared > diff --git a/kpartx/Makefile b/kpartx/Makefile > index e9900fb..742d3bc 100644 > --- a/kpartx/Makefile > +++ b/kpartx/Makefile > @@ -3,13 +3,14 @@ > # > include ../Makefile.inc > > -CFLAGS += $(BIN_CFLAGS) -I. -I$(multipathdir) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 > +CPPFLAGS += -I. -I$(multipathdir) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 > +CFLAGS += $(BIN_CFLAGS) > LDFLAGS += $(BIN_LDFLAGS) > > LIBDEPS += -ldevmapper > > ifneq ($(call check_func,dm_task_set_cookie,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) > - CFLAGS += -DLIBDM_API_COOKIE > + CPPFLAGS += -DLIBDM_API_COOKIE > endif > > OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o dasd.o sun.o \ > diff --git a/libdmmp/Makefile b/libdmmp/Makefile > index 00fc852..2e99b3e 100644 > --- a/libdmmp/Makefile > +++ b/libdmmp/Makefile > @@ -15,8 +15,8 @@ HEADERS = libdmmp/libdmmp.h > > OBJS = libdmmp.o libdmmp_mp.o libdmmp_pg.o libdmmp_path.o libdmmp_misc.o > > -CFLAGS += $(LIB_CFLAGS) -fvisibility=hidden -I$(libdmmpdir) -I$(mpathcmddir) \ > - $(shell $(PKGCONFIG) --cflags json-c) > +CPPFLAGS += -I$(libdmmpdir) -I$(mpathcmddir) $(shell $(PKGCONFIG) --cflags json-c) > +CFLAGS += $(LIB_CFLAGS) -fvisibility=hidden > > LIBDEPS += $(shell $(PKGCONFIG) --libs json-c) -L$(mpathcmddir) -lmpathcmd -lpthread > > diff --git a/libdmmp/test/Makefile b/libdmmp/test/Makefile > index 20b3945..76b24d6 100644 > --- a/libdmmp/test/Makefile > +++ b/libdmmp/test/Makefile > @@ -9,7 +9,7 @@ _mpathcmddir=../$(mpathcmddir) > > TEST_EXEC = libdmmp_test > SPD_TEST_EXEC = libdmmp_speed_test > -CFLAGS += -I$(_libdmmpdir) > +CPPFLAGS += -I$(_libdmmpdir) > LDFLAGS += -L$(_libdmmpdir) -ldmmp > > all: $(TEST_EXEC) $(SPD_TEST_EXEC) > diff --git a/libmpathvalid/Makefile b/libmpathvalid/Makefile > index fefeb2a..0a51925 100644 > --- a/libmpathvalid/Makefile > +++ b/libmpathvalid/Makefile > @@ -5,7 +5,8 @@ DEVLIB = libmpathvalid.so > LIBS = $(DEVLIB).$(SONAME) > VERSION_SCRIPT := libmpathvalid.version > > -CFLAGS += $(LIB_CFLAGS) -I$(multipathdir) -I$(mpathcmddir) > +CPPFLAGS += -I$(multipathdir) -I$(mpathcmddir) > +CFLAGS += $(LIB_CFLAGS) > > LIBDEPS += -lpthread -ldevmapper -ldl -L$(multipathdir) \ > -lmultipath -L$(mpathcmddir) -lmpathcmd -ludev > diff --git a/libmultipath/Makefile b/libmultipath/Makefile > index 2fc3f3b..fb03200 100644 > --- a/libmultipath/Makefile > +++ b/libmultipath/Makefile > @@ -8,12 +8,13 @@ DEVLIB = libmultipath.so > LIBS = $(DEVLIB).$(SONAME) > VERSION_SCRIPT := libmultipath.version > > -CFLAGS += $(LIB_CFLAGS) -I$(mpathcmddir) -I$(mpathpersistdir) -I$(nvmedir) > +CPPFLAGS += -I$(mpathcmddir) -I$(mpathpersistdir) -I$(nvmedir) > +CFLAGS += $(LIB_CFLAGS) > > LIBDEPS += -lpthread -ldl -ldevmapper -ludev -L$(mpathcmddir) -lmpathcmd -lurcu -laio > > ifdef SYSTEMD > - CFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) > + CPPFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) > ifeq ($(shell test $(SYSTEMD) -gt 209 && echo 1), 1) > LIBDEPS += -lsystemd > else > @@ -22,31 +23,31 @@ ifdef SYSTEMD > endif > > ifneq ($(call check_func,dm_task_no_flush,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) > - CFLAGS += -DLIBDM_API_FLUSH -D_GNU_SOURCE > + CPPFLAGS += -DLIBDM_API_FLUSH -D_GNU_SOURCE > endif > > ifneq ($(call check_func,dm_task_get_errno,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) > - CFLAGS += -DLIBDM_API_GET_ERRNO > + CPPFLAGS += -DLIBDM_API_GET_ERRNO > endif > > ifneq ($(call check_func,dm_task_set_cookie,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) > - CFLAGS += -DLIBDM_API_COOKIE > + CPPFLAGS += -DLIBDM_API_COOKIE > endif > > ifneq ($(call check_func,udev_monitor_set_receive_buffer_size,$(LIBUDEV_INCDIR)/libudev.h),0) > - CFLAGS += -DLIBUDEV_API_RECVBUF > + CPPFLAGS += -DLIBUDEV_API_RECVBUF > endif > > ifneq ($(call check_func,dm_task_deferred_remove,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) > - CFLAGS += -DLIBDM_API_DEFERRED > + CPPFLAGS += -DLIBDM_API_DEFERRED > endif > > ifneq ($(call check_func,dm_hold_control_dev,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) > - CFLAGS += -DLIBDM_API_HOLD_CONTROL > + CPPFLAGS += -DLIBDM_API_HOLD_CONTROL > endif > > ifneq ($(call check_var,ELS_DTAG_LNK_INTEGRITY,$(LINUX_HEADERS_INCDIR)/scsi/fc/fc_els.h),0) > - CFLAGS += -DFPIN_EVENT_HANDLER > + CPPFLAGS += -DFPIN_EVENT_HANDLER > endif > > # object files referencing MULTIPATH_DIR or CONFIG_DIR > diff --git a/libmultipath/checkers/Makefile b/libmultipath/checkers/Makefile > index 8e0ed5e..8d8e45e 100644 > --- a/libmultipath/checkers/Makefile > +++ b/libmultipath/checkers/Makefile > @@ -3,7 +3,8 @@ > # > include ../../Makefile.inc > > -CFLAGS += $(LIB_CFLAGS) -I.. > +CPPFLAGS += -I.. > +CFLAGS += $(LIB_CFLAGS) > LDFLAGS += -L.. -lmultipath > LIBDEPS = -lmultipath -laio -lpthread -lrt > > diff --git a/libmultipath/foreign/Makefile b/libmultipath/foreign/Makefile > index f447a1c..42cea4d 100644 > --- a/libmultipath/foreign/Makefile > +++ b/libmultipath/foreign/Makefile > @@ -4,7 +4,8 @@ > TOPDIR=../.. > include ../../Makefile.inc > > -CFLAGS += $(LIB_CFLAGS) -I.. -I$(nvmedir) > +CPPFLAGS += -I.. -I$(nvmedir) > +CFLAGS += $(LIB_CFLAGS) > LDFLAGS += -L.. > LIBDEPS = -lmultipath -ludev -lpthread -lrt > > diff --git a/libmultipath/prioritizers/Makefile b/libmultipath/prioritizers/Makefile > index 16c6397..a5ab5e1 100644 > --- a/libmultipath/prioritizers/Makefile > +++ b/libmultipath/prioritizers/Makefile > @@ -3,7 +3,8 @@ > # > include ../../Makefile.inc > > -CFLAGS += $(LIB_CFLAGS) -I.. > +CPPFLAGS += -I.. > +CFLAGS += $(LIB_CFLAGS) > LDFLAGS += -L.. > LIBDEPS = -lmultipath -lm -lpthread -lrt > > @@ -25,7 +26,7 @@ LIBS = \ > > ifneq ($(call check_file,$(LINUX_HEADERS_INCDIR)/linux/nvme_ioctl.h),0) > LIBS += libprioana.so > - CFLAGS += -I../nvme > + CPPFLAGS += -I../nvme > endif > > all: $(LIBS) > diff --git a/mpathpersist/Makefile b/mpathpersist/Makefile > index eb26970..2e4d483 100644 > --- a/mpathpersist/Makefile > +++ b/mpathpersist/Makefile > @@ -1,6 +1,7 @@ > include ../Makefile.inc > > -CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathpersistdir) > +CPPFLAGS += -I$(multipathdir) -I$(mpathpersistdir) > +CFLAGS += $(BIN_CFLAGS) > LDFLAGS += $(BIN_LDFLAGS) > > LIBDEPS += -L$(mpathpersistdir) -lmpathpersist -L$(multipathdir) -lmultipath \ > diff --git a/multipath/Makefile b/multipath/Makefile > index c930499..bcb0453 100644 > --- a/multipath/Makefile > +++ b/multipath/Makefile > @@ -3,7 +3,8 @@ > # > include ../Makefile.inc > > -CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathcmddir) > +CPPFLAGS += -I$(multipathdir) -I$(mpathcmddir) > +CFLAGS += $(BIN_CFLAGS) > LDFLAGS += $(BIN_LDFLAGS) > LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathcmddir) -lmpathcmd \ > -lpthread -ldevmapper -ldl -ludev > diff --git a/multipathd/Makefile b/multipathd/Makefile > index 1449080..c937cd5 100644 > --- a/multipathd/Makefile > +++ b/multipathd/Makefile > @@ -1,30 +1,31 @@ > include ../Makefile.inc > > ifneq ($(call check_func,dm_task_get_errno,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) > - CFLAGS += -DLIBDM_API_GET_ERRNO > + CPPFLAGS += -DLIBDM_API_GET_ERRNO > endif > > ifneq ($(call check_var,ELS_DTAG_LNK_INTEGRITY,$(LINUX_HEADERS_INCDIR)/scsi/fc/fc_els.h),0) > - CFLAGS += -DFPIN_EVENT_HANDLER > + CPPFLAGS += -DFPIN_EVENT_HANDLER > FPIN_SUPPORT = 1 > endif > # > # debugging stuff > # > -#CFLAGS += -DLCKDBG > -#CFLAGS += -D_DEBUG_ > -#CFLAGS += -DLOGDBG > -CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathpersistdir) \ > - -I$(mpathcmddir) -I$(thirdpartydir) > +#CPPFLAGS += -DLCKDBG > +#CPPFLAGS += -D_DEBUG_ > +#CPPFLAGS += -DLOGDBG > + > +CPPFLAGS += -I$(multipathdir) -I$(mpathpersistdir) -I$(mpathcmddir) -I$(thirdpartydir) \ > + $(shell $(PKGCONFIG) --modversion liburcu 2>/dev/null | \ > + awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') > +CFLAGS += $(BIN_CFLAGS) > LDFLAGS += $(BIN_LDFLAGS) > LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathpersistdir) -lmpathpersist \ > -L$(mpathcmddir) -lmpathcmd -ludev -ldl -lurcu -lpthread \ > -ldevmapper -lreadline > -CFLAGS += $(shell $(PKGCONFIG) --modversion liburcu 2>/dev/null | \ > - awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') > > ifdef SYSTEMD > - CFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) > + CPPFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) > ifeq ($(shell test $(SYSTEMD) -gt 209 && echo 1), 1) > LIBDEPS += -lsystemd > else > @@ -32,7 +33,7 @@ ifdef SYSTEMD > endif > endif > ifeq ($(ENABLE_DMEVENTS_POLL),0) > - CFLAGS += -DNO_DMEVENTS_POLL > + CPPFLAGS += -DNO_DMEVENTS_POLL > endif > > OBJS = main.o pidfile.o uxlsnr.o uxclnt.o cli.o cli_handlers.o waiter.o \ > diff --git a/tests/Makefile b/tests/Makefile > index a069e37..d20ef23 100644 > --- a/tests/Makefile > +++ b/tests/Makefile > @@ -11,8 +11,8 @@ TEST_MISSING_INITIALIZERS = $(shell \ > || echo -Wno-missing-field-initializers) > W_MISSING_INITIALIZERS := $(call TEST_MISSING_INITIALIZERS) > > -CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathcmddir) \ > - -Wno-unused-parameter $(W_MISSING_INITIALIZERS) -DTESTCONFDIR=\"$(TESTDIR)/conf.d\" > +CPPFLAGS += -I$(multipathdir) -I$(mpathcmddir) -DTESTCONFDIR=\"$(TESTDIR)/conf.d\" > +CFLAGS += $(BIN_CFLAGS) -Wno-unused-parameter $(W_MISSING_INITIALIZERS) > LIBDEPS += -L. -L$(mpathcmddir) -lmultipath -lmpathcmd -lcmocka > > TESTS := uevent parser util dmevents hwtable blacklist unaligned vpd pgpolicy \ -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dm-devel] [PATCH 1/2] multipath-tools: move CPPFLAGS before CFLAGS 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 1 sibling, 0 replies; 4+ messages in thread From: Martin Liška @ 2022-05-10 10:31 UTC (permalink / raw) To: mwilck, Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel On 5/10/22 11:35, mwilck@suse.com wrote: > 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> Reviewed-by: Martin Liska <mliska@suse.cz> > --- > 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 -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel ^ permalink raw reply [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.