5 # Makefile for OpenPilot project build PiOS and the AP.
7 # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2012.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 # You should have received a copy of the GNU General Public License along
21 # with this program; if not, write to the Free Software Foundation, Inc.,
22 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 # Set developer code and compile options
27 # Set to YES to compile for debugging
30 # Set to YES to use the Servo output pins for debugging via scope or logic analyser
31 ENABLE_DEBUG_PINS ?= NO
33 # Set to Yes to enable the AUX UART which is mapped on the S1 (Tx) and S2 (Rx) servo outputs
40 # Set to YES when using Code Sourcery toolchain
43 # Remove command is different for Code Sourcery on Windows
48 # YES enables -mthumb option to flags for source-files listed
52 # List of modules to include
53 MODULES += Actuator ManualControl Stabilization
54 MODULES += AltitudeHold FixedWingPathFollower PathPlanner
55 #MODULES += VtolPathFollower ## OP-700: VtolPathFollower disabled because its currently unsafe - remove this line once Sambas code has been merged
56 MODULES += Attitude/revolution
57 #MODULES += OveroSync/simulated
59 # To run simulation instead of connect to SITL
60 MODULES += Sensors/simulated
64 # MCU name, submodel and board
65 # - MCU used for compiler-option (-mtune)
66 # - MODEL used for linker-script name (-T) and passed as define
67 # - BOARD just passed as define (optional)
72 ifeq ($(USE_BOOTLOADER), YES)
73 BOOT_MODEL = $(MODEL)_BL
76 BOOT_MODEL = $(MODEL)_NB
79 # Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.)
80 OUTDIR = ../../build/sim_osx
82 # Target file name (without extension).
87 OPSYSTEMINC = $(OPSYSTEM)/inc
88 OPUAVTALK = ../UAVTalk
89 OPUAVTALKINC = $(OPUAVTALK)/inc
90 OPUAVOBJ = ../UAVObjects
91 OPUAVOBJINC = $(OPUAVOBJ)/inc
93 OPMODULEDIR = ../modules
94 FLIGHTLIB = ../libraries
95 FLIGHTLIBINC = $(FLIGHTLIB)/inc
98 PIOSPOSIX = $(PIOS)/osx
99 APPLIBDIR = $(PIOSPOSIX)/libraries
100 RTOSDIR = $(APPLIBDIR)/FreeRTOS
101 RTOSSRCDIR = $(RTOSDIR)/Source
102 RTOSINCDIR = $(RTOSSRCDIR)/include
103 DOXYGENDIR = ../Doc/Doxygen
104 PYMITE = $(FLIGHTLIB)/PyMite
105 PYMITELIB = $(PYMITE)/lib
106 PYMITEPLAT = $(PYMITE)/platform/openpilot_sitl
107 PYMITETOOLS = $(PYMITE)/tools
108 PYMITEVM = $(PYMITE)/vm
109 PYMITEINC = $(PYMITEVM)
110 PYMITEINC += $(PYMITEPLAT)
111 PYMITEINC += $(OUTDIR)
112 FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib
113 FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans
115 UAVOBJPYTHONSYNTHDIR = $(OUTDIR)/../uavobject-synthetics/python
117 # List C source files here. (C dependencies are automatically generated.)
118 # use file-extension c for "c-only"-files
120 MODNAMES = $(notdir ${MODULES})
125 SRC += $(OUTDIR)/pmlib_img.c
126 SRC += $(OUTDIR)/pmlib_nat.c
127 SRC += $(OUTDIR)/pmlibusr_img.c
128 SRC += $(OUTDIR)/pmlibusr_nat.c
129 SRC += $(wildcard ${PYMITEVM}/*.c)
130 SRC += $(wildcard ${PYMITEPLAT}/*.c)
133 SRC += ${foreach MOD, ${MODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}}
134 SRC += ${OUTDIR}/InitMods.c
136 SRC += ${OPMODULEDIR}/System/systemmod.c
137 SRC += $(OPSYSTEM)/revolution.c
138 SRC += $(OPSYSTEM)/pios_board_sim.c
139 SRC += $(OPSYSTEM)/alarms.c
140 SRC += $(OPUAVTALK)/uavtalk.c
141 SRC += $(OPUAVOBJ)/uavobjectmanager.c
142 SRC += $(OPUAVOBJ)/eventdispatcher.c
143 SRC += $(FLIGHT_UAVOBJ_DIR)/uavobjectsinit.c
146 SRC += $(OPTESTS)/test_common.c
147 SRC += $(OPTESTS)/$(TESTAPP).c
154 #include $(FLIGHT_UAVOBJ_DIR)/Makefile.inc
155 include ./UAVObjects.inc
157 UAVOBJSRCFILENAMES += attitudesimulated
158 UAVOBJSRC = $(foreach UAVOBJSRCFILE,$(UAVOBJSRCFILENAMES),$(FLIGHT_UAVOBJ_DIR)/$(UAVOBJSRCFILE).c )
159 UAVOBJDEFINE = $(foreach UAVOBJSRCFILE,$(UAVOBJSRCFILENAMES),-DUAVOBJ_INIT_$(UAVOBJSRCFILE) )
162 CFLAGS_UAVOBJECTS = $(UAVOBJDEFINE)
165 ## PIOS Hardware (posix)
166 SRC += $(PIOSPOSIX)/pios_crc.c
167 SRC += $(PIOSPOSIX)/pios_sys.c
168 SRC += $(PIOSPOSIX)/pios_led.c
169 SRC += $(PIOSPOSIX)/pios_irq.c
170 SRC += $(PIOSPOSIX)/pios_delay.c
171 SRC += $(PIOSPOSIX)/pios_sdcard.c
172 SRC += $(PIOSPOSIX)/pios_udp.c
173 SRC += $(PIOSPOSIX)/pios_tcp.c
174 SRC += $(PIOSPOSIX)/pios_com.c
175 SRC += $(PIOSPOSIX)/pios_servo.c
176 SRC += $(PIOSPOSIX)/pios_wdg.c
177 SRC += $(PIOSPOSIX)/pios_debug.c
179 SRC += $(PIOSPOSIX)/pios_rcvr.c
180 SRC += $(PIOSPOSIX)/pios_gcsrcvr.c
182 ## Libraries for flight calculations
183 SRC += $(FLIGHTLIB)/fifo_buffer.c
184 SRC += $(FLIGHTLIB)/WorldMagModel.c
185 SRC += $(FLIGHTLIB)/CoordinateConversions.c
186 SRC += $(FLIGHTLIB)/paths.c
187 SRC += $(FLIGHTLIB)/insgps13state.c
189 ## RTOS and RTOS Portable
190 SRC += $(RTOSSRCDIR)/list.c
191 SRC += $(RTOSSRCDIR)/queue.c
192 UNAME := $(shell uname)
193 SRC += $(RTOSSRCDIR)/task.c
194 SRC += $(RTOSSRCDIR)/timers.c
195 SRC += $(RTOSSRCDIR)/portable/GCC/Posix/port.c
196 SRC += $(RTOSSRCDIR)/portable/MemMang/heap_3.c
200 # List C source files here which must be compiled in ARM-Mode (no -mthumb).
201 # use file-extension c for "c-only"-files
202 ## just for testing, timer.c could be compiled in thumb-mode too
205 # List C++ source files here.
206 # use file-extension .cpp for C++-files (not .C)
209 # List C++ source files here which must be compiled in ARM-Mode.
210 # use file-extension .cpp for C++-files (not .C)
211 #CPPSRCARM = $(TARGET).cpp
215 # List any extra directories to look for include files here.
216 # Each directory must be seperated by a space.
217 EXTRAINCDIRS = $(OPSYSTEM)
218 EXTRAINCDIRS += $(OPSYSTEMINC)
219 EXTRAINCDIRS += $(OPUAVTALK)
220 EXTRAINCDIRS += $(OPUAVTALKINC)
221 EXTRAINCDIRS += $(OPUAVOBJ)
222 EXTRAINCDIRS += $(OPUAVOBJINC)
223 EXTRAINCDIRS += $(FLIGHT_UAVOBJ_DIR)
224 EXTRAINCDIRS += $(PIOS)
225 EXTRAINCDIRS += $(PIOSINC)
226 EXTRAINCDIRS += $(FLIGHTLIBINC)
227 EXTRAINCDIRS += $(PIOSPOSIX)
228 EXTRAINCDIRS += $(RTOSINCDIR)
229 EXTRAINCDIRS += $(APPLIBDIR)
230 EXTRAINCDIRS += $(RTOSSRCDIR)/portable/GCC/Posix
231 EXTRAINCDIRS += $(PYMITEINC)
233 EXTRAINCDIRS += ${foreach MOD, ${MODULES}, $(OPMODULEDIR)/${MOD}/inc} ${OPMODULEDIR}/System/inc
236 # List any extra directories to look for library files here.
237 # Also add directories where the linker should search for
238 # includes from linker-script to the list
239 # Each directory must be seperated by a space.
243 # Each library-name must be seperated by a space.
244 # i.e. to link with libxyz.a, libabc.a and libefsl.a:
245 # EXTRA_LIBS = xyz abc efsl
246 # for newlib-lpc (file: libnewlibc-lpc.a):
247 # EXTRA_LIBS = newlib-lpc
250 # Path to Linker-Scripts
251 LINKERSCRIPTPATH = $(PIOSSTM32F10X)
253 # Optimization level, can be [0, 1, 2, 3, s].
254 # 0 = turn off optimization. s = optimize for size.
255 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
263 # Output format. (can be ihex or binary or both)
264 # binary to create a load-image in raw-binary format i.e. for SAM-BA,
265 # ihex to create a load-image in Intel hex format
273 # Place project-specific -D (define) and/or
274 # -U options for C here.
275 ifeq ($(ENABLE_DEBUG_PINS), YES)
276 CDEFS += -DPIOS_ENABLE_DEBUG_PINS
278 ifeq ($(ENABLE_AUX_UART), YES)
279 CDEFS += -DPIOS_ENABLE_AUX_UART
281 ifeq ($(USE_BOOTLOADER), YES)
282 CDEFS += -DUSE_BOOTLOADER
285 # Compiler flag to set the C Standard level.
287 # gnu89 - c89 plus GCC extensions
288 # c99 - ISO C99 standard (not yet fully implemented)
289 # gnu99 - c99 plus GCC extensions
290 CSTANDARD = -std=gnu99
296 # -g*: generate debugging information
297 # -O*: optimization level
298 # -f...: tuning, see GCC manual and avr-libc documentation
299 # -Wall...: warning level
300 # -Wa,...: tell GCC to pass this to the assembler.
301 # -adhlns...: create assembler listing
303 # Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
306 CFLAGS = -g$(DEBUGF) -DDEBUG
309 CFLAGS += -DDIAG_TASKS
311 CFLAGS += $(CFLAGS_UAVOBJECTS)
312 CFLAGS += -DARCH_POSIX
314 CFLAGS += -mtune=$(MCU)
316 CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
319 #CROSS_COMPILE=/usr/local/android-ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-
321 CFLAGS += -fomit-frame-pointer
322 ifeq ($(CODE_SOURCERY), YES)
323 CFLAGS += -fpromote-loop-indices
328 # Compiler flags to generate dependency files:
329 CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d
332 #CONLYFLAGS += -Wnested-externs
333 CONLYFLAGS += $(CSTANDARD)
336 # -Wa,...: tell GCC to pass this to the assembler.
337 # -ahlns: create listing
338 ASFLAGS = -mtune=$(MCU) -I. -x assembler-with-cpp
340 ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
341 ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
346 # -Wl,...: tell GCC to pass this to linker.
347 # -Map: create map file
348 # --cref: add cross reference to map file
350 LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS))
352 LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS))
353 LDFLAGS += $(MATH_LIB)
356 # To include simulation model
357 LDFLAGS += -L$(OUTDIR)
358 #LDFLAGS += -lsimmodel
361 # Define programs and commands.
362 CC = $(ARM_SDK_PREFIX)gcc
363 CPP = $(ARM_SDK_PREFIX)g++
364 AR = $(ARM_SDK_PREFIX)ar
365 OBJCOPY = $(ARM_SDK_PREFIX)objcopy
366 OBJDUMP = $(ARM_SDK_PREFIX)objdump
367 SIZE = $(ARM_SDK_PREFIX)size
368 NM = $(ARM_SDK_PREFIX)nm
375 MSG_ERRORS_NONE = Errors: none
376 MSG_BEGIN = ${quote}-------- begin (mode: $(RUN_MODE)) --------${quote}
377 MSG_END = ${quote}-------- end --------${quote}
378 MSG_MODINIT = ${quote}**** Generating ModInit.c${quote}
379 MSG_SIZE_BEFORE = ${quote}Size before:${quote}
380 MSG_SIZE_AFTER = ${quote}Size after build:${quote}
381 MSG_LOAD_FILE = ${quote}Creating load file:${quote}
382 MSG_EXTENDED_LISTING = ${quote}Creating Extended Listing/Disassembly:${quote}
383 MSG_SYMBOL_TABLE = ${quote}Creating Symbol Table:${quote}
384 MSG_LINKING = ${quote}**** Linking :${quote}
385 MSG_COMPILING = ${quote}**** Compiling C :${quote}
386 MSG_COMPILING_ARM = ${quote}**** Compiling C (ARM-only):${quote}
387 MSG_COMPILINGCPP = ${quote}Compiling C++ :${quote}
388 MSG_COMPILINGCPP_ARM = ${quote}Compiling C++ (ARM-only):${quote}
389 MSG_ASSEMBLING = ${quote}**** Assembling:${quote}
390 MSG_ASSEMBLING_ARM = ${quote}****Assembling (ARM-only):${quote}
391 MSG_CLEANING = ${quote}Cleaning project:${quote}
392 MSG_FORMATERROR = ${quote}Can not handle output-format${quote}
393 MSG_ASMFROMC = ${quote}Creating asm-File from C-Source:${quote}
394 MSG_ASMFROMC_ARM = ${quote}Creating asm-File from C-Source (ARM-only):${quote}
395 MSG_PYMITEINIT = ${quote}**** Generating PyMite intermediate code${quote}
397 # List of all source files.
398 ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC)
399 # List of all source files without directory and file-extension.
400 ALLSRCBASE = $(notdir $(basename $(ALLSRC)))
402 # Define all object files.
403 ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE)))
405 # Define all listing files (used for make clean).
406 LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE)))
407 # Define all depedency-files (used for make clean).
408 DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE)))
410 elf: $(OUTDIR)/$(TARGET).elf
411 lss: $(OUTDIR)/$(TARGET).lss
412 sym: $(OUTDIR)/$(TARGET).sym
413 hex: $(OUTDIR)/$(TARGET).hex
414 bin: $(OUTDIR)/$(TARGET).bin
417 #all: begin gccversion sizebefore build sizeafter finished end
418 #all: begin gencode gccversion build sizeafter finished end
421 ifeq ($(LOADFORMAT),ihex)
422 build: elf hex lss sym
424 ifeq ($(LOADFORMAT),binary)
425 build: elf bin lss sym
427 ifeq ($(LOADFORMAT),both)
428 build: elf hex bin lss sym
430 $(error "$(MSG_FORMATERROR) $(FORMAT)")
435 # Generate intermediate code
436 gencode: ${OUTDIR}/InitMods.c ${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h
438 getmodname = $(firstword $(subst /, ,$1))
440 MOD_GEN := $(foreach MOD,$(MODULES),$(call getmodname,$(MOD)))
442 # Generate code for module initialization
443 ${OUTDIR}/InitMods.c: Makefile.osx
446 @echo ${quote}// Autogenerated file${quote} > ${OUTDIR}/InitMods.c
447 @echo ${quote}${foreach MOD, ${MOD_GEN}, extern unsigned int ${MOD}Initialize(void);}${quote} >> ${OUTDIR}/InitMods.c
448 @echo ${quote}${foreach MOD, ${MOD_GEN}, extern unsigned int ${MOD}Start(void);}${quote} >> ${OUTDIR}/InitMods.c
449 @echo ${quote}void InitModules() {${quote} >> ${OUTDIR}/InitMods.c
450 @echo ${quote}${foreach MOD, ${MOD_GEN}, ${MOD}Initialize();}${quote} >> ${OUTDIR}/InitMods.c
451 @echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c
452 @echo ${quote}void StartModules() {${quote} >> ${OUTDIR}/InitMods.c
453 @echo ${quote}${foreach MOD, ${MOD_GEN}, ${MOD}Start();}${quote} >> ${OUTDIR}/InitMods.c
454 @echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c
456 # Generate code for PyMite
457 ${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h: $(wildcard ${PYMITELIB}/*.py) $(wildcard ${PYMITEPLAT}/*.py) $(wildcard ${FLIGHTPLANLIB}/*.py) $(wildcard ${FLIGHTPLANS}/*.py) $(wildcard $(UAVOBJPYTHONSYNTHDIR)/*.py)
458 @echo ${MSG_PYMITEINIT}
459 @$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -s --memspace=flash -o $(OUTDIR)/pmlib_img.c --native-file=$(OUTDIR)/pmlib_nat.c $(PYMITELIB)/list.py $(PYMITELIB)/dict.py $(PYMITELIB)/__bi.py $(PYMITELIB)/sys.py $(PYMITELIB)/string.py $(wildcard $(FLIGHTPLANLIB)/*.py) $(wildcard $(UAVOBJPYTHONSYNTHDIR)/*.py)
460 @$(PYTHON) $(PYMITETOOLS)/pmGenPmFeatures.py $(PYMITEPLAT)/pmfeatures.py > $(OUTDIR)/pmfeatures.h
461 @$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -u -o $(OUTDIR)/pmlibusr_img.c --native-file=$(OUTDIR)/pmlibusr_nat.c $(FLIGHTPLANS)/test.py
469 ## @echo $(MSG_ERRORS_NONE)
475 # Display sizes of sections.
476 ELFSIZE = $(SIZE) -A $(OUTDIR)/$(TARGET).elf
477 ##ELFSIZE = $(SIZE) --format=Berkeley --common $(OUTDIR)/$(TARGET).elf
479 # @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
482 # @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
483 @echo $(MSG_SIZE_AFTER)
486 # Display compiler version information.
491 # Program the device.
492 ifeq ($(USE_BOOTLOADER), YES)
493 # Program the device with OP Upload Tool".
494 program: $(OUTDIR)/$(TARGET).bin
495 @echo ${quote}Programming with OP Upload Tool${quote}
496 ../../ground/src/experimental/upload-build-desktop/debug/OPUploadTool -d 0 -p $(OUTDIR)/$(TARGET).bin
498 ifeq ($(FLASH_TOOL),OPENOCD)
499 # Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script".
500 program: $(OUTDIR)/$(TARGET).elf
501 @echo ${quote}Programming with OPENOCD${quote}
502 $(OOCD_EXE) $(OOCD_CL)
506 # Create final output file (.hex) from ELF output file.
509 @echo $(MSG_LOAD_FILE) $@
510 $(OBJCOPY) -O ihex $< $@
512 # Create final output file (.bin) from ELF output file.
515 @echo $(MSG_LOAD_FILE) $@
516 $(OBJCOPY) -O binary $< $@
518 # Create extended listing file/disassambly from ELF output file.
519 # using objdump testing: option -C
522 @echo $(MSG_EXTENDED_LISTING) $@
523 $(OBJDUMP) -h -S -C -r $< > $@
524 # $(OBJDUMP) -x -S $< > $@
526 # Create a symbol table from ELF output file.
529 @echo $(MSG_SYMBOL_TABLE) $@
532 # Link: create ELF output file from object files.
533 .SECONDARY : $(TARGET).elf
534 .PRECIOUS : $(ALLOBJ)
536 @echo $(MSG_LINKING) $@
537 # use $(CC) for C-only projects or $(CPP) for C++-projects:
538 $(CC) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS)
539 # $(CPP) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS)
542 # Assemble: create object files from assembler source files.
543 define ASSEMBLE_TEMPLATE
544 $(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
546 @echo $(MSG_ASSEMBLING) $$< to $$@
547 $(CC) -c $(THUMB) $$(ASFLAGS) $$< -o $$@
549 $(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src))))
551 # Assemble: create object files from assembler source files. ARM-only
552 define ASSEMBLE_ARM_TEMPLATE
553 $(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
555 @echo $(MSG_ASSEMBLING_ARM) $$< to $$@
556 $(CC) -c $$(ASFLAGS) $$< -o $$@
558 $(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src))))
561 # Compile: create object files from C source files.
562 define COMPILE_C_TEMPLATE
563 $(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
565 @echo $(MSG_COMPILING) $$< to $$@
566 $(CC) -c $(THUMB) $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@
568 $(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src))))
570 # Compile: create object files from C source files. ARM-only
571 define COMPILE_C_ARM_TEMPLATE
572 $(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
574 @echo $(MSG_COMPILING_ARM) $$< to $$@
575 $(CC) -c $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@
577 $(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src))))
580 # Compile: create object files from C++ source files.
581 define COMPILE_CPP_TEMPLATE
582 $(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
584 @echo $(MSG_COMPILINGCPP) $$< to $$@
585 $(CC) -c $(THUMB) $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@
587 $(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src))))
589 # Compile: create object files from C++ source files. ARM-only
590 define COMPILE_CPP_ARM_TEMPLATE
591 $(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
593 @echo $(MSG_COMPILINGCPP_ARM) $$< to $$@
594 $(CC) -c $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@
596 $(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src))))
599 # Compile: create assembler files from C source files. ARM/Thumb
600 $(SRC:.c=.s) : %.s : %.c
601 @echo $(MSG_ASMFROMC) $< to $@
602 $(CC) $(THUMB) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@
604 # Compile: create assembler files from C source files. ARM only
605 $(SRCARM:.c=.s) : %.s : %.c
606 @echo $(MSG_ASMFROMC_ARM) $< to $@
607 $(CC) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@
609 # Generate Doxygen documents
611 doxygen $(DOXYGENDIR)/doxygen.cfg
613 # Target: clean project.
614 clean: begin clean_list finished end
618 @echo $(MSG_CLEANING)
619 $(REMOVE) $(OUTDIR)/$(TARGET).map
620 $(REMOVE) $(OUTDIR)/$(TARGET).elf
621 $(REMOVE) $(OUTDIR)/$(TARGET).hex
622 $(REMOVE) $(OUTDIR)/$(TARGET).bin
623 $(REMOVE) $(OUTDIR)/$(TARGET).sym
624 $(REMOVE) $(OUTDIR)/$(TARGET).lss
625 $(REMOVE) $(wildcard $(OUTDIR)/*.c)
626 $(REMOVE) $(wildcard $(OUTDIR)/*.h)
628 $(REMOVE) $(LSTFILES)
629 $(REMOVE) $(DEPFILES)
630 $(REMOVE) $(SRC:.c=.s)
631 $(REMOVE) $(SRCARM:.c=.s)
632 $(REMOVE) $(CPPSRC:.cpp=.s)
633 $(REMOVE) $(CPPSRCARM:.cpp=.s)
636 # Create output files directory
637 # all known MS Windows OS define the ComSpec environment variable
639 $(shell md $(OUTDIR) 2>NUL)
641 $(shell mkdir $(OUTDIR) 2>/dev/null)
644 # Include the dependency files.
646 -include $(shell md $(OUTDIR)\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*)
648 -include $(shell mkdir $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*)
653 # Listing of phony targets.
654 .PHONY : all begin finish end sizebefore sizeafter gccversion \
655 build elf hex bin lss sym clean clean_list program gencode