The first version that was demonstrated to get an IPv6 address
[firmerware] / Makefile
1
2 # TODO: this should be src/Kconfig
3 Kconfig := src/target/Kconfig
4
5 #
6 # Default target "all"
7 #
8 .PHONY += all
9 all: configincludes tags bin/firmerware.bin
10
11 #
12 # Builder helping hand
13 #
14 .PHONY += help
15 help:
16         @echo
17         @echo "*** Try 'make menuconfig' followed by 'make'"
18         @echo "    Learn about object sizes at any stage with 'make size'"
19         @echo
20         @echo Platform-specific notes are part of the target help descriptions.
21         @echo
22
23
24 #
25 # Load configuration file and various Makefiles
26 #
27 -include .config
28
29 include bin/kconfig/Makefile
30
31 include src/kernel/Makefile
32 include src/net/Makefile
33 include src/phone/Makefile
34
35 include src/target/Makefile
36 include src/function/Makefile
37 include src/driver/Makefile
38
39 BINPATH = $(CONFIG_PLATFORM_BIN_PATH):$(PATH)
40
41 #
42 # Dependencies for generated include files
43 # TODO: Solve cyclic dependencies on non-generated file
44 #
45 include/config.h: .config
46         ( cat $< ; for m in $(metavars-y) ; do echo $$m ; done ) | sed -e '/^#/d' -e 's/^\([A-Za-z0-9_]*\)=\(.*\)/#define \1 \2/'  > $@
47         for i in $(includes-y) ; do echo "#include <$$i>" >> $@ ; done
48
49 .PHONY += configincludes
50 configincludes: include/config.h
51
52 #
53 # Include dependency files
54 #
55 -include $(objs-top-kernel-y:.o=.d)
56 -include $(objs-top-net-y:.o=.d)
57 -include $(objs-top-phone-y:.o=.d)
58 -include $(objs-top-bottom-y:.o=.d)
59
60 #
61 # The main building targets
62 #
63 # Building is done in two phases; first top.o and bottom.o
64 # each hold their respective halves of the process, then they
65 # are composed to form the target binary.  This separation
66 # enables a thoroughness check on the API separation.  The
67 # rule is that all API calls between the two halves must be
68 # documented in doc/top2bottom.*
69 #
70
71 bin/top-kernel.o: $(objs-top-kernel-y)
72         PATH=$(BINPATH) $(LD) $(LDFLAGS) -r -o $@ $(objs-top-kernel-y)
73
74 bin/top-net.o: $(objs-top-net-y)
75         PATH=$(BINPATH) $(LD) $(LDFLAGS) -r -o $@ $(objs-top-net-y)
76
77 bin/top-phone.o: $(objs-top-phone-y)
78         PATH=$(BINPATH) $(LD) $(LDFLAGS) -r -o $@ $(objs-top-phone-y)
79
80 # bin/top.o: bin/top-kernel.o bin/top-net.o bin/top-phone.o
81 #       $(LD) $(LDFLAGS) -r -o $@ bin/top-kernel.o bin/top-net.o bin/top-phone.o
82 bin/top.o: $(objs-top-y)
83         PATH=$(BINPATH) $(LD) $(LDFLAGS) -r -o $@ $(objs-top-y)
84
85 bin/bottom.o: $(objs-bottom-y)
86         PATH=$(BINPATH) $(LD) $(LDFLAGS) -r -o $@ $(objs-bottom-y)
87
88 #
89 # Create a "tags" file for easy Vim navigation
90 #
91 tags: src/net/6bed4.c
92         ctags $(objs-top-kernel-y:.o=.c) $(objs-top-net-y:.o=.c) $(objs-top-phone-y:.o=.c) $(objs-bottom-y:.o=.c) include/0cpm/*.h include/config.h
93
94 .PHONY += clean
95 clean:
96         rm -f $(objs-top-y) $(objs-top-n) $(objs-top-)
97         rm -f $(objs-top-kernel-y) $(objs-top-kernel-n) $(objs-top-kernel-)
98         rm -f $(objs-top-net-y) $(objs-top-net-n) $(objs-top-net-)
99         rm -f $(objs-top-phone-y) $(objs-top-phone-n) $(objs-top-phone-)
100         # rm -f $(objs-top-net-y)
101         # rm -f $(objs-top-phone-y)
102         rm -f $(objs-bottom-y) $(objs-bottom-n) $(objs-bottom-)
103         rm -f $(objs-top-y:.o=.d) $(objs-top-n:.o=.d) $(objs-top-:.o=.d)
104         # rm -f $(objs-top-kernel-y:.o=.d)
105         # rm -f $(objs-top-net-y:.o=.d)
106         # rm -f $(objs-top-phone-y:.o=.d)
107         rm -f $(objs-bottom-y:.o=.d) $(objs-bottom-n:.o=.d) $(objs-bottom-:.o=.d)
108         rm -f bin/top-kernel.o bin/top-net.o bin/top-phone.o
109         rm -f bin/top.o bin/bottom.o
110         rm -f include/config.h
111         rm -f tags src/net/6bed4.c
112         rm -f bin/firmerware.exe bin/firmerware.bin
113
114 .PHONY += size
115 size:
116         @echo
117         @echo '*** Top half kernel sizes:'
118         @echo
119         @size $(objs-top-kernel-y) || true
120         @echo
121         @echo '*** Top half network sizes:'
122         @echo
123         @size $(objs-top-net-y) || true
124         @echo
125         @echo '*** Top half phone sizes:'
126         @echo
127         @size $(objs-top-phone-y) || true
128         @echo
129         @echo '*** Bottom half sizes:'
130         @echo
131         @size $(objs-bottom-y) || true
132         @echo
133         @echo '*** Major component sizes:'
134         @echo
135         @size bin/top-kernel.o bin/top-net.o bin/top-phone.o bin/bottom.o || true
136         @echo