Build: Update to latest DMBS version.
[pub/lufa.git] / LUFA / Build / DMBS / DMBS / gcc.md
1 DMBS - Dean's Makefile Build System
2 ===================================
3
4
5 Module: GCC
6 -----------------
7
8 The GCC module provides build targets to compile a user application, using a
9 variant of GCC for a specific target architecture (such as `avr-gcc`).
10
11 ## Importing This Module into a Makefile:
12
13 To use this module in your application makefile, add the following code to your
14 makefile:
15
16 include $(DMBS_PATH)/gcc.mk
17
18 ## Prerequisites:
19
20 This module requires the GCC compiler to be installed and available in the
21 system's `PATH` variable for the desired target architecture.
22
23 ## Build Targets:
24
25 The following targets are supported by this module:
26
27 <table>
28 <tbody>
29 <tr>
30 <td>size</td>
31 <td>Show the compiled binary size for the various memory segments.</td>
32 </tr>
33 <tr>
34 <td>symbol-sizes</td>
35 <td>Show the size of each symbol in the compiled binary (useful to find large functions to optimize further).</td>
36 </tr>
37 <tr>
38 <td>all</td>
39 <td>Build application and generate all binary (BIN, ELF, HEX) and auxiliary (LSS, MAP, SYM, etc.) output files.</td>
40 </tr>
41 <tr>
42 <td>lib</td>
43 <td>Generate a static `.a` library from the application code, containing the flash region's data.</td>
44 </tr>
45 <tr>
46 <td>elf</td>
47 <td>Generate an ELF debug file from the application code, containing all region's data.</td>
48 </tr>
49 <tr>
50 <td>bin</td>
51 <td>Generate a flat BIN binary file from the application code, containing the flash region's data.</td>
52 </tr>
53 <tr>
54 <td>hex</td>
55 <td>Generate a pair of Intel HEX files from the application code, containing the flash region's data (HEX) and EEPROM data (EEP).</td>
56 </tr>
57 <tr>
58 <td>lss</td>
59 <td>Generate a LSS listing file showing the disassembly of the compiled application.</td>
60 </tr>
61 <tr>
62 <td>clean</td>
63 <td>Remove all generated project intermediary and binary output files.</td>
64 </tr>
65 <tr>
66 <td>mostlyclean</td>
67 <td>Remove all generated project intermediary output files, but preserve the binary output files.</td>
68 </tr>
69 </tbody>
70 </table>
71
72 ## Mandatory Variables:
73
74 The following variables must be defined (with a `NAME = VALUE` syntax, one
75 variable per line) in the user makefile to be able to use this module:
76
77 <table>
78 <tbody>
79 <tr>
80 <td>MCU</td>
81 <td>Name of the Atmel processor model (e.g. `at90usb1287`).</td>
82 </tr>
83 <tr>
84 <td>TARGET</td>
85 <td>Name of the application output file prefix (e.g. `TestApplication`).</td>
86 </tr>
87 <tr>
88 <td>ARCH</td>
89 <td>Target device architecture (e.g. `AVR8`).</td>
90 </tr>
91 <tr>
92 <td>SRC</td>
93 <td>List of all project source files (C, C++, ASM).</td>
94 </tr>
95 </tbody>
96 </table>
97
98 ## Optional Variables:
99
100 The following variables may be defined (with a `NAME = VALUE` syntax, one
101 variable per line) in the user makefile. If not specified, a default value will
102 be assumed.
103
104 <table>
105 <tbody>
106 <tr>
107 <td>COMPILER_PATH</td>
108 <td>Path to the compiler to use, in case a specific compiler should be substituted for the one in the system's `PATH` variable. Default is blank (use `PATH` provided compiler).</td>
109 </tr>
110 <tr>
111 <td>OPTIMIZATION</td>
112 <td>Optimization level to use when compiling C and C++ source files. Default is `s` (optimize for smallest size).</td>
113 </tr>
114 <tr>
115 <td>C_STANDARD</td>
116 <td>C language standard used when compiling C language source files. Default is `gnu99` (C99 standard with GNU extensions)./td>
117 </tr>
118 <tr>
119 <td>CPP_STANDARD</td>
120 <td>C++ language standard used when compiling C++ language source files. Default is `gnu++11` (C++11 standard with GNU extensions)./td>
121 </tr>
122 <tr>
123 <td>F_CPU</td>
124 <td>Processor core clock frequency, in Hz. This is used by some architectures for functions such as software spin-loop delays. Default is blank (no value defined).</td>
125 </tr>
126 <tr>
127 <td>C_FLAGS</td>
128 <td>Common GCC flags passed to the compiler for C language (C) input files. Default is blank (no additional flags).</td>
129 </tr>
130 <tr>
131 <td>CPP_FLAGS</td>
132 <td>Common GCC flags passed to the compiler for C++ language (CPP) input files. Default is blank (no additional flags).</td>
133 </tr>
134 <tr>
135 <td>ASM_FLAGS</td>
136 <td>Common GCC flags passed to the assembler for assembly language (S) input files. Default is blank (no additional flags).</td>
137 </tr>
138 <tr>
139 <td>CC_FLAGS</td>
140 <td>Common GCC flags passed to the compiler for all source file types. Default is blank (no additional flags).</td>
141 </tr>
142 <tr>
143 <td>LD_FLAGS</td>
144 <td>Extra flags to pass to the GNU linker when linking the compiled object files into the resulting binary. Default is blank (no additional flags).</td>
145 </tr>
146 <tr>
147 <td>LINKER_RELAXATIONS</td>
148 <td>Boolean, if `Y` linker relaxations will be enabled to slightly reduce the resulting binary's size. Default is `Y`.</td>
149 </tr>
150 <tr>
151 <td>JUMP_TABLES</td>
152 <td>Boolean, if `Y` jump tables will be enabled to slightly reduce the resulting binary's size - note that this can cause incorrect jumps if the binary is relocated after compilation, such as for a bootloader. Default is `N`.</td>
153 </tr>
154 <tr>
155 <td>LTO</td>
156 <td>Boolean, if `Y` link time optimization will be enabled to reduce the resulting binary's size. For larger projects you might also want to add `-mcall-prologues` to the `CC_FLAGS`. Default is `N`.</td>
157 </tr>
158 <tr>
159 <td>OBJDIR</td>
160 <td>Directory to store the intermediate object files, as they are generated from the source files. Default is `obj`.</td>
161 </tr>
162 <tr>
163 <td>OBJECT_FILES</td>
164 <td>List of additional `.o` object files to link into the final binary. Default is blank (no additional objects).</td>
165 </tr>
166 <tr>
167 <td>DEBUG_FORMAT</td>
168 <td>Debug ELF file format to generate. Default is `dwarf-2`.</td>
169 </tr>
170 <tr>
171 <td>DEBUG_LEVEL</td>
172 <td>Level of the debugging information to generate in the compiled object files. Debug is 2 (medium level debugging information).</td>
173 </tr>
174 </tbody>
175 </table>
176
177 ## Provided Variables:
178
179 The following variables may be referenced in a user makefile (via `$(NAME)`
180 syntax) if desired, as they are provided by this module.
181
182 <table>
183 <tbody>
184 <tr>
185 <td>N/A</td>
186 <td>This module provides no variables.</td>
187 </tr>
188 </tbody>
189 </table>
190
191 ## Provided Macros:
192
193 The following macros may be referenced in a user makefile (via
194 `$(call NAME, ARG1, ARG2, ...)` syntax) if desired, as they are provided by
195 this module.
196
197 <table>
198 <tbody>
199 <tr>
200 <td>N/A</td>
201 <td>This module provides no macros.</td>
202 </tr>
203 </tbody>
204 </table>
205
206 ## Module Changelog:
207
208 The changes to this module since its initial release are listed below, as of the
209 DMBS version where the change was made.
210
211 ### 20180122
212 Changed C++ default language standard from gnu++98 to gnu++11.
213
214 ### 20171231
215 Added `-fpack-struct` for C files only (not C++).
216 Added `-fno-exceptions` and `-fno-threadsafe-statics` for C++ source files.
217 Added file-specific compilation flags.
218 Added `LTO` optional variable.
219
220 ### 20170426
221 Added `JUMP_TABLES` optional variable.
222
223 ### 20160403
224 Initial release.