xref: /netbsd-src/sys/external/bsd/acpica/dist/generate/unix/Makefile.config (revision c7960b37466ae0fd417c32e6acbb4b956ac7a121)
1#
2# Makefile.config
3#
4# Common configuration and setup file to generate the ACPICA tools and
5# utilities: the iASL compiler, acpiexec, acpihelp, acpisrc, acpixtract,
6# 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 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 ($(UNAME_S), Haiku)
75ACPI_HOST =       _HAIKU
76endif
77
78ifeq ($(ACPI_HOST), _APPLE)
79INSTALL  =   cp
80INSTALLFLAGS ?= -f
81else
82INSTALL =    install
83
84# Do not strip debug info when in debug mode
85ifeq ($(DEBUG),TRUE)
86INSTALLFLAGS ?= -m 555
87else
88INSTALLFLAGS ?= -m 555 -s
89endif
90
91endif
92
93INSTALLPROG = \
94	mkdir -p $(DESTDIR)$(INSTALLDIR); \
95	$(INSTALL) $(INSTALLFLAGS) ../$(BINDIR)/$(PROG) $(DESTDIR)$(INSTALLDIR)/$(PROG)
96
97#
98# Rename a .exe file if necessary
99#
100RENAMEPROG = \
101	@if [ -e "$(PROG).exe" ] ; then \
102		mv $(PROG).exe $(PROG); \
103		echo "- Rename $(PROG).exe to $(PROG)"; \
104	fi;
105
106#
107# Copy the final executable to the local bin directory
108#
109COPYPROG = \
110	@mkdir -p ../$(BINDIR); \
111	cp -f $(PROG) ../$(BINDIR); \
112	echo "- Copy $(PROG) to $(FINAL_PROG)";
113
114#
115# Main ACPICA source directories
116#
117ACPICA_SRC =            ../../../source
118ACPICA_COMMON =         $(ACPICA_SRC)/common
119ACPICA_TOOLS =          $(ACPICA_SRC)/tools
120ACPICA_OSL =            $(ACPICA_SRC)/os_specific/service_layers
121ACPICA_CORE =           $(ACPICA_SRC)/components
122ACPICA_INCLUDE =        $(ACPICA_SRC)/include
123ACPICA_DEBUGGER =       $(ACPICA_CORE)/debugger
124ACPICA_DISASSEMBLER =   $(ACPICA_CORE)/disassembler
125ACPICA_DISPATCHER =     $(ACPICA_CORE)/dispatcher
126ACPICA_EVENTS =         $(ACPICA_CORE)/events
127ACPICA_EXECUTER =       $(ACPICA_CORE)/executer
128ACPICA_HARDWARE =       $(ACPICA_CORE)/hardware
129ACPICA_NAMESPACE =      $(ACPICA_CORE)/namespace
130ACPICA_PARSER =         $(ACPICA_CORE)/parser
131ACPICA_RESOURCES =      $(ACPICA_CORE)/resources
132ACPICA_TABLES =         $(ACPICA_CORE)/tables
133ACPICA_UTILITIES =      $(ACPICA_CORE)/utilities
134
135#
136# ACPICA tool and utility source directories
137#
138ACPIBIN =               $(ACPICA_TOOLS)/acpibin
139ACPIDUMP =              $(ACPICA_TOOLS)/acpidump
140ACPIEXAMPLES =          $(ACPICA_TOOLS)/examples
141ACPIEXEC =              $(ACPICA_TOOLS)/acpiexec
142ACPIHELP =              $(ACPICA_TOOLS)/acpihelp
143ACPISRC =               $(ACPICA_TOOLS)/acpisrc
144ACPIXTRACT =            $(ACPICA_TOOLS)/acpixtract
145ASL_COMPILER =          $(ACPICA_SRC)/compiler
146
147#
148# Common ACPICA header files
149#
150ACPICA_HEADERS = \
151    $(wildcard $(ACPICA_INCLUDE)/*.h) \
152    $(wildcard $(ACPICA_INCLUDE)/platform/*.h)
153
154#
155# Common compiler flags
156# The _GNU_SOURCE symbol is required for many hosts.
157#
158OPT_CFLAGS ?= $(CWARNINGFLAGS)
159
160#
161# Debug flags
162#
163ifeq ($(DEBUG),TRUE)
164CFLAGS +=-g
165LDFLAGS +=-g
166endif
167
168#
169# Common compiler flags
170# The _GNU_SOURCE symbol is required for many hosts.
171#
172ifeq ($(M32),TRUE)
173CFLAGS +=-m32
174LDFLAGS +=-m32
175endif
176
177#
178# Optionally disable optimizations. Optimization causes problems on
179# some compilers such as gcc 4.4
180#
181ifneq ($(NOOPT),TRUE)
182OPT_CFLAGS += -O2
183else
184OPT_CFLAGS += -O0
185endif
186
187#
188# Optionally disable fortify source. This option can cause
189# compile errors in toolchains where it is already defined.
190#
191ifneq ($(NOFORTIFY),TRUE)
192OPT_CFLAGS += -D_FORTIFY_SOURCE=2
193endif
194
195CFLAGS += \
196    -D$(ACPI_HOST)\
197    -D_GNU_SOURCE\
198    -I$(ACPICA_INCLUDE)
199
200#
201# QNX requires __EXT to enable most functions in its C library, analogous
202# to _GNU_SOURCE.
203#
204ifeq ($(ACPI_HOST), _QNX)
205    CFLAGS+=-D__EXT
206endif
207
208#
209# Common compiler warning flags. The warning flags in addition
210# to -Wall are not automatically included in -Wall.
211#
212CWARNINGFLAGS = \
213    -std=c99\
214    -Wall\
215    -Wbad-function-cast\
216    -Wdeclaration-after-statement\
217    -Wformat=2\
218    -Wmissing-declarations\
219    -Wmissing-prototypes\
220    -Wstrict-aliasing=0\
221    -Wstrict-prototypes\
222    -Wswitch-default\
223    -Wpointer-arith\
224    -Wundef
225
226ifneq ($(NOWERROR),TRUE)
227CWARNINGFLAGS += -Werror
228endif
229
230#
231# Common gcc 4+ warning flags
232#
233CWARNINGFLAGS += \
234    -Waddress\
235    -Waggregate-return\
236    -Winit-self\
237    -Winline\
238    -Wmissing-declarations\
239    -Wmissing-field-initializers\
240    -Wnested-externs\
241    -Wold-style-definition\
242    -Wno-format-nonliteral\
243    -Wredundant-decls
244#
245# Per-host flags and exclusions
246#
247ifneq ($(ACPI_HOST), _FreeBSD)
248    CWARNINGFLAGS += \
249        -Wempty-body
250
251    ifneq ($(ACPI_HOST), _APPLE)
252        CWARNINGFLAGS += \
253            -Woverride-init\
254            -Wlogical-op\
255            -Wmissing-parameter-type\
256            -Wold-style-declaration\
257            -Wtype-limits
258    endif
259endif
260
261#
262# Extra warning flags (for possible future use)
263#
264#CWARNINGFLAGS += \
265#	-Wcast-qual\
266#	-Wconversion\
267#	-Wshadow\
268
269#
270# M4 macro processor is used to build the final parser file
271#
272# Bison/Flex configuration
273#
274# -y: act like yacc
275#
276# -i: generate case insensitive scanner
277# -s: suppress default rule, abort on unknown input
278#
279# Optional for Bison/yacc:
280# -v: verbose, produces a .output file
281# -d: produces the defines header file
282#
283# Berkeley yacc configuration
284#
285#YACC=      byacc
286#YFLAGS +=
287#
288YACC=       bison
289YFLAGS +=   -y
290
291MACROPROC=  m4
292MFLAGS=     -P -I$(ASL_COMPILER)
293
294LEX=        flex
295LFLAGS +=   -i -s
296DLFLAGS +=   -i
297