1# tools/power/acpi/Makefile - ACPI tool Makefile 2# 3# Copyright (c) 2013, Intel Corporation 4# Author: Lv Zheng <[email protected]> 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 22SUBDIRS = tools/ec 23 24# --- 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 72KERNEL_INCLUDE := ../../../include 73CFLAGS += -D_LINUX -DDEFINE_ALTERNATE_TYPES -I$(KERNEL_INCLUDE) 74CFLAGS += $(WARNINGS) 75 76ifeq ($(strip $(V)),false) 77 QUIET=@ 78 ECHO=@echo 79else 80 QUIET= 81 ECHO=@\# 82endif 83export QUIET ECHO 84 85# if DEBUG is enabled, then we do not strip or optimize 86ifeq ($(strip $(DEBUG)),true) 87 CFLAGS += -O1 -g -DDEBUG 88 STRIPCMD = /bin/true -Since_we_are_debugging 89else 90 CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer 91 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment 92endif 93 94# --- ACPIDUMP BEGIN --- 95 96vpath %.c \ 97 tools/acpidump 98 99DUMP_OBJS = \ 100 acpidump.o 101 102DUMP_OBJS := $(addprefix $(OUTPUT)tools/acpidump/,$(DUMP_OBJS)) 103 104$(OUTPUT)acpidump: $(DUMP_OBJS) 105 $(ECHO) " LD " $@ 106 $(QUIET) $(LD) $(CFLAGS) $(LDFLAGS) $(DUMP_OBJS) -L$(OUTPUT) -o $@ 107 $(QUIET) $(STRIPCMD) $@ 108 109$(OUTPUT)tools/acpidump/%.o: %.c 110 $(ECHO) " CC " $@ 111 $(QUIET) $(CC) -c $(CFLAGS) -o $@ $< 112 113# --- ACPIDUMP END --- 114 115all: $(OUTPUT)acpidump 116 echo $(OUTPUT) 117 118clean: 119 -find $(OUTPUT) \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \ 120 | xargs rm -f 121 -rm -f $(OUTPUT)acpidump 122 123install-tools: 124 $(INSTALL) -d $(DESTDIR)${sbindir} 125 $(INSTALL_PROGRAM) $(OUTPUT)acpidump $(DESTDIR)${sbindir} 126 127install-man: 128 $(INSTALL_DATA) -D man/acpidump.8 $(DESTDIR)${mandir}/man8/acpidump.8 129 130install: all install-tools install-man 131 132uninstall: 133 - rm -f $(DESTDIR)${sbindir}/acpidump 134 - rm -f $(DESTDIR)${mandir}/man8/acpidump.8 135 136.PHONY: all utils install-tools install-man install uninstall clean 137