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 HOST to an appropriate value (_LINUX, _FreeBSD, _APPLE, _CYGWIN, etc.)
30#     See include/platform/acenv.h for supported values.
31#     Note: 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
37HOST ?= _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)
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
55HOST =       _APPLE
56endif
57
58ifeq ($(UNAME_S), DragonFly)
59HOST =       _DragonFly
60endif
61
62ifeq ($(UNAME_S), FreeBSD)
63HOST =       _FreeBSD
64endif
65
66ifeq ($(UNAME_S), NetBSD)
67HOST =       _NetBSD
68endif
69
70ifeq ($(HOST), _APPLE)
71INSTALL  =   cp
72INSTALLFLAGS ?= -f
73else
74INSTALL =    install
75INSTALLFLAGS ?= -m 555 -s
76endif
77
78INSTALLPROG = \
79	mkdir -p $(DESTDIR)$(INSTALLDIR); \
80	$(INSTALL) $(INSTALLFLAGS) ../$(BINDIR)/$(PROG) $(DESTDIR)$(INSTALLDIR)/$(PROG)
81
82#
83# Rename a .exe file if necessary
84#
85RENAMEPROG = \
86	@if [ -e "$(PROG).exe" ] ; then \
87		mv $(PROG).exe $(PROG); \
88		echo "Renamed $(PROG).exe to $(PROG)"; \
89	fi;
90
91#
92# Copy the final executable to the local bin directory
93#
94COPYPROG = \
95	@mkdir -p ../$(BINDIR); \
96	cp -f $(PROG) ../$(BINDIR); \
97	echo "Copied $(PROG) to $(FINAL_PROG)";
98
99#
100# Main ACPICA source directories
101#
102ACPICA_SRC =            ../../../source
103ACPICA_COMMON =         $(ACPICA_SRC)/common
104ACPICA_TOOLS =          $(ACPICA_SRC)/tools
105ACPICA_OSL =            $(ACPICA_SRC)/os_specific/service_layers
106ACPICA_CORE =           $(ACPICA_SRC)/components
107ACPICA_INCLUDE =        $(ACPICA_SRC)/include
108ACPICA_DEBUGGER =       $(ACPICA_CORE)/debugger
109ACPICA_DISASSEMBLER =   $(ACPICA_CORE)/disassembler
110ACPICA_DISPATCHER =     $(ACPICA_CORE)/dispatcher
111ACPICA_EVENTS =         $(ACPICA_CORE)/events
112ACPICA_EXECUTER =       $(ACPICA_CORE)/executer
113ACPICA_HARDWARE =       $(ACPICA_CORE)/hardware
114ACPICA_NAMESPACE =      $(ACPICA_CORE)/namespace
115ACPICA_PARSER =         $(ACPICA_CORE)/parser
116ACPICA_RESOURCES =      $(ACPICA_CORE)/resources
117ACPICA_TABLES =         $(ACPICA_CORE)/tables
118ACPICA_UTILITIES =      $(ACPICA_CORE)/utilities
119
120#
121# ACPICA tool and utility source directories
122#
123ACPIBIN =               $(ACPICA_TOOLS)/acpibin
124ACPIDUMP =              $(ACPICA_TOOLS)/acpidump
125ACPIEXAMPLES =          $(ACPICA_TOOLS)/examples
126ACPIEXEC =              $(ACPICA_TOOLS)/acpiexec
127ACPIHELP =              $(ACPICA_TOOLS)/acpihelp
128ACPINAMES =             $(ACPICA_TOOLS)/acpinames
129ACPISRC =               $(ACPICA_TOOLS)/acpisrc
130ACPIXTRACT =            $(ACPICA_TOOLS)/acpixtract
131ASL_COMPILER =          $(ACPICA_SRC)/compiler
132
133#
134# Common ACPICA header files
135#
136ACPICA_HEADERS = \
137    $(wildcard $(ACPICA_INCLUDE)/*.h) \
138    $(wildcard $(ACPICA_INCLUDE)/platform/*.h)
139
140#
141# Common compiler flags
142# The _GNU_SOURCE symbol is required for many hosts.
143#
144OPT_CFLAGS ?= $(CWARNINGFLAGS)
145
146#
147# Optionally disable optimizations. Optimization causes problems on
148# some compilers such as gcc 4.4
149#
150ifneq ($(NOOPT),TRUE)
151OPT_CFLAGS += -O2
152endif
153
154#
155# Optionally disable fortify source. This option can cause
156# compile errors in toolchains where it is already defined.
157#
158ifneq ($(NOFORTIFY),TRUE)
159OPT_CFLAGS += -D_FORTIFY_SOURCE=2
160endif
161
162CFLAGS += \
163    -D$(HOST)\
164    -D_GNU_SOURCE\
165    -I$(ACPICA_INCLUDE)
166
167#
168# Common compiler warning flags. The warning flags in addition
169# to -Wall are not automatically included in -Wall.
170#
171CWARNINGFLAGS = \
172    -std=c99\
173    -Wall\
174    -Wbad-function-cast\
175    -Wdeclaration-after-statement\
176    -Werror\
177    -Wformat=2\
178    -Wmissing-declarations\
179    -Wmissing-prototypes\
180    -Wstrict-aliasing=0\
181    -Wstrict-prototypes\
182    -Wswitch-default\
183    -Wpointer-arith\
184    -Wundef
185
186#
187# Common gcc 4+ warning flags
188#
189CWARNINGFLAGS += \
190    -Waddress\
191    -Waggregate-return\
192    -Winit-self\
193    -Winline\
194    -Wmissing-declarations\
195    -Wmissing-field-initializers\
196    -Wnested-externs\
197    -Wold-style-definition\
198    -Woverride-init\
199    -Wno-format-nonliteral\
200    -Wredundant-decls
201#
202# Per-host flags and exclusions
203#
204ifneq ($(HOST), _FreeBSD)
205    CWARNINGFLAGS += \
206        -Wempty-body
207
208    ifneq ($(HOST), _APPLE)
209        CWARNINGFLAGS += \
210        -Wlogical-op\
211        -Wmissing-parameter-type\
212        -Wold-style-declaration\
213        -Wtype-limits
214    endif
215endif
216
217#
218# Extra warning flags (for possible future use)
219#
220#CWARNINGFLAGS += \
221#	-Wcast-qual\
222#	-Wconversion\
223#	-Wshadow\
224
225#
226# M4 macro processor is used to build the final parser file
227#
228# Bison/Flex configuration
229#
230# -y: act like yacc
231#
232# -i: generate case insensitive scanner
233# -s: suppress default rule, abort on unknown input
234#
235# Optional for Bison/yacc:
236# -v: verbose, produces a .output file
237# -d: produces the defines header file
238#
239# Berkeley yacc configuration
240#
241#YACC=      byacc
242#YFLAGS +=
243#
244YACC=       bison
245YFLAGS +=   -y
246
247MACROPROC=  m4
248MFLAGS=     -P -I$(ASL_COMPILER)
249
250LEX=        flex
251LFLAGS +=   -i -s
252