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.


# This file is auto-generated by build utility
# Module Name:
# %s
# Abstract:
# Auto-generated makefile for building modules, libraries or platform
# Platform Macro Definition
PLATFORM_NAME = ${platform_name}
PLATFORM_GUID = ${platform_guid}
PLATFORM_VERSION = ${platform_version}
PLATFORM_RELATIVE_DIR = ${platform_relative_directory}
PLATFORM_DIR = $(WORKSPACE)${sep}${platform_relative_directory}
PLATFORM_OUTPUT_DIR = ${platform_output_directory}
# Module Macro Definition
MODULE_NAME = ${module_name}
MODULE_GUID = ${module_guid}
MODULE_VERSION = ${module_version}
MODULE_TYPE = ${module_type}
MODULE_FILE = ${module_file}
MODULE_FILE_BASE_NAME = ${module_file_base_name}
MODULE_RELATIVE_DIR = ${module_relative_directory}
MODULE_DIR = $(WORKSPACE)${sep}${module_relative_directory}
MODULE_ENTRY_POINT = ${module_entry_point}
ARCH_ENTRY_POINT = ${arch_entry_point}
IMAGE_ENTRY_POINT = ${image_entry_point}
# Build Configuration Macro Definition
ARCH = ${arch}
TOOLCHAIN = ${toolchain_tag}
TOOLCHAIN_TAG = ${toolchain_tag}
TARGET = ${build_target}
# Build Directory Macro Definition
# PLATFORM_BUILD_DIR = ${platform_build_directory}
BUILD_DIR = ${platform_build_directory}
BIN_DIR = $(BUILD_DIR)${sep}${architecture}
MODULE_BUILD_DIR = ${module_build_directory}
OUTPUT_DIR = ${module_output_directory}
DEBUG_DIR = ${module_debug_directory}
# Shell Command Macro
RD = rmdir /s /q
RM = del /f /q
MD = mkdir
CP = copy /y
MV = move /y
# Tools definitions specific to this module
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.
TIANO = TianoCompress
TIANO_GUID = A31280AD-481E-41B6-95E8-127F4C984779
MAKE_FILE = ${makefile_path}
# Build Macro
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.
${macro_name} = \
\t$(OUTPUT_DIR)${sep}${filename} \\
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.
${macro_name}_LIST = $(OUTPUT_DIR)${sep}${macro_name}.lst
\t${common_dependency_file} \\
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
# Overridable Target Macro Definitions
FORCE_REBUILD = force_build
BC_TARGET = $ {backward_compatible_target}
CODA_TARGET = $ {remaining_build_target} \\
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.
# Default target, which will build dependent libraries in addition to
# source files
all: mbuild
# Target used when called from platform makefile, which will bypass
# the build of dependent libraries since the platform makefile builds
# all libraries first.
# ModuleTarget
# Build Target used in multi-thread build mode, which will bypass the
# init and gen_libs targets
# Phony target which is used to force executing commands for a target
# Target to update the FD
fds: mbuild gen_fds
# Initialization target: print build information and create necessary directories
init: info dirs
\[email protected] Building ... $(MODULE_DIR)${sep}$(MODULE_FILE) [$(ARCH)]
\[email protected]@if not exist $(DEBUG_DIR) $(MD) $(DEBUG_DIR)
\[email protected] not exist $(OUTPUT_DIR) $(MD) $(OUTPUT_DIR)
\[email protected]$(CP) $(DEBUG_DIR)${ds}AutoGen.h \
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.
# GenLibsTarget
\[email protected]"$(MAKE)" $(MAKE_FLAGS) \
-f ${dependent_library_build_directory}${sep}${makefile_name}
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.
\[email protected] $(MODULE_BUILD_DIR)
# Build Flash Device Image
\[email protected]"$(MAKE)" $(MAKE_FLAGS) -f $(BUILD_DIR)${sep}${makefile_name} fds
\[email protected] $(MODULE_BUILD_DIR)
# Individual Object Build Targets
Note: The above line is repeated for each CODA_TARGET using the format from the build_rule.txt file to build intermediate files.
# clean all intermediate files
\tif exist $(OUTPUT_DIR) $(RD) $(OUTPUT_DIR)
# clean all generated files
\tif exist $(DEBUG_DIR) $(RD) $(DEBUG_DIR)
\tif exist $(OUTPUT_DIR) $(RD) $(OUTPUT_DIR)
\t$(RM) *.pdb *.idb > NUL 2>&1
\t$(RM) $(BIN_DIR)${sep}$(MODULE_NAME).efi
# clean all dependent libraries built
\t${library_build_command} cleanall
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.
\[email protected] $(MODULE_BUILD_DIR)\n\n