1## @file
2#  GNU/Linux makefile for C tools build.
3#
4#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
5#
6#  SPDX-License-Identifier: BSD-2-Clause-Patent
7#
8
9ifndef HOST_ARCH
10  #
11  # If HOST_ARCH is not defined, then we use 'uname -m' to attempt
12  # try to figure out the appropriate HOST_ARCH.
13  #
14  uname_m = $(shell uname -m)
15  $(info Attempting to detect HOST_ARCH from 'uname -m': $(uname_m))
16  ifneq (,$(strip $(filter $(uname_m), x86_64 amd64)))
17    HOST_ARCH=X64
18  endif
19  ifeq ($(patsubst i%86,IA32,$(uname_m)),IA32)
20    HOST_ARCH=IA32
21  endif
22  ifneq (,$(findstring aarch64,$(uname_m)))
23    HOST_ARCH=AARCH64
24  else ifneq (,$(findstring arm64,$(uname_m)))
25    HOST_ARCH=AARCH64
26  else ifneq (,$(findstring arm,$(uname_m)))
27    HOST_ARCH=ARM
28  endif
29  ifneq (,$(findstring riscv64,$(uname_m)))
30    HOST_ARCH=RISCV64
31  endif
32  ifndef HOST_ARCH
33    $(info Could not detected HOST_ARCH from uname results)
34    $(error HOST_ARCH is not defined!)
35  endif
36  $(info Detected HOST_ARCH of $(HOST_ARCH) using uname.)
37endif
38
39export HOST_ARCH
40
41MAKEROOT = .
42
43include Makefiles/header.makefile
44
45all: makerootdir subdirs
46	@echo Finished building BaseTools C Tools with HOST_ARCH=$(HOST_ARCH)
47
48LIBRARIES = Common
49VFRAUTOGEN = VfrCompile/VfrLexer.h
50APPLICATIONS = \
51  BrotliCompress \
52  VfrCompile \
53  EfiRom \
54  GenFfs \
55  GenFv \
56  GenFw \
57  GenSec \
58  GenCrc32 \
59  LzmaCompress \
60  TianoCompress \
61  VolInfo \
62  DevicePath
63
64SUBDIRS := $(LIBRARIES) $(APPLICATIONS)
65
66$(LIBRARIES): $(MAKEROOT)/libs
67$(APPLICATIONS): $(LIBRARIES) $(MAKEROOT)/bin $(VFRAUTOGEN)
68
69.PHONY: outputdirs
70makerootdir:
71	-mkdir -p $(MAKEROOT)
72
73.PHONY: subdirs $(SUBDIRS)
74subdirs: $(SUBDIRS)
75$(SUBDIRS):
76	$(MAKE) -C $@
77
78.PHONY: $(patsubst %,%-clean,$(sort $(SUBDIRS)))
79$(patsubst %,%-clean,$(sort $(SUBDIRS))):
80	-$(MAKE) -C $(@:-clean=) clean
81
82$(VFRAUTOGEN): VfrCompile/VfrSyntax.g
83	$(MAKE) -C VfrCompile VfrLexer.h
84
85clean:  $(patsubst %,%-clean,$(sort $(SUBDIRS)))
86
87clean: localClean
88
89localClean:
90	rm -f $(MAKEROOT)/bin/*
91	-rmdir $(MAKEROOT)/libs $(MAKEROOT)/bin
92
93include Makefiles/footer.makefile
94