]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Conf/build_rule.template
f036fb375fa9c612d3da89a22cf72c0342ef8392
[mirror_edk2.git] / BaseTools / Conf / build_rule.template
1 #
2 # Copyright (c) 2007-2009, Intel Corporation
3 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
4 # All rights reserved. This program and the accompanying materials
5 # are licensed and made available under the terms and conditions of the BSD License
6 # which accompanies this distribution. The full text of the license may be found at
7 # http://opensource.org/licenses/bsd-license.php
8
9 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 #
12 # Filename: build_rule.template
13 #
14
15 ## Syntax
16 #
17 # "*" is used to indicate that the source files will be processed at the same time.
18 # "?" is used to indicate that the source files will be processed one by one.
19 #
20 # "[" <File-Type>[.<Build-Type>][.<Arch>][, <File-Type>[.<Build-Type>][.<Arch>]] "]" <EOL>
21 # <InputFile[.<ToolChainFamily>]> <EOL>
22 # (?|*).<File-Extension> [(\n|,) (?|*).<File-Extension>]
23 #
24 # <OutputFile[.<ToolChainFamily>]> <EOL>
25 # <FileFullPath>
26 #
27 # <ExtraDependency>
28 # <FileFullPath>
29 #
30 # <Command[.<ToolChainFamily>]> <EOL>
31 # <Command1>
32 # [<Command2>]
33 #
34 # <Build-Type> is the MODULE_TYPE in EDK2 or COMPONENT_TYPE in EDK.
35 # Missing <InputFile> will cause an exception and break build.
36 # Missing <Command> will cause that related build target won't be generated but
37 # won't break build.
38 #
39
40 ## Placeholders for string substitution
41 #
42 # ${src} Source file(s) to be built (full path)
43 # ${s_path} Source file directory (absolute path)
44 # ${s_dir} Source file relative directory within a module
45 # (Note: ${s_dir} is always equals to "." if source file is given in absolute path.)
46 # ${s_name} Source file name without path
47 # ${s_base} Source file name without extension and path
48 # ${s_ext} Source file extension
49 #
50 # ${dst} Destination file(s) built from ${src} (full path)
51 # ${d_path} Destination file directory (absolute path)
52 # ${d_name} Destination file name without path
53 # ${d_base} Destination file name without extension and path
54 # ${d_ext} Destination file extension
55 #
56 # (+) Directory separator
57 #
58
59 ## Macro
60 # $(WORKSPACE) Workspace directory
61 # $(OUTPUT_DIR) Directory for intermediate files for building a module
62 # $(DEBUG_DIR) Directory for files used to debug a module
63 # $(BUILD_DIR) All files for building a platform will be put in this directory
64 # $(BIN_DIR) Common directory for executable files
65 # $(FV_DIR) Directory to store flash image files
66 # $(INC) Search path of current module
67 # $(INC_LIST) A file containing search pathes of current module
68 # $(LIBS) Static library files of current module
69 # $(<tool>_FLAGS) Tools flags of current module
70 # $(MODULE_NAME) Current module name
71 # $(MODULE_TYPE) Current module type
72 # $(ARCH) Architecture of current module
73 # $(TOOLCHAIN) Toolchain used to build current module
74 # $(TARGET) Target of current module (DEBUG/RELEASE)
75 # $(<tool>) Path of tool
76 # $(EDK_TOOLS_PATH) Path of build tools
77 # $(<FILE_TYPES>) File list of each file type
78 # (Note: The macro name is derived from file type name. For example,
79 # C-Code-File will have C_CODE_FILES macro.)
80 # $(<FILE_TYPES_LIST>) Macro point to a file containing list of files of a file type
81 # (
82 # Note: The macro and file name are derived from file type name.
83 # For example, C-Code-File will have C_CODE_FILES_LIST macro pointing
84 # to $(OUTPUT_DIR)/c_code_files.lst. The list file and macro name
85 # will be generated only when this macro is used in command line.
86 # This is intended to get over the long command line limitation.
87 # )
88 #
89 # $(CP) copy command
90 # $(MV) move command
91 # $(RM) delete command
92 # $(MD) create dir command
93 # $(RD) remove dir command
94 #
95
96 ## Reserved File-Type
97 #
98 # Don't change following names of file types and their associated files,
99 # which are also used in tools' code
100 #
101 # C-Code-File
102 # C-Header-File
103 # Dynamic-Library-File
104 # Static-Library-File
105 # Visual-Form-Representation-File
106 # Unicode-Text-File
107 #
108
109 [C-Code-File]
110 <InputFile>
111 ?.c
112 ?.C
113 ?.cc
114 ?.CC
115 ?.cpp
116 ?.Cpp
117 ?.CPP
118
119 <ExtraDependency>
120 $(MAKE_FILE)
121
122 <OutputFile>
123 $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
124
125 <Command.MSFT, Command.INTEL>
126 "$(CC)" /Fo${dst} $(CC_FLAGS) $(INC) ${src}
127
128 <Command.GCC, Command.RVCT>
129 # For RVCTCYGWIN CC_FLAGS must be first to work around pathing issues
130 "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}
131 "$(SYMRENAME)" $(SYMRENAME_FLAGS) ${dst}
132
133 [C-Header-File]
134 <InputFile>
135 *.h, *.H
136
137 <OutputFile>
138
139 <Command>
140
141
142 [Assembly-Code-File.COMMON.COMMON]
143 <InputFile.MSFT, InputFile.INTEL, InputFile.RVCT>
144 ?.asm, ?.Asm, ?.ASM
145
146 <InputFile.GCC>
147 ?.S, ?.s
148
149 <ExtraDependency>
150 $(MAKE_FILE)
151
152 <OutputFile>
153 $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
154
155 <Command.MSFT, Command.INTEL>
156 "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
157 Trim --source-code --convert-hex -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
158 "$(ASM)" /Fo${dst} $(ASM_FLAGS) /I${s_path} $(INC) ${d_path}(+)${s_base}.iii
159
160 <Command.GCC, Command.RVCT>
161 "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
162 Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
163 # For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues
164 "$(ASM)" $(ASM_FLAGS) -o ${dst} $(INC) ${d_path}(+)${s_base}.iii
165
166 [Assembly-Code-File.COMMON.IPF]
167 <InputFile>
168 ?.s
169
170 <ExtraDependency>
171 $(MAKE_FILE)
172
173 <OutputFile>
174 $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
175
176 <Command.MSFT, Command.INTEL>
177 "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
178 Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
179 # For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues
180 "$(ASM)" $(ASM_FLAGS) -o ${dst} ${d_path}(+)${s_base}.iii
181
182 [Visual-Form-Representation-File]
183 <InputFile>
184 ?.vfr
185 ?.Vfr
186 ?.VFR
187
188 <ExtraDependency>
189 $(MAKE_FILE)
190
191 <OutputFile>
192 $(DEBUG_DIR)(+)${s_dir}(+)${s_base}.c
193
194 <Command>
195 -$(MD) $(OUTPUT_DIR)(+)${s_dir} > NUL 2>&1
196 "$(VFRPP)" $(VFRPP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
197 -$(MD) ${d_path} > NUL 2>&1
198 "$(VFR)" $(VFR_FLAGS) --output-directory ${d_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
199
200 [Object-File]
201 <InputFile>
202 *.obj
203 *.o
204
205 <OutputFile>
206 $(OUTPUT_DIR)(+)$(MODULE_NAME).lib
207
208 <Command.MSFT, Command.INTEL>
209 "$(SLINK)" $(SLINK_FLAGS) /OUT:${dst} @$(OBJECT_FILES_LIST)
210
211 <Command.GCC>
212 "$(SLINK)" -cr ${dst} $(SLINK_FLAGS) @"$(OBJECT_FILES_LIST)"
213
214 <Command.RVCT>
215 "$(SLINK)" $(SLINK_FLAGS) ${dst} --via $(OBJECT_FILES_LIST)
216
217 <Command.RVCTCYGWIN>
218 # $(OBJECT_FILES_LIST) has wrong paths for cygwin
219 "$(SLINK)" $(SLINK_FLAGS) ${dst} $(OBJECT_FILES)
220
221 <Command.XCODE>
222 "$(SLINK)" $(SLINK_FLAGS) ${dst} -filelist $(OBJECT_FILES_LIST)
223
224 [Static-Library-File]
225 <InputFile>
226 *.lib
227
228 <ExtraDependency>
229 $(MAKE_FILE)
230
231 <OutputFile>
232 $(DEBUG_DIR)(+)$(MODULE_NAME).dll
233
234 <Command.MSFT, Command.INTEL>
235 "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST)
236
237 <Command.GCC>
238 "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -\( $(DLINK_SPATH) @"$(STATIC_LIBRARY_FILES_LIST)" -\) $(DLINK2_FLAGS)
239 "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
240
241 <Command.RVCT>
242 "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) --via $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
243
244 <Command.RVCTCYGWIN>
245 #$(STATIC_LIBRARY_FILES_LIST) has wrong paths for cygwin
246 "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) $(DLINK2_FLAGS)
247
248 <Command.XCODE>
249 "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
250
251
252 [Static-Library-File.USER_DEFINED]
253 <InputFile>
254 *.lib
255
256 <ExtraDependency>
257 $(MAKE_FILE)
258
259 <OutputFile>
260 $(DEBUG_DIR)(+)$(MODULE_NAME)
261
262 <Command.MSFT, Command.INTEL>
263 "$(DLINK)" $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST)
264
265 <Command.GCC>
266 "$(DLINK)" $(DLINK_FLAGS) -\( $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) -\) $(DLINK2_FLAGS)
267
268 <Command.RVCT>
269 "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) --via $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
270
271 <Command.RVCTCYGWIN>
272 #$(STATIC_LIBRARY_FILES_LIST) has the wrong paths for cygwin
273 "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) $(DLINK2_FLAGS)
274
275 <Command.XCODE>
276 "$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
277
278
279 [Dynamic-Library-File]
280 <InputFile>
281 ?.dll
282
283 <OutputFile>
284 $(DEBUG_DIR)(+)$(MODULE_NAME).efi
285
286 <Command.MSFT, Command.INTEL, Command.GCC, Command.RVCT>
287 GenFw -e $(MODULE_TYPE) -o ${dst} ${src}
288 $(CP) ${dst} $(OUTPUT_DIR)
289 $(CP) ${dst} $(BIN_DIR)
290 -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
291
292 <Command.XCODE>
293 # tool to convert Mach-O to PE/COFF
294 "$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
295 # create symbol file for GDB debug
296 -$(DSYMUTIL) ${src}
297 GenFw -e $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
298 $(CP) ${dst} $(OUTPUT_DIR)
299 $(CP) ${dst} $(BIN_DIR)
300 -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
301
302 [Dependency-Expression-File]
303 <InputFile>
304 ?.dxs, ?.Dxs, ?.DXS
305
306 <OutputFile>
307 $(OUTPUT_DIR)(+)$(MODULE_NAME).depex
308
309 <Command>
310 "$(PP)" $(CC_FLAGS) $(APP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
311 Trim --source-code -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
312 GenDepex -t $(MODULE_TYPE) -o ${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
313
314 [Acpi-Source-Language-File]
315 <InputFile>
316 ?.asl, ?.Asl, ?.ASL
317
318 <OutputFile>
319 $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml
320
321 <ExtraDependency>
322 $(MAKE_FILE)
323
324 <Command.MSFT, Command.INTEL>
325 Trim --asl-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i ${src}
326 "$(ASLPP)" $(ASLPP_FLAGS) $(INC) /I${s_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
327 "$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
328
329 <Command.GCC>
330 Trim --asl-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i ${src}
331 "$(ASLPP)" $(ASLPP_FLAGS) $(INC) -I${s_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
332 "$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
333
334 [C-Code-File.AcpiTable]
335 <InputFile>
336 ?.c
337
338 <OutputFile>
339 $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.acpi
340
341 <ExtraDependency>
342 $(MAKE_FILE)
343
344 <Command.MSFT, Command.INTEL>
345 "$(ASLCC)" /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src}
346 "$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
347 GenFw -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll
348
349 <Command.GCC>
350 "$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src}
351 "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
352 GenFw -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll
353
354 [Acpi-Table-Code-File]
355 <InputFile>
356 ?.aslc, ?.act
357
358 <OutputFile>
359 $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.acpi
360
361 <ExtraDependency>
362 $(MAKE_FILE)
363
364 <Command.MSFT, Command.INTEL>
365 "$(ASLCC)" /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src}
366 "$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
367 GenFw -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll
368
369 <Command.GCC>
370 "$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src}
371 "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
372 GenFw -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll
373
374 <Command.XCODE>
375 "$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(INC) ${src}
376 "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
377 "$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.efi
378 GenFw -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.efi
379
380
381 [Masm16-Code-File]
382 <InputFile>
383 ?.asm16, ?.Asm16, ?.ASM16
384
385 <ExtraDependency>
386 $(MAKE_FILE)
387
388 <OutputFile>
389 $(OUTPUT_DIR)(+)${s_base}.com
390
391 <Command.MSFT, Command.INTEL>
392 cd $(OUTPUT_DIR)(+)${s_dir}
393 "$(ASM)" /nologo /c /omf /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj ${src}
394 "$(ASMLINK)" $(ASMLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj,${dst},,,,
395
396 <Command.GCC>
397 "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
398 Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
399 "$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii
400 "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -( $(DLINK_SPATH) $(LIBS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj -)
401
402 <Command.XCODE>
403 "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
404 Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
405 "$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii
406 "$(SLINK)" $(SLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
407 otool -t $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib | hex2bin.py ${dst}
408
409
410 [Microcode-File]
411 <InputFile>
412 ?.txt, ?.TXT, ?.Txt, ?.mut
413
414 <OutputFile>
415 $(OUTPUT_DIR)(+)${s_base}.mcb
416
417 <Command>
418 GenFw -o ${dst} -m ${src}
419
420 [Microcode-Binary-File]
421 <InputFile>
422 *.mcb
423
424 <OutputFile>
425 $(OUTPUT_DIR)(+)$(MODULE_NAME).bin
426
427 <Command>
428 GenFw -o ${dst} -j $(MICROCODE_BINARY_FILES)
429 -$(CP) ${dst} $(BIN_DIR)
430
431 [EFI-Image-File]
432 <InputFile>
433 ?.efi, ?.Efi, ?.EFI
434
435 <OutputFile>
436
437 <Command>
438
439 [Unicode-Text-File]
440 <InputFile>
441 *.uni, *.Uni, *.UNI
442
443 <OutputFile>
444 $(DEBUG_DIR)(+)AutoGen.c
445 $(DEBUG_DIR)(+)$(MODULE_NAME)StrDefs.h
446
447 <Command>
448
449 [Efi-Image.UEFI_OPTIONROM]
450 <InputFile>
451 ?.efi, ?.EFI, ?.Efi
452
453 <OutputFile>
454 $(BIN_DIR)(+)$(MODULE_NAME).rom
455
456 <Command>
457 $(OPTROM) -i $(PCI_DEVICE_ID) -f $(PCI_VENDOR_ID) -l $(PCI_CLASS_CODE) -r $(PCI_REVISION) -o $dst $(OPTROM_FLAGS) $src
458