From 87b8b165ba6498ffcb20a923a0741ac380a84eeb Mon Sep 17 00:00:00 2001 From: "Mark D. Studebaker" Date: Mon, 29 Apr 2002 01:37:07 +0000 Subject: [PATCH] use $CFLAGS and $CPPFLAGS from environment or if specified in Makfile. Patch from "Kevin P. Fleming" git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1361 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 3 +++ Makefile | 63 +++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/CHANGES b/CHANGES index 3b1e3231..648def3e 100644 --- a/CHANGES +++ b/CHANGES @@ -25,10 +25,13 @@ ask CVS about it: Makefiles: For 2.4+ kernels, modules now install in kernel/drivers/[i2c,sensors] , not misc/ , and removes old versions in misc/ . + Use $CFLAGS and $CPPFLAGS if defined. Module i2c-savage4: new Module i2c-viapro: Add support for VT8233A (0x3147) Module w83781d: Add multiple VRM version support + Program eeprom: new Program mkpatch: Install new sensors_vid.h + Program sensord: Major update, add rrd support Program sensors-detect: Add VT8233A, several S3 devices; fix perl warnings 2.6.3 (20020322) diff --git a/Makefile b/Makefile index 816111e8..d3882dd2 100644 --- a/Makefile +++ b/Makefile @@ -125,6 +125,11 @@ MACHINE := $(shell uname -m) # Extra non-default programs to build; e.g., sensord # PROG_EXTRA := sensord +# Set these to add preprocessor or compiler flags, or use +# environment variables +# CFLAGS := +# CPPFLAGS := + ################################################## # Below this, nothing should need to be changed. # ################################################## @@ -159,39 +164,51 @@ LN := ln -sfn GREP := grep # Determine the default compiler flags -# MODCFLAGS is to create in-kernel object files (modules); PROGFLAGS is to -# create non-kernel object files (which are linked into executables). -# ARCFLAGS are used to create archive object files (static libraries), and -# LIBCFLAGS are for shared library objects. -CFLAGS := -I. -Ikernel/include -I$(I2C_HEADERS) -I$(LINUX_HEADERS) -O2 +# Set CFLAGS or CPPFLAGS above to add your own flags to all. +# ALLCPPFLAGS/ALLCFLAGS are common flags, plus any user-specified overrides from the environment or make command line. +# MODCPPFLAGS/MODCFLAGS is to create in-kernel object files (modules). +# PROGCPPFLAGS/PROGCFLAGS is to create non-kernel object files (which are linked into executables). +# ARCPPFLAGS/ARCFLAGS are used to create archive object files (static libraries). +# LIBCPPFLAGS/LIBCFLAGS are for shared library objects. +ALL_CPPFLAGS := -I. -Ikernel/include -I$(I2C_HEADERS) -I$(LINUX_HEADERS) +ALL_CFLAGS := -O2 ifeq ($(DEBUG),1) -CFLAGS += -DDEBUG +ALL_CPPFLAGS += -DDEBUG endif ifeq ($(WARN),1) -CFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \ - -Wcast-align -Wwrite-strings -Wnested-externs -Winline +ALL_CFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \ + -Wcast-align -Wwrite-strings -Wnested-externs -Winline endif -MODCFLAGS := $(CFLAGS) -D__KERNEL__ -DMODULE -fomit-frame-pointer -MODCFLAGS := $(MODCFLAGS) -DEXPORT_SYMTAB -PROGCFLAGS := $(CFLAGS) -ARCFLAGS := $(CFLAGS) -LIBCFLAGS := $(CFLAGS) -fpic +ALL_CPPFLAGS += $(CPPFLAGS) +ALL_CFLAGS += $(CFLAGS) + +MODCPPFLAGS := +MODCFLAGS := ifeq ($(MACHINE),alpha) MODCFLAGS += -ffixed-8 endif ifeq ($(SMP),1) -MODCFLAGS += -D__SMP__ +MODCPPFLAGS += -D__SMP__ endif ifeq ($(MODVER),1) -MODCFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h +MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h endif +MODCPPFLAGS += -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -fomit-frame-pointer $(ALL_CPPFLAGS) +MODCFLAGS += $(ALL_CFLAGS) +PROGCPPFLAGS := $(ALL_CPPFLAGS) +PROGCFLAGS := $(ALL_CFLAGS) +ARCPPFLAGS := $(ALL_CPPFLAGS) +ARCFLAGS := $(ALL_CFLAGS) +LIBCPPFLAGS := $(ALL_CPPFLAGS) +LIBCFLAGS := -fpic $(ALL_CFLAGS) + .PHONY: all clean install version package dep # Make all the default rule @@ -246,20 +263,20 @@ version: # .o files are used for modules %.o: %.c - $(CC) $(MODCFLAGS) -c $< -o $@ + $(CC) $(MODCPPFLAGS) $(MODCFLAGS) -c $< -o $@ %.d: %.c - $(CC) -M -MG $(MODCFLAGS) $< | \ + $(CC) -M -MG $(MODCPPFLAGS) $(MODCFLAGS) $< | \ sed -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@ # .ro files are used for programs (as opposed to modules) %.ro: %.c - $(CC) $(PROGCFLAGS) -c $< -o $@ + $(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@ %.rd: %.c - $(CC) -M -MG $(PROGCFLAGS) $< | \ + $(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \ sed -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@ @@ -269,19 +286,19 @@ version: # .ao files are used for static archives %.ao: %.c - $(CC) $(ARCFLAGS) -c $< -o $@ + $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@ %.ad: %.c - $(CC) -M -MG $(ARCFLAGS) $< | \ + $(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \ sed -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@ # .lo files are used for shared libraries %.lo: %.c - $(CC) $(LIBCFLAGS) -c $< -o $@ + $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@ %.ld: %.c - $(CC) -M -MG $(LIBCFLAGS) $< | \ + $(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \ sed -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@