1#
2# Makefile.config
3#
4# Common configuration and setup file to generate the ACPICA tools and
5# utilities: the iASL compiler, acpiexec, acpihelp, acpinames, acpisrc,
6# acpixtract, acpibin.
7#
8# This file is included by the individual makefiles for each tool.
9#
10
11#
12# Note: This makefile is intended to be used from within the native
13# ACPICA directory structure, from under generate/unix. It specifically
14# places all object files in a generate/unix subdirectory, not within
15# the various ACPICA source directories. This prevents collisions
16# between different compilations of the same source file with different
17# compile options, and prevents pollution of the source code.
18#
19
20#
21# Configuration
22#
23# OPT_CFLAGS can be overridden on the make command line by
24#   adding OPT_CFLAGS="..." to the invocation.
25#
26# Notes:
27#   gcc should be version 4 or greater, otherwise some of the options
28#     used will not be recognized.
29#   Optional: Set ACPI_HOST to an appropriate value (_LINUX, _FreeBSD, _APPLE, _CYGWIN, etc.)
30#     See include/platform/acenv.h for supported values.
31#     Note: ACPI_HOST is not nearly as important for applications as it
32#     is for the kernel-resident version of ACPICA, and it may
33#     not be necessary to change it.
34#
35.SUFFIXES :
36PROGS = acpibin acpidump acpiexamples acpiexec acpihelp acpinames acpisrc acpixtract iasl
37ACPI_HOST ?= _CYGWIN
38CC ?=    gcc
39
40#
41# Common defines
42#
43OBJDIR =     obj
44BINDIR =     bin
45COMPILEOBJ = $(CC) -c $(CFLAGS) $(OPT_CFLAGS) -o $@ $<
46LINKPROG =   $(CC) $(OBJECTS) -o $(PROG) $(LDFLAGS) $(OPT_LDFLAGS)
47PREFIX ?=    /usr
48INSTALLDIR = $(PREFIX)/bin
49UNAME_S := $(shell uname -s)
50
51#
52# Host detection and configuration
53#
54ifeq ($(UNAME_S), Darwin)  # Mac OS X
55ACPI_HOST =       _APPLE
56endif
57
58ifeq ($(UNAME_S), DragonFly)
59ACPI_HOST =       _DragonFly
60endif
61
62ifeq ($(UNAME_S), FreeBSD)
63ACPI_HOST =       _FreeBSD
64endif
65
66ifeq ($(UNAME_S), NetBSD)
67ACPI_HOST =       _NetBSD
68endif
69
70ifeq ($(UNAME_S), QNX)
71ACPI_HOST =       _QNX
72endif
73
74ifeq ($(ACPI_HOST), _APPLE)
75INSTALL  =   cp
76INSTALLFLAGS ?= -f
77else
78INSTALL =    install
79INSTALLFLAGS ?= -m 555 -s
80endif
81
82INSTALLPROG = \
83	mkdir -p $(DESTDIR)$(INSTALLDIR); \
84	$(INSTALL) $(INSTALLFLAGS) ../$(BINDIR)/$(PROG) $(DESTDIR)$(INSTALLDIR)/$(PROG)
85
86#
87# Rename a .exe file if necessary
88#
89RENAMEPROG = \
90	@if [ -e "$(PROG).exe" ] ; then \
91		mv $(PROG).exe $(PROG); \
92		echo "- Rename $(PROG).exe to $(PROG)"; \
93	fi;
94
95#
96# Copy the final executable to the local bin directory
97#
98COPYPROG = \
99	@mkdir -p ../$(BINDIR); \
100	cp -f $(PROG) ../$(BINDIR); \
101	echo "- Copy $(PROG) to $(FINAL_PROG)";
102
103#
104# Main ACPICA source directories
105#
106ACPICA_SRC =            ../../../source
107ACPICA_COMMON =         $(ACPICA_SRC)/common
108ACPICA_TOOLS =          $(ACPICA_SRC)/tools
109ACPICA_OSL =            $(ACPICA_SRC)/os_specific/service_layers
110ACPICA_CORE =           $(ACPICA_SRC)/components
111ACPICA_INCLUDE =        $(ACPICA_SRC)/include
112ACPICA_DEBUGGER =       $(ACPICA_CORE)/debugger
113ACPICA_DISASSEMBLER =   $(ACPICA_CORE)/disassembler
114ACPICA_DISPATCHER =     $(ACPICA_CORE)/dispatcher
115ACPICA_EVENTS =         $(ACPICA_CORE)/events
116ACPICA_EXECUTER =       $(ACPICA_CORE)/executer
117ACPICA_HARDWARE =       $(ACPICA_CORE)/hardware
118ACPICA_NAMESPACE =      $(ACPICA_CORE)/namespace
119ACPICA_PARSER =         $(ACPICA_CORE)/parser
120ACPICA_RESOURCES =      $(ACPICA_CORE)/resources
121ACPICA_TABLES =         $(ACPICA_CORE)/tables
122ACPICA_UTILITIES =      $(ACPICA_CORE)/utilities
123
124#
125# ACPICA tool and utility source directories
126#
127ACPIBIN =               $(ACPICA_TOOLS)/acpibin
128ACPIDUMP =              $(ACPICA_TOOLS)/acpidump
129ACPIEXAMPLES =          $(ACPICA_TOOLS)/examples
130ACPIEXEC =              $(ACPICA_TOOLS)/acpiexec
131ACPIHELP =              $(ACPICA_TOOLS)/acpihelp
132ACPINAMES =             $(ACPICA_TOOLS)/acpinames
133ACPISRC =               $(ACPICA_TOOLS)/acpisrc
134ACPIXTRACT =            $(ACPICA_TOOLS)/acpixtract
135ASL_COMPILER =          $(ACPICA_SRC)/compiler
136
137#
138# Common ACPICA header files
139#
140ACPICA_HEADERS = \
141    $(wildcard $(ACPICA_INCLUDE)/*.h) \
142    $(wildcard $(ACPICA_INCLUDE)/platform/*.h)
143
144#
145# Common compiler flags
146# The _GNU_SOURCE symbol is required for many hosts.
147#
148OPT_CFLAGS ?= $(CWARNINGFLAGS)
149
150#
151# Debug flags
152#
153ifeq ($(DEBUG),TRUE)
154CFLAGS +=-g
155LDFLAGS +=-g
156endif
157
158#
159# Common compiler flags
160# The _GNU_SOURCE symbol is required for many hosts.
161#
162ifeq ($(M32),TRUE)
163CFLAGS +=-m32
164LDFLAGS +=-m32
165endif
166
167#
168# Optionally disable optimizations. Optimization causes problems on
169# some compilers such as gcc 4.4
170#
171ifneq ($(NOOPT),TRUE)
172OPT_CFLAGS += -O2
173else
174OPT_CFLAGS += -O0
175endif
176
177#
178# Optionally disable fortify source. This option can cause
179# compile errors in toolchains where it is already defined.
180#
181ifneq ($(NOFORTIFY),TRUE)
182OPT_CFLAGS += -D_FORTIFY_SOURCE=2
183endif
184
185CFLAGS += \
186    -D$(ACPI_HOST)\
187    -D_GNU_SOURCE\
188    -I$(ACPICA_INCLUDE)
189
190#
191# QNX requires __EXT to enable most functions in its C library, analogous
192# to _GNU_SOURCE.
193#
194ifeq ($(ACPI_HOST), _QNX)
195    CFLAGS+=-D__EXT
196endif
197
198#
199# Common compiler warning flags. The warning flags in addition
200# to -Wall are not automatically included in -Wall.
201#
202CWARNINGFLAGS = \
203    -std=c99\
204    -Wall\
205    -Wbad-function-cast\
206    -Wdeclaration-after-statement\
207    -Werror\
208    -Wformat=2\
209    -Wmissing-declarations\
210    -Wmissing-prototypes\
211    -Wstrict-aliasing=0\
212    -Wstrict-prototypes\
213    -Wswitch-default\
214    -Wpointer-arith\
215    -Wundef
216
217#
218# Common gcc 4+ warning flags
219#
220CWARNINGFLAGS += \
221    -Waddress\
222    -Waggregate-return\
223    -Winit-self\
224    -Winline\
225    -Wmissing-declarations\
226    -Wmissing-field-initializers\
227    -Wnested-externs\
228    -Wold-style-definition\
229    -Wno-format-nonliteral\
230    -Wredundant-decls
231#
232# Per-host flags and exclusions
233#
234ifneq ($(ACPI_HOST), _FreeBSD)
235    CWARNINGFLAGS += \
236        -Wempty-body
237
238    ifneq ($(ACPI_HOST), _APPLE)
239        CWARNINGFLAGS += \
240            -Woverride-init\
241            -Wlogical-op\
242            -Wmissing-parameter-type\
243            -Wold-style-declaration\
244            -Wtype-limits
245    endif
246endif
247
248#
249# Extra warning flags (for possible future use)
250#
251#CWARNINGFLAGS += \
252#	-Wcast-qual\
253#	-Wconversion\
254#	-Wshadow\
255
256#
257# M4 macro processor is used to build the final parser file
258#
259# Bison/Flex configuration
260#
261# -y: act like yacc
262#
263# -i: generate case insensitive scanner
264# -s: suppress default rule, abort on unknown input
265#
266# Optional for Bison/yacc:
267# -v: verbose, produces a .output file
268# -d: produces the defines header file
269#
270# Berkeley yacc configuration
271#
272#YACC=      byacc
273#YFLAGS +=
274#
275YACC=       bison
276YFLAGS +=   -y
277
278MACROPROC=  m4
279MFLAGS=     -P -I$(ASL_COMPILER)
280
281LEX=        flex
282LFLAGS +=   -i -s
283DLFLAGS +=   -i
284