blob: d63f5156a820335cb92bfe83b6b094bb2d30a4fd [file] [log] [blame]
Jordan Crouse7249f792008-03-20 00:11:05 +00001##
2## This file is part of the coreinfo project.
3##
4## Copyright (C) 2008 Advanced Micro Devices, Inc.
Uwe Hermann2216d1b2008-03-24 15:47:49 +00005## Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
Jordan Crouse7249f792008-03-20 00:11:05 +00006##
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
Patrick Georgib890a122015-03-26 15:17:45 +010018## Foundation, Inc.
Jordan Crouse7249f792008-03-20 00:11:05 +000019##
20
Marc Jones5d01b762012-11-30 17:04:58 -070021src := $(shell pwd)
22srctree := $(src)
Stefan Reinauer0ab2b252015-06-29 16:10:16 -070023srck := $(src)/../../util/kconfig
Marc Jones5d01b762012-11-30 17:04:58 -070024obj := $(src)/build
25objk := $(src)/build/util/kconfig
Uwe Hermann2216d1b2008-03-24 15:47:49 +000026
27export KERNELVERSION := 0.1.0
28export KCONFIG_AUTOHEADER := $(obj)/config.h
29export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
Stefan Reinauer0ab2b252015-06-29 16:10:16 -070030export KCONFIG_DEPENDENCIES := $(obj)/auto.conf.cmd
31export KCONFIG_SPLITCONFIG := $(obj)/config
32export KCONFIG_TRISTATE := $(obj)/tristate.conf
33export KCONFIG_NEGATIVES := 1
34export Kconfig := Kconfig
35
Marc Jones5d01b762012-11-30 17:04:58 -070036export V := $(V)
Uwe Hermann2216d1b2008-03-24 15:47:49 +000037
38CONFIG_SHELL := sh
39KBUILD_DEFCONFIG := configs/defconfig
40UNAME_RELEASE := $(shell uname -r)
41HAVE_DOTCONFIG := $(wildcard .config)
42MAKEFLAGS += -rR --no-print-directory
43
44# Make is silent per default, but 'make V=1' will show all compiler calls.
45ifneq ($(V),1)
Stefan Reinauer739a6adb2015-06-30 15:22:12 -070046.SILENT:
Uwe Hermann2216d1b2008-03-24 15:47:49 +000047endif
48
Marc Jones5d01b762012-11-30 17:04:58 -070049HOSTCC ?= gcc
50HOSTCXX ?= g++
Uwe Hermann2216d1b2008-03-24 15:47:49 +000051HOSTCFLAGS := -I$(srck) -I$(objk)
52HOSTCXXFLAGS := -I$(srck) -I$(objk)
53
Marc Jones9915b372012-11-30 17:15:36 -070054LIBCONFIG_PATH := ../libpayload
Stefan Reinauerccc55fd2015-06-29 16:44:12 -070055LIBPAYLOAD_DIR := build/libpayload
Marc Jones9915b372012-11-30 17:15:36 -070056LPCC := $(LIBPAYLOAD_DIR)/libpayload/bin/lpgcc
57LPAS := $(LIBPAYLOAD_DIR)/libpayload/bin/lpas
58HAVE_LIBPAYLOAD := $(wildcard $(LIBPAYLOAD_DIR)/libpayload/lib/libpayload.a)
59LIB_CONFIG ?= defconfig
Marc Jones5d01b762012-11-30 17:04:58 -070060OBJCOPY ?= objcopy
Jordan Crouse1cb92bc2008-04-10 00:05:41 +000061
Stefan Reinauerccc55fd2015-06-29 16:44:12 -070062INCLUDES = -I$(obj) -include $(LIBPAYLOAD_DIR)/libpayload/include/kconfig.h
63CFLAGS := -Wall -Werror -Os -fno-builtin $(INCLUDES)
Uwe Hermannab5b3e02008-03-31 20:30:18 +000064OBJECTS = cpuinfo_module.o cpuid.S.o pci_module.o coreboot_module.o \
Uwe Hermann2fbbb292008-07-08 16:18:38 +000065 nvram_module.o bootlog_module.o ramdump_module.o lar_module.o \
Uwe Hermann941c1fd2009-07-07 15:10:13 +000066 multiboot_module.o cbfs_module.o coreinfo.o
Uwe Hermannab5b3e02008-03-31 20:30:18 +000067OBJS = $(patsubst %,$(obj)/%,$(OBJECTS))
Uwe Hermann2216d1b2008-03-24 15:47:49 +000068TARGET = $(obj)/coreinfo.elf
69
Marc Jones5d01b762012-11-30 17:04:58 -070070ifneq ($(strip $(HAVE_DOTCONFIG)),)
Uwe Hermann2216d1b2008-03-24 15:47:49 +000071include $(src)/.config
Robert Millanc1f404f2008-11-11 23:41:08 +000072all: $(TARGET)
Jordan Crouse7249f792008-03-20 00:11:05 +000073
Stefan Reinauerccc55fd2015-06-29 16:44:12 -070074$(TARGET): $(src)/.config $(obj)/config.h $(OBJS) libpayload
Stefan Reinauer739a6adb2015-06-30 15:22:12 -070075 printf " LPCC $(subst $(shell pwd)/,,$(@)) (LINK)\n"
76 $(LPCC) -o $@ $(OBJS)
77 $(OBJCOPY) --only-keep-debug $@ $(TARGET).debug
78 $(OBJCOPY) --strip-debug $@
79 $(OBJCOPY) --add-gnu-debuglink=$(TARGET).debug $@
Uwe Hermann2216d1b2008-03-24 15:47:49 +000080
Marc Jones9915b372012-11-30 17:15:36 -070081$(obj)/%.S.o: $(src)/%.S libpayload
Stefan Reinauer739a6adb2015-06-30 15:22:12 -070082 printf " LPAS $(subst $(shell pwd)/,,$(@))\n"
83 $(LPAS) -o $@ $<
Uwe Hermann2216d1b2008-03-24 15:47:49 +000084
Marc Jones9915b372012-11-30 17:15:36 -070085$(obj)/%.o: $(src)/%.c libpayload
Stefan Reinauer739a6adb2015-06-30 15:22:12 -070086 printf " LPCC $(subst $(shell pwd)/,,$(@))\n"
87 $(LPCC) $(CFLAGS) -c -o $@ $<
Uwe Hermann2216d1b2008-03-24 15:47:49 +000088
Marc Jones5d01b762012-11-30 17:04:58 -070089else
90all: config
Uwe Hermann2216d1b2008-03-24 15:47:49 +000091endif
92
Marc Jones9915b372012-11-30 17:15:36 -070093ifneq ($(strip $(HAVE_LIBPAYLOAD)),)
94libpayload:
Stefan Reinauer739a6adb2015-06-30 15:22:12 -070095 printf "Found Libpayload $(LIBPAYLOAD_DIR).\n"
Marc Jones9915b372012-11-30 17:15:36 -070096else
97libpayload:
Stefan Reinauer739a6adb2015-06-30 15:22:12 -070098 printf "Building libpayload @ $(LIBCONFIG_PATH).\n"
99 make -C $(LIBCONFIG_PATH) distclean
100 make -C $(LIBCONFIG_PATH) $(LIB_CONFIG)
101 make -C $(LIBCONFIG_PATH) DESTDIR=$(shell pwd)/$(LIBPAYLOAD_DIR) install
Marc Jones9915b372012-11-30 17:15:36 -0700102endif
Marc Jones5d01b762012-11-30 17:04:58 -0700103
Stefan Reinauerccc55fd2015-06-29 16:44:12 -0700104$(obj)/config.h:
105 $(MAKE) oldconfig
106
Stefan Reinauer0ab2b252015-06-29 16:10:16 -0700107$(shell mkdir -p $(obj) $(objk)/lxdialog $(KCONFIG_SPLITCONFIG))
Uwe Hermann2216d1b2008-03-24 15:47:49 +0000108
Jordan Crouse7249f792008-03-20 00:11:05 +0000109clean:
Stefan Reinauer739a6adb2015-06-30 15:22:12 -0700110 rm -rf build/*.elf build/*.o
Jordan Crouse7249f792008-03-20 00:11:05 +0000111
Uwe Hermann2216d1b2008-03-24 15:47:49 +0000112distclean: clean
Stefan Reinauer739a6adb2015-06-30 15:22:12 -0700113 rm -rf build
114 rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig*
Jordan Crouse7249f792008-03-20 00:11:05 +0000115
Stefan Reinauer0ab2b252015-06-29 16:10:16 -0700116include $(srck)/Makefile
Jordan Crouse7249f792008-03-20 00:11:05 +0000117
Uwe Hermann2216d1b2008-03-24 15:47:49 +0000118.PHONY: $(PHONY) prepare clean distclean