mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-24 04:29:34 +00:00
Merge pull request #339 from KevinOConnor/CompilerFlags
Add additional optimization flags to Makefile
This commit is contained in:
commit
96e9db8919
@ -227,6 +227,22 @@ OPT = s
|
|||||||
|
|
||||||
DEFINES ?=
|
DEFINES ?=
|
||||||
|
|
||||||
|
# Program settings
|
||||||
|
CC = $(AVR_TOOLS_PATH)avr-gcc
|
||||||
|
CXX = $(AVR_TOOLS_PATH)avr-g++
|
||||||
|
OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
|
||||||
|
OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
|
||||||
|
AR = $(AVR_TOOLS_PATH)avr-ar
|
||||||
|
SIZE = $(AVR_TOOLS_PATH)avr-size
|
||||||
|
NM = $(AVR_TOOLS_PATH)avr-nm
|
||||||
|
AVRDUDE = avrdude
|
||||||
|
REMOVE = rm -f
|
||||||
|
MV = mv -f
|
||||||
|
|
||||||
|
# Tool for testing compiler flags
|
||||||
|
cc-option=$(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`" \
|
||||||
|
; then echo "$(2)"; else echo "$(3)"; fi ;)
|
||||||
|
|
||||||
# Place -D or -U options here
|
# Place -D or -U options here
|
||||||
CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)}
|
CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)}
|
||||||
CXXDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)}
|
CXXDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)}
|
||||||
@ -251,10 +267,12 @@ CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
|
|||||||
endif
|
endif
|
||||||
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
|
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
|
||||||
|
|
||||||
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
|
CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) \
|
||||||
CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
|
$(call cc-option,$(CC),-flto -fwhole-program,)
|
||||||
|
CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) \
|
||||||
|
$(call cc-option,$(CC),-flto -fwhole-program,)
|
||||||
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
|
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
|
||||||
LDFLAGS = -lm
|
LDFLAGS = -lm -Wl,--relax
|
||||||
|
|
||||||
|
|
||||||
# Programming support using avrdude. Settings and variables.
|
# Programming support using avrdude. Settings and variables.
|
||||||
@ -264,18 +282,6 @@ AVRDUDE_FLAGS = -D -C $(ARDUINO_INSTALL_DIR)/hardware/tools/avrdude.conf \
|
|||||||
-p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
|
-p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
|
||||||
-b $(UPLOAD_RATE)
|
-b $(UPLOAD_RATE)
|
||||||
|
|
||||||
# Program settings
|
|
||||||
CC = $(AVR_TOOLS_PATH)avr-gcc
|
|
||||||
CXX = $(AVR_TOOLS_PATH)avr-g++
|
|
||||||
OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
|
|
||||||
OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
|
|
||||||
AR = $(AVR_TOOLS_PATH)avr-ar
|
|
||||||
SIZE = $(AVR_TOOLS_PATH)avr-size
|
|
||||||
NM = $(AVR_TOOLS_PATH)avr-nm
|
|
||||||
AVRDUDE = avrdude
|
|
||||||
REMOVE = rm -f
|
|
||||||
MV = mv -f
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
|
OBJ = ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
|
||||||
OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
|
OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
|
||||||
@ -372,9 +378,13 @@ extcoff: $(TARGET).elf
|
|||||||
$(NM) -n $< > $@
|
$(NM) -n $< > $@
|
||||||
|
|
||||||
# Link: create ELF output file from library.
|
# Link: create ELF output file from library.
|
||||||
$(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
|
$(BUILD_DIR)/$(TARGET).elf: $(BUILD_DIR)/$(TARGET).o
|
||||||
$(Pecho) " CXX $@"
|
$(Pecho) " CXX $@"
|
||||||
$P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ -L. $(OBJ) $(LDFLAGS)
|
$P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ -L. $^ $(LDFLAGS)
|
||||||
|
|
||||||
|
$(BUILD_DIR)/$(TARGET).o: $(OBJ) Configuration.h
|
||||||
|
$(Pecho) " CXX $@"
|
||||||
|
$P $(CC) $(ALL_CXXFLAGS) -nostdlib -Wl,-r -o $@ $(OBJ)
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
|
$(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
|
||||||
$(Pecho) " CC $<"
|
$(Pecho) " CC $<"
|
||||||
|
Loading…
Reference in New Issue
Block a user