• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#/*++
2#
3# Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
4# 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#  Module Name:
13#
14#    Common.dsc
15#
16#  Abstract:
17#
18#    This is the build description file containing the platform
19#    independent build instructions.  Platform specific instructions will
20#    be prepended to produce the final build DSC file.
21#
22#
23#  Notes:
24#
25#    The info in this file is broken down into sections. The start of a section
26#    is designated by a "[" in the first column. So the [=====] separater ends
27#    a section.
28#
29#--*/
30
31[=============================================================================]
32#
33# These get emitted at the top of the generated master makefile.
34#
35[=============================================================================]
36[Makefile.out]
37#
38# From the [makefile.out] section of the DSC file
39#
40TOOLCHAIN =
41MAKE      = nmake -nologo
42
43!INCLUDE $(BUILD_DIR)\PlatformTools.env
44
45all : libraries fvs
46
47[=============================================================================]
48#
49# These get expanded and dumped out to each component makefile after the
50# component INF [defines] section gets parsed.
51#
52[=============================================================================]
53[Makefile.Common]
54#
55# From the [Makefile.Common] section of the description file.
56#
57PROCESSOR        = $(PROCESSOR)
58BASE_NAME        = $(BASE_NAME)
59BUILD_NUMBER     = $(BUILD_NUMBER)
60VERSION_STRING   = $(VERSION_STRING)
61TOOLCHAIN        = TOOLCHAIN_$(PROCESSOR)
62FILE_GUID        = $(FILE_GUID)
63COMPONENT_TYPE   = $(COMPONENT_TYPE)
64FV_DIR           = $(BUILD_DIR)\FV
65PLATFORM         = $(PROJECT_NAME)
66
67#
68# Define the global dependency files
69#
70!IF EXIST ($(DEST_DIR)\$(BASE_NAME)StrDefs.h)
71INC_DEPS         = $(INC_DEPS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h
72!ENDIF
73#ENV_DEPS         = $(ENV_DEPS) $(EDK_SOURCE)\Sample\CommonTools.env
74#ENV_DEPS         = $(ENV_DEPS) $(BUILD_DIR)\PlatformTools.env
75#ENV_DEPS         = $(ENV_DEPS) $(BUILD_DIR)\Config.env
76ALL_DEPS         = $(INC_DEPS) $(ENV_DEPS)
77
78!IF "$(LANGUAGE)" != ""
79LANGUAGE_FLAGS    = -lang $(LANGUAGE)
80!ENDIF
81
82!INCLUDE $(BUILD_DIR)\PlatformTools.env
83
84!IF "$(COMPONENT_TYPE)" == "PIC_PEIM" || "$(COMPONENT_TYPE)" == "PE32_PEIM" || "$(COMPONENT_TYPE)" == "RELOCATABLE_PEIM" || "$(COMPONENT_TYPE)" == "COMBINED_PEIM_DRIVER"
85DEPEX_TYPE = EFI_SECTION_PEI_DEPEX
86!ELSE
87DEPEX_TYPE = EFI_SECTION_DXE_DEPEX
88!ENDIF
89
90!IF "$(COMPONENT_TYPE)" != "LIBRARY" && EXIST($(BUILD_DIR)\$(PROCESSOR)\CompilerStub.lib)
91LIBS = $(LIBS) $(BUILD_DIR)\$(PROCESSOR)\CompilerStub.lib
92!ENDIF
93
94#
95# Command flags for MAKEDEPS tool
96#
97DEP_FLAGS = -target $** -o $(DEP_FILE) $(INC) -ignorenotfound -q
98DEP_FLAGS2 = -target $@ -o $(DEP_FILE) -cl
99
100[=============================================================================]
101#
102# These are the commands to compile source files. One of these blocks gets
103# emitted to the component's makefile for each source file. The section
104# name is encoded as [Compile.$(PROCESSOR).source_filename_extension], where
105# the source filename comes from the sources section of the component INF file.
106#
107# If the dependency list file already exists, then include it for this
108# source file. If it doesn't exist, then this is a clean build and the
109# dependency file will get created below and the source file will get
110# compiled.
111#
112# Current behavior is that the first clean build will not create dep files.
113# But the following second build has to create dep files before build source files.
114# CREATEDEPS flag is used to judge whether current build is the second build or not.
115#
116#
117[=============================================================================]
118[Compile.Ia32.asm,Compile.x64.asm]
119
120#
121# Add build dependency check
122#
123DEP_FILE    = $(DEST_DIR)\$(FILE)Asm.dep
124
125!IF EXIST($(DEP_FILE))
126!INCLUDE $(DEP_FILE)
127!ENDIF
128
129!IF EXIST($(DEST_DIR)\$(FILE).obj)
130DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Asm.dep
131!IF !EXIST($(DEP_FILE))
132CREATEDEPS = YES
133!ENDIF
134!ENDIF
135
136#
137# Update dep file for next round incremental build
138#
139$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj
140  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS) -asm
141
142#
143# Compile the file
144#
145$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)
146  $(ASM) $(ASM_FLAGS) $(SOURCE_FILE_NAME)
147
148[=============================================================================]
149[Compile.Ipf.s]
150
151#
152# Add build dependency check
153#
154DEP_FILE    = $(DEST_DIR)\$(FILE)S.dep
155
156!IF EXIST($(DEP_FILE))
157!INCLUDE $(DEP_FILE)
158!ENDIF
159
160!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
161
162!IF EXIST($(DEST_DIR)\$(FILE).obj)
163DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)S.dep
164!IF !EXIST($(DEP_FILE))
165CREATEDEPS = YES
166!ENDIF
167!ENDIF
168
169#
170# Update dep file for next round incremental build
171#
172$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj
173  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)
174
175!ENDIF
176
177#
178# Compile the file
179#
180$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)
181!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
182  $(CC) $(C_FLAGS_PRO) $(SOURCE_FILE_NAME) > $(DEST_DIR)\$(FILE).pro
183!ELSE
184  -$(CC) $(C_FLAGS_PRO) $(SOURCE_FILE_NAME) /showIncludes > $(DEST_DIR)\$(FILE).pro 2> $(DEST_DIR)\$(FILE)S.cl
185  @$(MAKEDEPS) -f $(DEST_DIR)\$(FILE)S.cl $(DEP_FLAGS2)
186!ENDIF
187  $(ASM) $(ASM_FLAGS) $(DEST_DIR)\$(FILE).pro
188
189[=============================================================================]
190[Compile.Ia32.c,Compile.Ipf.c,Compile.x64.c]
191
192#
193# Add build dependency check
194#
195DEP_FILE    = $(DEST_DIR)\$(FILE).dep
196
197!IF EXIST($(DEP_FILE))
198!INCLUDE $(DEP_FILE)
199!ENDIF
200
201!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
202
203!IF EXIST($(DEST_DIR)\$(FILE).obj)
204DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE).dep
205!IF !EXIST($(DEP_FILE))
206CREATEDEPS = YES
207!ENDIF
208!ENDIF
209
210#
211# Update dep file for next round incremental build
212#
213$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj
214  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)
215
216!ENDIF
217
218#
219# Compile the file
220#
221$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)
222!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
223  $(CC) $(C_FLAGS) $(SOURCE_FILE_NAME)
224!ELSE
225  -$(CC) $(C_FLAGS) $(SOURCE_FILE_NAME) /showIncludes > $(DEST_DIR)\$(FILE).cl
226  @$(MAKEDEPS) -f $(DEST_DIR)\$(FILE).cl $(DEP_FLAGS2)
227!ENDIF
228
229[=============================================================================]
230[Compile.Ebc.c]
231
232#
233# Add build dependency check
234#
235DEP_FILE    = $(DEST_DIR)\$(FILE).dep
236
237!IF EXIST($(DEP_FILE))
238!INCLUDE $(DEP_FILE)
239!ENDIF
240
241!IF EXIST($(DEST_DIR)\$(FILE).obj)
242DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE).dep
243!IF !EXIST($(DEP_FILE))
244CREATEDEPS = YES
245!ENDIF
246!ENDIF
247
248#
249# Update dep file for next round incremental build
250#
251$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj
252  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)
253
254#
255# Compile the file
256#
257$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)
258  $(EBC_CC) $(EBC_C_FLAGS) $(SOURCE_FILE_NAME)
259
260[=============================================================================]
261#
262# Commands for compiling a ".apr" Apriori source file.
263#
264[=============================================================================]
265[Compile.Ia32.Apr,Compile.Ipf.Apr,Compile.Ebc.Apr,Compile.x64.Apr]
266#
267# Create the raw binary file. If you get an error on the build saying it doesn't
268# know how to create the .apr file, then you're missing (or mispelled) the
269# "APRIORI=" on the component lines in components section in the DSC file.
270#
271$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME) $(INF_FILENAME)
272  $(GENAPRIORI) -v -f $(SOURCE_FILE_NAME) -o $(DEST_DIR)\$(BASE_NAME).bin
273
274$(DEST_DIR)\$(BASE_NAME).sec : $(DEST_DIR)\$(BASE_NAME).bin
275  $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME).bin -O $(DEST_DIR)\$(BASE_NAME).sec -S EFI_SECTION_RAW
276
277[=============================================================================]
278[Build.Ia32.Apriori,Build.Ipf.Apriori,Build.Ebc.Apriori,Build.x64.Apriori]
279
280all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).FFS
281
282#
283# Run GenFfsFile on the package file and .raw file to create the firmware file
284#
285$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).FFS : $(DEST_DIR)\$(BASE_NAME).sec $(PACKAGE_FILENAME)
286  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V
287
288#
289# Remove the generated temp and final files for this modules.
290#
291clean :
292!IF ("$(FILE_GUID)" != "")
293  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
294!ENDIF
295  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*
296  @del /q $(DEST_OUTPUT_DIRS)
297
298[=============================================================================]
299[Build.Ia32.Makefile,Build.Ipf.Makefile,Build.Ebc.Makefile,Build.x64.Makefile]
300
301#
302# Set some required macros
303#
304MAKEFILE_MACROS = SOURCE_DIR=$(SOURCE_DIR)                \
305                  BUILD_DIR=$(BUILD_DIR)                  \
306                  FILE_GUID=$(FILE_GUID)                  \
307                  DEST_DIR=$(DEST_DIR)                    \
308                  PROCESSOR=$(PROCESSOR)                  \
309                  TOOLCHAIN=TOOLCHAIN_$(PROCESSOR)        \
310                  BASE_NAME=$(BASE_NAME)                  \
311                  PACKAGE_FILENAME=$(PACKAGE_FILENAME)
312
313#
314# Just call the makefile from the source directory, passing in some
315# useful info.
316#
317all :
318  $(MAKE) -f $(SOURCE_DIR)\makefile.new all $(MAKEFILE_MACROS)
319
320#
321# Remove the generated temp and final files for this modules.
322#
323clean :
324  @- $(MAKE) -f $(SOURCE_DIR)\makefile.new clean $(MAKEFILE_MACROS) > NUL 2>&1
325!IF ("$(FILE_GUID)" != "")
326  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
327!ENDIF
328  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*
329  @del /q $(DEST_OUTPUT_DIRS)
330
331[=============================================================================]
332#
333# Instructions for building a component that uses a custom makefile. Encoding
334# is [build.$(PROCESSOR).$(BUILD_TYPE)].
335#
336# To build these components, simply call the makefile from the source
337# directory.
338#
339[=============================================================================]
340[Build.Ia32.Custom_Makefile,Build.Ipf.Custom_Makefile,Build.Ebc.Custom_Makefile,Build.x64.Custom_Makefile]
341
342#
343# Set some required macros
344#
345MAKEFILE_MACROS = SOURCE_DIR=$(SOURCE_DIR)                \
346                  BUILD_DIR=$(BUILD_DIR)                  \
347                  DEST_DIR=$(DEST_DIR)                    \
348                  FILE_GUID=$(FILE_GUID)                  \
349                  PROCESSOR=$(PROCESSOR)                  \
350                  TOOLCHAIN=TOOLCHAIN_$(PROCESSOR)        \
351                  BASE_NAME=$(BASE_NAME)                  \
352                  PLATFORM=$(PLATFORM)                    \
353                  SOURCE_FV=$(SOURCE_FV)                  \
354                  PACKAGE_FILENAME=$(PACKAGE_FILENAME)
355
356#
357# Just call the makefile from the source directory, passing in some
358# useful info.
359#
360all :
361  $(MAKE) -f $(SOURCE_DIR)\makefile all $(MAKEFILE_MACROS)
362
363#
364# Remove the generated temp and final files for this modules.
365#
366clean :
367  @- $(MAKE) -f $(SOURCE_DIR)\makefile clean $(MAKEFILE_MACROS) > NUL 2>&1
368!IF ("$(FILE_GUID)" != "")
369  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
370!ENDIF
371  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*
372  @del /q $(DEST_OUTPUT_DIRS)
373
374[=============================================================================]
375#
376# These commands are used to build libraries
377#
378[=============================================================================]
379[Build.Ia32.LIBRARY,Build.Ipf.LIBRARY,Build.x64.LIBRARY]
380#
381# LIB all the object files into to our target lib file. Put
382# a dependency on the component's INF file in case it changes.
383#
384LIB_NAME = $(LIB_DIR)\$(BASE_NAME).lib
385
386#
387# $(DEP_TARGETS) are not needed for binary build.
388#
389!IF ("$(BINARY)" == "TRUE") || (("$(BINARY)" == "") && ("$(EFI_BINARY_LIBRARY)" == "YES"))
390DEP_TARGETS=
391CREATEDEPS=
392!ENDIF
393
394#
395# Module can be built from source code or binary files.
396#
397!IF ((("$(BINARY)" == "TRUE") || (("$(BINARY)" == "") && ("$(EFI_BINARY_LIBRARY)" == "YES"))) \
398    && EXIST($(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).lib))
399$(LIB_NAME) : $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).lib
400  copy $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).lib $(LIB_NAME) /Y
401  if exist $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME)Obj.pdb \
402  copy $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME)Obj.pdb $(DEST_DIR)\$(BASE_NAME)Obj.pdb /Y
403!ELSE
404$(LIB_NAME) : $(OBJECTS) $(LIBS) $(INF_FILENAME) $(ENV_DEPS)
405  $(LIB) $(LIB_FLAGS) $(OBJECTS) $(LIBS) /OUT:$@
406!IF ("$(EFI_BINARY_BUILD)" == "YES")
407  if not exist $(EFI_PLATFORM_BIN)\$(PROCESSOR) mkdir $(EFI_PLATFORM_BIN)\$(PROCESSOR)
408  if exist $(LIB_NAME) copy $(LIB_NAME) $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).lib /Y
409  if exist $(DEST_DIR)\$(BASE_NAME)Obj.pdb copy $(DEST_DIR)\$(BASE_NAME)Obj.pdb $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME)Obj.pdb /Y
410!ENDIF
411!ENDIF
412
413!IF "$(CREATEDEPS)"=="YES"
414all : $(DEP_TARGETS)
415  $(MAKE) -f $(MAKEFILE_NAME) all
416!ELSE
417all : $(LIB_NAME) $(DEP_TARGETS)
418!ENDIF
419
420#
421# Remove the generated temp and final files for this modules.
422#
423clean :
424!IF ("$(FILE_GUID)" != "")
425  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
426!ENDIF
427  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*
428  @del /q $(DEST_OUTPUT_DIRS)
429
430[=============================================================================]
431[Build.Ebc.LIBRARY]
432#
433# LIB all the object files into to our target lib file. Put
434# a dependency on the component's INF file in case it changes.
435#
436LIB_NAME = $(LIB_DIR)\$(BASE_NAME).lib
437
438$(LIB_NAME) : $(OBJECTS) $(LIBS) $(INF_FILENAME) $(ENV_DEPS)
439   $(EBC_LIB) $(EBC_LIB_FLAGS) $(OBJECTS) $(LIBS) /OUT:$@
440
441!IF "$(CREATEDEPS)"=="YES"
442all : $(DEP_TARGETS)
443  $(MAKE) -f $(MAKEFILE_NAME) all
444!ELSE
445all : $(LIB_NAME) $(DEP_TARGETS)
446!ENDIF
447
448#
449# Remove the generated temp and final files for this modules.
450#
451clean :
452!IF ("$(FILE_GUID)" != "")
453  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
454!ENDIF
455  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*
456  @del /q $(DEST_OUTPUT_DIRS)
457
458[=============================================================================]
459#
460# This is the Build.$(PROCESSOR).$(COMPONENT_TYPE) section that tells how to
461# convert a firmware volume into an FV FFS file. Simply run it through
462# GenFfsFile with the appropriate package file. SOURCE_FV must be defined
463# in the component INF file Defines section.
464#
465[=============================================================================]
466[Build.Ia32.FvImageFile,Build.x64.FvImageFile,Build.Ipf.FvImageFile]
467
468all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).Fvi
469
470#
471# Run GenFfsFile on the package file and FV file to create the firmware
472# volume FFS file. This FFS file maybe contain one pad section for alignment requirement.
473#
474$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).Fvi : $(DEST_DIR)\$(SOURCE_FV)Fv.sec $(PACKAGE_FILENAME) $(PAD_SECTION)
475  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V
476
477#
478# Remove the generated temp and final files for this modules.
479#
480clean :
481!IF ("$(FILE_GUID)" != "")
482  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
483!ENDIF
484  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*
485  @del /q $(DEST_OUTPUT_DIRS)
486
487[=============================================================================]
488#
489# Since many of the steps are the same for the different component types, we
490# share this section for BS_DRIVER, RT_DRIVER, .... and IFDEF the parts that
491# differ.  The entire section gets dumped to the output makefile.
492#
493[=============================================================================]
494[Build.Ia32.BS_DRIVER|RT_DRIVER|SAL_RT_DRIVER|PE32_PEIM|PEI_CORE|PIC_PEIM|RELOCATABLE_PEIM|DXE_CORE|APPLICATION|COMBINED_PEIM_DRIVER, Build.Ipf.BS_DRIVER|RT_DRIVER|SAL_RT_DRIVER|PEI_CORE|PE32_PEIM|PIC_PEIM|DXE_CORE|APPLICATION|COMBINED_PEIM_DRIVER, Build.x64.BS_DRIVER|RT_DRIVER|SAL_RT_DRIVER|PE32_PEIM|PEI_CORE|PIC_PEIM|RELOCATABLE_PEIM|DXE_CORE|APPLICATION|COMBINED_PEIM_DRIVER]
495
496!IF "$(LOCALIZE)" == "YES"
497
498!IF (("$(EFI_GENERATE_HII_RESOURCE)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A"))
499#
500# This will generate HII resource section in PE/COFF image.
501#
502# Note: when HII package list is built into resource section, Driver no longer
503# refer to C array generated by VfrCompiler ($(FILE_NAME)Bin) and StrGather
504# ($(BASE_NAME)Strings); while in current build rule, those C array objects
505# will still be linked with the Driver, so please turn on link flag "/OPT:REF"
506# to minimize the code size.
507#
508HII_PACK_FILES   = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk
509LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).res
510LINK_FLAGS_DLL   = $(LINK_FLAGS_DLL) $(DEST_DIR)\$(BASE_NAME).res
511
512$(DEST_DIR)\$(BASE_NAME).rc : $(HII_PACK_FILES)
513  $(HIIPACK) -g $(FILE_GUID) $(HII_PACK_FILES) -rc $(DEST_DIR)\$(BASE_NAME).rc -hii $(DEST_DIR)\$(BASE_NAME).hii
514
515$(DEST_DIR)\$(BASE_NAME).res : $(DEST_DIR)\$(BASE_NAME).rc
516  $(RC) /fo $(DEST_DIR)\$(BASE_NAME).res $(DEST_DIR)\$(BASE_NAME).rc
517
518!ENDIF
519
520!IF (("$(EFI_GENERATE_HII_EXPORT)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" < "0x0002000A"))
521#
522# There will be one HII pack containing all the strings. Add that file
523# to the list of HII pack files we'll use to create our final HII export file.
524#
525HII_PACK_FILES    = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk
526LOCALIZE_TARGETS  = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).hii
527!ENDIF
528
529!IF ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A")
530#
531# Note: currently -ppflag option is only available for UefiStrGather
532# Note: /GS- will cause warning for preprocess, so filter it out from STRGATHER_PPFLAG
533#
534STRGATHER_PPFLAG = $(C_FLAGS: /GS-=)
535STRGATHER_FLAGS  = $(STRGATHER_FLAGS) -ppflag "$(STRGATHER_PPFLAG)" -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h
536!ENDIF
537
538$(DEST_DIR)\$(BASE_NAME).sdb : $(SDB_FILES) $(SOURCE_FILES)
539  $(STRGATHER) -scan -vdbr $(STRGATHER_FLAGS) -od $(DEST_DIR)\$(BASE_NAME).sdb \
540    -skipext .uni -skipext .h $(SOURCE_FILES)
541
542$(DEST_DIR)\$(BASE_NAME)Strings.c : $(DEST_DIR)\$(BASE_NAME).sdb
543  $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \
544    -oc $(DEST_DIR)\$(BASE_NAME)Strings.c
545
546$(DEST_DIR)\$(BASE_NAME)StrDefs.h : $(DEST_DIR)\$(BASE_NAME).sdb
547  $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \
548    -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h
549
550$(DEST_DIR)\$(BASE_NAME)Strings.hpk : $(DEST_DIR)\$(BASE_NAME).sdb
551  $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \
552    -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk
553
554OBJECTS = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME)Strings.obj
555
556$(DEST_DIR)\$(BASE_NAME)Strings.obj : $(DEST_DIR)\$(BASE_NAME)Strings.c $(INF_FILENAME) $(ALL_DEPS)
557  $(CC) $(C_FLAGS) $(DEST_DIR)\$(BASE_NAME)Strings.c
558
559LOCALIZE_TARGETS = $(DEST_DIR)\$(BASE_NAME)StrDefs.h $(LOCALIZE_TARGETS)
560
561!ENDIF
562
563#
564# If we have any objects associated with this component, then we're
565# going to build a local library from them.
566#
567!IFNDEF OBJECTS
568!ERROR No source files to build were defined in the INF file
569!ENDIF
570
571TARGET_LOCAL_LIB  = $(DEST_DIR)\$(BASE_NAME)Local.lib
572
573#
574# LIB all the object files into our (local) target lib file. Put
575# a dependency on the component's INF file in case it changes.
576#
577$(TARGET_LOCAL_LIB) : $(OBJECTS)  $(INF_FILENAME) $(ENV_DEPS)
578  $(LIB) $(LIB_FLAGS) $(OBJECTS) /OUT:$@
579
580#
581# Defines for standard intermediate files and build targets
582#
583TARGET_DLL      = $(BIN_DIR)\$(BASE_NAME).dll
584TARGET_EFI      = $(BIN_DIR)\$(BASE_NAME).efi
585TARGET_DPX      = $(DEST_DIR)\$(BASE_NAME).dpx
586TARGET_UI       = $(DEST_DIR)\$(BASE_NAME).ui
587TARGET_VER      = $(DEST_DIR)\$(BASE_NAME).ver
588TARGET_MAP      = $(BIN_DIR)\$(BASE_NAME).map
589TARGET_PDB      = $(BIN_DIR)\$(BASE_NAME).pdb
590TARGET_SYM      = $(BIN_DIR)\$(BASE_NAME).sym
591
592#
593# Target executable section extension depends on the component type.
594# Only define "TARGET_DXE_DPX" if it's a combined peim driver.
595#
596!IF "$(COMPONENT_TYPE)" == "PIC_PEIM"
597TARGET_PE32 = $(DEST_DIR)\$(BASE_NAME).pic
598!ELSE
599TARGET_PE32 = $(DEST_DIR)\$(BASE_NAME).pe32
600!ENDIF
601
602#
603# Target FFS file extension depends on the component type
604# Also define "TARGET_DXE_DPX" if it's a combined PEIM driver.
605#
606SUBSYSTEM = EFI_BOOT_SERVICE_DRIVER
607
608!IF "$(COMPONENT_TYPE)" == "APPLICATION"
609TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).app
610SUBSYSTEM       = EFI_APPLICATION
611!ELSE IF "$(COMPONENT_TYPE)" == "PEI_CORE"
612TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei
613!ELSE IF "$(COMPONENT_TYPE)" == "PE32_PEIM"
614TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei
615!ELSE IF "$(COMPONENT_TYPE)" == "RELOCATABLE_PEIM"
616TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei
617!ELSE IF "$(COMPONENT_TYPE)" == "PIC_PEIM"
618TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei
619!ELSE IF "$(COMPONENT_TYPE)" == "COMBINED_PEIM_DRIVER"
620TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei
621TARGET_DXE_DPX  = $(DEST_DIR)\$(BASE_NAME).dpxd
622!ELSE
623TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).dxe
624!ENDIF
625
626#
627# Different methods to build section based on if PIC_PEIM
628#
629!IF "$(COMPONENT_TYPE)" == "PIC_PEIM"
630
631$(TARGET_PE32) : $(TARGET_DLL)
632  $(PE2BIN) $(TARGET_DLL) $(DEST_DIR)\$(BASE_NAME).TMP
633#
634# BUGBUG: Build PEIM header, needs to go away with new PEI.
635#
636  $(TEMPGENSECTION) -P $(SOURCE_DIR)\$(BASE_NAME).INF -I $(DEST_DIR)\$(BASE_NAME).TMP -O $(TARGET_PIC_PEI).tmp -M $(TARGET_MAP) -S EFI_SECTION_TYPE_NO_HEADER
637  $(GENSECTION) -I $(TARGET_PIC_PEI).tmp -O $(TARGET_PE32) -S EFI_SECTION_PIC
638  del $(DEST_DIR)\$(BASE_NAME).TMP
639
640!ELSE
641
642$(TARGET_PE32) : $(TARGET_EFI)
643  $(GENSECTION) -I $(TARGET_EFI) -O $(TARGET_PE32) -S EFI_SECTION_PE32
644
645#
646# $(DEP_TARGETS) are not needed for binary build.
647#
648!IF "$(BINARY)" == "TRUE"
649DEP_TARGETS=
650CREATEDEPS=
651!ENDIF
652
653#
654# Build module to generate *.efi file from source code or binary file.
655#
656!IF (("$(BINARY)" == "TRUE") && EXIST($(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).efi))
657LOCALIZE_TARGETS=
658$(TARGET_EFI) : $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).efi
659  copy $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).efi $(TARGET_EFI) /Y
660  if exist $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).pdb \
661  copy $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).pdb $(TARGET_PDB) /Y
662!ELSE
663$(TARGET_EFI) : $(TARGET_DLL) $(INF_FILENAME)
664  $(FWIMAGE) -t 0 $(COMPONENT_TYPE) $(TARGET_DLL) $(TARGET_EFI)
665!IF ("$(EFI_BINARY_BUILD)" == "YES")
666  if not exist $(EFI_PLATFORM_BIN)\$(PROCESSOR) mkdir $(EFI_PLATFORM_BIN)\$(PROCESSOR)
667  if exist $(TARGET_EFI) copy $(TARGET_EFI) $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).efi /Y
668  if exist $(TARGET_PDB) copy $(TARGET_PDB) $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).pdb /Y
669!ENDIF
670!ENDIF
671
672!ENDIF
673
674#
675# Link all objects and libs to create the executable
676#
677$(TARGET_DLL) : $(TARGET_LOCAL_LIB) $(LIBS) $(INF_FILENAME) $(ENV_DEPS)
678  $(LINK) $(LINK_FLAGS_DLL) $(LIBS) /ENTRY:$(IMAGE_ENTRY_POINT) \
679     $(TARGET_LOCAL_LIB) /OUT:$(TARGET_DLL) /MAP:$(TARGET_MAP) \
680     /PDB:$(TARGET_PDB)
681  $(SETSTAMP) $(TARGET_DLL) $(BUILD_DIR)\GenStamp.txt
682!IF "$(EFI_GENERATE_SYM_FILE)" == "YES"
683  if exist $(TARGET_PDB) $(PE2SYM) $(TARGET_PDB) $(TARGET_SYM)
684!ENDIF
685
686!IF "$(EFI_ZERO_DEBUG_DATA)" == "YES"
687  $(ZERODEBUGDATA) $(TARGET_DLL)
688!ENDIF
689
690#
691# Create the user interface section
692#
693$(TARGET_UI) : $(INF_FILENAME)
694  $(GENSECTION) -O $(TARGET_UI) -S EFI_SECTION_USER_INTERFACE -A "$(BASE_NAME)"
695
696#
697# Create the version section
698#
699!IF "$(BUILD_NUMBER)" != ""
700!IF "$(VERSION_STRING)" != ""
701$(TARGET_VER) : $(INF_FILENAME)
702  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) -A "$(VERSION_STRING)"
703!ELSE
704$(TARGET_VER) : $(INF_FILENAME)
705  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)
706!ENDIF
707!ELSE
708$(TARGET_VER) : $(INF_FILENAME)
709  echo.>$(TARGET_VER)
710  type $(TARGET_VER)>$(TARGET_VER)
711!ENDIF
712
713#
714# Makefile entries to create the dependency expression section.
715# Use the DPX file from the source directory unless an override file
716# was specified.
717# If no DPX source file was specified, then create an empty file to
718# be used.
719#
720!IF "$(DPX_SOURCE)" != ""
721DPX_SOURCE_FILE = $(SOURCE_DIR)\$(DPX_SOURCE)
722!ENDIF
723
724!IF "$(DPX_SOURCE_OVERRIDE)" != ""
725DPX_SOURCE_FILE = $(DPX_SOURCE_OVERRIDE)
726!ENDIF
727
728!IF "$(DPX_SOURCE_FILE)" != ""
729!IF EXIST ($(DPX_SOURCE_FILE))
730
731#
732# Add build dependency check
733#
734DEP_FILE    = $(DEST_DIR)\$(BASE_NAME)dxs.dep
735
736!IF EXIST($(DEP_FILE))
737!INCLUDE $(DEP_FILE)
738!ENDIF
739
740!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
741
742!IF EXIST($(TARGET_DPX))
743DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs.dep
744!IF !EXIST($(DEP_FILE))
745CREATEDEPS = YES
746!ENDIF
747!ENDIF
748
749#
750# Update dep file for next round incremental build
751#
752$(DEP_FILE) : $(TARGET_DPX)
753  $(MAKEDEPS) -f $(DPX_SOURCE_FILE) $(DEP_FLAGS)
754
755!ENDIF
756
757$(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
758!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
759  $(CC) $(C_FLAGS_DPX) $(DPX_SOURCE_FILE) > $*.tmp1
760!ELSE
761  -$(CC) $(C_FLAGS_DPX) $(DPX_SOURCE_FILE) /showIncludes > $*.tmp1 2> $(DEST_DIR)\$(BASE_NAME)dxs.cl
762  @$(MAKEDEPS) -f $(DEST_DIR)\$(BASE_NAME)dxs.cl $(DEP_FLAGS2)
763!ENDIF
764  $(GENDEPEX) -I $*.tmp1 -O $*.tmp2
765  $(GENSECTION) -I $*.tmp2 -O $@ -S $(DEPEX_TYPE)
766  del $*.tmp1 > NUL
767  del $*.tmp2 > NUL
768!ELSE
769!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.
770!ENDIF
771!ELSE
772$(TARGET_DPX) : $(INF_FILENAME)
773  echo. > $(TARGET_DPX)
774  type $(TARGET_DPX) > $(TARGET_DPX)
775!ENDIF
776
777#
778# Makefile entries for DXE DPX for combined PEIM drivers.
779# If a DXE_DPX_SOURCE file was specified in the INF file, use it. Otherwise
780# create an empty file and use it as a DPX file.
781#
782!IF "$(COMPONENT_TYPE)" == "COMBINED_PEIM_DRIVER"
783!IF "$(DXE_DPX_SOURCE)" != ""
784!IF EXIST ($(SOURCE_DIR)\$(DXE_DPX_SOURCE))
785
786#
787# Add build dependency check
788#
789DEP_FILE    = $(DEST_DIR)\$(BASE_NAME)dxs2.dep
790
791!IF EXIST($(DEP_FILE))
792!INCLUDE $(DEP_FILE)
793!ENDIF
794
795!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
796
797!IF EXIST($(TARGET_DXE_DPX))
798DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs2.dep
799!IF !EXIST($(DEP_FILE))
800CREATEDEPS = YES
801!ENDIF
802!ENDIF
803
804#
805# Update dep file for next round incremental build
806#
807$(DEP_FILE) : $(TARGET_DXE_DPX)
808  $(MAKEDEPS) -f $(SOURCE_DIR)\$(DXE_DPX_SOURCE) $(DEP_FLAGS)
809
810!ENDIF
811
812$(TARGET_DXE_DPX) : $(SOURCE_DIR)\$(DXE_DPX_SOURCE) $(INF_FILENAME)
813!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
814  $(CC) $(C_FLAGS_DPX) $(SOURCE_DIR)\$(DXE_DPX_SOURCE) > $*.tmp1
815!ELSE
816  -$(CC) $(C_FLAGS_DPX) $(SOURCE_DIR)\$(DXE_DPX_SOURCE) /showIncludes > $*.tmp1 2> $(DEST_DIR)\$(BASE_NAME)dxs2.cl
817  @$(MAKEDEPS) -f $(DEST_DIR)\$(BASE_NAME)dxs2.cl $(DEP_FLAGS2)
818!ENDIF
819  $(GENDEPEX) -I $*.tmp1 -O $*.tmp2
820  $(GENSECTION) -I $*.tmp2 -O $@ -S EFI_SECTION_DXE_DEPEX
821  del $*.tmp1 > NUL
822  del $*.tmp2 > NUL
823!ELSE
824!ERROR Dependency expression source file "$(SOURCE_DIR)\$(DXE_DPX_SOURCE)" does not exist.
825!ENDIF
826!ELSE
827$(TARGET_DXE_DPX) : $(INF_FILENAME)
828  echo. > $(TARGET_DXE_DPX)
829  type $(TARGET_DXE_DPX) > $(TARGET_DXE_DPX)
830!ENDIF
831!ENDIF
832
833#
834# Describe how to build the HII export file from all the input HII pack files.
835# Use the FFS file GUID for the package GUID in the export file. Only used
836# when multiple VFR share strings.
837#
838$(DEST_DIR)\$(BASE_NAME).hii : $(HII_PACK_FILES)
839  $(HIIPACK) create -g $(FILE_GUID) -p $(HII_PACK_FILES) -o $(DEST_DIR)\$(BASE_NAME).hii
840
841#
842# If the build calls for creating an FFS file with the IFR included as
843# a separate binary (not compiled into the driver), then build the binary
844# section now. Note that the PACKAGE must be set correctly to actually get
845# this IFR section pulled into the FFS file.
846#
847!IF ("$(HII_IFR_PACK_FILES)" != "")
848
849$(DEST_DIR)\$(BASE_NAME)IfrBin.sec : $(HII_IFR_PACK_FILES)
850  $(HIIPACK) create -novarpacks -p $(HII_IFR_PACK_FILES) -o $(DEST_DIR)\$(BASE_NAME)IfrBin.hii
851  $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME)IfrBin.hii -O $(DEST_DIR)\$(BASE_NAME)IfrBin.sec -S EFI_SECTION_RAW
852
853BIN_TARGETS = $(BIN_TARGETS) $(DEST_DIR)\$(BASE_NAME)IfrBin.sec
854
855!ENDIF
856
857#
858# Build a FFS file from the sections and package
859#
860$(TARGET_FFS_FILE) : $(TARGET_PE32) $(TARGET_DPX) $(TARGET_UI) $(TARGET_VER) $(TARGET_DXE_DPX) $(PACKAGE_FILENAME)
861#
862# Some of our components require padding to align code
863#
864!IF "$(PROCESSOR)" == "IPF"
865!IF "$(COMPONENT_TYPE)" == "PIC_PEIM" || "$(COMPONENT_TYPE)" == "PE32_PEIM" || "$(COMPONENT_TYPE)" == "RELOCATABLE_PEIM" || "$(COMPONENT_TYPE)" == "SECURITY_CORE" || "$(COMPONENT_TYPE)" == "PEI_CORE" || "$(COMPONENT_TYPE)" == "COMBINED_PEIM_DRIVER"
866  copy $(BIN_DIR)\Blank.pad $(DEST_DIR)
867!ENDIF
868!ENDIF
869  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V
870
871!IF "$(CREATEDEPS)"=="YES"
872all : $(DEP_TARGETS)
873  $(MAKE) -f $(MAKEFILE_NAME) all
874!ELSE
875all : $(LOCALIZE_TARGETS) $(BIN_TARGETS) $(TARGET_FFS_FILE) $(DEP_TARGETS)
876!ENDIF
877
878#
879# Remove the generated temp and final files for this modules.
880#
881clean :
882!IF ("$(FILE_GUID)" != "")
883  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
884!ENDIF
885  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*
886  @del /q $(DEST_OUTPUT_DIRS)
887
888[=============================================================================]
889[Build.Ia32.TE_PEIM,Build.Ipf.TE_PEIM,Build.x64.TE_PEIM]
890#
891# Define the library file we'll build if we have any objects defined.
892#
893!IFDEF OBJECTS
894TARGET_LOCAL_LIB  = $(DEST_DIR)\$(BASE_NAME)Local.lib
895#
896# LIB all the object files into our (local) target lib file. Put
897# a dependency on the component's INF file in case it changes.
898#
899$(TARGET_LOCAL_LIB) : $(OBJECTS)  $(INF_FILENAME) $(ENV_DEPS)
900  $(LIB) $(LIB_FLAGS) $(OBJECTS) /OUT:$@
901
902!ELSE
903!ERROR No source files to build were defined in the INF file
904!ENDIF
905
906#
907# Defines for standard intermediate files and build targets
908#
909TARGET_DLL        = $(BIN_DIR)\$(BASE_NAME).dll
910TARGET_EFI        = $(BIN_DIR)\$(BASE_NAME).efi
911TARGET_DPX        = $(DEST_DIR)\$(BASE_NAME).dpx
912TARGET_UI         = $(DEST_DIR)\$(BASE_NAME).ui
913TARGET_VER        = $(DEST_DIR)\$(BASE_NAME).ver
914TARGET_MAP        = $(BIN_DIR)\$(BASE_NAME).map
915TARGET_PDB        = $(BIN_DIR)\$(BASE_NAME).pdb
916TARGET_SYM        = $(BIN_DIR)\$(BASE_NAME).sym
917TARGET_TE         = $(BIN_DIR)\$(BASE_NAME).te
918TARGET_PE32       = $(DEST_DIR)\$(BASE_NAME).pe32
919TARGET_TES        = $(DEST_DIR)\$(BASE_NAME).tes
920TARGET_FFS_FILE   = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei
921
922#
923# Create our TE section from our TE file
924#
925$(TARGET_TES) : $(TARGET_TE)
926  $(GENSECTION) -I $(TARGET_TE) -O $(TARGET_TES) -S EFI_SECTION_TE
927
928#
929# $(DEP_TARGETS) are not needed for binary build.
930#
931!IF "$(BINARY)" == "TRUE"
932DEP_TARGETS=
933CREATEDEPS=
934!ENDIF
935
936#
937# Build module to generate *.efi file from source code or binary file.
938#
939!IF (("$(BINARY)" == "TRUE") && EXIST($(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).efi))
940$(TARGET_EFI) : $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).efi
941  copy $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).efi $(TARGET_EFI) /Y
942  if exist $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).pdb \
943  copy $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).pdb $(TARGET_PDB) /Y
944!ELSE
945$(TARGET_EFI) : $(TARGET_DLL) $(INF_FILENAME)
946  $(FWIMAGE) $(COMPONENT_TYPE) $(TARGET_DLL) $(TARGET_EFI)
947!IF ("$(EFI_BINARY_BUILD)" == "YES")
948  if not exist $(EFI_PLATFORM_BIN)\$(PROCESSOR) mkdir $(EFI_PLATFORM_BIN)\$(PROCESSOR)
949  if exist $(TARGET_EFI) copy $(TARGET_EFI) $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).efi /Y
950  if exist $(TARGET_PDB) copy $(TARGET_PDB) $(EFI_PLATFORM_BIN)\$(PROCESSOR)\$(BASE_NAME).pdb /Y
951!ENDIF
952!ENDIF
953
954#
955# Run GenTEImage on the built .efi file to create our TE file.
956#
957$(TARGET_TE) : $(TARGET_EFI)
958  $(GENTEIMAGE) -o $(TARGET_TE) $(TARGET_EFI)
959
960#
961# Link all objects and libs to create the executable
962#
963$(TARGET_DLL) : $(TARGET_LOCAL_LIB) $(LIBS) $(INF_FILENAME) $(ENV_DEPS)
964  $(LINK) $(LINK_FLAGS_DLL) $(LIBS) /ENTRY:$(IMAGE_ENTRY_POINT) \
965     $(TARGET_LOCAL_LIB) /OUT:$(TARGET_DLL) /MAP:$(TARGET_MAP) \
966     /PDB:$(TARGET_PDB)
967  $(SETSTAMP) $(TARGET_DLL) $(BUILD_DIR)\GenStamp.txt
968!IF "$(EFI_GENERATE_SYM_FILE)" == "YES"
969  if exist $(TARGET_PDB) $(PE2SYM) $(TARGET_PDB) $(TARGET_SYM)
970!ENDIF
971
972!IF "$(EFI_ZERO_DEBUG_DATA)" == "YES"
973  $(ZERODEBUGDATA) $(TARGET_DLL)
974!ENDIF
975
976#
977# Create the user interface section
978#
979$(TARGET_UI) : $(INF_FILENAME)
980  $(GENSECTION) -O $(TARGET_UI) -S EFI_SECTION_USER_INTERFACE -A "$(BASE_NAME)"
981
982#
983# Create the version section
984#
985!IF "$(BUILD_NUMBER)" != ""
986!IF "$(VERSION_STRING)" != ""
987$(TARGET_VER) : $(INF_FILENAME)
988  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) -A "$(VERSION_STRING)"
989!ELSE
990$(TARGET_VER) : $(INF_FILENAME)
991  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)
992!ENDIF
993!ELSE
994$(TARGET_VER) : $(INF_FILENAME)
995  echo.>$(TARGET_VER)
996  type $(TARGET_VER)>$(TARGET_VER)
997!ENDIF
998
999#
1000# Makefile entries to create the dependency expression section.
1001# Use the DPX file from the source directory unless an override file
1002# was specified.
1003# If no DPX source file was specified, then create an empty file to
1004# be used.
1005#
1006!IF "$(DPX_SOURCE)" != ""
1007DPX_SOURCE_FILE = $(SOURCE_DIR)\$(DPX_SOURCE)
1008!ENDIF
1009
1010!IF "$(DPX_SOURCE_OVERRIDE)" != ""
1011DPX_SOURCE_FILE = $(DPX_SOURCE_OVERRIDE)
1012!ENDIF
1013
1014!IF "$(DPX_SOURCE_FILE)" != ""
1015!IF EXIST ($(DPX_SOURCE_FILE))
1016
1017#
1018# Add build dependency check
1019#
1020DEP_FILE    = $(DEST_DIR)\$(BASE_NAME)dxs.dep
1021
1022!IF EXIST($(DEP_FILE))
1023!INCLUDE $(DEP_FILE)
1024!ENDIF
1025
1026!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
1027
1028!IF EXIST($(TARGET_DPX))
1029DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs.dep
1030!IF !EXIST($(DEP_FILE))
1031CREATEDEPS = YES
1032!ENDIF
1033!ENDIF
1034
1035#
1036# Update dep file for next round incremental build
1037#
1038$(DEP_FILE) : $(TARGET_DPX)
1039  $(MAKEDEPS) -f $(DPX_SOURCE_FILE) $(DEP_FLAGS)
1040
1041!ENDIF
1042
1043$(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
1044!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
1045  $(CC) $(C_FLAGS_DPX) $(DPX_SOURCE_FILE) > $*.tmp1
1046!ELSE
1047  -$(CC) $(C_FLAGS_DPX) $(DPX_SOURCE_FILE) /showIncludes > $*.tmp1 2> $(DEST_DIR)\$(BASE_NAME)dxs.cl
1048  @$(MAKEDEPS) -f $(DEST_DIR)\$(BASE_NAME)dxs.cl $(DEP_FLAGS2)
1049!ENDIF
1050  $(GENDEPEX) -I $*.tmp1 -O $*.tmp2
1051  $(GENSECTION) -I $*.tmp2 -O $@ -S $(DEPEX_TYPE)
1052  del $*.tmp1 > NUL
1053  del $*.tmp2 > NUL
1054!ELSE
1055!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.
1056!ENDIF
1057!ELSE
1058$(TARGET_DPX) : $(INF_FILENAME)
1059  echo. > $(TARGET_DPX)
1060  type $(TARGET_DPX) > $(TARGET_DPX)
1061!ENDIF
1062
1063#
1064# Build an FFS file from the sections and package
1065#
1066$(TARGET_FFS_FILE) : $(TARGET_TES) $(TARGET_DPX) $(TARGET_UI) $(TARGET_VER) $(PACKAGE_FILENAME)
1067  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V
1068
1069!IF "$(CREATEDEPS)"=="YES"
1070all : $(DEP_TARGETS)
1071  $(MAKE) -f $(MAKEFILE_NAME) all
1072!ELSE
1073all : $(TARGET_FFS_FILE) $(DEP_TARGETS)
1074!ENDIF
1075
1076#
1077# Remove the generated temp and final files for this modules.
1078#
1079clean :
1080!IF ("$(FILE_GUID)" != "")
1081  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
1082!ENDIF
1083  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*
1084  @del /q $(DEST_OUTPUT_DIRS)
1085
1086[=============================================================================]
1087#
1088# These are the commands to build EBC EFI targets
1089#
1090[=============================================================================]
1091[Build.Ebc.BS_DRIVER|RT_DRIVER|APPLICATION]
1092
1093#
1094# Add the EBC library to our list of libs
1095#
1096LIBS = $(LIBS) $(EBC_TOOLS_PATH)\lib\EbcLib.lib
1097
1098!IF "$(LOCALIZE)" == "YES"
1099
1100!IF (("$(EFI_GENERATE_HII_RESOURCE)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A"))
1101#
1102# This will generate HII resource section in PE/COFF image.
1103#
1104# Note: when HII package list is built into resource section, Driver no longer
1105# refer to C array generated by VfrCompiler ($(FILE_NAME)Bin) and StrGather
1106# ($(BASE_NAME)Strings); while in current build rule, those C array objects
1107# will still be linked with the Driver, so please turn on link flag "/OPT:REF"
1108# to minimize the code size.
1109#
1110HII_PACK_FILES   = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk
1111LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).res
1112OBJECTS          = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME).res
1113
1114$(DEST_DIR)\$(BASE_NAME).rc : $(HII_PACK_FILES)
1115  $(HIIPACK) -g $(FILE_GUID) $(HII_PACK_FILES) -rc $(DEST_DIR)\$(BASE_NAME).rc -hii $(DEST_DIR)\$(BASE_NAME).hii
1116
1117$(DEST_DIR)\$(BASE_NAME).res : $(DEST_DIR)\$(BASE_NAME).rc
1118  $(RC) /fo $(DEST_DIR)\$(BASE_NAME).res $(DEST_DIR)\$(BASE_NAME).rc
1119
1120!ENDIF
1121
1122!IF (("$(EFI_GENERATE_HII_EXPORT)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" < "0x0002000A"))
1123#
1124# There will be one HII pack containing all the strings. Add that file
1125# to the list of HII pack files we'll use to create our final HII export file.
1126#
1127HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk
1128
1129LOCALIZE_TARGETS  = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).hii
1130!ENDIF
1131
1132!IF ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A")
1133#
1134# Note: currently -ppflag option is only available for UefiStrGather
1135# Note: /GS- will cause warning for preprocess, so filter it out from STRGATHER_PPFLAG
1136#
1137STRGATHER_PPFLAG = $(EBC_C_FLAGS: /GS-=)
1138STRGATHER_FLAGS  = $(STRGATHER_FLAGS) -ppflag "$(STRGATHER_PPFLAG)" -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h
1139!ENDIF
1140
1141$(DEST_DIR)\$(BASE_NAME).sdb : $(SDB_FILES) $(SOURCE_FILES)
1142  $(STRGATHER) -scan -vdbr $(STRGATHER_FLAGS) -od $(DEST_DIR)\$(BASE_NAME).sdb \
1143    -skipext .uni -skipext .h $(SOURCE_FILES)
1144
1145$(DEST_DIR)\$(BASE_NAME)Strings.c : $(DEST_DIR)\$(BASE_NAME).sdb
1146  $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \
1147    -oc $(DEST_DIR)\$(BASE_NAME)Strings.c
1148
1149$(DEST_DIR)\$(BASE_NAME)StrDefs.h : $(DEST_DIR)\$(BASE_NAME).sdb
1150  $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \
1151    -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h
1152
1153$(DEST_DIR)\$(BASE_NAME)Strings.hpk : $(DEST_DIR)\$(BASE_NAME).sdb
1154  $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \
1155    -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk
1156
1157OBJECTS = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME)Strings.obj
1158
1159$(DEST_DIR)\$(BASE_NAME)Strings.obj : $(DEST_DIR)\$(BASE_NAME)Strings.c $(INF_FILENAME) $(ALL_DEPS)
1160  $(EBC_CC) $(EBC_C_FLAGS) $(DEST_DIR)\$(BASE_NAME)Strings.c
1161
1162LOCALIZE_TARGETS = $(DEST_DIR)\$(BASE_NAME)StrDefs.h $(LOCALIZE_TARGETS)
1163
1164!ENDIF
1165
1166#
1167# If building an application, then the target is a .app, not .dxe
1168#
1169!IF "$(COMPONENT_TYPE)" == "APPLICATION"
1170TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).app
1171SUBSYSTEM       = EFI_APPLICATION
1172!ELSE
1173TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).dxe
1174SUBSYSTEM       = EFI_BOOT_SERVICE_DRIVER
1175!ENDIF
1176
1177#
1178# Defines for standard intermediate files and build targets
1179#
1180TARGET_EFI  = $(BIN_DIR)\$(BASE_NAME).efi
1181TARGET_DPX  = $(DEST_DIR)\$(BASE_NAME).dpx
1182TARGET_UI   = $(DEST_DIR)\$(BASE_NAME).ui
1183TARGET_VER  = $(DEST_DIR)\$(BASE_NAME).ver
1184TARGET_MAP  = $(BIN_DIR)\$(BASE_NAME).map
1185TARGET_PDB  = $(BIN_DIR)\$(BASE_NAME).pdb
1186TARGET_PE32 = $(DEST_DIR)\$(BASE_NAME).pe32
1187TARGET_DLL  = $(BIN_DIR)\$(BASE_NAME).dll
1188
1189#
1190# First link all the objects and libs together to make a .dll file
1191#
1192$(TARGET_DLL) : $(OBJECTS) $(LIBS) $(INF_FILENAME) $(ENV_DEPS)
1193  $(EBC_LINK) $(EBC_LINK_FLAGS) /SUBSYSTEM:$(SUBSYSTEM) /ENTRY:EfiStart \
1194    $(OBJECTS) $(LIBS) /OUT:$(TARGET_DLL) /MAP:$(TARGET_MAP)
1195  $(SETSTAMP) $(TARGET_DLL) $(BUILD_DIR)\GenStamp.txt
1196!IF "$(EFI_ZERO_DEBUG_DATA)" == "YES"
1197  $(ZERODEBUGDATA) $(TARGET_DLL)
1198!ENDIF
1199
1200#
1201# Now take the .dll file and make a .efi file
1202#
1203$(TARGET_EFI) : $(TARGET_DLL) $(INF_FILENAME)
1204  $(FWIMAGE) -t 0 $(COMPONENT_TYPE) $(TARGET_DLL) $(TARGET_EFI)
1205
1206#
1207# Now take the .efi file and make a .pe32 section
1208#
1209$(TARGET_PE32) : $(TARGET_EFI)
1210  $(GENSECTION) -I $(TARGET_EFI) -O $(TARGET_PE32) -S EFI_SECTION_PE32
1211
1212#
1213# Create the user interface section
1214#
1215$(TARGET_UI) : $(INF_FILENAME)
1216  $(GENSECTION) -O $(TARGET_UI) -S EFI_SECTION_USER_INTERFACE -A "$(BASE_NAME)"
1217
1218#
1219# Create the version section
1220#
1221!IF "$(BUILD_NUMBER)" != ""
1222!IF "$(VERSION_STRING)" != ""
1223$(TARGET_VER) : $(INF_FILENAME)
1224  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) -A "$(VERSION_STRING)"
1225!ELSE
1226$(TARGET_VER) : $(INF_FILENAME)
1227  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)
1228!ENDIF
1229!ELSE
1230$(TARGET_VER) : $(INF_FILENAME)
1231  echo. > $(TARGET_VER)
1232  type $(TARGET_VER) > $(TARGET_VER)
1233!ENDIF
1234
1235#
1236# Makefile entries to create the dependency expression section.
1237# Use the DPX file from the source directory unless an override file
1238# was specified.
1239# If no DPX source file was specified, then create an empty file to
1240# be used.
1241#
1242!IF "$(DPX_SOURCE)" != ""
1243DPX_SOURCE_FILE = $(SOURCE_DIR)\$(DPX_SOURCE)
1244!ENDIF
1245
1246!IF "$(DPX_SOURCE_OVERRIDE)" != ""
1247DPX_SOURCE_FILE = $(DPX_SOURCE_OVERRIDE)
1248!ENDIF
1249
1250!IF "$(DPX_SOURCE_FILE)" != ""
1251!IF EXIST ($(DPX_SOURCE_FILE))
1252
1253#
1254# Add build dependency check
1255#
1256DEP_FILE    = $(DEST_DIR)\$(BASE_NAME)dxs.dep
1257
1258!IF EXIST($(DEP_FILE))
1259!INCLUDE $(DEP_FILE)
1260!ENDIF
1261
1262!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
1263
1264!IF EXIST($(TARGET_DPX))
1265DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs.dep
1266!IF !EXIST($(DEP_FILE))
1267CREATEDEPS = YES
1268!ENDIF
1269!ENDIF
1270
1271#
1272# Update dep file for next round incremental build
1273#
1274$(DEP_FILE) : $(TARGET_DPX)
1275  $(MAKEDEPS) -f $(DPX_SOURCE_FILE) $(DEP_FLAGS)
1276
1277!ENDIF
1278
1279$(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
1280!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
1281  $(CC) $(C_FLAGS_DPX) $(DPX_SOURCE_FILE) > $*.tmp1
1282!ELSE
1283  -$(CC) $(C_FLAGS_DPX) $(DPX_SOURCE_FILE) /showIncludes > $*.tmp1 2> $(DEST_DIR)\$(BASE_NAME)dxs.cl
1284  @$(MAKEDEPS) -f $(DEST_DIR)\$(BASE_NAME)dxs.cl $(DEP_FLAGS2)
1285!ENDIF
1286  $(GENDEPEX) -I $*.tmp1 -O $*.tmp2
1287  $(GENSECTION) -I $*.tmp2 -O $@ -S $(DEPEX_TYPE)
1288  del $*.tmp1 > NUL
1289  del $*.tmp2 > NUL
1290!ELSE
1291!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.
1292!ENDIF
1293!ELSE
1294$(TARGET_DPX) : $(INF_FILENAME)
1295  echo. > $(TARGET_DPX)
1296  type $(TARGET_DPX) > $(TARGET_DPX)
1297!ENDIF
1298
1299#
1300# Describe how to build the HII export file from all the input HII pack files.
1301# Use the FFS file GUID for the package GUID in the export file. Only used
1302# when multiple VFR share strings.
1303#
1304$(DEST_DIR)\$(BASE_NAME).hii : $(HII_PACK_FILES)
1305  $(HIIPACK) create -g $(FILE_GUID) -p $(HII_PACK_FILES) -o $(DEST_DIR)\$(BASE_NAME).hii
1306
1307#
1308# If the build calls for creating an FFS file with the IFR included as
1309# a separate binary (not compiled into the driver), then build the binary
1310# section now. Note that the PACKAGE must be set correctly to actually get
1311# this IFR section pulled into the FFS file.
1312#
1313!IF ("$(HII_IFR_PACK_FILES)" != "")
1314
1315$(DEST_DIR)\$(BASE_NAME)IfrBin.sec : $(HII_IFR_PACK_FILES)
1316  $(HIIPACK) create -novarpacks -p $(HII_IFR_PACK_FILES) -o $(DEST_DIR)\$(BASE_NAME)IfrBin.hii
1317  $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME)IfrBin.hii -O $(DEST_DIR)\$(BASE_NAME)IfrBin.sec -S EFI_SECTION_RAW
1318
1319BIN_TARGETS = $(BIN_TARGETS) $(DEST_DIR)\$(BASE_NAME)IfrBin.sec
1320
1321!ENDIF
1322
1323#
1324# Build an FFS file from the sections and package
1325#
1326$(TARGET_FFS_FILE) : $(TARGET_PE32) $(TARGET_DPX) $(TARGET_UI) $(TARGET_VER) $(PACKAGE_FILENAME)
1327  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V
1328
1329!IF "$(CREATEDEPS)"=="YES"
1330all : $(DEP_TARGETS)
1331  $(MAKE) -f $(MAKEFILE_NAME) all
1332!ELSE
1333all : $(LOCALIZE_TARGETS) $(BIN_TARGETS) $(TARGET_FFS_FILE) $(DEP_TARGETS)
1334!ENDIF
1335
1336#
1337# Remove the generated temp and final files for this modules.
1338#
1339clean :
1340!IF ("$(FILE_GUID)" != "")
1341  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
1342!ENDIF
1343  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*
1344  @del /q $(DEST_OUTPUT_DIRS)
1345
1346[=============================================================================]
1347#
1348# These are the commands to build vendor-provided *.EFI files into an FV.
1349# To use them, create an INF file with BUILD_TYPE=BS_DRIVER_EFI.
1350# This section, as it now exists, only supports boot service drivers.
1351#
1352[=============================================================================]
1353[Build.Ia32.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI|PE32_PEIM_EFI,Build.Ipf.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI|PE32_PEIM_EFI,Build.Ebc.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI,Build.x64.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI|PE32_PEIM_EFI]
1354#
1355# Defines for standard intermediate files and build targets. For the source
1356# .efi file, take the one in the source directory if it exists. If there's not
1357# one there, look for one in the processor-specfic subdirectory.
1358#
1359!IF EXIST ("$(SOURCE_DIR)\$(BASE_NAME).efi")
1360TARGET_EFI        = $(SOURCE_DIR)\$(BASE_NAME).efi
1361!ELSEIF EXIST ("$(SOURCE_DIR)\$(PROCESSOR)\$(BASE_NAME).efi")
1362TARGET_EFI        = $(SOURCE_DIR)\$(PROCESSOR)\$(BASE_NAME).efi
1363!ELSE
1364!ERROR Pre-existing $(BASE_NAME).efi file not found in $(SOURCE_DIR) nor $(SOURCE_DIR)\$(PROCESSOR)
1365!ENDIF
1366
1367TARGET_DPX        = $(DEST_DIR)\$(BASE_NAME).dpx
1368TARGET_UI         = $(DEST_DIR)\$(BASE_NAME).ui
1369TARGET_VER        = $(DEST_DIR)\$(BASE_NAME).ver
1370TARGET_MAP        = $(BIN_DIR)\$(BASE_NAME).map
1371TARGET_PDB        = $(BIN_DIR)\$(BASE_NAME).pdb
1372TARGET_PE32       = $(DEST_DIR)\$(BASE_NAME).pe32
1373TARGET_DLL        = $(BIN_DIR)\$(BASE_NAME).dll
1374
1375#
1376# If building an application, then the target is a .app, not .dxe
1377#
1378!IF "$(COMPONENT_TYPE)" == "APPLICATION"
1379TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).app
1380!ELSE IF "$(COMPONENT_TYPE)" == "PE32_PEIM"
1381TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei
1382!ELSE
1383TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).dxe
1384!ENDIF
1385
1386#
1387# Take the .efi file and make a .pe32 file
1388#
1389$(TARGET_PE32) : $(TARGET_EFI)
1390  $(GENSECTION) -I $(TARGET_EFI) -O $(TARGET_PE32) -S EFI_SECTION_PE32
1391
1392#
1393# Create the user interface section
1394#
1395$(TARGET_UI) : $(INF_FILENAME)
1396  $(GENSECTION) -O $(TARGET_UI) -S EFI_SECTION_USER_INTERFACE -A "$(BASE_NAME)"
1397
1398#
1399# Create the version section
1400#
1401!IF "$(BUILD_NUMBER)" != ""
1402!IF "$(VERSION_STRING)" != ""
1403$(TARGET_VER) : $(INF_FILENAME)
1404  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) -A "$(VERSION_STRING)"
1405!ELSE
1406$(TARGET_VER) : $(INF_FILENAME)
1407  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)
1408!ENDIF
1409!ELSE
1410$(TARGET_VER) : $(INF_FILENAME)
1411  echo. > $(TARGET_VER)
1412  type $(TARGET_VER) > $(TARGET_VER)
1413!ENDIF
1414
1415#
1416# Makefile entries to create the dependency expression section.
1417# Use the DPX file from the source directory unless an override file
1418# was specified.
1419# If no DPX source file was specified, then create an empty file to
1420# be used.
1421#
1422!IF "$(DPX_SOURCE)" != ""
1423DPX_SOURCE_FILE = $(SOURCE_DIR)\$(DPX_SOURCE)
1424!ENDIF
1425
1426!IF "$(DPX_SOURCE_OVERRIDE)" != ""
1427DPX_SOURCE_FILE = $(DPX_SOURCE_OVERRIDE)
1428!ENDIF
1429
1430!IF "$(DPX_SOURCE_FILE)" != ""
1431!IF EXIST ($(DPX_SOURCE_FILE))
1432
1433#
1434# Add build dependency check
1435#
1436DEP_FILE    = $(DEST_DIR)\$(BASE_NAME)dxs.dep
1437
1438!IF EXIST($(DEP_FILE))
1439!INCLUDE $(DEP_FILE)
1440!ENDIF
1441
1442!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
1443
1444!IF EXIST($(TARGET_DPX))
1445DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs.dep
1446!IF !EXIST($(DEP_FILE))
1447CREATEDEPS = YES
1448!ENDIF
1449!ENDIF
1450
1451#
1452# Update dep file for next round incremental build
1453#
1454$(DEP_FILE) : $(TARGET_DPX)
1455  $(MAKEDEPS) -f $(DPX_SOURCE_FILE) $(DEP_FLAGS)
1456
1457!ENDIF
1458
1459$(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
1460!IF "$(EFI_USE_CL_FOR_DEP)" != "YES"
1461  $(CC) $(C_FLAGS_DPX) $(DPX_SOURCE_FILE) > $*.tmp1
1462!ELSE
1463  -$(CC) $(C_FLAGS_DPX) $(DPX_SOURCE_FILE) /showIncludes > $*.tmp1 2> $(DEST_DIR)\$(BASE_NAME)dxs.cl
1464  @$(MAKEDEPS) -f $(DEST_DIR)\$(BASE_NAME)dxs.cl $(DEP_FLAGS2)
1465!ENDIF
1466  $(GENDEPEX) -I $*.tmp1 -O $*.tmp2
1467  $(GENSECTION) -I $*.tmp2 -O $@ -S $(DEPEX_TYPE)
1468  del $*.tmp1 > NUL
1469  del $*.tmp2 > NUL
1470!ELSE
1471!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.
1472!ENDIF
1473!ELSE
1474$(TARGET_DPX) : $(INF_FILENAME)
1475  echo. > $(TARGET_DPX)
1476  type $(TARGET_DPX) > $(TARGET_DPX)
1477!ENDIF
1478
1479#
1480# Build a FFS file from the sections and package
1481#
1482$(TARGET_FFS_FILE) : $(TARGET_PE32) $(TARGET_DPX) $(TARGET_UI) $(TARGET_VER) $(PACKAGE_FILENAME)
1483  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V
1484
1485all : $(TARGET_FFS_FILE)
1486
1487#
1488# Remove the generated temp and final files for this modules.
1489#
1490clean :
1491!IF ("$(FILE_GUID)" != "")
1492  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
1493!ENDIF
1494  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*
1495  @del /q $(DEST_OUTPUT_DIRS)
1496
1497[=============================================================================]
1498[Compile.Ia32.Bin|Bmp,Compile.x64.Bin|Bmp,Compile.Ipf.Bin|Bmp]
1499#
1500# We simply define the binary source file name
1501#
1502BINARY_SOURCE_FILE = $(SOURCE_FILE_NAME)
1503
1504[=============================================================================]
1505[Build.Ia32.BINARY|Legacy16|Logo,Build.Ipf.BINARY|Legacy16|Logo,Build.x64.BINARY|Legacy16|Logo]
1506#
1507# Use GenFfsFile to convert it to an FFS file
1508#
1509$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs : $(BINARY_SOURCE_FILE) $(PACKAGE_FILENAME) $(INF_FILENAME)
1510  $(GENSECTION) -I $(BINARY_SOURCE_FILE) -O $(DEST_DIR)\$(BASE_NAME).sec -S EFI_SECTION_RAW
1511  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V
1512
1513all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs
1514
1515#
1516# Remove the generated temp and final files for this modules.
1517#
1518clean :
1519!IF ("$(FILE_GUID)" != "")
1520  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
1521!ENDIF
1522  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*
1523  @del /q $(DEST_OUTPUT_DIRS)
1524
1525[=============================================================================]
1526[Build.Ia32.RAWFILE|CONFIG,Build.Ipf.RAWFILE|CONFIG,Build.x64.RAWFILE|CONFIG]
1527#
1528# Use GenFfsFile to convert it to an raw FFS file
1529#
1530$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw : $(BINARY_SOURCE_FILE) $(PACKAGE_FILENAME) $(INF_FILENAME)
1531  copy $(BINARY_SOURCE_FILE) $(DEST_DIR)\$(BASE_NAME).bin /Y
1532  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V
1533
1534all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw
1535
1536#
1537# Remove the generated temp and final files for this modules.
1538#
1539clean :
1540!IF ("$(FILE_GUID)" != "")
1541  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
1542!ENDIF
1543  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*
1544  @del /q $(DEST_OUTPUT_DIRS)
1545
1546[=============================================================================]
1547#
1548# These are commands to compile unicode .uni files.
1549#
1550[=============================================================================]
1551[Compile.Ia32.Uni,Compile.Ipf.Uni,Compile.Ebc.Uni,Compile.x64.Uni]
1552#
1553# Emit an error message if the file's base name is the same as the
1554# component base name. This causes build issues.
1555#
1556!IF "$(FILE)" == "$(BASE_NAME)"
1557!ERROR Component Unicode string file name cannot be the same as the component BASE_NAME.
1558!ENDIF
1559
1560#
1561# Always create dep file for uni file as it can be created at the same time when
1562# strgather is parsing uni file.
1563#
1564DEP_FILE    = $(DEST_DIR)\$(FILE)Uni.dep
1565
1566!IF EXIST($(DEP_FILE))
1567!INCLUDE $(DEP_FILE)
1568!ENDIF
1569
1570$(DEST_DIR)\$(FILE).sdb : $(SOURCE_FILE_NAME) $(INF_FILENAME)
1571  $(STRGATHER) -parse -newdb -db $(DEST_DIR)\$(FILE).sdb -dep $(DEP_FILE) $(INC) $(SOURCE_FILE_NAME)
1572
1573SDB_FILES       = $(SDB_FILES) $(DEST_DIR)\$(FILE).sdb
1574STRGATHER_FLAGS = $(STRGATHER_FLAGS) -db $(DEST_DIR)\$(FILE).sdb
1575LOCALIZE        = YES
1576
1577[=============================================================================]
1578[Compile.Ia32.hfr,Compile.Ipf.hfr,Compile.Ebc.hfr,Compile.x64.hfr]
1579[=============================================================================]
1580[Compile.Ia32.Vfr,Compile.Ipf.Vfr,Compile.x64.Vfr]
1581
1582#
1583# Add build dependency check
1584#
1585DEP_FILE    = $(DEST_DIR)\$(FILE)Vfr.dep
1586
1587!IF EXIST($(DEP_FILE))
1588!INCLUDE $(DEP_FILE)
1589!ENDIF
1590
1591!IF EXIST($(DEST_DIR)\$(FILE).obj)
1592DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Vfr.dep
1593!IF !EXIST($(DEP_FILE))
1594CREATEDEPS = YES
1595!ENDIF
1596!ENDIF
1597
1598#
1599# Update dep file for next round incremental build
1600#
1601$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj
1602  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)
1603
1604HII_PACK_FILES  = $(HII_PACK_FILES) $(DEST_DIR)\$(FILE).hpk
1605
1606#
1607# Add a dummy command for building the HII pack file. In reality, it's built
1608# below, but the C_FLAGS macro reference the target as $@, so you can't specify
1609# the obj and hpk files as dual targets of the same command.
1610#
1611$(DEST_DIR)\$(FILE).hpk : $(DEST_DIR)\$(FILE).obj
1612
1613$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)
1614  $(VFRCOMPILE) $(VFRCOMPILE_FLAGS) $(INC) -ibin -od $(DEST_DIR)\$(SOURCE_RELATIVE_PATH) \
1615    -l $(VFR_FLAGS) $(SOURCE_FILE_NAME)
1616  $(CC) $(C_FLAGS) $(DEST_DIR)\$(FILE).c
1617
1618[=============================================================================]
1619[Compile.Ebc.Vfr]
1620
1621DEP_FILE    = $(DEST_DIR)\$(FILE)Vfr.dep
1622
1623!IF EXIST($(DEST_DIR)\$(FILE).obj)
1624DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Vfr.dep
1625!IF !EXIST($(DEP_FILE))
1626CREATEDEPS = YES
1627!ENDIF
1628!ENDIF
1629
1630!IF EXIST($(DEP_FILE))
1631!INCLUDE $(DEP_FILE)
1632!ENDIF
1633
1634#
1635# Update dep file for next round incremental build
1636#
1637$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj
1638  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)
1639
1640HII_PACK_FILES  = $(HII_PACK_FILES) $(DEST_DIR)\$(FILE).hpk
1641
1642#
1643# Add a dummy command for building the HII pack file. In reality, it's built
1644# below, but the C_FLAGS macro reference the target as $@, so you can't specify
1645# the obj and hpk files as dual targets of the same command.
1646#
1647$(DEST_DIR)\$(FILE).hpk : $(DEST_DIR)\$(FILE).obj
1648
1649$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)
1650  $(VFRCOMPILE) $(VFRCOMPILE_FLAGS) $(INC) -ibin -od $(DEST_DIR)\$(SOURCE_RELATIVE_PATH) \
1651    -l $(VFR_FLAGS) $(SOURCE_FILE_NAME)
1652  $(EBC_CC) $(EBC_C_FLAGS) $(DEST_DIR)\$(FILE).c
1653
1654[=============================================================================]
1655#
1656# Commands for building IFR as uncompressed binary into the FFS file. To
1657# use it, set COMPILE_SELECT=.vfr=Ifr_Bin for the component in the DSC file.
1658#
1659[=============================================================================]
1660[Compile.Ia32.Ifr_Bin,Compile.Ipf.Ifr_Bin,Compile.x64.Ifr_Bin]
1661
1662#
1663# Add build dependency check
1664#
1665DEP_FILE    = $(DEST_DIR)\$(FILE)Vfr.dep
1666
1667!IF EXIST($(DEP_FILE))
1668!INCLUDE $(DEP_FILE)
1669!ENDIF
1670
1671!IF EXIST($(DEST_DIR)\$(FILE).obj)
1672DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Vfr.dep
1673!IF !EXIST($(DEP_FILE))
1674CREATEDEPS = YES
1675!ENDIF
1676!ENDIF
1677
1678#
1679# Update dep file for next round incremental build
1680#
1681$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj
1682  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)
1683
1684HII_PACK_FILES  = $(HII_PACK_FILES) $(DEST_DIR)\$(FILE).hpk
1685
1686#
1687# Add a dummy command for building the HII pack file. In reality, it's built
1688# below, but the C_FLAGS macro reference the target as $@, so you can't specify
1689# the obj and hpk files as dual targets of the same command.
1690#
1691$(DEST_DIR)\$(FILE).hpk : $(DEST_DIR)\$(FILE).obj
1692
1693$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)
1694  $(VFRCOMPILE) $(VFRCOMPILE_FLAGS) $(INC) -ibin -od $(DEST_DIR)\$(SOURCE_RELATIVE_PATH) \
1695    -l $(VFR_FLAGS) $(SOURCE_FILE_NAME)
1696  $(CC) $(C_FLAGS) $(DEST_DIR)\$(FILE).c
1697
1698#
1699# Add to the variable that contains the list of VFR binary files we're going
1700# to merge together at the end of the build.
1701#
1702HII_IFR_PACK_FILES = $(HII_IFR_PACK_FILES) $(DEST_DIR)\$(FILE).hpk
1703
1704[=============================================================================]
1705#
1706# Commands for building IFR as uncompressed binary into the FFS file. To
1707# use it, set COMPILE_SELECT=.vfr=Ifr_Bin for the component in the DSC file.
1708#
1709[=============================================================================]
1710[Compile.Ebc.Ifr_Bin]
1711
1712#
1713# Add build dependency check
1714#
1715DEP_FILE    = $(DEST_DIR)\$(FILE)Vfr.dep
1716
1717!IF EXIST($(DEP_FILE))
1718!INCLUDE $(DEP_FILE)
1719!ENDIF
1720
1721!IF EXIST($(DEST_DIR)\$(FILE).obj)
1722DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Vfr.dep
1723!IF !EXIST($(DEP_FILE))
1724CREATEDEPS = YES
1725!ENDIF
1726!ENDIF
1727
1728#
1729# Update dep file for next round incremental build
1730#
1731$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj
1732  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)
1733
1734HII_PACK_FILES  = $(HII_PACK_FILES) $(DEST_DIR)\$(FILE).hpk
1735
1736#
1737# Add a dummy command for building the HII pack file. In reality, it's built
1738# below, but the C_FLAGS macro reference the target as $@, so you can't specify
1739# the obj and hpk files as dual targets of the same command.
1740#
1741$(DEST_DIR)\$(FILE).hpk : $(DEST_DIR)\$(FILE).obj
1742
1743$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)
1744  $(VFRCOMPILE) $(VFRCOMPILE_FLAGS) $(INC) -ibin -od $(DEST_DIR)\$(SOURCE_RELATIVE_PATH) \
1745    -l $(VFR_FLAGS) $(SOURCE_FILE_NAME)
1746  $(EBC_CC) $(EBC_C_FLAGS) $(DEST_DIR)\$(FILE).c
1747
1748#
1749# Add to the variable that contains the list of VFR binary files we're going
1750# to merge together at the end of the build.
1751#
1752HII_IFR_PACK_FILES = $(HII_IFR_PACK_FILES) $(DEST_DIR)\$(FILE).hpk
1753
1754[=============================================================================]
1755[Compile.Ia32.Fv,Compile.Ipf.Fv,Compile.x64.Fv]
1756#
1757# Run GenSection on the firmware volume image.
1758#
1759$(DEST_DIR)\$(SOURCE_FV)Fv.sec : $(SOURCE_FILE_NAME) $(INF_FILENAME)
1760  $(GENSECTION) -I $(SOURCE_FILE_NAME) -O $(DEST_DIR)\$(SOURCE_FV)Fv.sec -S EFI_SECTION_FIRMWARE_VOLUME_IMAGE
1761
1762[=============================================================================]
1763