|
| 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 <[email protected]> |
| 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 | + |
| 17 | +src := $(CURDIR) |
| 18 | +srctree := $(src) |
| 19 | +srck := $(src)/../../util/kconfig |
| 20 | +coreinfo_obj := $(src)/build |
| 21 | +objk := $(src)/build/util/kconfig |
| 22 | + |
| 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 |
| 33 | + |
| 34 | +export V := $(V) |
| 35 | + |
| 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 |
| 41 | + |
| 42 | +# Make is silent per default, but 'make V=1' will show all compiler calls. |
| 43 | +ifneq ($(V),1) |
| 44 | +.SILENT: |
| 45 | +endif |
| 46 | + |
| 47 | +HOSTCC ?= gcc |
| 48 | +HOSTCXX ?= g++ |
| 49 | +HOSTCFLAGS := -I$(srck) -I$(objk) |
| 50 | +HOSTCXXFLAGS := -I$(srck) -I$(objk) |
| 51 | + |
| 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-64 |
| 56 | +OBJCOPY ?= objcopy |
| 57 | + |
| 58 | +INCLUDES = -I$(coreinfo_obj) -include $(LIBPAYLOAD_OBJ)/include/kconfig.h -I$(src)/../../src/commonlib/include -I$(src)/include -I$(src) |
| 59 | +OBJECTS = common.o entry.o platform.o |
| 60 | +OBJS = $(patsubst %,$(coreinfo_obj)/%,$(OBJECTS)) |
| 61 | +TARGET = $(coreinfo_obj)/bareflank.elf |
| 62 | + |
| 63 | +all: real-all |
| 64 | + |
| 65 | +# in addition to the dependency below, create the file if it doesn't exist |
| 66 | +# to silence warnings about a file that would be generated anyway. |
| 67 | +$(if $(wildcard .xcompile),,$(eval $(shell ../../util/xcompile/xcompile $(XGCCPATH) > .xcompile || rm -f .xcompile))) |
| 68 | +.xcompile: ../../util/xcompile/xcompile |
| 69 | + $< $(XGCCPATH) > $@.tmp |
| 70 | + \mv -f $@.tmp $@ 2> /dev/null || rm -f $@.tmp $@ |
| 71 | + |
| 72 | +CONFIG_COMPILER_GCC := y |
| 73 | +ARCH-y := x86_64 |
| 74 | + |
| 75 | +include .xcompile |
| 76 | + |
| 77 | +CC := $(CC_$(ARCH-y)) |
| 78 | +AS := $(AS_$(ARCH-y)) |
| 79 | +OBJCOPY := $(OBJCOPY_$(ARCH-y)) |
| 80 | + |
| 81 | +LPCC := CC="$(CC)" $(LIBPAYLOAD_OBJ)/bin/lpgcc |
| 82 | +LPAS := AS="$(AS)" $(LIBPAYLOAD_OBJ)/bin/lpas |
| 83 | + |
| 84 | +CFLAGS += -Wall -Werror -Os -fno-builtin $(CFLAGS_$(ARCH-y)) $(INCLUDES) |
| 85 | + |
| 86 | +ifneq ($(strip $(HAVE_DOTCONFIG)),) |
| 87 | +include $(src)/.config |
| 88 | +real-all: $(TARGET) |
| 89 | + |
| 90 | +$(TARGET): $(src)/.config $(coreinfo_obj)/config.h $(OBJS) libpayload |
| 91 | + printf " LPCC $(subst $(CURDIR)/,,$(@)) (LINK)\n" |
| 92 | + $(LPCC) -o $@ $(OBJS) |
| 93 | + $(OBJCOPY) --only-keep-debug $@ $(TARGET).debug |
| 94 | + $(OBJCOPY) --strip-debug $@ |
| 95 | + $(OBJCOPY) --add-gnu-debuglink=$(TARGET).debug $@ |
| 96 | + |
| 97 | +$(coreinfo_obj)/%.S.o: $(src)/%.S libpayload |
| 98 | + printf " LPAS $(subst $(CURDIR)/,,$(@))\n" |
| 99 | + $(LPAS) -o $@ $< |
| 100 | + |
| 101 | +$(coreinfo_obj)/%.o: $(src)/%.c libpayload |
| 102 | + printf " LPCC $(subst $(CURDIR)/,,$(@))\n" |
| 103 | + $(LPCC) $(CFLAGS) -c -o $@ $< |
| 104 | + |
| 105 | +else |
| 106 | +real-all: config |
| 107 | +endif |
| 108 | + |
| 109 | +defaultbuild: |
| 110 | + $(MAKE) olddefconfig |
| 111 | + $(MAKE) all |
| 112 | + |
| 113 | +ifneq ($(strip $(HAVE_LIBPAYLOAD)),) |
| 114 | +libpayload: |
| 115 | + printf "Found Libpayload $(LIBPAYLOAD_OBJ).\n" |
| 116 | +else |
| 117 | +LPOPTS=obj="$(CURDIR)/lpbuild" DOTCONFIG="$(CURDIR)/lp.config" |
| 118 | +libpayload: |
| 119 | + printf "Building libpayload @ $(LIBPAYLOAD_PATH).\n" |
| 120 | + $(MAKE) -C $(LIBPAYLOAD_PATH) $(LPOPTS) distclean coreinfo_obj=$(coreinfo_obj)/libptmp |
| 121 | + $(MAKE) -C $(LIBPAYLOAD_PATH) $(LPOPTS) defconfig KBUILD_DEFCONFIG=$(LIBPAYLOAD_CONFIG) |
| 122 | + $(MAKE) -C $(LIBPAYLOAD_PATH) $(LPOPTS) install DESTDIR=$(coreinfo_obj) |
| 123 | +endif |
| 124 | + |
| 125 | +$(coreinfo_obj)/config.h: |
| 126 | + $(MAKE) oldconfig |
| 127 | + |
| 128 | +$(shell mkdir -p $(coreinfo_obj) $(objk)/lxdialog $(KCONFIG_SPLITCONFIG)) |
| 129 | + |
| 130 | +include $(srck)/Makefile |
| 131 | + |
| 132 | +.PHONY: $(PHONY) prepare |
| 133 | + |
| 134 | +else |
| 135 | + |
| 136 | +clean: |
| 137 | + rm -rf build/*.elf build/*.o .xcompile |
| 138 | + |
| 139 | +distclean: clean |
| 140 | + rm -rf build lpbuild |
| 141 | + rm -f .config* lp.config* |
| 142 | + |
| 143 | +.PHONY: clean distclean |
| 144 | +endif |
0 commit comments