blob: e5a3c4be2a10d696c31aebc733234964197affad [file] [log] [blame]
Lv Zhengf677b302014-01-15 12:04:09 +08001# tools/power/acpi/Makefile - ACPI tool Makefile
2#
3# Copyright (c) 2013, Intel Corporation
4# Author: Lv Zheng <lv.zheng@intel.com>
5#
6# This program is free software; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License
8# as published by the Free Software Foundation; version 2
9# of the License.
10
11OUTPUT=./
12ifeq ("$(origin O)", "command line")
13 OUTPUT := $(O)/
14endif
15
16ifneq ($(OUTPUT),)
17# check that the output directory actually exists
18OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd)
19$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
20endif
21
Thomas Renningerd7cddbb2014-04-07 15:16:57 +020022SUBDIRS = tools/ec
23
Lv Zhengf677b302014-01-15 12:04:09 +080024# --- CONFIGURATION BEGIN ---
25
26# Set the following to `true' to make a unstripped, unoptimized
27# binary. Leave this set to `false' for production use.
28DEBUG ?= true
29
30# make the build silent. Set this to something else to make it noisy again.
31V ?= false
32
33# Prefix to the directories we're installing to
34DESTDIR ?=
35
36# --- CONFIGURATION END ---
37
38# Directory definitions. These are default and most probably
39# do not need to be changed. Please note that DESTDIR is
40# added in front of any of them
41
42bindir ?= /usr/bin
43sbindir ?= /usr/sbin
44mandir ?= /usr/man
45
46# Toolchain: what tools do we use, and what options do they need:
47
48INSTALL = /usr/bin/install -c
49INSTALL_PROGRAM = ${INSTALL}
50INSTALL_DATA = ${INSTALL} -m 644
51INSTALL_SCRIPT = ${INSTALL_PROGRAM}
52
53# If you are running a cross compiler, you may want to set this
54# to something more interesting, like "arm-linux-". If you want
55# to compile vs uClibc, that can be done here as well.
56CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
57CC = $(CROSS)gcc
58LD = $(CROSS)gcc
59STRIP = $(CROSS)strip
60HOSTCC = gcc
61
62# check if compiler option is supported
63cc-supports = ${shell if $(CC) ${1} -S -o /dev/null -x c /dev/null > /dev/null 2>&1; then echo "$(1)"; fi;}
64
65# use '-Os' optimization if available, else use -O2
66OPTIMIZATION := $(call cc-supports,-Os,-O2)
67
68WARNINGS := -Wall
69WARNINGS += $(call cc-supports,-Wstrict-prototypes)
70WARNINGS += $(call cc-supports,-Wdeclaration-after-statement)
71
Len Brown0efea7b2012-09-22 22:33:19 -040072KERNEL_INCLUDE := ../../../include
Lv Zhengedbe47c2014-04-04 12:39:56 +080073ACPICA_INCLUDE := ../../../drivers/acpi/acpica
74CFLAGS += -D_LINUX -I$(KERNEL_INCLUDE) -I$(ACPICA_INCLUDE)
Lv Zhengf677b302014-01-15 12:04:09 +080075CFLAGS += $(WARNINGS)
Len Brown0efea7b2012-09-22 22:33:19 -040076
Lv Zhengf677b302014-01-15 12:04:09 +080077ifeq ($(strip $(V)),false)
78 QUIET=@
79 ECHO=@echo
80else
81 QUIET=
82 ECHO=@\#
83endif
84export QUIET ECHO
Len Brown0efea7b2012-09-22 22:33:19 -040085
Lv Zhengf677b302014-01-15 12:04:09 +080086# if DEBUG is enabled, then we do not strip or optimize
87ifeq ($(strip $(DEBUG)),true)
88 CFLAGS += -O1 -g -DDEBUG
89 STRIPCMD = /bin/true -Since_we_are_debugging
90else
91 CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer
92 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
93endif
Len Brown0efea7b2012-09-22 22:33:19 -040094
Lv Zhengf677b302014-01-15 12:04:09 +080095# --- ACPIDUMP BEGIN ---
Len Brown0e7cc272012-09-22 23:30:22 -040096
Lv Zhengf677b302014-01-15 12:04:09 +080097vpath %.c \
Lv Zhengedbe47c2014-04-04 12:39:56 +080098 ../../../drivers/acpi/acpica\
99 tools/acpidump\
100 common\
101 os_specific/service_layers
102
103CFLAGS += -DACPI_DUMP_APP -Itools/acpidump
Lv Zhengf677b302014-01-15 12:04:09 +0800104
105DUMP_OBJS = \
Lv Zhengedbe47c2014-04-04 12:39:56 +0800106 apdump.o\
107 apfiles.o\
108 apmain.o\
109 osunixdir.o\
110 osunixmap.o\
111 tbprint.o\
112 tbxfroot.o\
113 utbuffer.o\
114 utexcep.o\
115 utmath.o\
116 utstring.o\
117 utxferror.o\
118 oslinuxtbl.o\
119 cmfsize.o\
120 getopt.o
Lv Zhengf677b302014-01-15 12:04:09 +0800121
122DUMP_OBJS := $(addprefix $(OUTPUT)tools/acpidump/,$(DUMP_OBJS))
123
124$(OUTPUT)acpidump: $(DUMP_OBJS)
125 $(ECHO) " LD " $@
126 $(QUIET) $(LD) $(CFLAGS) $(LDFLAGS) $(DUMP_OBJS) -L$(OUTPUT) -o $@
127 $(QUIET) $(STRIPCMD) $@
128
129$(OUTPUT)tools/acpidump/%.o: %.c
130 $(ECHO) " CC " $@
131 $(QUIET) $(CC) -c $(CFLAGS) -o $@ $<
132
133# --- ACPIDUMP END ---
134
135all: $(OUTPUT)acpidump
136 echo $(OUTPUT)
137
138clean:
139 -find $(OUTPUT) \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
140 | xargs rm -f
141 -rm -f $(OUTPUT)acpidump
142
143install-tools:
Thomas Renninger75e4f202014-04-07 15:16:54 +0200144 $(INSTALL) -d $(DESTDIR)${sbindir}
Lv Zhengf677b302014-01-15 12:04:09 +0800145 $(INSTALL_PROGRAM) $(OUTPUT)acpidump $(DESTDIR)${sbindir}
146
147install-man:
148 $(INSTALL_DATA) -D man/acpidump.8 $(DESTDIR)${mandir}/man8/acpidump.8
149
150install: all install-tools install-man
151
152uninstall:
153 - rm -f $(DESTDIR)${sbindir}/acpidump
154 - rm -f $(DESTDIR)${mandir}/man8/acpidump.8
155
156.PHONY: all utils install-tools install-man install uninstall clean