Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 1 | ## |
| 2 | ## This file is part of the libpayload project. |
| 3 | ## |
| 4 | ## Copyright (C) 2008 Advanced Micro Devices, Inc. |
| 5 | ## Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de> |
| 6 | ## Copyright (C) 2011 secunet Security Networks AG |
| 7 | ## |
| 8 | ## Redistribution and use in source and binary forms, with or without |
| 9 | ## modification, are permitted provided that the following conditions |
| 10 | ## are met: |
| 11 | ## 1. Redistributions of source code must retain the above copyright |
| 12 | ## notice, this list of conditions and the following disclaimer. |
| 13 | ## 2. Redistributions in binary form must reproduce the above copyright |
| 14 | ## notice, this list of conditions and the following disclaimer in the |
| 15 | ## documentation and/or other materials provided with the distribution. |
| 16 | ## 3. The name of the author may not be used to endorse or promote products |
| 17 | ## derived from this software without specific prior written permission. |
| 18 | ## |
| 19 | ## THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 20 | ## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 | ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 | ## ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 23 | ## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 24 | ## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 25 | ## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 26 | ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 27 | ## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 28 | ## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 29 | ## SUCH DAMAGE. |
| 30 | ## |
| 31 | |
| 32 | export KERNELVERSION := 0.2.0 |
| 33 | |
Gabe Black | 51edd54 | 2013-09-30 23:00:33 -0700 | [diff] [blame] | 34 | ARCHDIR-$(CONFIG_LP_ARCH_ARM) := arm |
Furquan Shaikh | 8c8c377 | 2014-02-19 11:35:30 -0800 | [diff] [blame] | 35 | ARCHDIR-$(CONFIG_LP_ARCH_ARM64) := arm64 |
Gabe Black | 1ee2c6d | 2013-08-09 04:27:35 -0700 | [diff] [blame] | 36 | ARCHDIR-$(CONFIG_LP_ARCH_X86) := x86 |
Tadas Slotkus | 09ea8ea | 2011-07-15 03:41:11 +0300 | [diff] [blame] | 37 | DESTDIR ?= install |
Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 38 | |
| 39 | real-target: lib |
| 40 | |
Gabe Black | 1ee2c6d | 2013-08-09 04:27:35 -0700 | [diff] [blame] | 41 | classes-$(CONFIG_LP_PCI) += libpci |
| 42 | classes-$(CONFIG_LP_LIBC) += libc |
| 43 | classes-$(CONFIG_LP_CURSES) += libcurses |
| 44 | classes-$(CONFIG_LP_PDCURSES) += libmenu libform libpanel |
| 45 | classes-$(CONFIG_LP_CBFS) += libcbfs |
| 46 | classes-$(CONFIG_LP_LZMA) += liblzma |
Julius Werner | bf27391 | 2015-06-30 10:30:30 -0700 | [diff] [blame] | 47 | classes-$(CONFIG_LP_LZ4) += liblz4 |
Julius Werner | 50a8174 | 2014-05-15 11:57:38 -0700 | [diff] [blame] | 48 | classes-$(CONFIG_LP_REMOTEGDB) += libgdb |
Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 49 | libraries := $(classes-y) |
| 50 | classes-y += head.o |
| 51 | |
Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 52 | subdirs-y := arch/$(ARCHDIR-y) |
Julius Werner | 50a8174 | 2014-05-15 11:57:38 -0700 | [diff] [blame] | 53 | subdirs-y += crypto libc drivers libpci gdb |
Gabe Black | 1ee2c6d | 2013-08-09 04:27:35 -0700 | [diff] [blame] | 54 | subdirs-$(CONFIG_LP_CURSES) += curses |
| 55 | subdirs-$(CONFIG_LP_CBFS) += libcbfs |
| 56 | subdirs-$(CONFIG_LP_LZMA) += liblzma |
Julius Werner | bf27391 | 2015-06-30 10:30:30 -0700 | [diff] [blame] | 57 | subdirs-$(CONFIG_LP_LZ4) += liblz4 |
Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 58 | |
Stefan Reinauer | 1b4d394 | 2015-06-29 15:47:34 -0700 | [diff] [blame] | 59 | INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj) -include include/kconfig.h |
| 60 | |
Patrick Georgi | 9b8c738 | 2015-07-06 09:09:30 +0000 | [diff] [blame] | 61 | CFLAGS += $(EXTRA_CFLAGS) $(INCLUDES) -Os -pipe -nostdinc -ggdb3 |
Stefan Reinauer | 08c4150 | 2013-05-21 14:45:28 -0700 | [diff] [blame] | 62 | CFLAGS += -nostdlib -fno-builtin -ffreestanding -fomit-frame-pointer |
Stefan Reinauer | e559536 | 2015-07-01 11:30:03 -0700 | [diff] [blame] | 63 | CFLAGS += -ffunction-sections -fdata-sections |
Jacob Garber | 9cd53c5 | 2019-06-27 13:23:38 -0600 | [diff] [blame] | 64 | CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wvla |
Jacob Garber | 5f7b116 | 2019-07-19 17:35:28 -0600 | [diff] [blame] | 65 | CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs -Wimplicit-fallthrough |
Vadim Bendebury | 19c3da5 | 2014-05-15 14:12:54 -0700 | [diff] [blame] | 66 | CFLAGS += -Wstrict-aliasing -Wshadow -Werror |
Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 67 | |
| 68 | $(obj)/libpayload-config.h: $(KCONFIG_AUTOHEADER) |
| 69 | cmp $@ $< 2>/dev/null || cp $< $@ |
| 70 | |
| 71 | library-targets = $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a |
| 72 | lib: $$(library-targets) $(obj)/head.o |
| 73 | |
Patrick Georgi | 3b77b72 | 2011-07-07 15:41:53 +0200 | [diff] [blame] | 74 | extract_nth=$(word $(1), $(subst |, ,$(2))) |
| 75 | |
| 76 | ####################################################################### |
Martin Roth | 6116f36 | 2016-03-08 12:32:40 -0700 | [diff] [blame] | 77 | # Add handler for special include files |
Patrick Georgi | 3b77b72 | 2011-07-07 15:41:53 +0200 | [diff] [blame] | 78 | $(call add-special-class,includes) |
| 79 | includes-handler= \ |
| 80 | $(if $(wildcard $(1)$(call extract_nth,1,$(2))), \ |
| 81 | $(eval includes += $(1)$(2))) |
| 82 | |
Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 83 | $(obj)/libpayload.a: $(foreach class,$(libraries),$$($(class)-objs)) |
Martin Roth | 6116f36 | 2016-03-08 12:32:40 -0700 | [diff] [blame] | 84 | printf " AR $(subst $(CURDIR)/,,$(@))\n" |
Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 85 | $(AR) rc $@ $^ |
| 86 | |
| 87 | $(obj)/%.a: $$(%-objs) |
Martin Roth | 6116f36 | 2016-03-08 12:32:40 -0700 | [diff] [blame] | 88 | printf " AR $(subst $(CURDIR)/,,$(@))\n" |
Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 89 | $(AR) rc $@ $^ |
| 90 | |
| 91 | $(obj)/head.o: $(obj)/arch/$(ARCHDIR-y)/head.head.o.o |
Martin Roth | 6116f36 | 2016-03-08 12:32:40 -0700 | [diff] [blame] | 92 | printf " CP $(subst $(CURDIR)/,,$(@))\n" |
Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 93 | cp $^ $@ |
| 94 | |
| 95 | install: real-target |
| 96 | printf " INSTALL $(DESTDIR)/libpayload/lib\n" |
| 97 | install -m 755 -d $(DESTDIR)/libpayload/lib |
| 98 | for lib in $(library-targets); do \ |
| 99 | install -m 644 $$lib $(DESTDIR)/libpayload/lib/; \ |
| 100 | done |
Ronald G. Minnich | c2e8cf5 | 2013-02-14 11:32:29 -0800 | [diff] [blame] | 101 | install -m 644 arch/$(ARCHDIR-y)/libpayload.ldscript $(DESTDIR)/libpayload/lib/ |
Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 102 | install -m 755 -d $(DESTDIR)/libpayload/lib/$(ARCHDIR-y) |
| 103 | install -m 644 $(obj)/head.o $(DESTDIR)/libpayload/lib/$(ARCHDIR-y) |
| 104 | printf " INSTALL $(DESTDIR)/libpayload/include\n" |
| 105 | install -m 755 -d $(DESTDIR)/libpayload/include |
| 106 | for file in `find include -name *.h -type f`; do \ |
| 107 | install -m 755 -d $(DESTDIR)/libpayload/`dirname $$file`; \ |
| 108 | install -m 644 $$file $(DESTDIR)/libpayload/$$file; \ |
| 109 | done |
| 110 | install -m 644 $(obj)/libpayload-config.h $(DESTDIR)/libpayload/include |
Patrick Georgi | 3b77b72 | 2011-07-07 15:41:53 +0200 | [diff] [blame] | 111 | $(foreach item,$(includes), \ |
| 112 | install -m 755 -d $(DESTDIR)/libpayload/include/$(call extract_nth,2,$(item)); \ |
| 113 | install -m 644 $(call extract_nth,1,$(item)) $(DESTDIR)/libpayload/include/$(call extract_nth,2,$(item)); ) |
Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 114 | printf " INSTALL $(DESTDIR)/libpayload/bin\n" |
| 115 | install -m 755 -d $(DESTDIR)/libpayload/bin |
| 116 | install -m 755 bin/lpgcc $(DESTDIR)/libpayload/bin |
| 117 | install -m 755 bin/lpas $(DESTDIR)/libpayload/bin |
| 118 | install -m 644 bin/lp.functions $(DESTDIR)/libpayload/bin |
Stefan Reinauer | 658e4d3 | 2013-01-17 12:29:51 -0800 | [diff] [blame] | 119 | install -m 644 $(DOTCONFIG) $(DESTDIR)/libpayload/libpayload.config |
Stefan Reinauer | 5d86621 | 2015-07-08 17:09:49 -0700 | [diff] [blame] | 120 | install -m 755 .xcompile $(DESTDIR)/libpayload/libpayload.xcompile |
Patrick Georgi | b3db79e | 2011-04-21 18:48:50 +0200 | [diff] [blame] | 121 | |
| 122 | clean-for-update-target: |
| 123 | rm -f $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a |
| 124 | |
| 125 | clean-target: |
| 126 | prepare: |
Patrick Georgi | 34286b8 | 2013-12-21 21:08:53 +0100 | [diff] [blame] | 127 | |
| 128 | junit.xml: |
| 129 | echo '<?xml version="1.0" encoding="utf-8"?><testsuite>' > $@.tmp |
| 130 | for i in $(filter-out %.old,$(wildcard configs/*)); do \ |
| 131 | $(MAKE) clean; \ |
Keith Short | 31af70d | 2019-07-11 17:54:57 -0600 | [diff] [blame] | 132 | echo "Building libpayload for $$i"; \ |
Martin Roth | 6959f5c | 2016-03-23 16:07:54 -0600 | [diff] [blame] | 133 | cp "$$i" junit_config; \ |
| 134 | $(MAKE) olddefconfig DOTCONFIG=junit_config V=$(V) Q=$(Q) 2>/dev/null >/dev/null; \ |
Patrick Georgi | 34286b8 | 2013-12-21 21:08:53 +0100 | [diff] [blame] | 135 | echo "<testcase classname='libpayload' name='$$i'>" >> $@.tmp; \ |
Martin Roth | 6959f5c | 2016-03-23 16:07:54 -0600 | [diff] [blame] | 136 | $(MAKE) V=$(V) Q=$(Q) CONFIG_LP_CCACHE=$(CONFIG_LP_CCACHE) DOTCONFIG=junit_config >> $@.tmp.2 2>&1 && type="system-out" || type="failure"; \ |
Patrick Georgi | 34286b8 | 2013-12-21 21:08:53 +0100 | [diff] [blame] | 137 | if [ $$type = "failure" ]; then \ |
| 138 | echo "<failure type='buildFailed'>" >> $@.tmp; \ |
| 139 | else \ |
| 140 | echo "<$$type>" >> $@.tmp; \ |
| 141 | fi; \ |
| 142 | echo '<![CDATA[' >> $@.tmp; \ |
| 143 | cat $@.tmp.2 >> $@.tmp; \ |
| 144 | echo "]]></$$type>" >>$@.tmp; \ |
| 145 | rm -f $@.tmp.2; \ |
| 146 | echo "</testcase>" >> $@.tmp; \ |
| 147 | done |
| 148 | echo "</testsuite>" >> $@.tmp |
Keith Short | 31af70d | 2019-07-11 17:54:57 -0600 | [diff] [blame] | 149 | echo "libpayload build complete, test results in $@" |
Patrick Georgi | 34286b8 | 2013-12-21 21:08:53 +0100 | [diff] [blame] | 150 | mv $@.tmp $@ |
Martin Roth | 6c9c196 | 2017-08-03 09:25:43 -0600 | [diff] [blame] | 151 | |
| 152 | test-configs: |
| 153 | for config in $(filter-out %.old,$(wildcard configs/*)); do \ |
| 154 | $(MAKE) clean; \ |
| 155 | cp "$$config" test_config; \ |
| 156 | echo "*** Making libpayload config $$config ***"; \ |
| 157 | $(MAKE) olddefconfig DOTCONFIG=test_config V=$(V) Q=$(Q) ; \ |
| 158 | $(MAKE) V=$(V) Q=$(Q) CONFIG_LP_CCACHE=$(CONFIG_LP_CCACHE) DOTCONFIG=test_config; \ |
| 159 | done |