Patrick Georgi | 8480c0b | 2020-05-08 22:50:46 +0200 | [diff] [blame] | 1 | ## SPDX-License-Identifier: GPL-2.0-only |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 2 | |
Nico Huber | 1132600 | 2020-12-27 21:03:34 +0100 | [diff] [blame] | 3 | unexport $(COREBOOT_EXPORTS) |
| 4 | |
Martin Roth | 6116f36 | 2016-03-08 12:32:40 -0700 | [diff] [blame] | 5 | src := $(CURDIR) |
Nico Huber | 552163e | 2020-11-15 19:32:26 +0100 | [diff] [blame] | 6 | obj := build |
| 7 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 8 | srctree := $(src) |
Stefan Reinauer | 0ab2b25 | 2015-06-29 16:10:16 -0700 | [diff] [blame] | 9 | srck := $(src)/../../util/kconfig |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 10 | objk := $(src)/build/util/kconfig |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 11 | |
Nico Huber | 552163e | 2020-11-15 19:32:26 +0100 | [diff] [blame] | 12 | LIBPAYLOAD_DEFCONFIG ?= $(src)/../libpayload/configs/defconfig-tinycurses |
Stefan Reinauer | 0ab2b25 | 2015-06-29 16:10:16 -0700 | [diff] [blame] | 13 | |
Nico Huber | 552163e | 2020-11-15 19:32:26 +0100 | [diff] [blame] | 14 | PAYLOAD_DEPS := $(obj)/config.h |
| 15 | |
| 16 | OBJECTS = cpuinfo_module.o cpuid.S.o pci_module.o coreboot_module.o \ |
| 17 | nvram_module.o bootlog_module.o ramdump_module.o \ |
| 18 | multiboot_module.o cbfs_module.o timestamps_module.o coreinfo.o |
| 19 | OBJS = $(patsubst %,$(obj)/%,$(OBJECTS)) |
| 20 | TARGET = $(obj)/coreinfo.elf |
| 21 | |
| 22 | ARCH := x86_32 |
| 23 | |
| 24 | all: real-all |
| 25 | |
| 26 | include ../libpayload/Makefile.payload |
| 27 | |
| 28 | ifeq ($(filter %clean,$(MAKECMDGOALS)),) |
| 29 | export KERNELVERSION := 0.1.0 |
| 30 | export KCONFIG_AUTOHEADER := $(obj)/config.h |
| 31 | export KCONFIG_AUTOCONFIG := $(obj)/auto.conf |
| 32 | export KCONFIG_DEPENDENCIES := $(obj)/auto.conf.cmd |
| 33 | export KCONFIG_SPLITCONFIG := $(obj)/config |
| 34 | export KCONFIG_TRISTATE := $(obj)/tristate.conf |
| 35 | export KCONFIG_CONFIG := $(CURDIR)/.config |
| 36 | export KCONFIG_NEGATIVES := 1 |
| 37 | export Kconfig := Kconfig |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 38 | |
| 39 | CONFIG_SHELL := sh |
| 40 | KBUILD_DEFCONFIG := configs/defconfig |
| 41 | UNAME_RELEASE := $(shell uname -r) |
| 42 | HAVE_DOTCONFIG := $(wildcard .config) |
| 43 | MAKEFLAGS += -rR --no-print-directory |
| 44 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 45 | HOSTCC ?= gcc |
| 46 | HOSTCXX ?= g++ |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 47 | HOSTCFLAGS := -I$(srck) -I$(objk) |
| 48 | HOSTCXXFLAGS := -I$(srck) -I$(objk) |
| 49 | |
Nico Huber | 552163e | 2020-11-15 19:32:26 +0100 | [diff] [blame] | 50 | CFLAGS += -I$(obj) -I../../src/commonlib/include |
Martin Roth | cacbcf4 | 2015-11-16 22:33:48 -0700 | [diff] [blame] | 51 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 52 | ifneq ($(strip $(HAVE_DOTCONFIG)),) |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 53 | include $(src)/.config |
Martin Roth | cacbcf4 | 2015-11-16 22:33:48 -0700 | [diff] [blame] | 54 | real-all: $(TARGET) |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 55 | |
Jacob Garber | 5e6c30b | 2019-10-02 18:55:23 -0600 | [diff] [blame] | 56 | ifeq ($(CONFIG_LTO),y) |
| 57 | CFLAGS += -flto |
| 58 | endif |
| 59 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 60 | else |
Martin Roth | cacbcf4 | 2015-11-16 22:33:48 -0700 | [diff] [blame] | 61 | real-all: config |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 62 | endif |
| 63 | |
Martin Roth | 50943b1 | 2016-01-25 14:01:55 -0700 | [diff] [blame] | 64 | defaultbuild: |
| 65 | $(MAKE) olddefconfig |
| 66 | $(MAKE) all |
| 67 | |
Nico Huber | 552163e | 2020-11-15 19:32:26 +0100 | [diff] [blame] | 68 | $(obj)/config.h: |
Stefan Reinauer | ccc55fd | 2015-06-29 16:44:12 -0700 | [diff] [blame] | 69 | $(MAKE) oldconfig |
| 70 | |
Nico Huber | 552163e | 2020-11-15 19:32:26 +0100 | [diff] [blame] | 71 | $(shell mkdir -p $(objk)/lxdialog $(KCONFIG_SPLITCONFIG)) |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 72 | |
Patrick Georgi | 0ffef88 | 2017-01-19 23:20:14 +0100 | [diff] [blame] | 73 | include $(srck)/Makefile |
| 74 | |
Nico Huber | 552163e | 2020-11-15 19:32:26 +0100 | [diff] [blame] | 75 | .PHONY: $(PHONY) prepare all real-all defaultbuild |
Patrick Georgi | 0ffef88 | 2017-01-19 23:20:14 +0100 | [diff] [blame] | 76 | |
| 77 | else |
| 78 | |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 79 | distclean: clean |
Nico Huber | 552163e | 2020-11-15 19:32:26 +0100 | [diff] [blame] | 80 | rm -f .config* |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 81 | |
Nico Huber | 552163e | 2020-11-15 19:32:26 +0100 | [diff] [blame] | 82 | .PHONY: distclean |
Patrick Georgi | 0ffef88 | 2017-01-19 23:20:14 +0100 | [diff] [blame] | 83 | endif |