Add C_FLAGS, CPP_FLAGS and ASM_FLAGS variables to the build system BUILD module to...
authorDean Camera <dean@fourwalledcubicle.com>
Sat, 2 Jun 2012 11:18:28 +0000 (11:18 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sat, 2 Jun 2012 11:18:28 +0000 (11:18 +0000)
BuildTests/ModuleTest/makefile.test
LUFA/Build/lufa.build.in

index 94004b8..b3307f8 100644 (file)
@@ -27,8 +27,9 @@ TARGET       = Test
 SRC          = $(TARGET)_C.c $(TARGET)_CPP.cpp Dummy.S $(LUFA_SRC_USB)\r
 LUFA_PATH    = ../../LUFA/\r
 \r
-CC_FLAGS     = -Wextra\r
-#CC_FLAGS += -Werror # FIXME\r
+# Generic C/C++ compiler flags\r
+CC_FLAGS  = -Wextra\r
+CC_FLAGS += -Werror\r
 CC_FLAGS += -Wformat=2\r
 CC_FLAGS += -Winit-self\r
 CC_FLAGS += -Wswitch-enum\r
@@ -38,11 +39,9 @@ CC_FLAGS += -Wpointer-arith
 CC_FLAGS += -Wcast-align\r
 CC_FLAGS += -Wwrite-strings\r
 CC_FLAGS += -Wlogical-op\r
-CC_FLAGS += -Wmissing-parameter-type\r
 CC_FLAGS += -Wmissing-declarations\r
 CC_FLAGS += -Wmissing-field-initializers\r
 CC_FLAGS += -Wmissing-format-attribute\r
-CC_FLAGS += -Wnested-externs\r
 CC_FLAGS += -Woverlength-strings\r
 \r
 # Only enable rendundant declaration warnings for AVR8 target (FIXME)\r
@@ -50,6 +49,10 @@ ifeq ($(ARCH), AVR8)
 CC_FLAGS += -Wredundant-decls\r
 endif\r
 \r
+# C compiler only flags\r
+C_FLAGS += -Wmissing-parameter-type\r
+C_FLAGS += -Wnested-externs\r
+\r
 # Potential additional warnings to enable in the future (FIXME)\r
 #CC_FLAGS += -Wswitch-default\r
 #CC_FLAGS += -Wc++-compat\r
index be14a6f..d9d6b9f 100644 (file)
@@ -42,7 +42,11 @@ LUFA_BUILD_TARGETS += size checksource all elf hex clean
 #    C_STANDARD                - C Language Standard to use\r
 #    CPP_STANDARD              - C++ Language Standard to use\r
 #    F_CPU                     - Speed of the CPU, in Hz\r
-#    CC_FLAGS                  - Flags to pass to the compiler\r
+#    C_FLAGS                   - Flags to pass to the C compiler only\r
+#    CPP_FLAGS                 - Flags to pass to the C++ compiler only\r
+#    ASM_FLAGS                 - Flags to pass to the assembler only\r
+#    CC_FLAGS                  - Common flags to pass to the C/C++ compiler and\r
+#                                assembler\r
 #    LD_FLAGS                  - Flags to pass to the linker\r
 #\r
 # -----------------------------------------------------------------------------\r
@@ -83,6 +87,10 @@ OPTIMIZATION  ?= s
 F_CPU         ?=\r
 C_STANDARD    ?= gnu99\r
 CPP_STANDARD  ?= gnu++98\r
+C_FLAGS       ?=\r
+CPP_FLAGS     ?=\r
+ASM_FLAGS     ?=\r
+CC_FLAGS      ?=\r
 \r
 # Convert input source file list to differentiate them by type\r
 C_SOURCE   = $(filter %.c, $(SRC))\r
@@ -105,14 +113,16 @@ else ifeq ($(ARCH), UC3)
 else\r
   $(error Unsupported architecture.)\r
 endif\r
-CC_FLAGS += -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections\r
-CC_FLAGS += -Wall -Wstrict-prototypes\r
+CC_FLAGS += -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections\r
 CC_FLAGS += -I. -I$(LUFA_PATH)/..\r
 CC_FLAGS += -DARCH=ARCH_$(ARCH) -DBOARD=BOARD_$(BOARD) -DF_USB=$(F_USB)UL\r
 ifneq ($(F_CPU),)\r
    CC_FLAGS += -DF_CPU=$(F_CPU)UL\r
 endif\r
 \r
+# Additional language specific compiler flags\r
+C_FLAGS   += -Wstrict-prototypes\r
+\r
 # Create a list of flags to pass to the linker\r
 LD_FLAGS += -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections -lm\r
 ifneq ($(F_CPU), UC3)\r
@@ -162,15 +172,15 @@ lss: $(TARGET).lss
 \r
 %.o: %.c\r
        @echo $(MSG_COMPILE_CMD) Compiling C file \"$^\"\r
-       $(CROSS)gcc -c $(CC_FLAGS) -O$(OPTIMIZATION) -std=$(C_STANDARD) $< -o $@\r
+       $(CROSS)gcc -c $(CC_FLAGS) $(C_FLAGS) -O$(OPTIMIZATION) -std=$(C_STANDARD) $< -o $@\r
 \r
 %.o: %.cpp\r
        @echo $(MSG_COMPILE_CMD) Compiling C++ file \"$^\"\r
-       $(CROSS)gcc -c $(CC_FLAGS) -O$(OPTIMIZATION) -std=$(CPP_STANDARD) -x c++ $< -o $@\r
+       $(CROSS)gcc -c $(CC_FLAGS) $(CPP_FLAGS) -O$(OPTIMIZATION) -std=$(CPP_STANDARD) -x c++ $< -o $@\r
        \r
 %.o: %.S\r
        @echo $(MSG_COMPILE_CMD) Assembling \"$^\"\r
-       $(CROSS)gcc -c $(CC_FLAGS) -x assembler-with-cpp $< -o $@\r
+       $(CROSS)gcc -c $(CC_FLAGS) $(ASM_FLAGS) -x assembler-with-cpp $< -o $@\r
 \r
 .PRECIOUS : $(OBJECT_FILES)\r
 %.elf: $(OBJECT_FILES)\r