1
2# Makefile.config
3#
4# Common configuration and setup file to generate the ACPICA tools and
5# utilities: the acpidump.
6#
7# This file is included by the individual makefiles for each tool.
8#
9
10#
11# Note: This makefile is intended to be used from within the native
12# ACPICA directory structure, from under generate/efi. It specifically
13# places all object files in a generate/efi subdirectory, not within
14# the various ACPICA source directories. This prevents collisions
15# between different compilations of the same source file with different
16# compile options, and prevents pollution of the source code.
17#
18
19#
20# Configuration
21#
22# TARGET     Build target platform can be overridden on the make command
23#            line by adding the following to the invocation:
24#            TARGET="..."
25#            Possible target (ia32, x86_64, etc.) can be used to initiate
26#            a possible cross build.
27# OPT_CFLAGS Optimization CFLAGS can be overridden on the make command
28#            line by adding the following to the invocation:
29#            OPT_CFLAGS="..."
30#
31# Notes:
32#   gcc should be version 4 or greater, otherwise some of the options
33#     used will not be recognized.
34#
35
36.SUFFIXES :
37
38#
39# Common defines
40#
41PROGS =  acpidump efihello
42ACPI_HOST =   $(shell uname -m | sed s,i[3456789]86,ia32,)
43TARGET = $(shell uname -m | sed s,i[3456789]86,ia32,)
44OBJDIR = obj
45BINDIR = bin
46
47#
48# Main ACPICA source directories
49#
50ACPICA_SRC =            ../../../source
51ACPICA_COMMON =         $(ACPICA_SRC)/common
52ACPICA_TOOLS =          $(ACPICA_SRC)/tools
53ACPICA_OSL =            $(ACPICA_SRC)/os_specific/service_layers
54ACPICA_EFI =            $(ACPICA_SRC)/os_specific/efi
55ACPICA_CORE =           $(ACPICA_SRC)/components
56ACPICA_INCLUDE =        $(ACPICA_SRC)/include
57ACPICA_DEBUGGER =       $(ACPICA_CORE)/debugger
58ACPICA_DISASSEMBLER =   $(ACPICA_CORE)/disassembler
59ACPICA_DISPATCHER =     $(ACPICA_CORE)/dispatcher
60ACPICA_EVENTS =         $(ACPICA_CORE)/events
61ACPICA_EXECUTER =       $(ACPICA_CORE)/executer
62ACPICA_HARDWARE =       $(ACPICA_CORE)/hardware
63ACPICA_NAMESPACE =      $(ACPICA_CORE)/namespace
64ACPICA_PARSER =         $(ACPICA_CORE)/parser
65ACPICA_RESOURCES =      $(ACPICA_CORE)/resources
66ACPICA_TABLES =         $(ACPICA_CORE)/tables
67ACPICA_UTILITIES =      $(ACPICA_CORE)/utilities
68
69#
70# ACPICA tool and utility source directories
71#
72ACPIDUMP =              $(ACPICA_TOOLS)/acpidump
73EFIHELLO =              $(ACPICA_TOOLS)/efihello
74
75#
76# Common ACPICA header files
77#
78ACPICA_HEADERS = \
79	$(wildcard $(ACPICA_INCLUDE)/*.h) \
80	$(wildcard $(ACPICA_INCLUDE)/platform/*.h)
81
82#
83# GCC configuration
84#
85CC =        gcc
86LD =        ld
87OBJCOPY =   objcopy
88
89CFLAGS  = \
90	--save-temps\
91	-nostdinc\
92	-nostdlib\
93	-std=c99\
94	-U__linux__\
95	-U_LINUX\
96	-D_GNU_EFI\
97	-D_GNU_SOURCE\
98	-fno-builtin\
99	-iwithprefix include\
100	-fno-stack-protector\
101	-fno-strict-aliasing\
102	-fpic\
103	-fshort-wchar\
104	-I$(ACPICA_INCLUDE)
105LDFLAGS	= \
106	-nostdinc\
107	-nostdlib\
108	-znocombreloc\
109	-Bsymbolic\
110	-shared\
111	-no-undefined
112OBJCOPYFLAGS = \
113	-j .text\
114	-j .sdata\
115	-j .data\
116	-j .dynamic\
117	-j .dynsym\
118	-j .rel\
119	-j .rela\
120	-j .reloc\
121	--target=efi-app-$(TARGET)
122
123#
124# Common compiler flags
125# The _GNU_SOURCE symbol is required for many hosts.
126#
127OPT_CFLAGS ?= $(CWARNINGFLAGS)
128
129#
130# Optionally disable optimizations. Optimization causes problems on
131# some compilers such as gcc 4.4
132#
133ifneq ($(NOOPT),TRUE)
134OPT_CFLAGS += -O2
135endif
136
137#
138# Optionally disable fortify source. This option can cause
139# compile errors in toolchains where it is already defined.
140#
141ifneq ($(NOFORTIFY),TRUE)
142OPT_CFLAGS += -D_FORTIFY_SOURCE=2
143endif
144
145
146# Common compiler warning flags. The warning flags in addition
147# to -Wall are not automatically included in -Wall.
148#
149CWARNINGFLAGS = \
150	-Wall\
151	-Wbad-function-cast\
152	-Wdeclaration-after-statement\
153	-Wformat=2\
154	-Wmissing-declarations\
155	-Wmissing-prototypes\
156	-Wstrict-aliasing=0\
157	-Wswitch-default\
158	-Wpointer-arith\
159	-Wempty-body\
160	-Wlogical-op\
161	-Wmissing-parameter-type\
162	-Wold-style-declaration\
163	-Wtype-limits
164
165ifneq ($(NOWERROR),TRUE)
166CWARNINGFLAGS += -Werror
167endif
168
169#
170# Extra warning flags (for possible future use)
171#
172#CWARNINGFLAGS += \
173#	-Wcast-qual\
174#	-Wconversion\
175#	-Wshadow\
176#	-Wstrict-prototypes\
177#	-Wundef\
178
179CFLAGS += $(OPT_CFLAGS)
180
181#
182# EFI environment definitions
183#
184EFIINC =    /usr/include/efi
185
186ifeq ($(TARGET),ia32)
187
188CFLAGS +=   -DACPI_MACHINE_WIDTH=32
189ifeq ($(ACPI_HOST),x86_64)
190EFILIB =    /usr/lib32
191CFLAGS +=   -m32
192LDFLAGS	+=  -melf_i386
193else # ACPI_HOST eq ia32
194EFILIB =    /usr/lib
195endif
196
197else # TARGET eq x86_64
198
199CFLAGS += \
200	-DEFI_FUNCTION_WRAPPER\
201	-DACPI_MACHINE_WIDTH=64
202ifeq ($(ACPI_HOST),ia32)
203EFILIB =    /usr/lib64
204CFLAGS +=   -m64
205LDFLAGS	+=  -melf_x86_64
206else # ACPI_HOST eq x86_64
207EFILIB =    /usr/lib
208endif
209
210endif
211
212CFLAGS += \
213	-I$(EFIINC)\
214	-I$(EFIINC)/$(TARGET)\
215	-I$(EFIINC)/protocol
216LDFLAGS	+= \
217	-T $(EFILIB)/elf_$(TARGET)_efi.lds\
218	-L$(EFILIB)\
219	$(EFILIB)/crt0-efi-$(TARGET).o
220LIBS = \
221	-lefi\
222	-lgnuefi\
223	$(shell $(CC) -print-libgcc-file-name)
224
225#
226# Bison/Flex configuration
227#
228# -y: act like yacc
229#
230# -i: generate case insensitive scanner
231# -s: suppress default rule, abort on unknown input
232#
233# Optional for Bison/yacc:
234# -v: verbose, produces a .output file
235# -d: produces the defines header file
236#
237YACC=       bison
238YFLAGS +=   -y
239
240LEX=        flex
241LFLAGS +=   -i -s
242
243#
244# Command definitions
245#
246COMPILEOBJ =    $(CC) -c $(CFLAGS) -o $@ $<
247LINKPROG =      $(LD) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBS)
248OBJCOPYPROG =   $(OBJCOPY) $(OBJCOPYFLAGS) $< $@
249COPYPROG = \
250	@mkdir -p ../$(BINDIR); \
251	cp -f $< ../$(BINDIR); \
252	echo "Copied $< to $@";
253