-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
324 lines (277 loc) · 9.09 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
############################################################################
#
# Makefile -- Top level uClinux makefile.
#
# Copyright (c) 2001-2004, SnapGear (www.snapgear.com)
# Copyright (c) 2001, Lineo
#
VERSIONPKG = 3.1.0
VERSIONSTR = $(CONFIG_VENDOR)/$(CONFIG_PRODUCT) Version $(VERSIONPKG)
############################################################################
#
# Lets work out what the user wants, and if they have configured us yet
#
ifeq (.config,$(wildcard .config))
include .config
all: subdirs romfs modules modules_install image
else
all: config_error
endif
############################################################################
#
# Get the core stuff worked out
#
LINUXDIR = $(CONFIG_LINUXDIR)
LIBCDIR = $(CONFIG_LIBCDIR)
ROOTDIR = $(shell pwd)
PATH := $(PATH):$(ROOTDIR)/tools
HOSTCC = cc
IMAGEDIR = $(ROOTDIR)/images
RELDIR = $(ROOTDIR)/release
ROMFSDIR = $(ROOTDIR)/romfs
ROMFSINST= romfs-inst.sh
SCRIPTSDIR = $(ROOTDIR)/config/scripts
TFTPDIR = /tftpboot
LINUX_CONFIG = $(ROOTDIR)/$(LINUXDIR)/.config
CONFIG_CONFIG = $(ROOTDIR)/config/.config
MODULES_CONFIG = $(ROOTDIR)/modules/.config
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi)
ifeq (config.arch,$(wildcard config.arch))
include config.arch
ARCH_CONFIG = $(ROOTDIR)/config.arch
export ARCH_CONFIG
endif
ifneq ($(SUBARCH),)
# Using UML, so make the kernel and non-kernel with different ARCHs
MAKEARCH = $(MAKE) ARCH=$(SUBARCH) CROSS_COMPILE=$(CROSS_COMPILE)
MAKEARCH_KERNEL = $(MAKE) ARCH=$(ARCH) SUBARCH=$(SUBARCH) CROSS_COMPILE=$(CROSS_COMPILE)
else
MAKEARCH = $(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE)
MAKEARCH_KERNEL = $(MAKEARCH)
endif
DIRS = $(VENDOR_TOPDIRS) lib user
VENDDIR = $(ROOTDIR)/vendors/$(CONFIG_VENDOR)/$(CONFIG_PRODUCT)/.
export VENDOR PRODUCT ROOTDIR LINUXDIR HOSTCC CONFIG_SHELL
export CONFIG_CONFIG LINUX_CONFIG ROMFSDIR SCRIPTSDIR
export VERSIONPKG VERSIONSTR ROMFSINST PATH IMAGEDIR RELDIR RELFILES TFTPDIR
############################################################################
#
# Config stuff, we recall ourselves to load the new config.arch before
# running the kernel and other config scripts
#
.PHONY: config.tk config.in
config.in:
config/mkconfig > config.in
config.tk: config.in
$(MAKE) -C $(SCRIPTSDIR) tkparse
ARCH=dummy $(SCRIPTSDIR)/tkparse < config.in > config.tmp
@if [ -f /usr/local/bin/wish ]; then \
echo '#!'"/usr/local/bin/wish -f" > config.tk; \
else \
echo '#!'"/usr/bin/wish -f" > config.tk; \
fi
cat $(SCRIPTSDIR)/header.tk >> ./config.tk
cat config.tmp >> config.tk
rm -f config.tmp
echo "set defaults \"/dev/null\"" >> config.tk
echo "set help_file \"config/Configure.help\"" >> config.tk
cat $(SCRIPTSDIR)/tail.tk >> config.tk
chmod 755 config.tk
.PHONY: xconfig
xconfig: config.tk
@wish -f config.tk
@if [ ! -f .config ]; then \
echo; \
echo "You have not saved your config, please re-run make config"; \
echo; \
exit 1; \
fi
@config/setconfig defaults
@if egrep "^CONFIG_DEFAULTS_KERNEL=y" .config > /dev/null; then \
$(MAKE) linux_xconfig; \
fi
@if egrep "^CONFIG_DEFAULTS_MODULES=y" .config > /dev/null; then \
$(MAKE) modules_xconfig; \
fi
@if egrep "^CONFIG_DEFAULTS_VENDOR=y" .config > /dev/null; then \
$(MAKE) config_xconfig; \
fi
@config/setconfig final
.PHONY: config
config: config.in
@HELP_FILE=config/Configure.help \
$(CONFIG_SHELL) $(SCRIPTSDIR)/Configure config.in
@config/setconfig defaults
@if egrep "^CONFIG_DEFAULTS_KERNEL=y" .config > /dev/null; then \
$(MAKE) linux_config; \
fi
@if egrep "^CONFIG_DEFAULTS_MODULES=y" .config > /dev/null; then \
$(MAKE) modules_config; \
fi
@if egrep "^CONFIG_DEFAULTS_VENDOR=y" .config > /dev/null; then \
$(MAKE) config_config; \
fi
@config/setconfig final
.PHONY: menuconfig
menuconfig: config.in
$(MAKE) -C $(SCRIPTSDIR)/lxdialog all
@HELP_FILE=config/Configure.help \
$(CONFIG_SHELL) $(SCRIPTSDIR)/Menuconfig config.in
@if [ ! -f .config ]; then \
echo; \
echo "You have not saved your config, please re-run make config"; \
echo; \
exit 1; \
fi
@config/setconfig defaults
@if egrep "^CONFIG_DEFAULTS_KERNEL=y" .config > /dev/null; then \
$(MAKE) linux_menuconfig; \
fi
@if egrep "^CONFIG_DEFAULTS_MODULES=y" .config > /dev/null; then \
$(MAKE) modules_menuconfig; \
fi
@if egrep "^CONFIG_DEFAULTS_VENDOR=y" .config > /dev/null; then \
$(MAKE) config_menuconfig; \
fi
@config/setconfig final
.PHONY: oldconfig
oldconfig:
@$(MAKE) oldconfig_linux
@$(MAKE) oldconfig_modules
@$(MAKE) oldconfig_config
@$(MAKE) oldconfig_uClibc
@config/setconfig final
.PHONY: modules
modules:
. $(LINUXDIR)/.config; if [ "$$CONFIG_MODULES" = "y" ]; then \
[ -d $(LINUXDIR)/modules ] || mkdir $(LINUXDIR)/modules; \
$(MAKEARCH_KERNEL) -C $(LINUXDIR) modules; \
fi
.PHONY: modules_install
modules_install:
. $(LINUXDIR)/.config; if [ "$$CONFIG_MODULES" = "y" ]; then \
[ -d $(ROMFSDIR)/lib/modules ] || mkdir -p $(ROMFSDIR)/lib/modules; \
$(MAKEARCH_KERNEL) -C $(LINUXDIR) INSTALL_MOD_PATH=$(ROMFSDIR) DEPMOD=true modules_install; \
rm -f $(ROMFSDIR)/lib/modules/*/build; \
find $(ROMFSDIR)/lib/modules -type f | xargs -r $(STRIP) -g; \
fi
linux_xconfig:
$(MAKEARCH_KERNEL) -C $(LINUXDIR) xconfig
linux_menuconfig:
$(MAKEARCH_KERNEL) -C $(LINUXDIR) menuconfig
linux_config:
$(MAKEARCH_KERNEL) -C $(LINUXDIR) config
modules_xconfig:
[ ! -d modules ] || $(MAKEARCH) -C modules xconfig
modules_menuconfig:
[ ! -d modules ] || $(MAKEARCH) -C modules menuconfig
modules_config:
[ ! -d modules ] || $(MAKEARCH) -C modules config
modules_clean:
-[ ! -d modules ] || $(MAKEARCH) -C modules clean
config_xconfig:
$(MAKEARCH) -C config xconfig
config_menuconfig:
$(MAKEARCH) -C config menuconfig
config_config:
$(MAKEARCH) -C config config
oldconfig_config:
$(MAKEARCH) -C config oldconfig
oldconfig_modules:
[ ! -d modules ] || $(MAKEARCH) -C modules oldconfig
oldconfig_linux:
$(MAKEARCH_KERNEL) -C $(LINUXDIR) oldconfig
oldconfig_uClibc:
[ -z "$(findstring uClibc,$(LIBCDIR))" ] || $(MAKEARCH) -C $(LIBCDIR) oldconfig
############################################################################
#
# normal make targets
#
.PHONY: romfs
romfs:
for dir in $(DIRS) ; do [ ! -d $$dir ] || $(MAKEARCH) -C $$dir romfs || exit 1 ; done
-find $(ROMFSDIR)/. -name CVS | xargs -r rm -rf
.PHONY: image
image:
[ -d $(IMAGEDIR) ] || mkdir $(IMAGEDIR)
$(MAKEARCH) -C $(VENDDIR) image
.PHONY: netflash
netflash netflash_only:
make -C prop/mstools CONFIG_PROP_MSTOOLS_NETFLASH_NETFLASH=y
.PHONY: release
release:
make -C release release
%_fullrelease:
make -C release $@
#
# fancy target that allows a vendor to have other top level
# make targets, for example "make vendor_flash" will run the
# vendor_flash target in the vendors directory
#
vendor_%:
$(MAKEARCH) -C $(VENDDIR) $@
.PHONY: linux
linux linux%_only:
@if [ $(LINUXDIR) != linux-2.5.x -a $(LINUXDIR) != linux-2.6.x -a ! -f $(LINUXDIR)/.depend ] ; then \
echo "ERROR: you need to do a 'make dep' first" ; \
exit 1 ; \
fi
$(MAKEARCH_KERNEL) -C $(LINUXDIR) $(LINUXTARGET) || exit 1
if [ -f $(LINUXDIR)/vmlinux ]; then \
ln -f $(LINUXDIR)/vmlinux $(LINUXDIR)/linux ; \
fi
.PHONY: subdirs
subdirs: linux
for dir in $(DIRS) ; do [ ! -d $$dir ] || $(MAKEARCH_KERNEL) -C $$dir || exit 1 ; done
dep:
@if [ ! -f $(LINUXDIR)/.config ] ; then \
echo "ERROR: you need to do a 'make config' first" ; \
exit 1 ; \
fi
$(MAKEARCH_KERNEL) -C $(LINUXDIR) dep
# This one removes all executables from the tree and forces their relinking
.PHONY: relink
relink:
find user -name '*.gdb' | sed 's/^\(.*\)\.gdb/\1 \1.gdb/' | xargs rm -f
find prop -name '*.gdb' | sed 's/^\(.*\)\.gdb/\1 \1.gdb/' | xargs rm -f
find $(VENDDIR) -name '*.gdb' | sed 's/^\(.*\)\.gdb/\1 \1.gdb/' | xargs rm -f
clean: modules_clean
for dir in $(LINUXDIR) $(DIRS); do [ ! -d $$dir ] || $(MAKEARCH) -C $$dir clean ; done
rm -rf $(ROMFSDIR)/*
rm -f $(IMAGEDIR)/*
rm -f config.tk
rm -f $(LINUXDIR)/linux
rm -rf $(LINUXDIR)/net/ipsec/alg/libaes $(LINUXDIR)/net/ipsec/alg/perlasm
real_clean mrproper: clean
-$(MAKEARCH_KERNEL) -C $(LINUXDIR) mrproper
-$(MAKEARCH) -C config clean
-$(MAKEARCH) -C uClibc distclean
-$(MAKEARCH) -C $(RELDIR) clean
rm -rf romfs config.in config.arch config.tk images
rm -f modules/config.tk
rm -rf .config .config.old .oldconfig autoconf.h
distclean: mrproper
-$(MAKEARCH_KERNEL) -C $(LINUXDIR) distclean
-rm -f user/tinylogin/applet_source_list user/tinylogin/config.h
%_only:
[ ! -d "$(@:_only=)" ] || $(MAKEARCH) -C $(@:_only=)
%_clean:
[ ! -d "$(@:_clean=)" ] || $(MAKEARCH) -C $(@:_clean=) clean
config_error:
@echo "*************************************************"
@echo "You have not run make config."
@echo "The build sequence for this source tree is:"
@echo "1. 'make config' or 'make xconfig'"
@echo "2. 'make dep'"
@echo "3. 'make'"
@echo "*************************************************"
@exit 1
prune:
$(MAKE) -C user prune
dist-prep:
-find $(ROOTDIR) -name 'Makefile*.bin' | while read t; do \
$(MAKEARCH) -C `dirname $$t` -f `basename $$t` $@; \
done
############################################################################