-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
364 lines (306 loc) · 13.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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
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 COMMUNITIES
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/
if test -d "files/communities/$(COMMUNITY)/$(PLAT)"; \
then rsync -a files/communities/$(COMMUNITY)/$(PLAT)/ openwrt/$(REPO)/files/; \
fi
./gensettings $(REPO) $(PLAT) $(COMMUNITY)
endef
define create_firmware_file
echo $(DATE)_$$(echo $(VERSION) \
| sed -e "s/git-//g")/$(REPO)/`[[ "$(REPO)" == "attitude_adjustment" ]] \
&& echo $(SVNREVISION) || echo "stable"` \
> openwrt/$(REPO)/files/etc/firmware
endef
define brand_firmware
[[ -e config/communities/$(COMMUNITY)/banner ]] \
&& cp config/communities/$(COMMUNITY)/banner openwrt/$(REPO)/files/etc/banner || cp config/default/banner openwrt/$(REPO)/files/etc/banner
sed openwrt/$(REPO)/files/etc/banner -i \
-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/FFRLversion/$(DATE)_$(VERSION)/g" \
-e "s/buildSystem/`uname -n` by $(NAME) <$(MAIL)>/g"
[[ "$(REPO)" == "attitude_adjustment" ]] \
&& sed openwrt/$(REPO)/files/etc/banner -i -e "s/.*bleeding edge.*/ ATTITUDE ADJUSTMENT (12.09, r36088) -------------------------------------------/g"
sed openwrt/$(REPO)/files/etc/banner -i -e "s/BATMANVERSION/`grep '^PKG_VERSION:=' openwrt/$(REPO)/package/feeds/routing/batman-adv/Makefile | sed 's/^PKG_VERSION:='//g`/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 ' 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
fetch-attitude_adjustment: openwrt/attitude_adjustment/.repo_access
# TODO: bis Pakete aus dem Buildroot herausgelöst wurden existieren zwei Paket-
# Quellen:
# - ffrlgit: git://github.com/ffrl/ffrl-feed.git
# - ffrl: Verzeichnisse im Buildroot - laut Upstream (Jan/Jena) nicht
# Standardkonform
.NOTPARALLEL:
openwrt/trunk/.repo_access:
mkdir -p openwrt dl
@echo ' GIT-Clone OpenWrt Trunk/Development (FF-Adv Repo)'
git clone -q git://github.com/FreifunkAdvanced/openwrt.git $(@D)
[[ -h $(@D)/dl ]] || ln -s ../../dl $(@D)/
@echo ' UPDATE OpenWrt Trunk/Development feeds'
cd $(@D) && ./scripts/feeds uninstall -a > /dev/null 2&>1
cat feeds.conf.trunk feeds.conf.ffadv > $(@D)/feeds.conf
@echo ' INSERT Freifunk Rheinland Buildroot packages in OpenWrt Trunk/Development'
echo "src-link ffrl $$(pwd)/feeds/ffrl" >> $(@D)/feeds.conf
cd $(@D) && ./scripts/feeds update > /dev/null 2&>1
@echo ' INSTALL Freifunk Rheinland Git repo in OpenWrt Trunk/Development'
cd $(@D) && ./scripts/feeds install -a -p ffrlgit > /dev/null 2&>1
@echo ' INSTALL Freifunk Rheinland packages in OpenWrt Trunk/Development'
cd $(@D) && ./scripts/feeds install -a -p ffrl > /dev/null 2&>1
@echo ' LINK OpenWrt Trunk/Development packages'
cd $(@D) && $(MAKE) $(MAKEFLAGS) package/symlinks
@echo ' INSTALL OpenWrt Routing kmod-batman-adv package'
cd $(@D) && ./scripts/feeds install -p routing kmod-batman-adv > /dev/null 2&>1
touch $@
.NOTPARALLEL:
openwrt/attitude_adjustment/.repo_access:
mkdir -p openwrt dl
@echo ' GIT-Clone OpenWrt Attitude Adjustment (FF-Adv Repo)'
git clone -q git://github.com/FreifunkAdvanced/attitude_adjustment.git $(@D)
[[ -h $(@D)/dl ]] || ln -s ../../dl $(@D)/
@echo ' UPDATE OpenWrt Attitude Adjustment feeds'
cd $(@D) && ./scripts/feeds uninstall -a > /dev/null 2&>1
cat feeds.conf.attitude_adjustment feeds.conf.ffadv > $(@D)/feeds.conf
@echo ' INSERT Freifunk Rheinland Buildroot packages in OpenWrt Attitude Adjustment'
echo "src-link ffrl $$(pwd)/feeds/ffrl" >> $(@D)/feeds.conf
cd $(@D) && ./scripts/feeds update -a > /dev/null 2&>1
@echo ' INSTALL Freifunk Rheinland Git repo in OpenWrt Attitude Adjustment'
cd $(@D) && ./scripts/feeds install -a -p ffrlgit > /dev/null 2&>1
@echo ' INSTALL Freifunk Rheinland packages in OpenWrt Attitude Adjustment'
cd $(@D) && ./scripts/feeds install -a -p ffrl > /dev/null 2&>1
@echo ' LINK OpenWrt Attitude Adjustment packages'
cd $(@D) && $(MAKE) $(MAKEFLAGS) package/symlinks
@echo ' REMOVE OpenWrt Attitude Adjustment OpenVPN version'
cd $(@D) && ./scripts/feeds uninstall openvpn > /dev/null 2&>1
@echo ' REMOVE OpenWrt Attitude Adjustment uhttpd version'
cd $(@D) && ./scripts/feeds uninstall uhttpd > /dev/null 2&>1
@echo ' INSTALL OpenWrt FF-Adv trunk backports OpenVPN version (PolarSSL variant)'
cd $(@D) && ./scripts/feeds install -p ffadvbackports openvpn-polarssl > /dev/null 2&>1
@echo ' INSTALL OpenWrt FF-Adv trunk backports uhttpd2 version'
cd $(@D) && ./scripts/feeds install -p ffadvbackports uhttpd > /dev/null 2&>1
@echo ' INSTALL OpenWrt Routing kmod-batman-adv package'
cd $(@D) && ./scripts/feeds install -p routing kmod-batman-adv > /dev/null 2&>1
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-attitude_adjustment update-trunk
update-attitude_adjustment: openwrt/attitude_adjustment/.update
.NOTPARALLEL:
# update-trunk: settings_update
update-trunk: openwrt/trunk/.update
.NOTPARALLEL:
openwrt/trunk/.update:
mkdir -p openwrt dl
@echo ' GIT-Pull OpenWrt Trunk/Development (FF-Adv Repo)'
cd $(@D) && git pull -q
@echo ' UPDATE OpenWrt Trunk/Development feeds'
cd $(@D) && ./scripts/feeds uninstall -a > /dev/null 2&>1
cat feeds.conf.trunk feeds.conf.ffadv > $(@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/Development'
cd $(@D) && ./scripts/feeds install -a -p ffrl > /dev/null 2&>1
@echo ' LINK Trunk/Development packages'
cd $(@D) && $(MAKE) $(MAKEFLAGS) package/symlinks
@echo ' INSTALL OpenWrt Routing kmod-batman-adv package'
cd $(@D) && ./scripts/feeds install -p routing kmod-batman-adv > /dev/null 2&>1
touch $(@D).repo_access
.NOTPARALLEL:
openwrt/attitude_adjustment/.update:
mkdir -p openwrt dl
@echo ' GIT-Pull OpenWrt Attitude Adjustment (FF-Adv Repo)'
cd $(@D) && git pull -q
@echo ' UPDATE OpenWrt Attitude Adjustment feeds'
cd $(@D) && ./scripts/feeds uninstall -a > /dev/null 2&>1
cat feeds.conf.attitude_adjustment feeds.conf.ffadv > $(@D)/feeds.conf
@echo ' INSERT Freifunk Rheinland Buildroot packages in OpenWrt Attitude Adjustment'
echo "src-link ffrl $$(pwd)/feeds/ffrl" >> $(@D)/feeds.conf
cd $(@D) && ./scripts/feeds update -a > /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 Attitude Adjustment'
cd $(@D) && ./scripts/feeds install -a -p ffrl > /dev/null 2&>1
@echo ' LINK OpenWrt Attitude Adjustment packages'
cd $(@D) && $(MAKE) $(MAKEFLAGS) package/symlinks
@echo ' REMOVE OpenWrt Attitude Adjustment OpenVPN version'
cd $(@D) && ./scripts/feeds uninstall openvpn > /dev/null 2&>1
@echo ' REMOVE OpenWrt Attitude Adjustment uhttpd version'
cd $(@D) && ./scripts/feeds uninstall uhttpd > /dev/null 2&>1
@echo ' INSTALL OpenWrt FF-Adv trunk backports OpenVPN version (PolarSSL variant)'
cd $(@D) && ./scripts/feeds install -p ffadvbackports openvpn-polarssl > /dev/null 2&>1
@echo ' INSTALL OpenWrt FF-Adv trunk backports uhttpd2 version'
cd $(@D) && ./scripts/feeds install -p ffadvbackports uhttpd > /dev/null 2&>1
@echo ' INSTALL OpenWrt Routing kmod-batman-adv package'
cd $(@D) && ./scripts/feeds install -p routing kmod-batman-adv > /dev/null 2&>1
touch $(@D).repo_access
# ------------------------------------
# Clean targets
# ------------------------------------
clean:
-rm -r config/*.config image/*
mrpropper: mrpropper-attitude_adjustment mrpropper-trunk
mrpropper-trunk:
cd openwrt/trunk && $(MAKE) clean
mrpropper-attitude_adjustment:
cd openwrt/attitude_adjustment && $(MAKE) clean
# ------------------------------------
# Package targets
# ------------------------------------
pack:
./makepackages build
# ------------------------------------
# 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-%: COMMUNITY=$(shell echo $(@F) | cut -f4- -d-)
image-%:
image-%:
if [ "$(PLAT)" == "" ]; then \
for pla in $(PLATFORM); do \
$(MAKE) image-$(REPO)-$${pla}; \
done; \
elif [[ "$(COMMUNITY)" == "" ]]; then \
for com in $(COMMUNITIES); do \
$(MAKE) image-$(REPO)-$(PLAT)-$${com}; \
done; \
else \
[[ "$(REPO)" == "trunk" ]] && $(MAKE) images/$(DATE)_$(VERSION)/$(COMMUNITY)-$(PLAT)-$(REPO)-r$(SVNREVISION) || true; \
[[ "$(REPO)" != "trunk" ]] && $(MAKE) images/$(DATE)_$(VERSION)/$(COMMUNITY)-$(PLAT)-$(REPO) || true; \
fi
image/%:
@echo '"make image/$$(repo)/openwrt-$$(platform)-$$(COMMUNITY)" 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): COMMUNITY="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
# ar71xx build target
.SECONDEXPANSION:
images/%: REPO=$(shell echo $(@F) | cut -f3 -d-)
images/%: PLAT=$(shell echo $(@F) | cut -f2 -d-)
images/%: COMMUNITY=$(shell echo $(@F) | cut -f1 -d-)
images/%: openwrt/$$(REPO)/.repo_access
@echo ' BUILD OpenWrt $(REPO) for $(PLAT) in $(COMMUNITY)'
./buildconf $(PLAT) $(COMMUNITY) > 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)/ $@/
mkdir -p packages/$(PLAT)
rm -f packages/$(PLAT)/*
rsync --include="ffadv*" \
--exclude="*" -a \
openwrt/$(REPO)/bin/$(PLAT)/packages/ packages/$(PLAT)/
cd packages/$(PLAT) && md5sum * > md5sums
cd packages/$(PLAT) && ../../openwrt/$(REPO)/scripts/ipkg-make-index.sh . > Packages
cat packages/$(PLAT)/Packages | gzip > packages/$(PLAT)/Packages.gz