SWRA446 February 2015 CC1310 , CC1310 , CC2620 , CC2620 , CC2630 , CC2630 , CC2640 , CC2640 , CC2640R2F , CC2640R2F , CC2640R2F-Q1 , CC2640R2F-Q1 , CC2650 , CC2650 , CC2650MODA , CC2650MODA
This section describes the elements included in the makefile.
vpath | Defines the list of directories that the make command should search. All directories containing source files for the project should be added to this variable. All directories are relative to the directory containing the makefile. |
PROJECT | Contains the name of the project to build. The variable will be used to name the output files of the build |
OUT_DIR | Defines the directory of where to place the generated output files. |
OBJ_DIR | Defines the directory of where to place the generated object files. |
SOURCE_FILES | This variable contains all the source files in the project. All CC26xx/CC13xx projects will require the startup files startup_gcc.c and ccfg.c. These files are again depended on several driverlib files. In this example, all driverlib files are included, by searching for every .c file in the driverlib source folder. |
LINKERFILE | Defines the linker file for the project. The path is relative to the directory containing the makefile. |
INCLUDES | Contains the include directories used by the compiler. The variable must include the source and inc folder in the driverlib package. |
OBJGENOPTIONS | This variable contains options for the compiler when building object files. |
-Dgcc =1: Predefine gcc=1 | |
-O0: Set optimization for compilation time | |
-mcpu=cortex-m3: specifies the ARM processor to be cortex-M3 | |
-gdwarf-2: Produce debugging information in DWARF version 2 format. | |
-mthumb : Generate code for the Thumb instruction set | |
-fomit-frame-pointer: Don't keep the frame pointer in a register for functions that don't need one | |
-Wall: Enable all compiler’s warning messages | |
-Wstrict-prototypes: Warn if a function is declared or defined without specifying the argument types. | |
-D$(CHIP_ID)=1: Predefine symbol for chip ID. | |
OUTGENOPTIONS | This variable contains options for the compiler when building output files |
-mcpu=cortex-m3: specifies the ARM processor to be cortex-M3 | |
-nostartfiles: Do not use the standard system startup files when linking | |
-T $(LINKERFILE): specifies the linker script. | |
-Wl,: pass the subsequent options to the linker. | |
-Map=$(PROJECT).map: print a link map to the file $(PROJECT).map | |
--cref: Output a cross reference table | |
--no-warn-mismatch: allow linking together input files that are mismatched. | |
OBJECTFILES | This variable contains the name of all object files that will be generated from the source files. The variable content is created by replacing the .c in the sourcefiles with .o. |
.PHONY : all clean | Tell make that the targets all and clean are not associated with any files. |
clean : | Rule for cleaning up after the build. All output files and all object files are deleted. |
all: | Rule for building the complete project. |
$(OBJ_DIR): | This rule creates the directory to place object files if it doesn’t exist. |
$(OUT_DIR): | This rule creates the directory to place output files if it doesn’t exist. |
$(OBJECTFILES): | Rule to make sure the object directory is created before any object files. |
$(PROJECT).elf $(PROJECT).bin: | Rule to make sure the output directory is created before any of the output files. |
$(OBJ_DIR)/%.o: | Rule for building the object files. |
–o $@ places the output in a file with the same name as the target. | |
-c means that the source file should be compiled, but not linked. | |
$< sets the source file to be the first prerequisite. | |
$(PROJECT).elf: | Rule for building the .elf file. |
The option –o places the output in the directory passed as argument. | |
$(PROJECT).bin: | Rule for building the .bin file. |
$(OUT_DIR)/$< defines the input file. $< returns the first prerequisite. | |
$(OUT_DIR)/$@ defines the output file. $@ returns the target | |
--gap-fill 0xFF means that gaps between sections should be filled with 0xFF. | |
-O binary creates an output file in binary format. |