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 |
Paul Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 18 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
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) |
| 23 | srck := $(src)/util/kconfig |
| 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 |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 30 | export V := $(V) |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 31 | |
| 32 | CONFIG_SHELL := sh |
| 33 | KBUILD_DEFCONFIG := configs/defconfig |
| 34 | UNAME_RELEASE := $(shell uname -r) |
| 35 | HAVE_DOTCONFIG := $(wildcard .config) |
| 36 | MAKEFLAGS += -rR --no-print-directory |
| 37 | |
| 38 | # Make is silent per default, but 'make V=1' will show all compiler calls. |
| 39 | ifneq ($(V),1) |
| 40 | Q := @ |
| 41 | endif |
| 42 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 43 | HOSTCC ?= gcc |
| 44 | HOSTCXX ?= g++ |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 45 | HOSTCFLAGS := -I$(srck) -I$(objk) |
| 46 | HOSTCXXFLAGS := -I$(srck) -I$(objk) |
| 47 | |
Marc Jones | 9915b37 | 2012-11-30 17:15:36 -0700 | [diff] [blame] | 48 | LIBCONFIG_PATH := ../libpayload |
| 49 | LIBPAYLOAD_DIR := ./libpayloadbin |
| 50 | LPCC := $(LIBPAYLOAD_DIR)/libpayload/bin/lpgcc |
| 51 | LPAS := $(LIBPAYLOAD_DIR)/libpayload/bin/lpas |
| 52 | HAVE_LIBPAYLOAD := $(wildcard $(LIBPAYLOAD_DIR)/libpayload/lib/libpayload.a) |
| 53 | LIB_CONFIG ?= defconfig |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 54 | OBJCOPY ?= objcopy |
Jordan Crouse | 1cb92bc | 2008-04-10 00:05:41 +0000 | [diff] [blame] | 55 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 56 | INCLUDES = -I$(obj) |
Jordan Crouse | 1cb92bc | 2008-04-10 00:05:41 +0000 | [diff] [blame] | 57 | CFLAGS := -Wall -Werror -Os $(INCLUDES) |
Uwe Hermann | ab5b3e0 | 2008-03-31 20:30:18 +0000 | [diff] [blame] | 58 | 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] | 59 | nvram_module.o bootlog_module.o ramdump_module.o lar_module.o \ |
Uwe Hermann | 941c1fd | 2009-07-07 15:10:13 +0000 | [diff] [blame] | 60 | multiboot_module.o cbfs_module.o coreinfo.o |
Uwe Hermann | ab5b3e0 | 2008-03-31 20:30:18 +0000 | [diff] [blame] | 61 | OBJS = $(patsubst %,$(obj)/%,$(OBJECTS)) |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 62 | TARGET = $(obj)/coreinfo.elf |
| 63 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 64 | ifneq ($(strip $(HAVE_DOTCONFIG)),) |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 65 | include $(src)/.config |
Robert Millan | c1f404f | 2008-11-11 23:41:08 +0000 | [diff] [blame] | 66 | all: $(TARGET) |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 67 | |
Marc Jones | 9915b37 | 2012-11-30 17:15:36 -0700 | [diff] [blame] | 68 | $(TARGET): $(src)/.config $(OBJS) prepare libpayload |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 69 | $(Q)printf " LPCC $(subst $(shell pwd)/,,$(@))\n" |
| 70 | $(Q)$(LPCC) -o $@ $(OBJS) |
| 71 | $(Q)$(OBJCOPY) --only-keep-debug $@ $(TARGET).debug |
| 72 | $(Q)$(OBJCOPY) --strip-debug $@ |
| 73 | $(Q)$(OBJCOPY) --add-gnu-debuglink=$(TARGET).debug $@ |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 74 | |
Marc Jones | 9915b37 | 2012-11-30 17:15:36 -0700 | [diff] [blame] | 75 | $(obj)/%.S.o: $(src)/%.S libpayload |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 76 | $(Q)printf " LPAS $(subst $(shell pwd)/,,$(@))\n" |
| 77 | $(Q)$(LPAS) -o $@ $< |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 78 | |
Marc Jones | 9915b37 | 2012-11-30 17:15:36 -0700 | [diff] [blame] | 79 | $(obj)/%.o: $(src)/%.c libpayload |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 80 | $(Q)printf " LPCC $(subst $(shell pwd)/,,$(@))\n" |
| 81 | $(Q)$(LPCC) $(CFLAGS) -c -o $@ $< |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 82 | |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 83 | else |
| 84 | all: config |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 85 | endif |
| 86 | |
Marc Jones | 9915b37 | 2012-11-30 17:15:36 -0700 | [diff] [blame] | 87 | ifneq ($(strip $(HAVE_LIBPAYLOAD)),) |
| 88 | libpayload: |
| 89 | $(Q)printf "Found Libpayload $(LIBPAYLOAD_DIR).\n" |
| 90 | else |
| 91 | libpayload: |
| 92 | $(Q)printf "Building libpayload @ $(LIBCONFIG_PATH).\n" |
| 93 | $(Q)make -C $(LIBCONFIG_PATH) distclean |
| 94 | $(Q)make -C $(LIBCONFIG_PATH) $(LIB_CONFIG) |
| 95 | $(Q)make -C $(LIBCONFIG_PATH) DESTDIR=$(shell pwd)/$(LIBPAYLOAD_DIR) install |
| 96 | endif |
Marc Jones | 5d01b76 | 2012-11-30 17:04:58 -0700 | [diff] [blame] | 97 | |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 98 | prepare: |
| 99 | $(Q)mkdir -p $(obj)/util/kconfig/lxdialog |
| 100 | |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 101 | clean: |
Uwe Hermann | 134aaae | 2008-05-11 15:51:31 +0000 | [diff] [blame] | 102 | $(Q)rm -rf build/*.elf build/*.o |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 103 | |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 104 | distclean: clean |
Uwe Hermann | c758227 | 2008-04-03 22:20:35 +0000 | [diff] [blame] | 105 | $(Q)rm -rf build |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 106 | $(Q)rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 107 | |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 108 | include util/kconfig/Makefile |
Jordan Crouse | 7249f79 | 2008-03-20 00:11:05 +0000 | [diff] [blame] | 109 | |
Uwe Hermann | 2216d1b | 2008-03-24 15:47:49 +0000 | [diff] [blame] | 110 | .PHONY: $(PHONY) prepare clean distclean |
| 111 | |