| 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 |
ifneq ($(NOCOMPILE),1) |
| 32 |
GIT:=$(shell git -C "$(top)" rev-parse --git-dir 1>/dev/null 2>&1 \ |
| 33 |
&& command -v git) |
| 34 |
else |
| 35 |
GIT:= |
| 36 |
endif |
| 37 |
|
| 38 |
export KERNELVERSION := 0.2.0 |
| 39 |
|
| 40 |
ARCHDIR-$(CONFIG_LP_ARCH_ARM) := arm |
| 41 |
ARCHDIR-$(CONFIG_LP_ARCH_ARM64) := arm64 |
| 42 |
ARCHDIR-$(CONFIG_LP_ARCH_X86) := x86 |
| 43 |
ARCHDIR-$(CONFIG_LP_ARCH_MOCK) := mock |
| 44 |
DESTDIR ?= install |
| 45 |
|
| 46 |
real-target: lib |
| 47 |
|
| 48 |
classes-$(CONFIG_LP_PCI) += libpci |
| 49 |
classes-$(CONFIG_LP_LIBC) += libc |
| 50 |
classes-$(CONFIG_LP_CURSES) += libcurses |
| 51 |
classes-$(CONFIG_LP_PDCURSES) += libmenu libform libpanel |
| 52 |
classes-$(CONFIG_LP_CBFS) += libcbfs |
| 53 |
classes-$(CONFIG_LP_LZMA) += liblzma |
| 54 |
classes-$(CONFIG_LP_LZ4) += liblz4 |
| 55 |
classes-$(CONFIG_LP_REMOTEGDB) += libgdb |
| 56 |
classes-$(CONFIG_LP_VBOOT_LIB) += vboot_fw |
| 57 |
classes-$(CONFIG_LP_VBOOT_LIB) += tlcl |
| 58 |
libraries := $(classes-y) |
| 59 |
|
| 60 |
subdirs-y := arch/$(ARCHDIR-y) |
| 61 |
subdirs-y += crypto libc drivers libpci gdb |
| 62 |
subdirs-$(CONFIG_LP_CURSES) += curses |
| 63 |
subdirs-$(CONFIG_LP_CBFS) += libcbfs |
| 64 |
subdirs-$(CONFIG_LP_LZMA) += liblzma |
| 65 |
subdirs-$(CONFIG_LP_LZ4) += liblz4 |
| 66 |
subdirs-$(CONFIG_LP_VBOOT_LIB) += vboot |
| 67 |
|
| 68 |
INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj) |
| 69 |
INCLUDES += -include include/kconfig.h |
| 70 |
INCLUDES += -include $(coreboottop)/src/commonlib/bsd/include/commonlib/bsd/compiler.h |
| 71 |
INCLUDES += -I$(coreboottop)/src/commonlib/bsd/include |
| 72 |
ifeq ($(CONFIG_LP_GPL),y) |
| 73 |
INCLUDES += -I$(coreboottop)/src/commonlib/include |
| 74 |
endif |
| 75 |
INCLUDES += -I$(VBOOT_SOURCE)/firmware/include |
| 76 |
|
| 77 |
CFLAGS += $(INCLUDES) -Os -pipe -nostdinc -ggdb3 |
| 78 |
CFLAGS += -nostdlib -fno-builtin -ffreestanding -fomit-frame-pointer |
| 79 |
CFLAGS += -ffunction-sections -fdata-sections |
| 80 |
CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wvla |
| 81 |
CFLAGS += -Wwrite-strings -Wredundant-decls -Wimplicit-fallthrough |
| 82 |
CFLAGS += -Wstrict-aliasing -Wshadow -Wno-address-of-packed-member -Werror |
| 83 |
|
| 84 |
ifeq ($(CONFIG_LP_LTO),y) |
| 85 |
CFLAGS += -flto |
| 86 |
endif |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
forgetthis:=$(if $(GIT),$(shell git submodule update --init ../../3rdparty/vboot $(quiet_errors))) |
| 91 |
|
| 92 |
$(obj)/libpayload.config: $(DOTCONFIG) |
| 93 |
cp $< $@ |
| 94 |
|
| 95 |
$(obj)/libpayload-config.h: $(KCONFIG_AUTOHEADER) $(obj)/libpayload.config |
| 96 |
cmp $@ $< 2>/dev/null || cp $< $@ |
| 97 |
|
| 98 |
library-targets = $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a |
| 99 |
lib: $$(library-targets) $(obj)/libpayload.ldscript |
| 100 |
|
| 101 |
extract_nth=$(word $(1), $(subst |, ,$(2))) |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
$(call add-special-class,includes) |
| 106 |
includes-handler= \ |
| 107 |
$(if $(wildcard $(1)$(call extract_nth,1,$(2))), \ |
| 108 |
$(eval includes += $(1)$(2))) |
| 109 |
|
| 110 |
$(obj)/libpayload.a: $(foreach class,$(libraries),$$($(class)-objs)) |
| 111 |
printf " AR $(subst $(CURDIR)/,,$(@))\n" |
| 112 |
printf "create $@\n$(foreach objc,$(filter-out %.a,$^),addmod $(objc)\n)$(foreach lib,$(filter %.a,$^),addlib $(lib)\n)save\nend\n" | $(AR) -M |
| 113 |
for func in $$($(NM) $@ | awk '/ (w|W) / { print $$NF }'); do \ |
| 114 |
if $(NM) --no-weak --defined-only $@ | grep -Eq " $$func$$"; then \ |
| 115 |
printf "\nERROR: Function '$$func' appears as both weak and strong symbol in libpayload.\n"; \ |
| 116 |
printf " Weak symbol overrides don't work reliably from within the same library.\n\n"; \ |
| 117 |
rm $@; \ |
| 118 |
exit 1; \ |
| 119 |
fi \ |
| 120 |
done |
| 121 |
|
| 122 |
$(obj)/%.a: $$(%-objs) |
| 123 |
printf " AR $(subst $(CURDIR)/,,$(@))\n" |
| 124 |
printf "create $@\n$(foreach objc,$(filter-out %.a,$^),addmod $(objc)\n)$(foreach lib,$(filter %.a,$^),addlib $(lib)\n)save\nend\n" | $(AR) -M |
| 125 |
|
| 126 |
$(obj)/libpayload.ldscript: arch/$(ARCHDIR-y)/libpayload.ldscript $(obj)/libpayload-config.h |
| 127 |
@printf " LDSCRIPT $@\n" |
| 128 |
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -E -P -x assembler-with-cpp -undef -o $@ $< |
| 129 |
|
| 130 |
install: real-target |
| 131 |
printf " INSTALL $(DESTDIR)/libpayload/lib\n" |
| 132 |
install -m 755 -d $(DESTDIR)/libpayload/lib |
| 133 |
install -m 644 $(library-targets) $(DESTDIR)/libpayload/lib/ |
| 134 |
install -m 644 $(obj)/libpayload.ldscript $(DESTDIR)/libpayload/lib/ |
| 135 |
install -m 755 -d $(DESTDIR)/libpayload/lib/$(ARCHDIR-y) |
| 136 |
printf " INSTALL $(DESTDIR)/libpayload/include\n" |
| 137 |
install -m 755 -d $(DESTDIR)/libpayload/include |
| 138 |
find include -type d -exec install -m755 -d $(DESTDIR)/libpayload/{} \; |
| 139 |
find include -type f -exec install -m644 {} $(DESTDIR)/libpayload/{} \; |
| 140 |
cd $(coreboottop)/src/commonlib/bsd && find include -type d -exec install -m755 -d $(abspath $(DESTDIR))/libpayload/{} \; |
| 141 |
cd $(coreboottop)/src/commonlib/bsd && find include -type f -exec install -m644 {} $(abspath $(DESTDIR))/libpayload/{} \; |
| 142 |
ifeq ($(CONFIG_LP_GPL),y) |
| 143 |
cd $(coreboottop)/src/commonlib && find include -type d -exec install -m755 -d $(abspath $(DESTDIR))/libpayload/{} \; |
| 144 |
cd $(coreboottop)/src/commonlib && find include -type f -exec install -m644 {} $(abspath $(DESTDIR))/libpayload/{} \; |
| 145 |
endif |
| 146 |
install -m 644 $(obj)/libpayload-config.h $(DESTDIR)/libpayload/include |
| 147 |
$(foreach item,$(includes), \ |
| 148 |
install -m 755 -d $(DESTDIR)/libpayload/include/$(call extract_nth,2,$(item)); \ |
| 149 |
install -m 644 $(call extract_nth,1,$(item)) $(DESTDIR)/libpayload/include/$(call extract_nth,2,$(item)); ) |
| 150 |
printf " INSTALL $(DESTDIR)/libpayload/vboot\n" |
| 151 |
install -m 755 -d $(DESTDIR)/libpayload/vboot |
| 152 |
for file in `find $(VBOOT_SOURCE)/firmware/include \ |
| 153 |
$(VBOOT_SOURCE)/firmware/2lib/include \ |
| 154 |
-iname '*.h' -type f \ |
| 155 |
| sed 's,$(VBOOT_SOURCE)/firmware/,,'`; do \ |
| 156 |
install -m 755 -d $(DESTDIR)/libpayload/vboot/$$(dirname $$file); \ |
| 157 |
install -m 644 $(VBOOT_SOURCE)/firmware/$$file $(DESTDIR)/libpayload/vboot/$$file ; \ |
| 158 |
done |
| 159 |
printf " INSTALL $(DESTDIR)/libpayload/bin\n" |
| 160 |
install -m 755 -d $(DESTDIR)/libpayload/bin |
| 161 |
install -m 755 bin/lpgcc $(DESTDIR)/libpayload/bin |
| 162 |
install -m 755 bin/lpas $(DESTDIR)/libpayload/bin |
| 163 |
install -m 644 bin/lp.functions $(DESTDIR)/libpayload/bin |
| 164 |
install -m 644 $(DOTCONFIG) $(DESTDIR)/libpayload/libpayload.config |
| 165 |
install -m 755 $(xcompile) $(DESTDIR)/libpayload/libpayload.xcompile |
| 166 |
|
| 167 |
clean-for-update-target: |
| 168 |
rm -f $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a |
| 169 |
|
| 170 |
clean-target: |
| 171 |
prepare: |
| 172 |
|
| 173 |
junit.xml: |
| 174 |
echo '<?xml version="1.0" encoding="utf-8"?><testsuite>' > [email protected] |
| 175 |
for i in $(filter-out %.old %.unit-tests,$(wildcard configs/*)); do \ |
| 176 |
$(MAKE) clean; \ |
| 177 |
echo "Building libpayload for $$i"; \ |
| 178 |
cp "$$i" junit_config; \ |
| 179 |
$(MAKE) olddefconfig DOTCONFIG=junit_config V=$(V) Q=$(Q) 2>/dev/null >/dev/null; \ |
| 180 |
echo "<testcase classname='libpayload' name='$$i'>" >> [email protected]; \ |
| 181 |
$(MAKE) V=$(V) Q=$(Q) CONFIG_LP_CCACHE=$(CONFIG_LP_CCACHE) DOTCONFIG=junit_config >> [email protected] 2>&1 && type="system-out" || type="failure"; \ |
| 182 |
if [ $$type = "failure" ]; then \ |
| 183 |
echo "<failure type='buildFailed'>" >> [email protected]; \ |
| 184 |
else \ |
| 185 |
echo "<$$type>" >> [email protected]; \ |
| 186 |
fi; \ |
| 187 |
echo '<![CDATA[' >> [email protected]; \ |
| 188 |
cat [email protected] >> [email protected]; \ |
| 189 |
echo "]]></$$type>" >>[email protected]; \ |
| 190 |
rm -f [email protected]; \ |
| 191 |
echo "</testcase>" >> [email protected]; \ |
| 192 |
done |
| 193 |
echo "</testsuite>" >> [email protected] |
| 194 |
echo "libpayload build complete, test results in $@" |
| 195 |
mv [email protected] $@ |
| 196 |
|
| 197 |
test-configs: |
| 198 |
for config in $(filter-out %.old %.unit-tests,$(wildcard configs/*)); do \ |
| 199 |
$(MAKE) clean; \ |
| 200 |
cp "$$config" test_config; \ |
| 201 |
echo "*** Making libpayload config $$config ***"; \ |
| 202 |
$(MAKE) olddefconfig DOTCONFIG=test_config V=$(V) Q=$(Q) ; \ |
| 203 |
$(MAKE) V=$(V) Q=$(Q) CONFIG_LP_CCACHE=$(CONFIG_LP_CCACHE) DOTCONFIG=test_config; \ |
| 204 |
done |