forked from FreifunkAdvanced/ff-advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
316 lines (267 loc) · 10.8 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
SHELL := /bin/bash
VERSION := $(shell echo git-`git log --format=format:%h -n1`)
DATE := $(shell git log --format=format:%cd --date=short -n1)
include settings.mk
# *DOCUMENTATION*
# To see a list of typical targets execute "make help"
# More info can be located in ./README
NUMPROC := 1
OS := $(shell uname)
export NUMPROC
export REPOSITORY
export PLATFORM
export COMMUNITY
ifeq ($(OS),Linux)
NUMPROC := $(shell grep -c ^processor /proc/cpuinfo)
else ifeq ($(OS),Darwin)
NUMPROC := $(shell sysctl hw.ncpu | awk '{print $$2}')
else ifeq ($(OS),FreeBSD)
NUMPROC := $(shell sysctl hw.ncpu | awk '{print $$2}')
endif
# Always use # of processory plus 1
NUMPROC:=$$((${NUMPROC}+1))
NUMPROC:=$(shell echo ${NUMPROC})
ifeq ($(NUMPROC),0)
NUMPROC = 1
endif
# ------
# define
# ------
define move_files
cp -a files/common openwrt/$(REPO)/files
[ -d files/$(REPO)/$(PLAT) ] \
&& rsync -a files/$(REPO)/$(PLAT)/ openwrt/$(REPO)/files/
[ -d files/$(REPO)/$(PLAT)-$(MODEL) ] \
&& rsync -a files/$(REPO)/$(PLAT)-$(MODEL)/ openwrt/$(REPO)/files/
endef
define create_firmware_file
echo $(DATE)_$$(echo $(VERSION) \
| sed -e "s/git-//g")_$(REPO)-`[[ "$(REPO)" == "trunk" ]] \
&& echo $(SVNREVISION) || echo $(BACKFIREVERSION)` \
> openwrt/$(REPO)/files/etc/firmware
endef
define brand_firmware
[[ -e config/misc/banner.$(MODEL) ]] && \
sed config/misc/banner.$(MODEL) \
-e "s/SVNRV/$(SVNREVISION)/g" \
-e "s/LINUXVERSION/`grep '^LINUX_VERSION:=' openwrt/$(REPO)/target/linux/$(PLAT)/Makefile | sed 's/^LINUX_VERSION:='//g`/g" \
-e "s/BATMANVERSION/`grep '^PKG_VERSION:=' openwrt/$(REPO)/package/feeds/packages/batman-adv/Makefile | sed 's/^PKG_VERSION:='//g`/g" \
-e "s/FFRLversion/$(DATE)_$(VERSION)/g" \
-e "s/buildSystem/`uname -n` by $(NAME) <$(MAIL)>/g" > openwrt/$(REPO)/files/etc/banner
[[ "$(REPO)" == "backfire" ]] && \
sed openwrt/$(REPO)/files/etc/banner -i -e "s/.*bleeding edge.*/ Backfire (10.03.1, r29592) ----------------------------------------------------/g" || true
endef
define oldconfig
cd openwrt/$(REPO) && while true; do echo; done | $(MAKE) oldconfig >/dev/null
endef
# ------------------------------------
# Miscellaneous targets and flag lists
# ------------------------------------
# The first rule in the file had better be this one. Don't put any above it.
# This lives here to allow makefile fragments to contain dependencies.
# You can modify the default targets in settings.mk
all: ${DEFAULTIMAGES}
settings.mk:
@echo "Please edit settings.mk first."
@echo "Copy & edit settings.mk.example for your purposes."
[ -e settings.mk ] || exit 1
devimage: images/$(DATE)_$(VERSION)/devel-ar71xx-trunk-r$(SVNREVISION)
mcimage: images/$(DATE)_$(VERSION)/miniconfig-ar71xx-trunk-r$(SVNREVISION)
dir300image: images/$(DATE)_$(VERSION)/miniconfig-atheros_dir300-trunk-r$(SVNREVISION)
wrt54gimage: images/$(DATE)_$(VERSION)/miniconfig-brcm47xx_wrt54g-trunk-r$(SVNREVISION)
help:
cat doc/build-HOWTO
info:
@echo "Freifunk Rheinland Buildroot"
@echo " Version: $(VERSION)"
@echo " Date: $(DATE)"
@echo ''
@echo "Freifunk Jena hbbpd"
@echo " Version: $(FFJVERSION)"
@echo " Date: $(FFJDATE)"
@echo ''
@echo "OpenWrt"
@echo " Backfire: No longer supported"
@echo " Trunk: r$(SVNREVISION)"
@echo ''
@echo ' To see a list of typical targets execute "make help"'
@echo ' More info can be located in ./README'
# ------------------------------------
# Config targets | see config/Makefile
# ------------------------------------
config-all:
cd config && $(MAKE) $(REPOSITORY)
.SECONDEXPANSION:
config-%:
cd config && $(MAKE) $(shell echo $(@F) | sed s/config-//g )
# for historical reasons
config/%.config:
cd config && $(MAKE) $(shell echo $(@F) | sed -e "s:config/::g" )
# ------------------------------------
# Fetch targets
# ------------------------------------
fetch: fetch-trunk
fetch-trunk: openwrt/trunk/.repo_access
.NOTPARALLEL:
openwrt/trunk/.repo_access:
mkdir -p openwrt dl
@echo ' SVN OpenWrt Trunk r$(SVNREVISION)'
svn co -q -r $(SVNREVISION) svn://svn.openwrt.org/openwrt/trunk/ $(@D)
[[ -h $(@D)/dl ]] || ln -s ../../dl $(@D)/
@echo ' UPDATE OpenWrt Trunk r$(SVNREVISION) feeds'
cat $(@D)/feeds.conf.default feeds.conf > $(@D)/feeds.conf
echo "src-link ffrl $$(pwd)/feeds/ffrl" >> $(@D)/feeds.conf
cd $(@D) && ./scripts/feeds update > /dev/null 2&>1
@echo ' INSTALL Freifunk Jena hbbpd $(FFJVERSION) in OpenWrt Trunk'
cd $(@D) && ./scripts/feeds install -a -p ffj > /dev/null 2&>1
@echo ' INSTALL Freifunk Rheinland packages in OpenWrt Trunk'
cd $(@D) && ./scripts/feeds install -a -p ffrl > /dev/null 2&>1
@echo ' LINK OpenWrt Trunk r$(SVNREVISION) packages'
cd $(@D) && $(MAKE) $(MAKEFLAGS) package/symlinks
touch $@
# ------------------------------------
# Update targets
# ------------------------------------
settings_update: newSVN = $(shell svn info svn://svn.openwrt.org/openwrt/trunk/ 2> /dev/null | grep "Rev:" | sed -e "s/.*: //g" || exit 1)
settings_update: oldSVN = $(shell LANG=C svn info openwrt/trunk/ 2> /dev/null | grep "Rev:" | sed -e "s/.*: //g" || exit 1)
settings_update: SVNREVISION = $(newSVN)
settings_update:
if [ "$(newSVN)" == "" ] || [ "$(oldSVN)" == "" ];then echo " SVN nicht erreichbar"; exit 1; fi
@echo ' MOD settings.mk ($(oldSVN) -> $(newSVN))'
sed -i -e 's/SVNREVISION =.*/SVNREVISION = $(newSVN)/g' settings.mk
.NOTPARALLEL:
update: update-trunk
update-backfire: openwrt/backfire/.update
.NOTPARALLEL:
# update-trunk: settings_update
update-trunk: openwrt/trunk/.update
.NOTPARALLEL:
openwrt/trunk/.update:
mkdir -p openwrt dl
@echo ' SVN OpenWrt Trunk r$(SVNREVISION) (update)'
cd $(@D) && svn update -q -r $(SVNREVISION)
@echo ' UPDATE OpenWrt Trunk r$(SVNREVISION) feeds'
cat $(@D)/feeds.conf.default feeds.conf > $(@D)/feeds.conf
echo "src-link ffrl $$(pwd)/feeds/ffrl" >> $(@D)/feeds.conf
cd $(@D) && ./scripts/feeds update > /dev/null 2&>1
@echo ' INSTALL Freifunk Jena hbbpd $(FFJVERSION) (update)'
cd $(@D) && ./scripts/feeds install -a -p ffj > /dev/null 2&>1
@echo ' INSTALL Freifunk Rheinland packages in OpenWrt Trunk'
cd $(@D) && ./scripts/feeds install -a -p ffrl > /dev/null 2&>1
@echo ' LINK OpenWrt Trunk r$(SVNREVISION) packages'
cd $(@D) && $(MAKE) $(MAKEFLAGS) package/symlinks
touch $(@D).repo_access
# ------------------------------------
# Clean targets
# ------------------------------------
clean:
-rm -r config/*.config image/*
mrpropper: mrpropper-trunk
mrpropper-trunk:
cd openwrt/trunk && $(MAKE) clean
# ------------------------------------
# Build targets
# ------------------------------------
image:
for rep in $(REPOSITORY); do \
$(MAKE) $(MAKEFLAGS) image-$${rep}; \
done
.SECONDEXPANSION:
image-%: REPO=$(shell echo $(@F) | cut -f2 -d-)
image-%: PLAT=$(shell echo $(@F) | cut -f3 -d-)
image-%: MODEL=$(shell echo $(@F) | cut -f4- -d-)
image-%:
image-%:
if [ "$(PLAT)" == "" ]; then \
for pla in $(PLATFORM); do \
$(MAKE) image-$(REPO)-$${pla}; \
done; \
elif [[ "$(MODEL)" == "" ]]; then \
for com in $(COMMUNITY); do \
$(MAKE) image-$(REPO)-$(PLAT)-$${com}; \
done; \
else \
[[ "$(REPO)" == "trunk" ]] && $(MAKE) images/$(DATE)_$(VERSION)/$(MODEL)-$(PLAT)-$(REPO)-r$(SVNREVISION) || true; \
[[ "$(REPO)" != "trunk" ]] && $(MAKE) images/$(DATE)_$(VERSION)/$(MODEL)-$(PLAT)-$(REPO)-$(BACKFIREVERSION) || true; \
fi
image/%:
@echo '"make image/$$(repo)/openwrt-$$(platform)-$$(model)" is deprecated'
@echo 'please use the new make syntax:'
head -n24 doc/build-HOWTO
# create a pure OpenWrt image to test the .config and for package integration
images/$(DATE)_$(VERSION)/devel-ar71xx-trunk-r$(SVNREVISION): REPO="trunk"
images/$(DATE)_$(VERSION)/devel-ar71xx-trunk-r$(SVNREVISION): PLAT="ar71xx"
images/$(DATE)_$(VERSION)/devel-ar71xx-trunk-r$(SVNREVISION): MODEL="devel"
images/$(DATE)_$(VERSION)/devel-ar71xx-trunk-r$(SVNREVISION): openwrt/trunk/.repo_access
@echo ' BUILD Development OpenWrt trunk for ar71xx'
cp -p config/devel.config openwrt/trunk/.config
-rm -r openwrt/trunk/files 2> /dev/null || true
# mkdir -p openwrt/trunk/files/etc/
# $(create_firmware_file)
# $(brand_firmware)
# echo '! development image' >> openwrt/$(REPO)/files/etc/banner
# echo ' ------------------------------------------------------------------------------' >> openwrt/$(REPO)/files/etc/banner
cd openwrt/$(REPO) && $(MAKE) -j$(NUMPROC)
mkdir -p $@
# rsync -a openwrt/$(REPO)/bin/$(PLAT)/ $@/
mv openwrt/$(REPO)/bin/$(PLAT)/* $@/
# cd $@/ && rm md5sums
# cd $@/ && md5sum * > md5sums 2> /dev/null || true
# DIR-300 build target
images/$(DATE)_$(VERSION)/miniconfig-atheros_dir300-trunk-r$(SVNREVISION): REPO="trunk"
images/$(DATE)_$(VERSION)/miniconfig-atheros_dir300-trunk-r$(SVNREVISION): PLAT="atheros"
images/$(DATE)_$(VERSION)/miniconfig-atheros_dir300-trunk-r$(SVNREVISION): MODEL="miniconfig"
images/$(DATE)_$(VERSION)/miniconfig-atheros_dir300-trunk-r$(SVNREVISION): openwrt/trunk/.repo_access
@echo ' BUILD OpenWrt trunk for D-Link DIR-300'
./genconfig dir300 > openwrt/$(REPO)/.config
$(oldconfig)
-rm -r openwrt/$(REPO)/files 2> /dev/null || true
mkdir -p openwrt/$(REPO)/files/etc/
$(create_firmware_file)
$(brand_firmware)
cd openwrt/$(REPO) && $(MAKE) -j$(NUMPROC)
mkdir -p $@
rsync --exclude="*-squashfs.bin" \
--exclude="*.elf" \
--exclude="*-vmlinux.gz" -a \
openwrt/$(REPO)/bin/$(PLAT)/ $@/
cd $@/ && rm md5sums
cd $@/ && md5sum * > md5sums 2> /dev/null || true
# WRT54G build target
images/$(DATE)_$(VERSION)/miniconfig-brcm47xx_wrt54g-trunk-r$(SVNREVISION): REPO="trunk"
images/$(DATE)_$(VERSION)/miniconfig-brcm47xx_wrt54g-trunk-r$(SVNREVISION): PLAT="brcm47xx"
images/$(DATE)_$(VERSION)/miniconfig-brcm47xx_wrt54g-trunk-r$(SVNREVISION): MODEL="miniconfig"
images/$(DATE)_$(VERSION)/miniconfig-brcm47xx_wrt54g-trunk-r$(SVNREVISION): openwrt/trunk/.repo_access
@echo ' BUILD OpenWrt trunk for Linksys WRT54G'
./genconfig wrt54g > openwrt/$(REPO)/.config
$(oldconfig)
-rm -r openwrt/$(REPO)/files 2> /dev/null || true
mkdir -p openwrt/$(REPO)/files/etc/
$(create_firmware_file)
$(brand_firmware)
cd openwrt/$(REPO) && $(MAKE) -j$(NUMPROC)
mkdir -p $@
rsync -a openwrt/$(REPO)/bin/$(PLAT)/packages $@/
rsync --exclude="*3g*" \
--include="*wrt54g*" \
--include="*-rootfs.tar.gz" \
--include="openwrt-brcm47xx-squashfs.trx" \
--exclude="*" -a \
openwrt/$(REPO)/bin/$(PLAT)/ $@/
cd $@/ && md5sum * > md5sums 2> /dev/null || true
# ar71xx build target
.SECONDEXPANSION:
images/%: REPO=$(shell echo $(@F) | cut -f3 -d-)
images/%: PLAT=$(shell echo $(@F) | cut -f2 -d-)
images/%: MODEL=$(shell echo $(@F) | cut -f1 -d-)
images/%: openwrt/$$(REPO)/.repo_access
@echo ' BUILD OpenWrt $(REPO) for $(PLAT) in $(MODEL)'
./genconfig $(PLAT) > openwrt/$(REPO)/.config
-rm -r openwrt/$(REPO)/files
$(move_files)
$(create_firmware_file)
$(brand_firmware)
$(oldconfig)
cd openwrt/$(REPO) && $(MAKE) -j$(NUMPROC)
mkdir -p $@
rsync -a openwrt/$(REPO)/bin/$(PLAT)/ $@/