summaryrefslogtreecommitdiff
path: root/generate/efi/Makefile.config
blob: 1f3aa74d49d56545fe23e0585c81bc4f8015dbc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260

# Makefile.config
#
# Common configuration and setup file to generate the ACPICA tools and
# utilities: the acpidump.
#
# This file is included by the individual makefiles for each tool.
#

#
# Note: This makefile is intended to be used from within the native
# ACPICA directory structure, from under generate/efi. It specifically
# places all object files in a generate/efi subdirectory, not within
# the various ACPICA source directories. This prevents collisions
# between different compilations of the same source file with different
# compile options, and prevents pollution of the source code.
#

#
# Configuration
#
# TARGET     Build target platform can be overridden on the make command
#            line by adding the followings to the invocation:
#            TARGET="..."
#            Possible target (ia32, x86_64, etc.) can be used to initiate
#            a possible cross build.
# OPT_CFLAGS Optimization CFLAGS can be overridden on the make command
#            line by adding the followings to the invocation:
#            OPT_CFLAGS="..."
# SHARED     Testing build to check if symbols are not implemented.
#            GCC won't complain missing of symbols as our programs are
#            compiled with -shared. This can be overridden on the make
#            command line by adding the followings to the invocation:
#            SHARED=false
#            Link failures should only be seen for the _start and
#            DivU64x32.  They are the only 2 GNU EFI functions we are
#            using in order not to introduce architecture specific code
#            into ACPICA.
#
# Notes:
#   gcc should be version 4 or greater, otherwise some of the options
#     used will not be recognized.
#

.SUFFIXES :

#
# Common defines
#
PROGS =  acpidump acpiexec
HOST =   $(shell uname -m | sed s,i[3456789]86,ia32,)
TARGET = $(shell uname -m | sed s,i[3456789]86,ia32,)
SHARED ?= true
OBJDIR = obj
BINDIR = bin

#
# Main ACPICA source directories
#
ACPICA_SRC =            ../../../source
ACPICA_COMMON =         $(ACPICA_SRC)/common
ACPICA_TOOLS =          $(ACPICA_SRC)/tools
ACPICA_OSL =            $(ACPICA_SRC)/os_specific/service_layers
ACPICA_CORE =           $(ACPICA_SRC)/components
ACPICA_INCLUDE =        $(ACPICA_SRC)/include
ACPICA_DEBUGGER =       $(ACPICA_CORE)/debugger
ACPICA_DISASSEMBLER =   $(ACPICA_CORE)/disassembler
ACPICA_DISPATCHER =     $(ACPICA_CORE)/dispatcher
ACPICA_EVENTS =         $(ACPICA_CORE)/events
ACPICA_EXECUTER =       $(ACPICA_CORE)/executer
ACPICA_HARDWARE =       $(ACPICA_CORE)/hardware
ACPICA_NAMESPACE =      $(ACPICA_CORE)/namespace
ACPICA_PARSER =         $(ACPICA_CORE)/parser
ACPICA_RESOURCES =      $(ACPICA_CORE)/resources
ACPICA_TABLES =         $(ACPICA_CORE)/tables
ACPICA_UTILITIES =      $(ACPICA_CORE)/utilities

#
# ACPICA tool and utility source directories
#
ACPIDUMP =              $(ACPICA_TOOLS)/acpidump
ACPIEXEC =              $(ACPICA_TOOLS)/acpiexec

