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