2 ## This file is part of the libpayload project.
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
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted provided that the following conditions
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.
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
32 export KERNELVERSION := 0.2.0
34 ARCHDIR-$(CONFIG_TARGET_I386) := i386
35 ARCHDIR-$(CONFIG_TARGET_POWERPC) := powerpc
39 classes-$(CONFIG_PCI) += libpci
40 classes-$(CONFIG_LIBC) += libc
41 classes-$(CONFIG_TINYCURSES) += libcurses
42 libraries := $(classes-y)
45 libpci-c-deps = $(obj)/libpayload-config.h
46 libc-c-deps = $(obj)/libpayload-config.h
47 libcurses-c-deps = $(obj)/libpayload-config.h
48 head.o-S-deps = $(obj)/libpayload-config.h
50 subdirs-y := arch/$(ARCHDIR-y)
51 subdirs-y += crypto libc drivers libpci
52 subdirs-$(CONFIG_TINYCURSES) += curses
54 INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj)
55 CFLAGS = $(INCLUDES) -O2 -pipe -g
56 CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
57 CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
58 CFLAGS += -Wstrict-aliasing -Wshadow -fno-builtin
60 $(obj)/libpayload-config.h: $(KCONFIG_AUTOHEADER)
61 cmp $@ $< 2>/dev/null || cp $< $@
63 library-targets = $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a
64 lib: $$(library-targets) $(obj)/head.o
66 $(obj)/libpayload.a: $(foreach class,$(libraries),$$($(class)-objs))
67 printf " AR $(subst $(shell pwd)/,,$(@))\n"
70 $(obj)/%.a: $$(%-objs)
71 printf " AR $(subst $(shell pwd)/,,$(@))\n"
74 $(obj)/head.o: $(obj)/arch/$(ARCHDIR-y)/head.head.o.o
75 printf " CP $(subst $(shell pwd)/,,$(@))\n"
79 printf " INSTALL $(DESTDIR)/libpayload/lib\n"
80 install -m 755 -d $(DESTDIR)/libpayload/lib
81 for lib in $(library-targets); do \
82 install -m 644 $$lib $(DESTDIR)/libpayload/lib/; \
84 install -m 644 lib/libpayload.ldscript $(DESTDIR)/libpayload/lib/
85 install -m 755 -d $(DESTDIR)/libpayload/lib/$(ARCHDIR-y)
86 install -m 644 $(obj)/head.o $(DESTDIR)/libpayload/lib/$(ARCHDIR-y)
87 printf " INSTALL $(DESTDIR)/libpayload/include\n"
88 install -m 755 -d $(DESTDIR)/libpayload/include
89 for file in `find include -name *.h -type f`; do \
90 install -m 755 -d $(DESTDIR)/libpayload/`dirname $$file`; \
91 install -m 644 $$file $(DESTDIR)/libpayload/$$file; \
93 install -m 644 $(obj)/libpayload-config.h $(DESTDIR)/libpayload/include
94 printf " INSTALL $(DESTDIR)/libpayload/bin\n"
95 install -m 755 -d $(DESTDIR)/libpayload/bin
96 install -m 755 bin/lpgcc $(DESTDIR)/libpayload/bin
97 install -m 755 bin/lpas $(DESTDIR)/libpayload/bin
98 install -m 644 bin/lp.functions $(DESTDIR)/libpayload/bin
99 install -m 644 .config $(DESTDIR)/libpayload/libpayload.config
101 clean-for-update-target:
102 rm -f $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a