-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmakefile
More file actions
184 lines (139 loc) · 5.26 KB
/
Copy pathmakefile
File metadata and controls
184 lines (139 loc) · 5.26 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# Makefile for Polaric Tracker
# Target file name (without extension).
TARGET = firmware
# Output format for .hex files, can be [srec|ihex]. Note that we have
# a special .img target for binary output.
FORMAT = ihex
# MCU name and clock speed
MCU = at90usb1287
F_CPU = 8000000
# Define programs.
SHELL = sh
AR = ar
COMPILE = avr-gcc
ASSEMBLE = avr-gcc -x assembler-with-cpp
REMOVE = rm -f
COPY = cp
MOVE = mv
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
HEXSIZE = @avr-size --target=$(FORMAT) $(TARGET).hex
ELFSIZE = @avr-size $(TARGET).elf
LISP = clisp
# LUFA definitions
USB_PATH = LUFA/Drivers/USB
LUFA_OPTS = -D USB_DEVICE_ONLY
LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
USB_CFLAGS = \
-I$(USB_PATH) -DF_CLOCK=$(F_CPU)UL $(LUFA_OPTS)
USB_SRC = usb_descriptors.c usb.c \
$(USB_PATH)/LowLevel/USBController.c $(USB_PATH)/LowLevel/Device.c \
$(USB_PATH)/LowLevel/USBInterrupt.c $(USB_PATH)/HighLevel/USBTask.c \
$(USB_PATH)/HighLevel/Events.c $(USB_PATH)/HighLevel/EndpointStream.c $(USB_PATH)/HighLevel/PipeStream.c \
$(USB_PATH)/HighLevel/DeviceStandardReq.c $(USB_PATH)/LowLevel/Endpoint.c \
$(USB_PATH)/Class/Device/CDC.c
USB_INCLUDE = -I$(USB_PATH)
# List of C source files which should be preprocessed
PSRC = commands.c
# List C source files here.
SRC = main.c config.c ui.c kernel/kernel.c kernel/timer.c \
kernel/stream.c uart.c gps.c afsk_tx.c afsk_rx.c \
hdlc_encoder.c hdlc_decoder.c fbuf.c ax25.c adc.c monitor.c digipeater.c \
tracker.c radio.c transceiver.c heardlist.c $(PSRC) $(USB_SRC)
# List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.
ASRC =
# Compiler flags.
CFLAGS = -O2 $(USB_CFLAGS) -I. -DF_CPU=$(F_CPU)UL -funsigned-char --std=gnu99 -Wall -Wa,-ahlms=$(<:.c=.lst) -fno-strict-aliasing -fshort-enums
# Assembler flags.
ASFLAGS = -Wa,-ahlms=$(<:.s=.lst),--gstabs
# Linker flags (passed via GCC).
LDFLAGS = -Wl,--script=$(TARGET).x,-Map=$(TARGET).map,--cref,-u,vfprintf,-u,vfscanf -lprintf_flt -lscanf_flt -lm -lc -lm
# Define all project specific object files.
OBJ = $(SRC:.c=.o) $(ASRC:.s=.o)
# Define all listing files.
LST = $(ASRC:.s=.lst) $(SRC:.c=.lst)
# Compiler flags to generate dependency files.
GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
# Add target processor to flags.
CFLAGS += -mmcu=$(MCU) $(GENDEPFLAGS)
ASFLAGS += -mmcu=$(MCU)
LDFLAGS += -mmcu=$(MCU)
.PHONY : build
build: $(TARGET).elf $(TARGET).hex $(TARGET).lss $(TARGET).bin line1 overallsize line2
.PHONY : BuildAll
buildall: clean build
.PHONY : overallsize
overallsize:
@echo Elf size:
$(ELFSIZE)
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@
# Create final output files (.hex, .lss) from ELF output file.
%.hex: %.elf
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
# Create extended listing file from ELF output file.
%.lss: %.elf
$(OBJDUMP) -h -S $< > $@
# Link: create ELF output file from object files.
.SECONDARY : $(TRG).elf
.PRECIOUS : $(OBJ)
%.elf: $(OBJ)
$(COMPILE) $(OBJ) $(LDFLAGS) --output $@
# I need to specify this rule explicit for some reason - la7dja
$(TARGET).elf: $(OBJ)
$(COMPILE) $(OBJ) $(LDFLAGS) --output $@
# Compile: create object files from C source files.
%.o : %.c
$(COMPILE) -c $(CFLAGS) $< -o $@
# Compile: create assembler files from C source files.
%.s : %.c
$(COMPILE) -S -fverbose-asm $(CFLAGS) $< -o $@
# Assemble: create object files from assembler files.
%.o : %.s
$(ASSEMBLE) -c $(ASFLAGS) $< -o $@
# device firmware upload via usb
dfu: $(TARGET).hex
dfu-programmer $(MCU) erase
dfu-programmer $(MCU) flash $(TARGET).hex
dfu-programmer $(MCU) start
# device firmware upload via JTAG
JTAGID=jtagmkII
JTAGDEV=usb
jtag: $(TARGET).hex
avrdude -p$(MCU) -P$(JTAGDEV) -c$(JTAGID) -D -Uflash:w:$(TARGET).hex
# Target: line1 project.
.PHONY : line1
line1 :
@echo ---------------------------------------------------------------------------------------------------
# Target: line2 project.
.PHONY : line2
line2 :
@echo ---------------------------------------------------------------------------------------------------
# Target: clean project.
.SILENT : Clean
.PHONY : Clean
clean :
$(REMOVE) $(TARGET).hex
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).elf
$(REMOVE) $(TARGET).bin
$(REMOVE) $(TARGET).map
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).sym
$(REMOVE) $(TARGET).lnk
$(REMOVE) $(TARGET).lss
$(REMOVE) $(OBJ)
$(REMOVE) $(LST)
$(REMOVE) $(SRC:.c=.s)
# Include the dependency files.
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
# List assembly only source file dependencies here: