-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
82 lines (63 loc) · 2.19 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Add inputs and outputs from these tool invocations to the build variables
PROJECT := syzycube
AVRDUDE_PORT ?= /dev/tty.usbserial-FTFA7ZBP
###
LSS := syzycube.lss
FLASH_IMAGE := syzycube.hex
ELF := syzycube.elf
SIZEDUMMY := sizedummy
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS := ADXL345.c main.c console.c TLC5947DAP.c
S_UPPER_SRCS :=
#ffft.S
OBJS := $(C_SRCS:%.c=%.o) $(S_UPPER_SRCS:%.S=%.o)
DEPS := $(OBJS:%.o=%.d)
LIBS := -lm
# All Target
all: $(PROJECT).elf secondary-outputs
# Target to invoke avrdude
run: $(PROJECT).hex
avrdude -pm168 -carduino -P$(AVRDUDE_PORT) -b19200 -Uflash:w:syzycube.hex:a
# Tool invocations
$(PROJECT).elf: $(OBJS)
@echo 'Building target: $@'
@echo 'Invoking: AVR C Linker'
avr-gcc -Wl,-Map,$(PROJECT).map -mmcu=atmega168p -o"$(PROJECT).elf" $(OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
$(PROJECT).lss: $(PROJECT).elf
@echo 'Invoking: AVR Create Extended Listing'
-avr-objdump -h -S $(PROJECT).elf >"$(PROJECT).lss"
@echo 'Finished building: $@'
@echo ' '
$(PROJECT).hex: $(PROJECT).elf
@echo 'Create Flash image (ihex format)'
-avr-objcopy -R .eeprom -O ihex $(PROJECT).elf "$(PROJECT).hex"
@echo 'Finished building: $@'
@echo ' '
sizedummy: $(PROJECT).elf
@echo 'Invoking: Print Size'
-avr-size --format=berkeley -t $(PROJECT).elf
@echo 'Finished building: $@'
@echo ' '
# Each subdirectory must supply rules for building sources it contributes
%.o: %.c
@echo 'Building file: $<'
@echo 'Invoking: AVR Compiler'
avr-gcc -Wall -Os -fpack-struct -fshort-enums -std=c99 -funsigned-char -funsigned-bitfields -mmcu=atmega168p -DF_CPU=16000000UL -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -c -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '
%.o: %.S
@echo 'Building file: $<'
@echo 'Invoking: AVR Assembler'
avr-gcc -x assembler-with-cpp -mmcu=atmega168p -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -c -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '
# Other Targets
clean:
-$(RM) $(PROJECT).elf $(PROJECT).lss $(PROJECT).hex $(PROJECT).map $(OBJS) $(DEPS)
-@echo ' '
secondary-outputs: $(LSS) $(FLASH_IMAGE) $(SIZEDUMMY)
.PHONY: all clean dependents sizedummy
.SECONDARY:
-include $(DEPS)