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
40 classes-$(CONFIG_PCI) += libpci
41 classes-$(CONFIG_LIBC) += libc
42 classes-$(CONFIG_CURSES) += libcurses
43 classes-$(CONFIG_PDCURSES) += libmenu libform libpanel
44 classes-$(CONFIG_CBFS) += libcbfs
45 classes-$(CONFIG_LZMA) += liblzma
46 libraries := $(classes-y)
49 libpci-c-deps = $(obj)/libpayload-config.h
50 libc-c-deps = $(obj)/libpayload-config.h
51 libcurses-c-deps = $(obj)/libpayload-config.h
52 head.o-S-deps = $(obj)/libpayload-config.h
54 subdirs-y := arch/$(ARCHDIR-y)
55 subdirs-y += crypto libc drivers libpci
56 subdirs-$(CONFIG_CURSES) += curses
57 subdirs-$(CONFIG_CBFS) += libcbfs
58 subdirs-$(CONFIG_LZMA) += liblzma
60 INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj)
61 CFLAGS = $(INCLUDES) -O2 -pipe -g
62 CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
63 CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
64 CFLAGS += -Wstrict-aliasing -Wshadow -fno-builtin
66 $(obj)/libpayload-config.h: $(KCONFIG_AUTOHEADER)
67 cmp $@ $< 2>/dev/null || cp $< $@
69 library-targets = $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a
70 lib: $$(library-targets) $(obj)/head.o
72 extract_nth=$(word $(1), $(subst |, ,$(2)))
74 #######################################################################
75 # Add handler for special include files
76 $(call add-special-class,includes)
78 $(if $(wildcard $(1)$(call extract_nth,1,$(2))), \
79 $(eval includes += $(1)$(2)))
81 $(obj)/libpayload.a: $(foreach class,$(libraries),$$($(class)-objs))
82 printf " AR $(subst $(shell pwd)/,,$(@))\n"
85 $(obj)/%.a: $$(%-objs)
86 printf " AR $(subst $(shell pwd)/,,$(@))\n"
89 $(obj)/head.o: $(obj)/arch/$(ARCHDIR-y)/head.head.o.o
90 printf " CP $(subst $(shell pwd)/,,$(@))\n"
94 printf " INSTALL $(DESTDIR)/libpayload/lib\n"
95 install -m 755 -d $(DESTDIR)/libpayload/lib
96 for lib in $(library-targets); do \
97 install -m 644 $$lib $(DESTDIR)/libpayload/lib/; \
99 install -m 644 lib/libpayload.ldscript $(DESTDIR)/libpayload/lib/
100 install -m 755 -d $(DESTDIR)/libpayload/lib/$(ARCHDIR-y)
101 install -m 644 $(obj)/head.o $(DESTDIR)/libpayload/lib/$(ARCHDIR-y)
102 printf " INSTALL $(DESTDIR)/libpayload/include\n"
103 install -m 755 -d $(DESTDIR)/libpayload/include
104 for file in `find include -name *.h -type f`; do \
105 install -m 755 -d $(DESTDIR)/libpayload/`dirname $$file`; \
106 install -m 644 $$file $(DESTDIR)/libpayload/$$file; \
108 install -m 644 $(obj)/libpayload-config.h $(DESTDIR)/libpayload/include
109 $(foreach item,$(includes), \
110 install -m 755 -d $(DESTDIR)/libpayload/include/$(call extract_nth,2,$(item)); \
111 install -m 644 $(call extract_nth,1,$(item)) $(DESTDIR)/libpayload/include/$(call extract_nth,2,$(item)); )
112 printf " INSTALL $(DESTDIR)/libpayload/bin\n"
113 install -m 755 -d $(DESTDIR)/libpayload/bin
114 install -m 755 bin/lpgcc $(DESTDIR)/libpayload/bin
115 install -m 755 bin/lpas $(DESTDIR)/libpayload/bin
116 install -m 644 bin/lp.functions $(DESTDIR)/libpayload/bin
117 install -m 644 .config $(DESTDIR)/libpayload/libpayload.config
119 clean-for-update-target:
120 rm -f $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a