CURSES := -I/usr/include/ncurses -lncurses
-LDFLAGS := -Wl,-warn-common
-
-CFLAGS := -D_GNU_SOURCE -O2 -g3 -fno-common -ffast-math -I proc \
+# Preprocessor flags.
+PKG_CPPFLAGS := -D_GNU_SOURCE -I proc
+CPPFLAGS :=
+ALL_CPPFLAGS := $(PKG_CPPFLAGS) $(CPPFLAGS)
+
+# Left out -Wconversion due to noise in glibc headers.
+# Left out a number of things that older compilers lack:
+# -Wpadded -Wunreachable-code -Wdisabled-optimization
+#
+# Since none of the PKG_CFLAGS things are truly required
+# to compile procps, they might best be moved to CFLAGS.
+# On the other hand, they aren't normal -O -g things either.
+#
+PKG_CFLAGS := -fno-common -ffast-math \
-W -Wall -Wshadow -Wcast-align -Wredundant-decls \
-Wbad-function-cast -Wcast-qual -Wwrite-strings -Waggregate-return \
-# -Wpadded -Wunreachable-code -Wdisabled-optimization \
- -Wstrict-prototypes -Wmissing-prototypes # -Wconversion
+ -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS := -O2 -g3
+ALL_CFLAGS := $(PKG_CFLAGS) $(CFLAGS)
+
+PKG_LDFLAGS := -Wl,-warn-common
+LDFLAGS :=
+ALL_LDFLAGS := $(PKG_LDFLAGS) $(LDFLAGS)
############ misc.
#endif
#
#%.d: %.c
-# depend.sh $(CFLAGS) $< > $@
+# depend.sh $(ALL_CPPFLAGS) $(ALL_CFLAGS) $< > $@
############
# don't want to type "make procps-$(TARVERSION).tar.gz"
############ prog.c --> prog.o
%.o : %.c
- $(CC) $(CFLAGS) -c -o $@ $^
+ $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $^
w.o: w.c
- $(CC) $(CFLAGS) $(W_SHOWFROM) -c $<
+ $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(W_SHOWFROM) -c $<
############ prog.o --> prog
pmap w uptime tload free sysctl vmstat utmp pgrep skill: % : %.o $(LIBPROC)
- $(CC) $(LDFLAGS) -o $@ $^
+ $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -o $@ $^
top: % : %.o $(LIBPROC)
- $(CC) $(LDFLAGS) -o $@ $^ $(CURSES)
+ $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -o $@ $^ $(CURSES)
watch: % : %.o
- $(CC) $(LDFLAGS) -o $@ $^ $(CURSES)
+ $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -o $@ $^ $(CURSES)
############ progX --> progY
# Separate rule for this directory, to use -fpic or -fPIC
$(filter-out proc/version.o,$(LIBOBJ)): proc/%.o: proc/%.c
- $(CC) -c $(CFLAGS) $(LIBFLAGS) $< -o $@
+ $(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(LIBFLAGS) $< -o $@
LIB_X := COPYING module.mk library.map
TARFILES += $(LIBSRC) $(LIBHDR) $(addprefix proc/,$(LIB_X))
# AUTOMATIC DEPENDENCY GENERATION -- GCC AND GNUMAKE DEPENDENT
proc/.depend: $(LIBSRC) $(LIBHDR)
- $(strip $(CC) $(LIB_CFLAGS) -MM -MG $(LIBSRC) > $@)
+ $(strip $(CC) $(ALL_CPPFLAGS) $(LIB_CFLAGS) -MM -MG $(LIBSRC) > $@)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),tar)
proc/version.o: proc/version.c proc/version.h
- $(CC) $(CFLAGS) $(LIBFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\" -c -o $@ $<
+ $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(LIBFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\" -c -o $@ $<
TARFILES += $(PSSRC) $(addprefix ps/,$(PS_X))
ps/ps: $(PSOBJ) $(LIBPROC)
- $(CC) $(LDFLAGS) -o $@ $^
+ $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -o $@ $^
# This just adds the stacktrace code
ps/debug: $(PSOBJ) stacktrace.o $(LIBPROC)
- $(CC) -o $@ $^ -lefence
+ $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -o $@ $^ -lefence
$(PSOBJ): %.o: %.c ps/common.h proc/$(SONAME)
- $(CC) -c $(CFLAGS) $< -o $@
+ $(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) $< -o $@
ps/stacktrace.o: ps/stacktrace.c