Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 1 | ## |
| 2 | ## This file is part of the coreinfo project. |
| 3 | ## |
| 4 | ## Copyright (C) 2008 Advanced Micro Devices, Inc. |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 5 | ## Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de> |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 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 |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 18 | ## Foundation, Inc. |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 19 | ## |
| 20 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 21 | src := $(shell pwd) |
| 22 | srctree := $(src) |
Stefan Reinauer | 0ab2b25 | 2015-06-29 16:10:16 -0700 | [diff] [blame] | 23 | srck := $(src)/../../util/kconfig |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 24 | obj := $(src)/build |
| 25 | objk := $(src)/build/util/kconfig |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 26 | |
| 27 | export KERNELVERSION := 0.1.0 |
| 28 | export KCONFIG_AUTOHEADER := $(obj)/config.h |
| 29 | export KCONFIG_AUTOCONFIG := $(obj)/auto.conf |
Stefan Reinauer | 0ab2b25 | 2015-06-29 16:10:16 -0700 | [diff] [blame] | 30 | export KCONFIG_DEPENDENCIES := $(obj)/auto.conf.cmd |
| 31 | export KCONFIG_SPLITCONFIG := $(obj)/config |
| 32 | export KCONFIG_TRISTATE := $(obj)/tristate.conf |
| 33 | export KCONFIG_NEGATIVES := 1 |
| 34 | export Kconfig := Kconfig |
| 35 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 36 | export V := $(V) |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 37 | |
| 38 | CONFIG_SHELL := sh |
| 39 | KBUILD_DEFCONFIG := configs/defconfig |
| 40 | UNAME_RELEASE := $(shell uname -r) |
| 41 | HAVE_DOTCONFIG := $(wildcard .config) |
| 42 | MAKEFLAGS += -rR --no-print-directory |
| 43 | |
| 44 | # Make is silent per default, but 'make V=1' will show all compiler calls. |
| 45 | ifneq ($(V),1) |
Stefan Reinauer | 739a6adb | 2015-06-30 15:22:12 -0700 | [diff] [blame] | 46 | .SILENT: |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 47 | endif |
| 48 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 49 | HOSTCC ?= gcc |
| 50 | HOSTCXX ?= g++ |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 51 | HOSTCFLAGS := -I$(srck) -I$(objk) |
| 52 | HOSTCXXFLAGS := -I$(srck) -I$(objk) |
| 53 | |
Marc Jones | 9915b37 | 2012-11-30 17:15:36 -0700 | [diff] [blame] | 54 | LIBCONFIG_PATH := ../libpayload |
Stefan Reinauer | ccc55fd | 2015-06-29 16:44:12 -0700 | [diff] [blame] | 55 | LIBPAYLOAD_DIR := build/libpayload |
Marc Jones | 9915b37 | 2012-11-30 17:15:36 -0700 | [diff] [blame] | 56 | LPCC := $(LIBPAYLOAD_DIR)/libpayload/bin/lpgcc |
| 57 | LPAS := $(LIBPAYLOAD_DIR)/libpayload/bin/lpas |
| 58 | HAVE_LIBPAYLOAD := $(wildcard $(LIBPAYLOAD_DIR)/libpayload/lib/libpayload.a) |
| 59 | LIB_CONFIG ?= defconfig |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 60 | OBJCOPY ?= objcopy |
Jordan Crouse | 1cb92bc | 2008-04-10 00:05:41 +0000 | [diff] [blame] | 61 | |
Stefan Reinauer | ccc55fd | 2015-06-29 16:44:12 -0700 | [diff] [blame] | 62 | INCLUDES = -I$(obj) -include $(LIBPAYLOAD_DIR)/libpayload/include/kconfig.h |
| 63 | CFLAGS := -Wall -Werror -Os -fno-builtin $(INCLUDES) |
Uwe Hermann | ab5b3e0 | 2008-03-31 20:30:18 +0000 | [diff] [blame] | 64 | OBJECTS = cpuinfo_module.o cpuid.S.o pci_module.o coreboot_module.o \ |
Uwe Hermann | 2fbbb29 | 2008-07-08 16:18:38 +0000 | [diff] [blame] | 65 | nvram_module.o bootlog_module.o ramdump_module.o lar_module.o \ |
Uwe Hermann | 941c1fd | 2009-07-07 15:10:13 +0000 | [diff] [blame] | 66 | multiboot_module.o cbfs_module.o coreinfo.o |
Uwe Hermann | ab5b3e0 | 2008-03-31 20:30:18 +0000 | [diff] [blame] | 67 | OBJS = $(patsubst %,$(obj)/%,$(OBJECTS)) |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 68 | TARGET = $(obj)/coreinfo.elf |
| 69 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 70 | ifneq ($(strip $(HAVE_DOTCONFIG)),) |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 71 | include $(src)/.config |
Robert Millan | c1f404f | 2008-11-11 23:41:08 +0000 | [diff] [blame] | 72 | all: $(TARGET) |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 73 | |
Stefan Reinauer | ccc55fd | 2015-06-29 16:44:12 -0700 | [diff] [blame] | 74 | $(TARGET): $(src)/.config $(obj)/config.h $(OBJS) libpayload |
Stefan Reinauer | 739a6adb | 2015-06-30 15:22:12 -0700 | [diff] [blame] | 75 | 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 Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 80 | |
Marc Jones | 9915b37 | 2012-11-30 17:15:36 -0700 | [diff] [blame] | 81 | $(obj)/%.S.o: $(src)/%.S libpayload |
Stefan Reinauer | 739a6adb | 2015-06-30 15:22:12 -0700 | [diff] [blame] | 82 | printf " LPAS $(subst $(shell pwd)/,,$(@))\n" |
| 83 | $(LPAS) -o $@ $< |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 84 | |
Marc Jones | 9915b37 | 2012-11-30 17:15:36 -0700 | [diff] [blame] | 85 | $(obj)/%.o: $(src)/%.c libpayload |
Stefan Reinauer | 739a6adb | 2015-06-30 15:22:12 -0700 | [diff] [blame] | 86 | printf " LPCC $(subst $(shell pwd)/,,$(@))\n" |
| 87 | $(LPCC) $(CFLAGS) -c -o $@ $< |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 88 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 89 | else |
| 90 | all: config |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 91 | endif |
| 92 | |
Marc Jones | 9915b37 | 2012-11-30 17:15:36 -0700 | [diff] [blame] | 93 | ifneq ($(strip $(HAVE_LIBPAYLOAD)),) |
| 94 | libpayload: |
Stefan Reinauer | 739a6adb | 2015-06-30 15:22:12 -0700 | [diff] [blame] | 95 | printf "Found Libpayload $(LIBPAYLOAD_DIR).\n" |
Marc Jones | 9915b37 | 2012-11-30 17:15:36 -0700 | [diff] [blame] | 96 | else |
| 97 | libpayload: |
Stefan Reinauer | 739a6adb | 2015-06-30 15:22:12 -0700 | [diff] [blame] | 98 | 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 Jones | 9915b37 | 2012-11-30 17:15:36 -0700 | [diff] [blame] | 102 | endif |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 103 | |
Stefan Reinauer | ccc55fd | 2015-06-29 16:44:12 -0700 | [diff] [blame] | 104 | $(obj)/config.h: |
| 105 | $(MAKE) oldconfig |
| 106 | |
Stefan Reinauer | 0ab2b25 | 2015-06-29 16:10:16 -0700 | [diff] [blame] | 107 | $(shell mkdir -p $(obj) $(objk)/lxdialog $(KCONFIG_SPLITCONFIG)) |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 108 | |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 109 | clean: |
Stefan Reinauer | 739a6adb | 2015-06-30 15:22:12 -0700 | [diff] [blame] | 110 | rm -rf build/*.elf build/*.o |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 111 | |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 112 | distclean: clean |
Stefan Reinauer | 739a6adb | 2015-06-30 15:22:12 -0700 | [diff] [blame] | 113 | rm -rf build |
| 114 | rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 115 | |
Stefan Reinauer | 0ab2b25 | 2015-06-29 16:10:16 -0700 | [diff] [blame] | 116 | include $(srck)/Makefile |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 117 | |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 118 | .PHONY: $(PHONY) prepare clean distclean |