Appendix J Makefiles
This appendix describes the format of the Makefiles created by the EDK II build system.

J.1 NMAKE Module Makefile Format

The build system will generate a top level Makefile for each module in the platform, using the target and tool chain as an identifier for the combination. If multiple architectures are part of the platform build, there will be a separate tree under the directory for each module that requires multi-architecture builds.

Template

1
# DO NOT EDIT
2
# This file is auto-generated by build utility
3
#
4
# Module Name:
5
#
6
# %s
7
#
8
# Abstract:
9
#
10
# Auto-generated makefile for building modules, libraries or platform
11
#
12
13
#
14
# Platform Macro Definition
15
#
16
PLATFORM_NAME = ${platform_name}
17
PLATFORM_GUID = ${platform_guid}
18
PLATFORM_VERSION = ${platform_version}
19
PLATFORM_RELATIVE_DIR = ${platform_relative_directory}
20
PLATFORM_DIR = $(WORKSPACE)${sep}${platform_relative_directory}
21
PLATFORM_OUTPUT_DIR = ${platform_output_directory}
22
23
#
24
# Module Macro Definition
25
#
26
MODULE_NAME = ${module_name}
27
MODULE_GUID = ${module_guid}
28
MODULE_VERSION = ${module_version}
29
MODULE_TYPE = ${module_type}
30
MODULE_FILE = ${module_file}
31
MODULE_FILE_BASE_NAME = ${module_file_base_name}
32
BASE_NAME = $(MODULE_NAME)
33
MODULE_RELATIVE_DIR = ${module_relative_directory}
34
MODULE_DIR = $(WORKSPACE)${sep}${module_relative_directory}
35
36
MODULE_ENTRY_POINT = ${module_entry_point}
37
ARCH_ENTRY_POINT = ${arch_entry_point}
38
IMAGE_ENTRY_POINT = ${image_entry_point}
39
40
${module_extra_defines}
41
#
42
# Build Configuration Macro Definition
43
#
44
ARCH = ${arch}
45
TOOLCHAIN = ${toolchain_tag}
46
TOOLCHAIN_TAG = ${toolchain_tag}
47
TARGET = ${build_target}
48
49
#
50
# Build Directory Macro Definition
51
#
52
# PLATFORM_BUILD_DIR = ${platform_build_directory}
53
BUILD_DIR = ${platform_build_directory}
54
BIN_DIR = $(BUILD_DIR)${sep}${architecture}
55
LIB_DIR = $(BIN_DIR)
56
MODULE_BUILD_DIR = ${module_build_directory}
57
OUTPUT_DIR = ${module_output_directory}
58
DEBUG_DIR = ${module_debug_directory}
59
DEST_DIR_OUTPUT = $(OUTPUT_DIR)
60
DEST_DIR_DEBUG = $(DEBUG_DIR)
61
62
#
63
# Shell Command Macro
64
#
65
RD = rmdir /s /q
66
RM = del /f /q
67
MD = mkdir
68
CP = copy /y
69
MV = move /y
70
71
#
72
# Tools definitions specific to this module
73
#
74
${module_tool_definitions}
Copied!
Note: ${module_tool_definitions} individual lines that contain an environment name followed by the equal sign, followed by a string. The following two lines are an example.
1
TIANO = TianoCompress
2
TIANO_GUID = A31280AD-481E-41B6-95E8-127F4C984779
3
4
MAKE_FILE = ${makefile_path}
5
6
#
7
# Build Macro
8
#
Copied!
Note: The value of ${macroname} is derived from the file types identified in the build_rule.txt file, these are typically: OBJECT_FILES and STATIC_LIBRARY_FILES a special macro name, INC is also emitted listing the EDK II Include directories required from a module's dependent packages. The INC list entry prepends the compiler's option character sequence to include the directory in the search list.
1
${macro_name} = \
2
\t$(OUTPUT_DIR)${sep}${filename} \\
Copied!
Note: The above line is duplicated for additional files, the "\" is removed from the last line if this list. A text file for each of these macro sets (except INC) is generated in the module's OUTPUT directory.
1
${macro_name}_LIST = $(OUTPUT_DIR)${sep}${macro_name}.lst
2
3
COMMON_DEPS = \
4
\t${common_dependency_file} \\
Copied!
Note: The above line is duplicated for all header files required by the module (defined by the #include statements) and files included by header files required by the module
1
#
2
# Overridable Target Macro Definitions
3
#
4
FORCE_REBUILD = force_build
5
INIT_TARGET = init
6
PCH_TARGET =
7
BC_TARGET = $ {backward_compatible_target}
8
CODA_TARGET = $ {remaining_build_target} \\
Copied!
Note: The above line contains the name of the output .efi file generated by the drivers or the .lib file generated by libraries. The backslash character is added to allow extra lines after $(CODE_TARGET) is specified.
1
#
2
# Default target, which will build dependent libraries in addition to
3
# source files
4
#
5
6
all: mbuild
7
8
#
9
# Target used when called from platform makefile, which will bypass
10
# the build of dependent libraries since the platform makefile builds
11
# all libraries first.
12
#
13
14
pbuild: $(INIT_TARGET) $(BC_TARGET) $(PCH_TARGET) $(CODA_TARGET)
15
16
17
#
18
# ModuleTarget
19
#
20
21
mbuild: $(INIT_TARGET) $(BC_TARGET) gen_libs $(PCH_TARGET)$(CODA_TARGET)
22
23
#
24
# Build Target used in multi-thread build mode, which will bypass the
25
# init and gen_libs targets
26
#
27
28
tbuild: $(BC_TARGET) $(PCH_TARGET) $(CODA_TARGET)
29
30
#
31
# Phony target which is used to force executing commands for a target
32
#
33
34
force_build:
36
37
#
38
# Target to update the FD
39
#
40
41
fds: mbuild gen_fds
42
43
#
44
# Initialization target: print build information and create necessary directories
45
#
46
init: info dirs
47
48
info:
49
\[email protected] Building ... $(MODULE_DIR)${sep}$(MODULE_FILE) [$(ARCH)]
50
51
dirs:
52
\[email protected]@if not exist $(DEBUG_DIR) $(MD) $(DEBUG_DIR)
53
\[email protected] not exist $(OUTPUT_DIR) $(MD) $(OUTPUT_DIR)
54
55
strdefs:
56
\[email protected]$(CP) $(DEBUG_DIR)${ds}AutoGen.h \
57
$(DEBUG_DIR)${ds}$(MODULE_NAME)StrDefs.h
Copied!
Note: The above two lines are not exact, as they will appear on the same line in the generated Makefile without the "\" line extension character.
1
#
2
# GenLibsTarget
3
#
4
gen_libs:
5
\[email protected]"$(MAKE)" $(MAKE_FLAGS) \
6
-f ${dependent_library_build_directory}${sep}${makefile_name}
Copied!
Note: The above two lines are not exact, as they will appear on the same line in the generated Makefile without the "\" line extension character. The line is repeated for every library instance that the module requires to be linked against.
1
\[email protected] $(MODULE_BUILD_DIR)
2
3
#
4
# Build Flash Device Image
5
#
6
gen_fds:
7
\[email protected]"$(MAKE)" $(MAKE_FLAGS) -f $(BUILD_DIR)${sep}${makefile_name} fds
8
\[email protected] $(MODULE_BUILD_DIR)
9
10
#
11
# Individual Object Build Targets
12
#
13
${file_build_target}
Copied!
Note: The above line is repeated for each CODA_TARGET using the format from the build_rule.txt file to build intermediate files.
1
#
2
# clean all intermediate files
3
#
4
clean:
5
\tif exist $(OUTPUT_DIR) $(RD) $(OUTPUT_DIR)
6
\t$
7
8
#
9
# clean all generated files
10
#
11
cleanall:
12
\tif exist $(DEBUG_DIR) $(RD) $(DEBUG_DIR)
13
\tif exist $(OUTPUT_DIR) $(RD) $(OUTPUT_DIR)
14
\t$(RM) *.pdb *.idb > NUL 2>&1
15
\t$(RM) $(BIN_DIR)${sep}$(MODULE_NAME).efi
16
17
#
18
# clean all dependent libraries built
19
#
20
cleanlib:
21
\t${library_build_command} cleanall
Copied!
Note: The above ${library_build_command} is repeated for every library instance used to link against the driver or application module. It first tests for the existence of the makefile and if it exists, runs the make command. If the module is a library, the above lines are not emitted.
1
\[email protected] $(MODULE_BUILD_DIR)\n\n
Copied!
Last modified 1yr ago