The Makefiles don't use `CPPFLAGS` or `LDFLAGS`, and set `CFLAGS`
unconditionally. Rename `CFLAGS`, and add `CPPFLAGS` and `LDFLAGS` to the
compilation and linking recipes in order to support the common patterns of
providing these flags via the command-line and the environment.
Signed-off-by: Jeremy Sowden <azazel@xxxxxxxxxx>
---
Makefile | 8 ++++----
libipvs/Makefile | 12 ++++++------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
index d247d4075160..d79f72496000 100644
--- a/Makefile
+++ b/Makefile
@@ -47,9 +47,9 @@ INSTALL = install
STATIC_LIBS = libipvs/libipvs.a
ifeq "${ARCH}" "sparc64"
- CFLAGS = -Wall -Wunused -Wstrict-prototypes -g -m64 -pipe -mcpu=ultrasparc
-mcmodel=medlow
+ DEFAULT_CFLAGS = -Wall -Wunused -Wstrict-prototypes -g -m64 -pipe
-mcpu=ultrasparc -mcmodel=medlow
else
- CFLAGS = -Wall -Wunused -Wstrict-prototypes -g
+ DEFAULT_CFLAGS = -Wall -Wunused -Wstrict-prototypes -g
endif
@@ -88,7 +88,7 @@ libs:
make -C libipvs
ipvsadm: $(OBJS) $(STATIC_LIBS)
- $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+ $(CC) $(DEFAULT_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
install: all
if [ ! -d $(SBIN) ]; then $(MKDIR) -p $(SBIN); fi
@@ -140,4 +140,4 @@ debs:
dpkg-buildpackage
%.o: %.c
- $(CC) $(CFLAGS) $(INCLUDE) $(DEFINES) -c -o $@ $<
+ $(CC) $(DEFAULT_CFLAGS) $(CFLAGS) $(INCLUDE) $(DEFINES)
$(CPPFLAGS) -c -o $@ $<
diff --git a/libipvs/Makefile b/libipvs/Makefile
index b31c8eac514d..f29671178422 100644
--- a/libipvs/Makefile
+++ b/libipvs/Makefile
@@ -2,10 +2,10 @@
CC = gcc
PKG_CONFIG ?= pkg-config
-CFLAGS = -Wall -Wunused -Wstrict-prototypes -g -fPIC
+DEFAULT_CFLAGS = -Wall -Wunused -Wstrict-prototypes -g -fPIC
ifneq (0,$(HAVE_NL))
-CFLAGS += -DLIBIPVS_USE_NL
-CFLAGS += $(shell \
+DEFINES += -DLIBIPVS_USE_NL
+DEFAULT_CFLAGS += $(shell \
if which $(PKG_CONFIG) > /dev/null 2>&1; then \
if $(PKG_CONFIG) --cflags libnl-3.0 2> /dev/null; then :; \
elif $(PKG_CONFIG) --cflags libnl-2.0 2> /dev/null; then :; \
@@ -16,7 +16,7 @@ endif
INCLUDE += $(shell if [ -f ../../ip_vs.h ]; then \
echo "-I../../."; fi;)
-DEFINES = $(shell if [ ! -f ../../ip_vs.h ]; then \
+DEFINES += $(shell if [ ! -f ../../ip_vs.h ]; then \
echo "-DHAVE_NET_IP_VS_H"; fi;)
DEFINES += $(shell if which $(PKG_CONFIG) > /dev/null 2>&1;
then \
if $(PKG_CONFIG) --exists libnl-3.0; then :; \
@@ -34,10 +34,10 @@ $(STATIC_LIB): libipvs.o ip_vs_nl_policy.o
ar rv $@ $^
$(SHARED_LIB): libipvs.o ip_vs_nl_policy.o
- $(CC) -shared -Wl,-soname,$@ -o $@ $^
+ $(CC) $(DEFAULT_CFLAGS) $(CFLAGS) -shared -Wl,-soname,$@
$(LDFLAGS) -o $@ $^
%.o: %.c
- $(CC) $(CFLAGS) $(INCLUDE) $(DEFINES) -c -o $@ $<
+ $(CC) $(DEFAULT_CFLAGS) $(CFLAGS) $(INCLUDE) $(DEFINES)
$(CPPFLAGS) -c -o $@ $<
clean:
rm -f *.[ao] *~ *.orig *.rej core *.so
--
2.45.2
|