|
|
|
@ -86,16 +86,27 @@ CPP_STANDARD ?= c++98
|
|
|
|
|
|
|
|
|
|
# Convert input source file list to differentiate them by type
|
|
|
|
|
C_SOURCE = $(filter %.c, $(SRC))
|
|
|
|
|
CPP_SOURCE = $(filter %.cpp, $(SRC)) $(filter %.c++, $(SRC))
|
|
|
|
|
CPP_SOURCE = $(filter %.cpp, $(SRC))
|
|
|
|
|
ASM_SOURCE = $(filter %.S, $(SRC))
|
|
|
|
|
|
|
|
|
|
# Convert input source filenames into a list of required output object files
|
|
|
|
|
OBJECT_FILES = $(C_SOURCE:%.c=%.o) $(CPP_SOURCE:%.c++=%.o) $(CPP_SOURCE:%.c++=%.o) $(ASM_SOURCE:%.S=%.o)
|
|
|
|
|
OBJECT_FILES = $(filter %.o, $(C_SOURCE:%.c=%.o) $(CPP_SOURCE:%.cpp=%.o) $(ASM_SOURCE:%.S=%.o))
|
|
|
|
|
|
|
|
|
|
# Create a list of flags to pass to the compiler
|
|
|
|
|
CC_FLAGS += -mmcu=$(MCU) -I. -I$(LUFA_PATH)/.. -gdwarf-2 -pipe
|
|
|
|
|
ifeq ($(ARCH),AVR8)
|
|
|
|
|
CC_FLAGS += -mmcu=$(MCU) -gdwarf-2 -fshort-enums -fno-inline-small-functions -fpack-struct
|
|
|
|
|
CROSS = avr-
|
|
|
|
|
else ifeq ($(ARCH),XMEGA)
|
|
|
|
|
CC_FLAGS += -mmcu=$(MCU) -gdwarf-2 -fshort-enums -fno-inline-small-functions -fpack-struct
|
|
|
|
|
CROSS = avr-
|
|
|
|
|
else ifeq ($(ARCH),UC3)
|
|
|
|
|
CC_FLAGS += -mpart=$(MCU) -g3 -masm-addr-pseudos
|
|
|
|
|
CROSS = avr32-
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
CC_FLAGS += -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections
|
|
|
|
|
CC_FLAGS += -Wall -Wstrict-prototypes
|
|
|
|
|
CC_FLAGS += -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections -fshort-enums -fno-inline-small-functions -fpack-struct -fshort-enums
|
|
|
|
|
CC_FLAGS += -I. -I$(LUFA_PATH)/.. -pipe
|
|
|
|
|
CC_FLAGS += -DARCH=ARCH_$(ARCH) -DBOARD=BOARD_$(BOARD) -DF_USB=$(F_USB)UL
|
|
|
|
|
ifneq ($(F_CPU),)
|
|
|
|
|
CC_FLAGS += -DF_CPU=$(F_CPU)UL
|
|
|
|
@ -147,33 +158,32 @@ lss: $(TARGET).lss
|
|
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
|
@echo $(MSG_COMPILE_CMD) Compiling C file \"$^\"
|
|
|
|
|
avr-gcc -c $(CC_FLAGS) -O$(OPTIMIZATION) --std=$(C_STANDARD) $< -o $@
|
|
|
|
|
$(CROSS)gcc -c $(CC_FLAGS) -O$(OPTIMIZATION) --std=$(C_STANDARD) $< -o $@
|
|
|
|
|
|
|
|
|
|
%.o: %.cpp
|
|
|
|
|
%.o: %.c++
|
|
|
|
|
@echo $(MSG_COMPILE_CMD) Compiling C++ file \"$^\"
|
|
|
|
|
avr-gcc -c $(CC_FLAGS) -O$(OPTIMIZATION) --std=$(CPP_STANDARD) -x c++ $< -o $@
|
|
|
|
|
$(CROSS)gcc -c $(CC_FLAGS) -O$(OPTIMIZATION) --std=$(CPP_STANDARD) -x c++ $< -o $@
|
|
|
|
|
|
|
|
|
|
%.o: %.S
|
|
|
|
|
@echo $(MSG_COMPILE_CMD) Assembling \"$^\"
|
|
|
|
|
avr-gcc -c $(CC_FLAGS) -x assembler-with-cpp $< -o $@
|
|
|
|
|
$(CROSS)gcc -c $(CC_FLAGS) -x assembler-with-cpp $< -o $@
|
|
|
|
|
|
|
|
|
|
.PRECIOUS : $(OBJECT_FILES)
|
|
|
|
|
%.elf: $(OBJECT_FILES)
|
|
|
|
|
@echo $(MSG_LINKER_CMD) Linking object files into \"$@\"
|
|
|
|
|
avr-gcc $^ $(CC_FLAGS) $(LD_FLAGS) -o $@
|
|
|
|
|
$(CROSS)gcc $^ $(CC_FLAGS) $(LD_FLAGS) -o $@
|
|
|
|
|
|
|
|
|
|
%.hex: %.elf
|
|
|
|
|
@echo $(MSG_OBJCPY_CMD) Extracting HEX file data from \"$@\"
|
|
|
|
|
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@
|
|
|
|
|
$(CROSS)objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@
|
|
|
|
|
|
|
|
|
|
%.eep: %.elf
|
|
|
|
|
@echo $(MSG_OBJCPY_CMD) Extracting EEP file data from \"$@\"
|
|
|
|
|
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex $< $@ || exit 0
|
|
|
|
|
$(CROSS)objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex $< $@ || exit 0
|
|
|
|
|
|
|
|
|
|
%.lss: %.elf
|
|
|
|
|
@echo $(MSG_OBJDMP_CMD) Extracting LSS file data from \"$@\"
|
|
|
|
|
avr-objdump -h -S -z $< > $@
|
|
|
|
|
$(CROSS)objdump -h -S -z $< > $@
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
|
@echo $(MSG_REMOVE_CMD) Removing object files \"$(OBJECT_FILES)\"
|
|
|
|
|