]> granicus.if.org Git - esp-idf/commitdiff
build system: fix setting C**FLAGS from project makefile
authorIvan Grokhotkov <ivan@espressif.com>
Thu, 20 Oct 2016 09:17:54 +0000 (17:17 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Thu, 20 Oct 2016 09:17:54 +0000 (17:17 +0800)
Kconfig
make/project.mk

diff --git a/Kconfig b/Kconfig
index 97da1f01f59ed05abee93803303b982dc459c840..deb0cea839e67fd65f601f982b763a63b52c12b0 100644 (file)
--- a/Kconfig
+++ b/Kconfig
@@ -28,9 +28,15 @@ choice OPTIMIZATION_LEVEL
     default OPTIMIZATION_LEVEL_DEBUG
     help
         This option sets optimization level.
-        For "Release" setting, -Os flag is added to CFLAGS,
+        
+        - for "Release" setting, -Os flag is added to CFLAGS,
          and -DNDEBUG flag is added to CPPFLAGS.
-        For "Debug" setting, -Og flag is added to CFLAGS.
+         
+        - for "Debug" setting, -Og flag is added to CFLAGS.
+        
+        To override any of these settings, set CFLAGS and/or CPPFLAGS
+        in project makefile, before including $(IDF_PATH)/make/project.mk.
+        
 config OPTIMIZATION_LEVEL_DEBUG
     bool "Debug"
 config OPTIMIZATION_LEVEL_RELEASE
index b646dfc4192274cae1295d6d29a0c5d99c824845..887086fd47fb9d524672fac0f4ef8501d682018a 100644 (file)
@@ -149,16 +149,16 @@ LDFLAGS ?= -nostdlib \
        -Wl,-EL
 
 # Set default CPPFLAGS, CFLAGS, CXXFLAGS
-#
 # These are exported so that components can use them when compiling.
-#
 # If you need your component to add CFLAGS/etc for it's own source compilation only, set CFLAGS += in your component's Makefile.
-#
 # If you need your component to add CFLAGS/etc globally for all source
-# files, set CFLAGS += in your component's Makefile.projbuild
+#  files, set CFLAGS += in your component's Makefile.projbuild
+# If you need to set CFLAGS/CPPFLAGS/CXXFLAGS at project level, set them in application Makefile
+#  before including project.mk. Default flags will be added before the ones provided in application Makefile.
 
 # CPPFLAGS used by C preprocessor
-CPPFLAGS = -DESP_PLATFORM
+# If any flags are defined in application Makefile, add them at the end. 
+CPPFLAGS := -DESP_PLATFORM $(CPPFLAGS)
 
 # Warnings-related flags relevant both for C and C++
 COMMON_WARNING_FLAGS = -Wall -Werror \
@@ -186,10 +186,24 @@ endif
 OPTIMIZATION_FLAGS += -ggdb
 
 # List of flags to pass to C compiler
-CFLAGS = -std=gnu99 $(strip $(OPTIMIZATION_FLAGS) $(COMMON_FLAGS) $(COMMON_WARNING_FLAGS))
+# If any flags are defined in application Makefile, add them at the end.
+CFLAGS := $(strip \
+       -std=gnu99 \
+       $(OPTIMIZATION_FLAGS) \
+       $(COMMON_FLAGS) \
+       $(COMMON_WARNING_FLAGS) \
+       $(CFLAGS))
 
 # List of flags to pass to C++ compiler
-CXXFLAGS = -std=gnu++11 -fno-exceptions -fno-rtti $(strip $(OPTIMIZATION_FLAGS) $(COMMON_FLAGS) $(COMMON_WARNING_FLAGS))
+# If any flags are defined in application Makefile, add them at the end.
+CXXFLAGS := $(strip \
+       -std=gnu++11 \
+       -fno-exceptions \
+       -fno-rtti \
+       $(OPTIMIZATION_FLAGS) \
+       $(COMMON_FLAGS) \
+       $(COMMON_WARNING_FLAGS) \
+       $(CXXFLAGS))
 
 export CFLAGS CPPFLAGS CXXFLAGS