payloads/coreinfo: Enable -Wmissing-prototypes
[coreboot.git] / payloads / coreinfo / Makefile
blob1e9eb80d20ea4fb1455fd122232bff971fadb46b
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.
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.
17 src := $(CURDIR)
18 srctree := $(src)
19 srck := $(src)/../../util/kconfig
20 coreinfo_obj := $(src)/build
21 objk := $(src)/build/util/kconfig
23 ifeq ($(filter %clean,$(MAKECMDGOALS)),)
24 export KERNELVERSION := 0.1.0
25 export KCONFIG_AUTOHEADER := $(coreinfo_obj)/config.h
26 export KCONFIG_AUTOCONFIG := $(coreinfo_obj)/auto.conf
27 export KCONFIG_DEPENDENCIES := $(coreinfo_obj)/auto.conf.cmd
28 export KCONFIG_SPLITCONFIG := $(coreinfo_obj)/config
29 export KCONFIG_TRISTATE := $(coreinfo_obj)/tristate.conf
30 export KCONFIG_CONFIG := $(CURDIR)/.config
31 export KCONFIG_NEGATIVES := 1
32 export Kconfig := Kconfig
34 export V := $(V)
36 CONFIG_SHELL := sh
37 KBUILD_DEFCONFIG := configs/defconfig
38 UNAME_RELEASE := $(shell uname -r)
39 HAVE_DOTCONFIG := $(wildcard .config)
40 MAKEFLAGS += -rR --no-print-directory
42 # Make is silent per default, but 'make V=1' will show all compiler calls.
43 ifneq ($(V),1)
44 .SILENT:
45 endif
47 HOSTCC ?= gcc
48 HOSTCXX ?= g++
49 HOSTCFLAGS := -I$(srck) -I$(objk)
50 HOSTCXXFLAGS := -I$(srck) -I$(objk)
52 LIBPAYLOAD_PATH := $(realpath ../libpayload)
53 LIBPAYLOAD_OBJ := $(coreinfo_obj)/libpayload
54 HAVE_LIBPAYLOAD := $(wildcard $(LIBPAYLOAD_OBJ)/lib/libpayload.a)
55 LIBPAYLOAD_CONFIG ?= configs/defconfig-tinycurses
56 OBJCOPY ?= objcopy
58 INCLUDES = -I$(coreinfo_obj) -include $(LIBPAYLOAD_OBJ)/include/kconfig.h -I$(src)/../../src/commonlib/include
59 OBJECTS = cpuinfo_module.o cpuid.S.o pci_module.o coreboot_module.o \
60 nvram_module.o bootlog_module.o ramdump_module.o \
61 multiboot_module.o cbfs_module.o timestamps_module.o coreinfo.o
62 OBJS = $(patsubst %,$(coreinfo_obj)/%,$(OBJECTS))
63 TARGET = $(coreinfo_obj)/coreinfo.elf
65 all: real-all
67 # in addition to the dependency below, create the file if it doesn't exist
68 # to silence warnings about a file that would be generated anyway.
69 $(if $(wildcard .xcompile),,$(eval $(shell ../../util/xcompile/xcompile $(XGCCPATH) > .xcompile || rm -f .xcompile)))
70 .xcompile: ../../util/xcompile/xcompile
71 $< $(XGCCPATH) > $@.tmp
72 \mv -f $@.tmp $@ 2> /dev/null || rm -f $@.tmp $@
74 CONFIG_COMPILER_GCC := y
75 ARCH-y := x86_32
77 include .xcompile
79 CC := $(CC_$(ARCH-y))
80 AS := $(AS_$(ARCH-y))
81 OBJCOPY := $(OBJCOPY_$(ARCH-y))
83 LPCC := CC="$(CC)" $(LIBPAYLOAD_OBJ)/bin/lpgcc
84 LPAS := AS="$(AS)" $(LIBPAYLOAD_OBJ)/bin/lpas
86 CFLAGS += -Wall -Wextra -Wmissing-prototypes -Werror
87 CFLAGS += -Os -fno-builtin $(CFLAGS_$(ARCH-y)) $(INCLUDES)
89 ifneq ($(strip $(HAVE_DOTCONFIG)),)
90 include $(src)/.config
91 real-all: $(TARGET)
93 $(TARGET): $(src)/.config $(coreinfo_obj)/config.h $(OBJS) libpayload
94 printf " LPCC $(subst $(CURDIR)/,,$(@)) (LINK)\n"
95 $(LPCC) -o $@ $(OBJS)
96 $(OBJCOPY) --only-keep-debug $@ $(TARGET).debug
97 $(OBJCOPY) --strip-debug $@
98 $(OBJCOPY) --add-gnu-debuglink=$(TARGET).debug $@
100 $(coreinfo_obj)/%.S.o: $(src)/%.S libpayload
101 printf " LPAS $(subst $(CURDIR)/,,$(@))\n"
102 $(LPAS) -o $@ $<
104 $(coreinfo_obj)/%.o: $(src)/%.c libpayload
105 printf " LPCC $(subst $(CURDIR)/,,$(@))\n"
106 $(LPCC) $(CFLAGS) -c -o $@ $<
108 else
109 real-all: config
110 endif
112 defaultbuild:
113 $(MAKE) olddefconfig
114 $(MAKE) all
116 ifneq ($(strip $(HAVE_LIBPAYLOAD)),)
117 libpayload:
118 printf "Found Libpayload $(LIBPAYLOAD_OBJ).\n"
119 else
120 LPOPTS=obj="$(CURDIR)/lpbuild" DOTCONFIG="$(CURDIR)/lp.config"
121 libpayload:
122 printf "Building libpayload @ $(LIBPAYLOAD_PATH).\n"
123 $(MAKE) -C $(LIBPAYLOAD_PATH) $(LPOPTS) distclean coreinfo_obj=$(coreinfo_obj)/libptmp
124 $(MAKE) -C $(LIBPAYLOAD_PATH) $(LPOPTS) defconfig KBUILD_DEFCONFIG=$(LIBPAYLOAD_CONFIG)
125 $(MAKE) -C $(LIBPAYLOAD_PATH) $(LPOPTS) install DESTDIR=$(coreinfo_obj)
126 endif
128 $(coreinfo_obj)/config.h:
129 $(MAKE) oldconfig
131 $(shell mkdir -p $(coreinfo_obj) $(objk)/lxdialog $(KCONFIG_SPLITCONFIG))
133 include $(srck)/Makefile
135 .PHONY: $(PHONY) prepare
137 else
139 clean:
140 rm -rf build/*.elf build/*.o .xcompile
142 distclean: clean
143 rm -rf build lpbuild
144 rm -f .config* lp.config*
146 .PHONY: clean distclean
147 endif