forked from autosportlabs/RaceCapture-Pro_firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
644 lines (532 loc) · 17.1 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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
# Hey Emacs, this is a -*- makefile -*-
#
# WinARM template makefile
# by Martin Thomas, Kaiserslautern, Germany
#
# based on the WinAVR makefile written by Eric B. Weddington, J�rg Wunsch, et al.
# Released to the Public Domain
# Please read the make user manual!
#
#
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make program = Download the hex file to the device
#
# (TODO: make filename.s = Just compile filename.c into the assembler code only)
#
# To rebuild project do "make clean" then "make all".
#
# Changelog:
# - 17. Feb. 2005 - added thumb-interwork support (mth)
# - 28. Apr. 2005 - added C++ support (mth)
# - 29. Arp. 2005 - changed handling for lst-Filename (mth)
# - 1. Nov. 2005 - exception-vector placement options (mth)
# - 15. Nov. 2005 - added library-search-path (EXTRA_LIB...) (mth)
# - 2. Dec. 2005 - fixed ihex and binary file extensions (mth)
#
include version.mk
RELEASE_DIR ?= .
RELEASE_NAME_BIN = RaceCapturePro-$(MAJOR).$(MINOR).$(BUGFIX).bin
RELEASE_NAME_ELF = RaceCapturePro-$(MAJOR).$(MINOR).$(BUGFIX).elf
# MCU name and submodel
MCU = arm7tdmi
SUBMDL = AT91SAM7S256
#SUBMDL = AT91SAM7S64
THUMB = -mthumb
THUMB_IW = -mthumb-interwork
## Create ROM-Image (final)
RUN_MODE=ROM_RUN
## Exception-Vector placement only supported for "ROM_RUN"
## (placement settings ignored when using "RAM_RUN")
## - Exception vectors in ROM:
#VECTOR_LOCATION=VECTORS_IN_ROM
## - Exception vectors in RAM:
VECTOR_LOCATION=VECTORS_IN_RAM
## Output format. (can be ihex or binary)
#FORMAT = ihex
FORMAT = binary
# Target file name (without extension).
TARGET = main
# Common directories
INCLUDE_DIR = include
SRC_DIR = src
SAM7s_BASE_DIR = SAM7s_base
HW_DIR = $(SAM7s_BASE_DIR)/hardware
RTOS_DIR = $(SAM7s_BASE_DIR)/FreeRTOS
RTOS_SRC_DIR = $(RTOS_DIR)/Source
RTOS_PORT_DIR = $(RTOS_SRC_DIR)/portable
RTOS_GCC_DIR = $(RTOS_PORT_DIR)/GCC/ARM7_AT91SAM7S
RTOS_MEMMANG_DIR = $(RTOS_PORT_DIR)/MemMang
USB_SRC_DIR = $(SAM7s_BASE_DIR)/usb
SERIAL_SRC_DIR = $(SAM7s_BASE_DIR)/serial
UART_SRC_DIR = $(SAM7s_BASE_DIR)/uart
SAM7S_UTIL_DIR = $(SAM7s_BASE_DIR)/util
SPI_DIR = $(SAM7s_BASE_DIR)/spi
MEMORY_SRC_DIR = $(SAM7s_BASE_DIR)/memory
LUA_SRC_DIR = $(SAM7s_BASE_DIR)/lua
CMD_SRC_DIR = $(SAM7s_BASE_DIR)/command
FILTER_DIR = $(SRC_DIR)/filter
LOGGING_DIR = $(SRC_DIR)/logging
TASKS_DIR = tasks
JSMN_SRC_DIR = $(SRC_DIR)/jsmn
API_SRC_DIR = $(SRC_DIR)/api
MESSAGING_SRC_DIR = $(SRC_DIR)/messaging
DEVICES_SRC_DIR = $(SRC_DIR)/devices
PRED_TIMER_DIR = $(SRC_DIR)/predictive_timer
UTIL_DIR = $(SRC_DIR)/util
JSON_DIR = ./json
GPS_SRC_DIR = $(SRC_DIR)/gps
#App specific dirs
FAT_SD_SRC_DIR = fat_sd
LOGGER_SRC_DIR = logger
SDCARD_SRC_DIR = sdcard
ACCELEROMETER_SRC_DIR = accelerometer
# List C source files here. (C dependencies are automatically generated.)
# use file-extension c for "c-only"-files
SRC = \
$(TARGET).c \
$(JSMN_SRC_DIR)/jsmn.c \
baseCommands.c \
$(API_SRC_DIR)/api.c \
$(SRC_DIR)/$(LOGGER_SRC_DIR)/loggerApi.c \
$(HW_DIR)/lib_AT91SAM7S256.c \
$(RTOS_SRC_DIR)/tasks.c \
$(RTOS_SRC_DIR)/queue.c \
$(RTOS_SRC_DIR)/list.c \
$(RTOS_GCC_DIR)/port.c \
$(UTIL_DIR)/modp_numtoa.c \
$(UTIL_DIR)/modp_atonum.c \
$(SAM7S_UTIL_DIR)/taskUtil.c \
$(SPI_DIR)/spi.c \
$(USB_SRC_DIR)/source/usb_comm.c \
$(USB_SRC_DIR)/source/USB-CDC.c \
$(UART_SRC_DIR)/usart.c \
$(CMD_SRC_DIR)/command.c \
$(SERIAL_SRC_DIR)/serial.c \
$(FAT_SD_SRC_DIR)/fattime.c \
$(FAT_SD_SRC_DIR)/ff.c \
$(FAT_SD_SRC_DIR)/sd_spi_at91.c \
$(FAT_SD_SRC_DIR)/rtc.c \
$(SDCARD_SRC_DIR)/sdcard.c \
$(ACCELEROMETER_SRC_DIR)/accelerometer.c \
$(LOGGER_SRC_DIR)/sampleRecord.c \
$(LOGGER_SRC_DIR)/fileWriter.c \
$(LOGGER_SRC_DIR)/loggerHardware.c \
$(LOGGER_SRC_DIR)/loggerData.c \
$(LOGGER_SRC_DIR)/gpioTasks.c \
$(LOGGER_SRC_DIR)/loggerTaskEx.c \
$(LOGGER_SRC_DIR)/connectivityTask.c \
$(GPS_SRC_DIR)/gps.c \
$(LOGGER_SRC_DIR)/gpsTask.c \
$(LOGGER_SRC_DIR)/loggerConfig.c \
$(GPS_SRC_DIR)/geometry.c \
$(LOGGER_SRC_DIR)/luaLoggerBinding.c \
$(LOGGER_SRC_DIR)/loggerCommands.c \
$(MEMORY_SRC_DIR)/memory.c \
$(LUA_SRC_DIR)/luaTask.c \
$(LUA_SRC_DIR)/luaScript.c \
$(LUA_SRC_DIR)/luaBaseBinding.c \
$(LUA_SRC_DIR)/luaCommands.c \
$(RTOS_PORT_DIR)/MemMang/heap_2_combine.c \
$(LOGGING_DIR)/printk.c \
$(FILTER_DIR)/filter.c \
$(LOGGING_DIR)/ring_buffer.c \
$(TASKS_DIR)/heartbeat.c \
$(MESSAGING_SRC_DIR)/messaging.c \
$(PRED_TIMER_DIR)/predictive_timer.c \
$(UTIL_DIR)/linear_interpolate.c \
$(DEVICES_SRC_DIR)/cellModem.c \
$(DEVICES_SRC_DIR)/null_device.c \
$(DEVICES_SRC_DIR)/bluetooth.c \
$(DEVICES_SRC_DIR)/sim900.c
# List C source files here which must be compiled in ARM-Mode.
# use file-extension c for "c-only"-files
SRCARM = $(RTOS_GCC_DIR)/portISR.c \
interrupt_utils.c \
$(USB_SRC_DIR)/source/USBIsr.c \
$(LOGGER_SRC_DIR)/gpioIsr.c \
$(UART_SRC_DIR)/serialIsr.c \
$(LOGGER_SRC_DIR)/timerIsr.c
# List C++ source files here.
# use file-extension cpp for C++-files (use extension .cpp)
CPPSRC =
# List C++ source files here which must be compiled in ARM-Mode.
# use file-extension cpp for C++-files (use extension .cpp)
#CPPSRCARM = $(TARGET).cpp
CPPSRCARM =
# 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 =
# List Assembler source files here which must be assembled in ARM-Mode..
ASRCARM = startup_SAM7S.S
#ASRCARM = crt.S
# Optimization level, can be [0, 1, 2, 3, s].
# 0 = turn off optimization. s = optimize for size.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = s
# Debugging format.
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
#DEBUG = stabs
#DEBUG = dwarf-2
DEBUG = -g
#DEBUG =
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
EXTRAINCDIRS = SAM7s_lua/src
# List any extra directories to look for library files here.
# Each directory must be seperated by a space.
EXTRA_LIBDIRS = SAM7s_lua/src
# Compiler flag to set the C Standard level.
# c89 - "ANSI" C
# gnu89 - c89 plus GCC extensions
# c99 - ISO C99 standard (not yet fully implemented)
# gnu99 - c99 plus GCC extensions
CSTANDARD = -std=gnu99
# Place -D or -U options for C here
CDEFS = -D$(RUN_MODE) -DMAJOR_REV=\"$(MAJOR)\" -DMINOR_REV=\"$(MINOR)\" -DBUGFIX_REV=\"$(BUGFIX)\"
# Compile for SAM7 using GCC
CDEFS += -DSAM7_GCC
# If using THUMB mode, then add this for the assembly process
CDEFS += -DTHUMB_INTERWORK
# Place -I options here
CINCS = \
-I. \
-I$(RTOS_MEMMANG_DIR) \
-I$(UTIL_DIR) \
-I$(SAM7S_UTIL_DIR) \
-I$(LUA_SRC_DIR) \
-I$(MEMORY_SRC_DIR) \
-I$(FAT_SD_SRC_DIR) \
-I$(SDCARD_SRC_DIR) \
-I$(SERIAL_SRC_DIR) \
-I$(SPI_DIR) \
-I$(UART_SRC_DIR) \
-I$(ACCELEROMETER_SRC_DIR) \
-I$(LOGGER_SRC_DIR) \
-I$(USB_SRC_DIR)/include \
-I$(HW_DIR)/include \
-I$(RTOS_SRC_DIR)/include \
-I$(RTOS_GCC_DIR) \
-I$(CMD_SRC_DIR) \
-I$(INCLUDE_DIR) \
-I$(INCLUDE_DIR)/jsmn \
-I$(INCLUDE_DIR)/api \
-I$(INCLUDE_DIR)/logger \
-I$(INCLUDE_DIR)/logging \
-I$(INCLUDE_DIR)/filter \
-I$(INCLUDE_DIR)/messaging \
-I$(INCLUDE_DIR)/predictive_timer \
-I$(INCLUDE_DIR)/util \
-I$(INCLUDE_DIR)/devices \
-I$(INCLUDE_DIR)/gps \
-I$(JSON_DIR)
#CINCS = -I. -I$(HW_DIR)/include -I$(RTOS_SRC_DIR)/include -I$(RTOS_GCC_DIR)
# Place -D or -U options for ASM here
ADEFS = -D$(RUN_MODE)
ifdef VECTOR_LOCATION
CDEFS += -D$(VECTOR_LOCATION)
ADEFS += -D$(VECTOR_LOCATION)
endif
# Compiler flags.
# -g*: generate debugging information
# -O*: optimization level
# -f...: tuning, see GCC manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -adhlns...: create assembler listing
#
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
CFLAGS = $(DEBUG)
CFLAGS += $(CDEFS) $(CINCS)
CFLAGS += -O$(OPT)
CFLAGS += -Wall
CFLAGS += -fomit-frame-pointer
CFLAGS += -Wcast-align -Wimplicit
CFLAGS += -Wpointer-arith -Wswitch
CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow -Wunused
CFLAGS += -ffunction-sections -fdata-sections
#CFLAGS += -Wno-strict-aliasing -Wextra
CFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<)
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
#AT91-lib warnings with:
##CFLAGS += -Wcast-qual
# flags only for C
CONLYFLAGS += -Wnested-externs
CONLYFLAGS += $(CSTANDARD)
#AT91-lib warnings with:
##CONLYFLAGS += -Wmissing-prototypes
##CONLYFLAGS += -Wstrict-prototypes
##CONLYFLAGS += -Wmissing-declarations
# flags only for C++ (arm-elf-g++)
# CPPFLAGS = -fno-rtti -fno-exceptions
CPPFLAGS =
# Assembler flags.
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create listing
# -g$(DEBUG):have the assembler create line number information
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:.S=.lst), $(DEBUG)
#Additional libraries.
# Extra libraries
# Each library-name must be seperated by a space.
EXTRA_LIBS = lua m
#Support for newlibc-lpc (file: libnewlibc-lpc.a)
#NEWLIBLPC = -lnewlib-lpc
MATH_LIB = -lm
# CPLUSPLUS_LIB = -lstdc++
# Linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -nostartfiles -Wl,-Map=$(TARGET).map,--cref,--gc-sections
LDFLAGS += -lc
LDFLAGS += $(NEWLIBLPC) $(MATH_LIB)
LDFLAGS += -lc -lgcc
LDFLAGS += $(CPLUSPLUS_LIB)
LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS))
LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS))
# Set Linker-Script Depending On Selected Memory and Controller
LDFLAGS +=-T$(SUBMDL)-ROM.ld
# ---------------------------------------------------------------------------
# Flash-Programming support using lpc21isp by Martin Maurer
# only for Philips LPC and Analog ADu ARMs
#
# Settings and variables:
#LPC21ISP = lpc21isp
LPC21ISP = lpc21isp_beta
LPC21ISP_PORT = com1
LPC21ISP_BAUD = 115200
LPC21ISP_XTAL = 14746
LPC21ISP_FLASHFILE = $(TARGET).hex
# verbose output:
## LPC21ISP_DEBUG = -debug
# enter bootloader via RS232 DTR/RTS (only if hardware supports this
# feature - see Philips AppNote):
LPC21ISP_CONTROL = -control
# ---------------------------------------------------------------------------
# Define directories, if needed.
## DIRARM = c:/WinARM/
## DIRARMBIN = $(DIRAVR)/bin/
## DIRAVRUTILS = $(DIRAVR)/utils/bin/
# Define programs and commands.
SHELL = sh
#gnuarm settings
CC = arm-elf-gcc
CPP = arm-elf-g++
OBJCOPY = arm-elf-objcopy
OBJDUMP = arm-elf-objdump
SIZE = arm-elf-size
NM = arm-elf-nm
#CodeSourcery settings
#CC = arm-none-eabi-gcc
#CPP = arm-none-eabi-g++
#OBJCOPY = arm-none-eabi-objcopy
#OBJDUMP = arm-none-eabi-objdump
#SIZE = arm-none-eabi-size
#NM = arm-none-eabi-nm
REMOVE = rm -f
COPY = cp
# Define Messages
# English
MSG_ERRORS_NONE = Errors: none
MSG_BEGIN = "-------- begin (mode: $(RUN_MODE)) --------"
MSG_END = -------- end --------
MSG_SIZE_BEFORE = Size before:
MSG_SIZE_AFTER = Size after:
MSG_FLASH = Creating load file for Flash:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
MSG_LINKING = Linking:
MSG_COMPILING = Compiling C:
MSG_COMPILING_ARM = "Compiling C (ARM-only):"
MSG_COMPILINGCPP = Compiling C++:
MSG_COMPILINGCPP_ARM = "Compiling C++ (ARM-only):"
MSG_ASSEMBLING = Assembling:
MSG_ASSEMBLING_ARM = "Assembling (ARM-only):"
MSG_CLEANING = Cleaning project:
MSG_FORMATERROR = Can not handle output-format
MSG_LPC21_RESETREMINDER = You may have to bring the target in bootloader-mode now.
# Define all object files.
COBJ = $(SRC:.c=.o)
AOBJ = $(ASRC:.S=.o)
COBJARM = $(SRCARM:.c=.o)
AOBJARM = $(ASRCARM:.S=.o)
CPPOBJ = $(CPPSRC:.cpp=.o)
CPPOBJARM = $(CPPSRCARM:.cpp=.o)
# Define all listing files.
LST = $(ASRC:.S=.lst) $(ASRCARM:.S=.lst) $(SRC:.c=.lst) $(SRCARM:.c=.lst)
LST += $(CPPSRC:.cpp=.lst) $(CPPSRCARM:.cpp=.lst)
# Compiler flags to generate dependency files.
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. $(CFLAGS) $(GENDEPFLAGS)
ALL_ASFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. -x assembler-with-cpp $(ASFLAGS)
# Default target.
all: begin gccversion sizebefore build sizeafter finished end
ifeq ($(FORMAT),ihex)
build: elf hex lss sym
hex: $(TARGET).hex
else
ifeq ($(FORMAT),binary)
build: elf bin lss sym
bin: $(TARGET).bin
else
$(error "$(MSG_FORMATERROR) $(FORMAT)")
endif
endif
elf: $(TARGET).elf
lss: $(TARGET).lss
sym: $(TARGET).sym
# Eye candy.
begin:
@echo
@echo $(MSG_BEGIN)
@echo
@echo $(PATH)
finished:
@echo $(MSG_ERRORS_NONE)
end:
@echo $(MSG_END)
@echo
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
ELFSIZE = $(SIZE) -A $(TARGET).elf
sizebefore:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
sizeafter:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
# Display compiler version information.
gccversion :
@$(CC) --version
# Create final output files (.hex, .eep) from ELF output file.
# TODO: handle an .eeprom-section but should be redundant
%.hex: %.elf
@echo
@echo $(MSG_FLASH) $@
@$(OBJCOPY) -O $(FORMAT) $< $@
# Create final output file (.bin) from ELF output file.
%.bin: %.elf
@echo
@echo $(MSG_FLASH) $@
@$(OBJCOPY) -O $(FORMAT) $< $@
# Create extended listing file from ELF output file.
# testing: option -C
%.lss: %.elf
@echo
# @echo $(MSG_EXTENDED_LISTING) $@
# $(OBJDUMP) -h -S -C $< > $@
# Create a symbol table from ELF output file.
%.sym: %.elf
@echo
@echo $(MSG_SYMBOL_TABLE) $@
@$(NM) -n $< > $@
# Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf
.PRECIOUS : $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)
%.elf: $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)
@echo
@echo $(MSG_LINKING) $@
@$(CC) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)
# $(CPP) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)
# Compile: create object files from C source files. ARM/Thumb
$(COBJ) : %.o : %.c
@echo
@echo $(MSG_COMPILING) $<
@$(CC) -c $(THUMB) $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
# Compile: create object files from C source files. ARM-only
$(COBJARM) : %.o : %.c
@echo
@echo $(MSG_COMPILING_ARM) $<
@$(CC) -c $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
# Compile: create object files from C++ source files. ARM/Thumb
$(CPPOBJ) : %.o : %.cpp
@echo
@echo $(MSG_COMPILINGCPP) $<
@$(CPP) -c $(THUMB) $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@
# Compile: create object files from C++ source files. ARM-only
$(CPPOBJARM) : %.o : %.cpp
@echo
@echo $(MSG_COMPILINGCPP_ARM) $<
@$(CPP) -c $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@
# Compile: create assembler files from C source files. ARM/Thumb
## does not work - TODO - hints welcome
##$(COBJ) : %.s : %.c
## $(CC) $(THUMB) -S $(ALL_CFLAGS) $< -o $@
# Assemble: create object files from assembler source files. ARM/Thumb
$(AOBJ) : %.o : %.S
@echo
@echo $(MSG_ASSEMBLING) $<
@$(CC) -c $(THUMB) $(ALL_ASFLAGS) $< -o $@
# Assemble: create object files from assembler source files. ARM-only
$(AOBJARM) : %.o : %.S
@echo
@echo $(MSG_ASSEMBLING_ARM) $<
@$(CC) -c $(ALL_ASFLAGS) $< -o $@
# Target: clean project.
clean: begin clean_list finished end
clean_list :
@echo
@echo $(MSG_CLEANING)
$(REMOVE) $(TARGET).hex
$(REMOVE) *.bin
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).elf
$(REMOVE) $(TARGET).map
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).a90
$(REMOVE) $(TARGET).sym
$(REMOVE) $(TARGET).lnk
$(REMOVE) $(TARGET).lss
$(REMOVE) $(COBJ)
$(REMOVE) $(CPPOBJ)
$(REMOVE) $(AOBJ)
$(REMOVE) $(COBJARM)
$(REMOVE) $(CPPOBJARM)
$(REMOVE) $(AOBJARM)
$(REMOVE) $(LST)
$(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRC:.c=.d)
$(REMOVE) $(SRCARM:.c=.s)
$(REMOVE) $(SRCARM:.c=.d)
$(REMOVE) $(CPPSRC:.cpp=.s)
$(REMOVE) $(CPPSRC:.cpp=.d)
$(REMOVE) $(CPPSRCARM:.cpp=.s)
$(REMOVE) $(CPPSRCARM:.cpp=.d)
$(REMOVE) .dep/*
clean_all: clean
$(REMOVE) cscope.* TAGS
# Include the dependency files.
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
# Listing of phony targets.
.PHONY : all begin finish end sizebefore sizeafter gccversion \
build elf hex bin lss sym clean clean_list program
release : clean all
mv main.bin $(RELEASE_DIR)/$(RELEASE_NAME_BIN)
mv main.elf $(RELEASE_DIR)/$(RELEASE_NAME_ELF)
cp RELEASE_NOTES.TXT $(RELEASE_DIR)
# **********************************************************************************************
# FLASH PROGRAMMING (using OpenOCD 0.5.0 and Olimex ARM-USB-OCD)
# **********************************************************************************************
# inspect for later-> @cmd /c 'echo mww 0xfffffd08 0xa5000401 >> $(OPENOCD_SCRIPT)'
# program the AT91SAM7S256 internal flash memory
program: $(PROGRAM_TARGET)
openocd -f flash.cfg
cscope.files:
@find . -type f -name '*.[hcS]' -print >cscope.files
cscope: cscope.files
@rm -f cscope.out
@cscope -b -f cscope.out
TAGS: cscope.files
@etags `cat cscope.files`