-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
162 lines (118 loc) · 4.32 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#
# Copyright (C) 2008-2009 by coresystems GmbH
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc.
#
export PROGRAM_NAME := FILO
export PROGRAM_VERSION := 0.6.0
export src := $(shell pwd)
export srctree := $(src)
export srck := $(src)/util/kconfig
export obj := $(src)/build
export objk := $(src)/build/util/kconfig
-include $(src)/.config
ARCHDIR-$(CONFIG_TARGET_I386) := x86
ARCHDIR-$(CONFIG_TARGET_ARM) := arm
SUBDIRS-y =
SUBDIRS-y += main fs drivers $(ARCHDIR-y)
SUBDIRS-$(CONFIG_USE_GRUB) += flashupdate
$(foreach subdir,$(SUBDIRS-y),$(eval include $(subdir)/Makefile.inc))
TARGET := $(obj)/filo.elf
OBJS := $(patsubst %,$(obj)/%,$(TARGETS-y))
LIBPAYLOAD_OBJ := $(obj)/libpayload
LIBPAYLOAD_PREFIX ?= $(LIBPAYLOAD_OBJ)
LIBPAYLOAD_DEFCONFIG ?=
ifeq ($(CONFIG_CCACHE),y)
CCACHE := $(word 1,$(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH)))))
endif
all: real-all
# $(LIBPAYLOAD_PREFIX) decides if we build against an installed libpayload.
ifneq ($(wildcard $(LIBPAYLOAD_PREFIX)/lib/libpayload.a),)
include Makefile.standalone
# Otherwise, try to find libpayload sources.
else ifneq ($(wildcard $(LIBCONFIG_PATH)/Makefile.payload),)
include $(LIBCONFIG_PATH)/Makefile.payload
else ifneq ($(wildcard ../../../libpayload/Makefile.payload),)
include ../../../libpayload/Makefile.payload
else ifneq ($(wildcard ../coreboot/payloads/libpayload/Makefile.payload),)
include ../coreboot/payloads/libpayload/Makefile.payload
else
$(error Could not find libpayload.)
endif
ifeq ($(filter %clean,$(MAKECMDGOALS)),)
export KERNELVERSION := $(PROGRAM_VERSION)
export KCONFIG_AUTOHEADER := $(obj)/config.h
export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
export KCONFIG_CONFIG := .config
export KCONFIG_RUSTCCFG := $(obj)/rustc_cfg
CONFIG_SHELL := sh
KBUILD_DEFCONFIG := configs/defconfig
UNAME_RELEASE := $(shell uname -r)
HAVE_DOTCONFIG := $(wildcard .config)
BUILD_INFO = ($(shell whoami)@$(shell hostname)) $(shell LANG=C date)
HOSTCC ?= gcc
HOSTCXX ?= g++
HOSTCFLAGS := -I$(srck) -I$(objk) -pipe
HOSTCXXFLAGS := -I$(srck) -I$(objk) -pipe
ifeq ($(strip $(HAVE_DOTCONFIG)),)
real-all: defconfig
include util/kconfig/Makefile.inc
else
ARCH-$(CONFIG_TARGET_I386) := x86_32
ARCH-$(CONFIG_TARGET_ARM) := arm
ARCH := $(ARCH-y)
OBJCOPY := $(OBJCOPY_$(ARCH-y))
LIBGCC = $(shell $(CC_$(ARCH-y)) $(CFLAGS) -print-libgcc-file-name)
CFLAGS += -imacros $(obj)/config.h
CFLAGS += -I$(ARCHDIR-y)/include -Iinclude -I$(obj)
CFLAGS += -Wshadow -pipe -fomit-frame-pointer -fno-common -fno-strict-aliasing
# FIXME: We override Makefile.payload's -Werror, because
# FILO doesn't build without warnings yet.
CFLAGS += -Wno-error
LIBS := $(LIBPAYLOAD) $(LIBGCC)
real-all: prepare $(TARGET)
$(obj)/filo.bzImage: $(TARGET) $(obj)/x86/linux_head.o
$(OBJCOPY) -O binary $(obj)/x86/linux_head.o [email protected]
$(OBJCOPY) -O binary $< [email protected]
mv [email protected] $@
include util/kconfig/Makefile.inc
$(KCONFIG_AUTOHEADER): $(src)/.config
$(MAKE) syncconfig
$(OBJS): $(KCONFIG_AUTOHEADER) $(obj)/version.h
endif
$(obj)/version.h: Makefile
printf " GEN $(subst $(shell pwd)/,,$(@))\n"
echo '#define PROGRAM_NAME "$(PROGRAM_NAME)"' > $@
echo '#define PROGRAM_VERSION "$(PROGRAM_VERSION)"' >> $@
echo '#define PROGRAM_VERSION_FULL "$(PROGRAM_VERSION) $(BUILD_INFO)"' >> $@
echo '#define BUILD_INFO "$(BUILD_INFO)"' >> $@
$(obj)/%/:
mkdir -p $@
ifndef NOMKDIR
$(shell mkdir -p $(KCONFIG_SPLITCONFIG) $(objk)/lxdialog)
endif
prepare: $(sort $(dir $(OBJS))) $(obj)/util/kconfig/lxdialog/
FORCE:
.PHONY: $(PHONY) prepare libpayload FORCE
else # %clean,$(MAKECMDGOALS)
clean:
rm -rf $(sort $(dir $(OBJS))) $(obj)/util
rm -rf $(obj)/version.h
distclean: clean
rm -rf $(obj)
rm -f .config lib.config .config.old .xcompile ..config.tmp .kconfig.d .tmpconfig*
.PHONY: clean distclean
endif