soc/intel: Remove blank lines before '}' and after '{'
[coreboot2.git] / payloads / libpayload / Makefile.mk
blobafaa06dd3d543a9435ca827cff8dbcc336054ec2
1 ##
2 ##
3 ## Copyright (C) 2008 Advanced Micro Devices, Inc.
4 ## Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
5 ## Copyright (C) 2011 secunet Security Networks AG
6 ##
7 ## Redistribution and use in source and binary forms, with or without
8 ## modification, are permitted provided that the following conditions
9 ## are met:
10 ## 1. Redistributions of source code must retain the above copyright
11 ## notice, this list of conditions and the following disclaimer.
12 ## 2. Redistributions in binary form must reproduce the above copyright
13 ## notice, this list of conditions and the following disclaimer in the
14 ## documentation and/or other materials provided with the distribution.
15 ## 3. The name of the author may not be used to endorse or promote products
16 ## derived from this software without specific prior written permission.
18 ## THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 ## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ## ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 ## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 ## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 ## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 ## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 ## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 ## SUCH DAMAGE.
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
38 export KERNELVERSION := 0.2.0
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
46 real-target: lib
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 classes-y += head.o
61 subdirs-y := arch/$(ARCHDIR-y)
62 subdirs-y += crypto libc drivers libpci gdb
63 subdirs-$(CONFIG_LP_CURSES) += curses
64 subdirs-$(CONFIG_LP_CBFS) += libcbfs
65 subdirs-$(CONFIG_LP_LZMA) += liblzma
66 subdirs-$(CONFIG_LP_LZ4) += liblz4
67 subdirs-$(CONFIG_LP_VBOOT_LIB) += vboot
69 INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj)
70 INCLUDES += -include include/kconfig.h
71 INCLUDES += -include $(coreboottop)/src/commonlib/bsd/include/commonlib/bsd/compiler.h
72 INCLUDES += -I$(coreboottop)/src/commonlib/bsd/include
73 ifeq ($(CONFIG_LP_GPL),y)
74 INCLUDES += -I$(coreboottop)/src/commonlib/include
75 endif
76 INCLUDES += -I$(VBOOT_SOURCE)/firmware/include
78 CFLAGS += $(INCLUDES) -Os -pipe -nostdinc -ggdb3
79 CFLAGS += -nostdlib -fno-builtin -ffreestanding -fomit-frame-pointer
80 CFLAGS += -ffunction-sections -fdata-sections
81 CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wvla
82 CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs -Wimplicit-fallthrough
83 CFLAGS += -Wstrict-aliasing -Wshadow -Werror
85 ifeq ($(CONFIG_LP_LTO),y)
86 CFLAGS += -flto
87 endif
89 # Some of the commonlib cbfs headers include vboot headers, so initialize the
90 # submodule in case we are building a payload outside the main coreboot build
91 forgetthis:=$(if $(GIT),$(shell git submodule update --init ../../3rdparty/vboot $(quiet_errors)))
93 $(obj)/libpayload.config: $(DOTCONFIG)
94 cp $< $@
96 $(obj)/libpayload-config.h: $(KCONFIG_AUTOHEADER) $(obj)/libpayload.config
97 cmp $@ $< 2>/dev/null || cp $< $@
99 library-targets = $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a
100 lib: $$(library-targets) $(obj)/head.o
102 extract_nth=$(word $(1), $(subst |, ,$(2)))
104 #######################################################################
105 # Add handler for special include files
106 $(call add-special-class,includes)
107 includes-handler= \
108 $(if $(wildcard $(1)$(call extract_nth,1,$(2))), \
109 $(eval includes += $(1)$(2)))
111 $(obj)/libpayload.a: $(foreach class,$(libraries),$$($(class)-objs))
112 printf " AR $(subst $(CURDIR)/,,$(@))\n"
113 printf "create $@\n$(foreach objc,$(filter-out %.a,$^),addmod $(objc)\n)$(foreach lib,$(filter %.a,$^),addlib $(lib)\n)save\nend\n" | $(AR) -M
115 $(obj)/%.a: $$(%-objs)
116 printf " AR $(subst $(CURDIR)/,,$(@))\n"
117 printf "create $@\n$(foreach objc,$(filter-out %.a,$^),addmod $(objc)\n)$(foreach lib,$(filter %.a,$^),addlib $(lib)\n)save\nend\n" | $(AR) -M
119 $(obj)/head.o: $(obj)/arch/$(ARCHDIR-y)/head.head.o.o
120 printf " CP $(subst $(CURDIR)/,,$(@))\n"
121 cp $^ $@
123 install: real-target
124 printf " INSTALL $(DESTDIR)/libpayload/lib\n"
125 install -m 755 -d $(DESTDIR)/libpayload/lib
126 install -m 644 $(library-targets) $(DESTDIR)/libpayload/lib/
127 install -m 644 arch/$(ARCHDIR-y)/libpayload.ldscript $(DESTDIR)/libpayload/lib/
128 install -m 755 -d $(DESTDIR)/libpayload/lib/$(ARCHDIR-y)
129 install -m 644 $(obj)/head.o $(DESTDIR)/libpayload/lib/$(ARCHDIR-y)
130 printf " INSTALL $(DESTDIR)/libpayload/include\n"
131 install -m 755 -d $(DESTDIR)/libpayload/include
132 find include -type d -exec install -m755 -d $(DESTDIR)/libpayload/{} \;
133 find include -type f -exec install -m644 {} $(DESTDIR)/libpayload/{} \;
134 cd $(coreboottop)/src/commonlib/bsd && find include -type d -exec install -m755 -d $(abspath $(DESTDIR))/libpayload/{} \;
135 cd $(coreboottop)/src/commonlib/bsd && find include -type f -exec install -m644 {} $(abspath $(DESTDIR))/libpayload/{} \;
136 ifeq ($(CONFIG_LP_GPL),y)
137 cd $(coreboottop)/src/commonlib && find include -type d -exec install -m755 -d $(abspath $(DESTDIR))/libpayload/{} \;
138 cd $(coreboottop)/src/commonlib && find include -type f -exec install -m644 {} $(abspath $(DESTDIR))/libpayload/{} \;
139 endif
140 install -m 644 $(obj)/libpayload-config.h $(DESTDIR)/libpayload/include
141 $(foreach item,$(includes), \
142 install -m 755 -d $(DESTDIR)/libpayload/include/$(call extract_nth,2,$(item)); \
143 install -m 644 $(call extract_nth,1,$(item)) $(DESTDIR)/libpayload/include/$(call extract_nth,2,$(item)); )
144 printf " INSTALL $(DESTDIR)/libpayload/vboot\n"
145 install -m 755 -d $(DESTDIR)/libpayload/vboot
146 for file in `find $(VBOOT_SOURCE)/firmware/include \
147 $(VBOOT_SOURCE)/firmware/2lib/include \
148 -iname '*.h' -type f \
149 | sed 's,$(VBOOT_SOURCE)/firmware/,,'`; do \
150 install -m 755 -d $(DESTDIR)/libpayload/vboot/$$(dirname $$file); \
151 install -m 644 $(VBOOT_SOURCE)/firmware/$$file $(DESTDIR)/libpayload/vboot/$$file ; \
152 done
153 printf " INSTALL $(DESTDIR)/libpayload/bin\n"
154 install -m 755 -d $(DESTDIR)/libpayload/bin
155 install -m 755 bin/lpgcc $(DESTDIR)/libpayload/bin
156 install -m 755 bin/lpas $(DESTDIR)/libpayload/bin
157 install -m 644 bin/lp.functions $(DESTDIR)/libpayload/bin
158 install -m 644 $(DOTCONFIG) $(DESTDIR)/libpayload/libpayload.config
159 install -m 755 $(xcompile) $(DESTDIR)/libpayload/libpayload.xcompile
161 clean-for-update-target:
162 rm -f $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a
164 clean-target:
165 prepare:
167 junit.xml:
168 echo '<?xml version="1.0" encoding="utf-8"?><testsuite>' > $@.tmp
169 for i in $(filter-out %.old %.unit-tests,$(wildcard configs/*)); do \
170 $(MAKE) clean; \
171 echo "Building libpayload for $$i"; \
172 cp "$$i" junit_config; \
173 $(MAKE) olddefconfig DOTCONFIG=junit_config V=$(V) Q=$(Q) 2>/dev/null >/dev/null; \
174 echo "<testcase classname='libpayload' name='$$i'>" >> $@.tmp; \
175 $(MAKE) V=$(V) Q=$(Q) CONFIG_LP_CCACHE=$(CONFIG_LP_CCACHE) DOTCONFIG=junit_config >> $@.tmp.2 2>&1 && type="system-out" || type="failure"; \
176 if [ $$type = "failure" ]; then \
177 echo "<failure type='buildFailed'>" >> $@.tmp; \
178 else \
179 echo "<$$type>" >> $@.tmp; \
180 fi; \
181 echo '<![CDATA[' >> $@.tmp; \
182 cat $@.tmp.2 >> $@.tmp; \
183 echo "]]></$$type>" >>$@.tmp; \
184 rm -f $@.tmp.2; \
185 echo "</testcase>" >> $@.tmp; \
186 done
187 echo "</testsuite>" >> $@.tmp
188 echo "libpayload build complete, test results in $@"
189 mv $@.tmp $@
191 test-configs:
192 for config in $(filter-out %.old %.unit-tests,$(wildcard configs/*)); do \
193 $(MAKE) clean; \
194 cp "$$config" test_config; \
195 echo "*** Making libpayload config $$config ***"; \
196 $(MAKE) olddefconfig DOTCONFIG=test_config V=$(V) Q=$(Q) ; \
197 $(MAKE) V=$(V) Q=$(Q) CONFIG_LP_CCACHE=$(CONFIG_LP_CCACHE) DOTCONFIG=test_config; \
198 done