1# 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 22# --- CONFIGURATION BEGIN --- 23 24# Set the following to `true' to make a unstripped, unoptimized 25# binary. Leave this set to `false' for production use. 26DEBUG ?= true 27 28# make the build silent. Set this to something else to make it noisy again. 29V ?= false 30 31# Prefix to the directories we're installing to 32DESTDIR ?= 33 34# --- CONFIGURATION END --- 35 36# Directory definitions. These are default and most probably 37# do not need to be changed. Please note that DESTDIR is 38# added in front of any of them 39 40bindir ?= /usr/bin 41sbindir ?= /usr/sbin 42mandir ?= /usr/man 43 44# Toolchain: what tools do we use, and what options do they need: 45 46INSTALL = /usr/bin/install -c 47INSTALL_PROGRAM = ${INSTALL} 48INSTALL_DATA = ${INSTALL} -m 644 49INSTALL_SCRIPT = ${INSTALL_PROGRAM} 50 51# If you are running a cross compiler, you may want to set this 52# to something more interesting, like "arm-linux-". If you want 53# to compile vs uClibc, that can be done here as well. 54CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc- 55CC = $(CROSS)gcc 56LD = $(CROSS)gcc 57STRIP = $(CROSS)strip 58HOSTCC = gcc 59 60# check if compiler option is supported 61cc-supports = ${shell if $(CC) ${1} -S -o /dev/null -x c /dev/null > /dev/null 2>&1; then echo "$(1)"; fi;} 62 63# use '-Os' optimization if available, else use -O2 64OPTIMIZATION := $(call cc-supports,-Os,-O2) 65 66WARNINGS := -Wall 67WARNINGS += $(call cc-supports,-Wstrict-prototypes) 68WARNINGS += $(call cc-supports,-Wdeclaration-after-statement) 69 70KERNEL_INCLUDE := ../../../include 71CFLAGS += -D_LINUX -DDEFINE_ALTERNATE_TYPES -I$(KERNEL_INCLUDE) 72CFLAGS += $(WARNINGS) 73 74ifeq ($(strip $(V)),false) 75 QUIET=@ 76 ECHO=@echo 77else 78 QUIET= 79 ECHO=@\# 80endif 81export QUIET ECHO 82 83# if DEBUG is enabled, then we do not strip or optimize 84ifeq ($(strip $(DEBUG)),true) 85 CFLAGS += -O1 -g -DDEBUG 86 STRIPCMD = /bin/true -Since_we_are_debugging 87else 88 CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer 89 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment 90endif 91 92# --- ACPIDUMP BEGIN --- 93 94vpath %.c \ 95 tools/acpidump 96 97DUMP_OBJS = \ 98 acpidump.o 99 100DUMP_OBJS := $(addprefix $(OUTPUT)tools/acpidump/,$(DUMP_OBJS)) 101 102$(OUTPUT)acpidump: $(DUMP_OBJS) 103 $(ECHO) " LD " $@ 104 $(QUIET) $(LD) $(CFLAGS) $(LDFLAGS) $(DUMP_OBJS) -L$(OUTPUT) -o $@ 105 $(QUIET) $(STRIPCMD) $@ 106 107$(OUTPUT)tools/acpidump/%.o: %.c 108 $(ECHO) " CC " $@ 109 $(QUIET) $(CC) -c $(CFLAGS) -o $@ $< 110 111# --- ACPIDUMP END --- 112 113all: $(OUTPUT)acpidump 114 echo $(OUTPUT) 115 116clean: 117 -find $(OUTPUT) \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \ 118 | xargs rm -f 119 -rm -f $(OUTPUT)acpidump 120 121install-tools: 122 $(INSTALL) -d $(DESTDIR)${sbindir} 123 $(INSTALL_PROGRAM) $(OUTPUT)acpidump $(DESTDIR)${sbindir} 124 125install-man: 126 $(INSTALL_DATA) -D man/acpidump.8 $(DESTDIR)${mandir}/man8/acpidump.8 127 128install: all install-tools install-man 129 130uninstall: 131 - rm -f $(DESTDIR)${sbindir}/acpidump 132 - rm -f $(DESTDIR)${mandir}/man8/acpidump.8 133 134.PHONY: all utils install-tools install-man install uninstall clean 135