Quickfix to repair 'make clean; make menuconfig' (trivial).
[coreboot.git] / payloads / coreinfo / Makefile
1 ##
2 ## This file is part of the coreinfo project.
3 ##
4 ## Copyright (C) 2008 Advanced Micro Devices, Inc.
5 ## Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
6 ##
7 ## This program is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; version 2 of the License.
10 ##
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ## GNU General Public License for more details.
15 ##
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, write to the Free Software
18 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19 ##
20
21 export src := $(shell pwd)
22 export srctree := $(src)
23 export srck := $(src)/util/kconfig
24 export obj := $(src)/build
25 export objk := $(src)/build/util/kconfig
26
27 export KERNELVERSION      := 0.1.0
28 export KCONFIG_AUTOHEADER := $(obj)/config.h
29 export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
30
31 CONFIG_SHELL := sh
32 KBUILD_DEFCONFIG := configs/defconfig
33 UNAME_RELEASE := $(shell uname -r)
34 HAVE_DOTCONFIG := $(wildcard .config)
35 MAKEFLAGS += -rR --no-print-directory
36
37 # Make is silent per default, but 'make V=1' will show all compiler calls.
38 ifneq ($(V),1)
39 Q := @
40 endif
41
42 HOSTCC = gcc
43 HOSTCXX = g++
44 HOSTCFLAGS := -I$(srck) -I$(objk)
45 HOSTCXXFLAGS := -I$(srck) -I$(objk)
46
47 LIBPAYLOAD_DIR := ../libpayload
48 CC = $(LIBPAYLOAD_DIR)/bin/lpgcc
49 AS = $(LIBPAYLOAD_DIR)/bin/lpas
50
51 INCLUDES = -Ibuild
52 CFLAGS := -Wall -Werror -Os $(INCLUDES)
53 OBJECTS = cpuinfo_module.o cpuid.S.o pci_module.o coreboot_module.o \
54           nvram_module.o bootlog_module.o lar_module.o coreinfo.o
55 OBJS    = $(patsubst %,$(obj)/%,$(OBJECTS))
56 TARGET  = $(obj)/coreinfo.elf
57
58 ifeq ($(strip $(HAVE_DOTCONFIG)),)
59
60 all: config
61
62 else
63
64 include $(src)/.config
65
66 all: prepare $(TARGET)
67
68 $(TARGET): $(src)/.config $(OBJS)
69         $(Q)printf "  LD      $(subst $(shell pwd)/,,$(@))\n"
70         $(Q)$(CC) -o $@ $(OBJS)
71         $(Q)printf "  STRIP   $(subst $(shell pwd)/,,$(@))\n"
72         $(Q)strip -s $@
73
74 $(obj)/%.S.o: $(src)/%.S
75         $(Q)printf "  AS      $(subst $(shell pwd)/,,$(@))\n"
76         $(Q)$(AS) -o $@ $<
77
78 $(obj)/%.o: $(src)/%.c
79         $(Q)printf "  CC      $(subst $(shell pwd)/,,$(@))\n"
80         $(Q)$(CC) $(CFLAGS) -c -o $@ $<
81
82 endif
83
84 prepare:
85         $(Q)mkdir -p $(obj)/util/kconfig/lxdialog
86
87 clean:
88         $(Q)rm -rf build/*.elf build/*.o
89
90 distclean: clean
91         $(Q)rm -rf build
92         $(Q)rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig*
93
94 include util/kconfig/Makefile
95
96 .PHONY: $(PHONY) prepare clean distclean
97