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 libraries := $(classes-y)
47 libpci-c-deps = $(obj)/libpayload-config.h
48 libc-c-deps = $(obj)/libpayload-config.h
49 libcurses-c-deps = $(obj)/libpayload-config.h
50 head.o-S-deps = $(obj)/libpayload-config.h
52 subdirs-y := arch/$(ARCHDIR-y)
53 subdirs-y += crypto libc drivers libpci
54 subdirs-$(CONFIG_CURSES) += curses
56 INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj)
57 CFLAGS = $(INCLUDES) -O2 -pipe -g
58 CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
59 CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
60 CFLAGS += -Wstrict-aliasing -Wshadow -fno-builtin
62 $(obj)/libpayload-config.h: $(KCONFIG_AUTOHEADER)
63 cmp $@ $< 2>/dev/null || cp $< $@
65 library-targets = $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a
66 lib: $$(library-targets) $(obj)/head.o
68 extract_nth=$(word $(1), $(subst |, ,$(2)))
70 #######################################################################
71 # Add handler for special include files
72 $(call add-special-class,includes)
74 $(if $(wildcard $(1)$(call extract_nth,1,$(2))), \
75 $(eval includes += $(1)$(2)))
77 $(obj)/libpayload.a: $(foreach class,$(libraries),$$($(class)-objs))
78 printf " AR $(subst $(shell pwd)/,,$(@))\n"
81 $(obj)/%.a: $$(%-objs)
82 printf " AR $(subst $(shell pwd)/,,$(@))\n"
85 $(obj)/head.o: $(obj)/arch/$(ARCHDIR-y)/head.head.o.o
86 printf " CP $(subst $(shell pwd)/,,$(@))\n"
90 printf " INSTALL $(DESTDIR)/libpayload/lib\n"
91 install -m 755 -d $(DESTDIR)/libpayload/lib
92 for lib in $(library-targets); do \
93 install -m 644 $$lib $(DESTDIR)/libpayload/lib/; \
95 install -m 644 lib/libpayload.ldscript $(DESTDIR)/libpayload/lib/
96 install -m 755 -d $(DESTDIR)/libpayload/lib/$(ARCHDIR-y)
97 install -m 644 $(obj)/head.o $(DESTDIR)/libpayload/lib/$(ARCHDIR-y)
98 printf " INSTALL $(DESTDIR)/libpayload/include\n"
99 install -m 755 -d $(DESTDIR)/libpayload/include
100 for file in `find include -name *.h -type f`; do \
101 install -m 755 -d $(DESTDIR)/libpayload/`dirname $$file`; \
102 install -m 644 $$file $(DESTDIR)/libpayload/$$file; \
104 install -m 644 $(obj)/libpayload-config.h $(DESTDIR)/libpayload/include
105 $(foreach item,$(includes), \
106 install -m 755 -d $(DESTDIR)/libpayload/include/$(call extract_nth,2,$(item)); \
107 install -m 644 $(call extract_nth,1,$(item)) $(DESTDIR)/libpayload/include/$(call extract_nth,2,$(item)); )
108 printf " INSTALL $(DESTDIR)/libpayload/bin\n"
109 install -m 755 -d $(DESTDIR)/libpayload/bin
110 install -m 755 bin/lpgcc $(DESTDIR)/libpayload/bin
111 install -m 755 bin/lpas $(DESTDIR)/libpayload/bin
112 install -m 644 bin/lp.functions $(DESTDIR)/libpayload/bin
113 install -m 644 .config $(DESTDIR)/libpayload/libpayload.config
115 clean-for-update-target:
116 rm -f $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a