#
# Common ACPICA header files
#
ACPICA_HEADERS = \
	$(wildcard $(ACPICA_INCLUDE)/*.h) \
	$(wildcard $(ACPICA_INCLUDE)/platform/*.h)

#
# GCC configuration
#
CC =        gcc
LD =        ld
OBJCOPY =   objcopy

CFLAGS  = \
	--save-temps\
	-nostdinc\
	-nostdlib\
	-std=c99\
	-U__linux__\
	-U_LINUX\
	-D_GNU_EFI\
	-D_GNU_SOURCE\
	-fno-builtin\
	-iwithprefix include\
	-fno-stack-protector\
	-fno-strict-aliasing\
	-fpic\
	-fshort-wchar\
	-I$(ACPICA_INCLUDE)
LDFLAGS	= \
	-nostdinc\
	-nostdlib\
	-znocombreloc\
	-Bsymbolic
ifeq ($(strip $(SHARED)), true)
LDFLAGS	+= \
	-shared
endif
LIBS    = \
	$(shell $(CC) -print-libgcc-file-name)
OBJCOPYFLAGS = \
	-j .text\
	-j .sdata\
	-j .data\
	-j .dynamic\
	-j .dynsym\
	-j .rel\
	-j .rela\
	-j .reloc\
	--target=efi-app-$(TARGET)

#
# Common compiler flags
# The _GNU_SOURCE symbol is required for many hosts.
#
OPT_CFLAGS ?= $(CWARNINGFLAGS)

#
# Optionally disable optimizations. Optimization causes problems on
# some compilers such as gcc 4.4
#
ifneq ($(NOOPT),TRUE)
OPT_CFLAGS += -O2
endif

#
# Optionally disable fortify source. This option can cause
# compile errors in toolchains where it is already defined.
#
ifneq ($(NOFORTIFY),TRUE)
OPT_CFLAGS += -D_FORTIFY_SOURCE=2
endif


# Common compiler warning flags. The warning flags in addition
# to -Wall are not automatically included in -Wall.
#
CWARNINGFLAGS = \
	-Wall\
	-Wbad-function-cast\
	-Wdeclaration-after-statement\
	-Werror\
	-Wformat=2\
	-Wmissing-declarations\
	-Wmissing-prototypes\
	-Wstrict-aliasing=0\
	-Wswitch-default\
	-Wpointer-arith\
	-Wempty-body\
	-Wlogical-op\
	-Wmissing-parameter-type\
	-Wold-style-declaration\
	-Wtype-limits
#
# Extra warning flags (for possible future use)
#
#CWARNINGFLAGS += \
#	-Wcast-qual\
#	-Wconversion\
#	-Wshadow\
#	-Wstrict-prototypes\
#	-Wundef\

CFLAGS += $(OPT_CFLAGS)

#
# EFI environment definitions
#
EFIINC =    /usr/include/efi

ifeq ($(TARGET),ia32)

CFLAGS +=   -DACPI_MACHINE_WIDTH=32
ifeq ($(HOST),x86_64)
EFILIB =    /usr/lib32
CFLAGS +=   -m32
LDFLAGS	+=  -melf_i386
else # HOST eq ia32
EFILIB =    /usr/lib
endif

else # TARGET eq x86_64

CFLAGS += \
	-DEFI_FUNCTION_WRAPPER\
	-DACPI_MACHINE_WIDTH=64
ifeq ($(HOST),ia32)
EFILIB =    /usr/lib64
CFLAGS +=   -m64
LDFLAGS	+=  -melf_x86_64
else # HOST eq x86_64
EFILIB =    /usr/lib
endif

endif

CFLAGS += \
	-I$(EFIINC)\
	-I$(EFIINC)/$(TARGET)\
	-I$(EFIINC)/protocol
LDFLAGS	+= \
	-T $(EFILIB)/elf_$(TARGET)_efi.lds\
	-L$(EFILIB)\
	$(EFILIB)/crt0-efi-$(TARGET).o
LIBS += \
	-lefi\
	-lgnuefi\

#
# Bison/Flex configuration
#
# -y: act like yacc
#
# -i: generate case insensitive scanner
# -s: suppress default rule, abort on unknown input
#
# Optional for Bison/yacc:
# -v: verbose, produces a .output file
# -d: produces the defines header file
#
YACC=       bison
YFLAGS +=   -y

LEX=        flex
LFLAGS +=   -i -s

#
# Command definitions
#
COMPILEOBJ =    $(CC) -c $(CFLAGS) -o $@ $<
LINKPROG =      $(LD) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBS)
OBJCOPYPROG =   $(OBJCOPY) $(OBJCOPYFLAGS) $< $@
COPYPROG = \
	@mkdir -p ../$(BINDIR); \
	cp -f $< ../$(BINDIR); \
	echo "Copied $< to $@";