-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
executable file
·305 lines (267 loc) · 7.73 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
############################################################################
#
# Realtek Semiconductor Corp.
#
# Makefile -- Top level dist makefile.
#
# Tony Wu ([email protected])
# Oct. 12, 2008
#
ifneq (.config,$(wildcard .config))
TARGET := config
#
# DIR_ROOT Used when .config not Exist
#
DIR_ROOT = $(shell pwd)
DIR_USERS = $(DIR_ROOT)/users
DIR_BZBOX = $(DIR_ROOT)/users/busybox-1.13
DIR_LINUX = $(DIR_ROOT)/linux-2.6.30
export DIR_ROOT DIR_USERS DIR_BZBOX DIR_LINUX
else
include .config
#
# variables
#
DIR_ROOT = $(shell pwd)
DIR_RSDK = $(DIR_ROOT)/$(CONFIG_RSDKDIR)
ifeq ($(CONFIG_ARCH_CPU_MIPS),y)
VAR_ARCH:= mips
CROSS_TARGET := mips-linux
CROSS_COMPILE:= msdk-linux-
else
VAR_ARCH:= rlx
CROSS_TARGET := rsdk-linux
CROSS_COMPILE := rsdk-linux-
endif
export VAR_ARCH CROSS_COMPILE CROSS_TARGET
ifeq ($(CONFIG_ARCH_CPU_EL),y)
VAR_ENDIAN := EL
else
VAR_ENDIAN := EB
endif
DIR_BOARD = $(DIR_ROOT)/target
DIR_ROMFS = $(DIR_ROOT)/target/romfs
DIR_TMPFS = $(DIR_ROOT)/target/tmpfs
DIR_IMAGE = $(DIR_ROOT)/target/image
DIR_TOOLS = $(DIR_ROOT)/target/tools
DIR_USERS = $(DIR_ROOT)/users
DIR_BZBOX = $(DIR_ROOT)/$(CONFIG_BZBOXDIR)
DIR_LINUX = $(DIR_ROOT)/$(CONFIG_LINUXDIR)
ROMFSINST = $(DIR_ROOT)/config/romfsinst
RCSCONFIG = $(DIR_ROMFS)/etc/init.d/rcS.conf
MAKE = PATH=$(DIR_RSDK)/bin:$(PATH); make
LSTRIP = PATH=$(DIR_RSDK)/bin:$(PATH); rsdk-linux-lstrip
SSTRIP = PATH=$(DIR_RSDK)/bin:$(PATH); rsdk-linux-sstrip
ifeq ($(CONFIG_ARCH_CPU_MIPS),y)
LSTRIP = PATH=$(DIR_RSDK)/bin:$(PATH); msdk-linux-lstrip
SSTRIP = PATH=$(DIR_RSDK)/bin:$(PATH); msdk-linux-sstrip
endif
export DIR_ROOT DIR_RSDK DIR_ROMFS DIR_IMAGE DIR_BOARD DIR_TMPFS
export DIR_LINUX DIR_BZBOX ROMFSINST DIR_TOOLS DIR_USERS
export RCSCONFIG
ERROR :=
ifneq ($(CONFIG_BZBOXDIR),$(wildcard $(CONFIG_BZBOXDIR)))
ERROR += '$(CONFIG_BZBOXDIR) does not exist '
endif
ifneq ($(CONFIG_LINUXDIR),$(wildcard $(CONFIG_LINUXDIR)))
ERROR += '$(CONFIG_LINUXDIR) does not exist '
endif
ifneq ($(CONFIG_RSDKDIR),$(wildcard $(CONFIG_RSDKDIR)))
ERROR += '$(CONFIG_RSDKDIR) does not exist'
endif
ifeq ($(ERROR),)
# for ramfs or MP build, rootfs must be ready before kernel
TARGET := bins romfs modules external_modules linux image
#TARGET := modules linux bins romfs image
else
TARGET := error
endif
endif
all: $(TARGET)
error:
@echo
@echo "=== NOTICE ==="
@echo
@for X in $(ERROR) ; do \
echo ERROR: $$X; \
done
@echo
@echo "Please run 'make config' to reconfigure"
@echo
#
# 0. target selection
#
.PHONY: config menuconfig
config menuconfig:
@chmod u+x config/genconfig
@chmod u+x config/setconfig
@config/genconfig > Kconfig
@config/mconf Kconfig
# @if egrep "^CONFIG_BOARD_rtl8196eu=y" .config > /dev/null; then \
# cp $(shell pwd)/linux-2.6.30/drivers/usb/Kconfig-otg $(shell pwd)/linux-2.6.30/drivers/usb/Kconfig; \
# else \
# cp $(shell pwd)/linux-2.6.30/drivers/usb/Kconfig-not-otg $(shell pwd)/linux-2.6.30/drivers/usb/Kconfig; \
# fi
@config/setconfig defaults
@if egrep "^CONFIG_MCONF_LINUX=y" .config > /dev/null; then \
if egrep "^CONFIG_BOARD_rtl8197F=y" .config > /dev/null; then \
$(MAKE) -C $(DIR_LINUX) menuconfig VAR_ARCH=mips-ori; \
else \
$(MAKE) -C $(DIR_LINUX) menuconfig; \
fi \
fi
# if egrep "^CONFIG_SLOT_0_8192FE=y" $(shell pwd)/linux-3.10/.config > /dev/null; then \
# rm $(shell pwd)/linux-3.10/drivers/net/wireless/rtl8192cd; \
# ln -s rtl8192cd_92f $(shell pwd)/linux-3.10/drivers/net/wireless/rtl8192cd; \
# else \
# rm $(shell pwd)/linux-3.10/drivers/net/wireless/rtl8192cd; \
# ln -s ../../../../linux-2.6.30/drivers/net/wireless/rtl8192cd $(shell pwd)/linux-3.10/drivers/net/wireless/rtl8192cd; \
# fi
@if egrep "^CONFIG_MCONF_USERS=y" .config > /dev/null; then \
$(MAKE) -C $(DIR_USERS) menuconfig; \
fi
@if egrep "^CONFIG_MCONF_BZBOX=y" .config > /dev/null; then \
$(MAKE) -C $(DIR_BZBOX) menuconfig; \
fi
@config/setconfig final
@config/hdrconfig $(DIR_ROOT)
#
# 1. user lib
#
#.PHONY: libs
#libs:
# $(MAKE) -C $(DIR_USERS) lib || exit $$?
#
# 2. user app
#
.PHONY: users bins
users bins:
if egrep "^CONFIG_BOARD_rtl8197F=y" .config > /dev/null; then \
$(MAKE) -C $(DIR_LINUX) dep VAR_ARCH=mips-ori > /dev/null; \
else \
$(MAKE) -C $(DIR_LINUX) dep > /dev/null; \
fi
$(MAKE) -C $(DIR_USERS) || exit $$?
#
#2.1 user menuconfig
#
users_menuconfig:
$(MAKE) -C $(DIR_USERS) menuconfig;
#
# 3. romfs
#
# [ -d $(DIR_ROMFS) ] || mkdir $(DIR_ROMFS)
.PHONY: romfs
romfs:
$(MAKE) -C $(DIR_BOARD) romfs || exit $$?
cp -R $(DIR_RSDK)/lib/*.so $(DIR_ROMFS)/lib
cp -R $(DIR_RSDK)/lib/*.so.* $(DIR_ROMFS)/lib
chmod 755 $(DIR_ROMFS)/lib/*.so
$(MAKE) -C $(DIR_USERS) romfs || exit $$?
$(LSTRIP) $(DIR_ROMFS)
#
# 4.0 kernel modules (if any)
#
.PHONY: modules
modules:
if egrep "^CONFIG_BOARD_rtl8197F=y" .config > /dev/null; then \
$(MAKE) -C $(DIR_LINUX) modules VAR_ARCH=mips-ori || exit $$?; \
$(MAKE) -C $(DIR_LINUX) modules_install INSTALL_MOD_PATH=$(DIR_ROMFS) VAR_ARCH=mips-ori || exit $$?; \
else \
$(MAKE) -C $(DIR_LINUX) modules || exit $$?; \
$(MAKE) -C $(DIR_LINUX) modules_install INSTALL_MOD_PATH=$(DIR_ROMFS) || exit $$?; \
fi
#
# 4.1 kernel image
#
.PHONY: linux
linux:
. $(DIR_LINUX)/.config; if [ "$$CONFIG_INITRAMFS_SOURCE" != "" ]; then \
cd $(DIR_LINUX); \
mkdir -p $(DIR_ROMFS); \
touch $$CONFIG_INITRAMFS_SOURCE | awk '{print $2}' || exit 1; \
cd $(DIR_ROOT); \
fi
if egrep "^CONFIG_BOARD_rtl8197F=y" .config > /dev/null; then \
$(MAKE) -C $(DIR_LINUX) VAR_ARCH=mips-ori || exit $$?; \
# $(MAKE) -C $(DIR_USERS)/MAP-master/modules VAR_ARCH=mips-ori || exit $$?; \
else \
$(MAKE) -C $(DIR_LINUX) || exit $$?; \
# $(MAKE) -C $(DIR_USERS)/MAP-master/modules || exit $$?; \
fi
if [ -f $(DIR_LINUX)/vmlinux ]; then \
ln -f $(DIR_LINUX)/vmlinux $(DIR_LINUX)/linux ; \
fi
uImage:
if egrep "^CONFIG_BOARD_rtl8197F=y" .config > /dev/null; then \
$(MAKE) -C $(DIR_LINUX) uImage VAR_ARCH=mips-ori; \
else \
$(MAKE) -C $(DIR_LINUX) uImage; \
fi
#
#4.2 kernel menuconfig
#
linux_menuconfig:
# @if egrep "^CONFIG_BOARD_rtl8196eu=y" .config > /dev/null; then \
# cp $(shell pwd)/linux-2.6.30/drivers/usb/Kconfig-otg $(shell pwd)/linux-2.6.30/drivers/usb/Kconfig; \
# else \
# cp $(shell pwd)/linux-2.6.30/drivers/usb/Kconfig-not-otg $(shell pwd)/linux-2.6.30/drivers/usb/Kconfig; \
# fi
if egrep "^CONFIG_BOARD_rtl8197F=y" .config > /dev/null; then \
$(MAKE) -C $(DIR_LINUX) menuconfig VAR_ARCH=mips-ori; \
else \
$(MAKE) -C $(DIR_LINUX) menuconfig; \
fi
#
#4.3 external modules
#
.PHONY: external_modules
external_modules:
if egrep "^CONFIG_BOARD_rtl8197F=y" .config > /dev/null; then \
$(MAKE) -C $(DIR_LINUX) dep VAR_ARCH=mips-ori > /dev/null; \
else \
$(MAKE) -C $(DIR_LINUX) dep > /dev/null; \
fi
$(MAKE) -C $(DIR_USERS) ex_mod || exit $$?
#
# 5. image
#
.PHONY: image
image:
[ -d $(DIR_IMAGE) ] || mkdir $(DIR_IMAGE)
$(MAKE) -C $(DIR_BOARD) image
#
# x. short-cut to build and clean one application
#
linux-clean:
if egrep "^CONFIG_BOARD_rtl8197F=y" .config > /dev/null; then \
$(MAKE) -C $(DIR_LINUX) clean VAR_ARCH=mips-ori; \
else \
$(MAKE) -C $(DIR_LINUX) clean; \
fi
%_build:
$(MAKE) -C users $(@:_build=)
%-build:
$(MAKE) -C users $(@:-build=)
%_clean:
$(MAKE) -C users/$(@:_clean=) clean
%-clean:
$(MAKE) -C users/$(@:-clean=) clean
#.PHONY: version
#version:
# $(MAKE) -C $(DIR_USERS)/goahead-2.1.1/LINUX release
.PHONY: clean distclean
clean:
$(MAKE) -C $(DIR_USERS) clean
if egrep "^CONFIG_BOARD_rtl8197F=y" .config > /dev/null; then \
$(MAKE) -C $(DIR_LINUX) clean VAR_ARCH=mips-ori; \
# $(MAKE) -C $(DIR_USERS)/MAP-master/modules clean VAR_ARCH=mips-ori; \
else \
$(MAKE) -C $(DIR_LINUX) clean; \
# $(MAKE) -C $(DIR_USERS)/MAP-master/modules clean; \
fi
rm -rf $(DIR_ROMFS)
mkdir -p $(DIR_ROMFS)
mkdir -p $(DIR_IMAGE)
distclean:
$(MAKE) -C $(DIR_USERS) distclean