-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
249 lines (201 loc) · 8.14 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
VERSION := $(shell echo git-`git log --format=format:%h -n1`)
DATE := $(shell git log --format=format:%cd --date=short -n1)
# *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
# OpenWrt
BACKFIREVERSION := 10.03.1
#SVNREVISION := 29909
SVNREVISION := 30795
#SVNREVISION := `svn info svn://svn.openwrt.org/openwrt/trunk/ | grep "Rev:" | sed -e "s/.*: //g"`
#SVNREVISION := `svn info openwrt/trunk| grep "Rev:" | sed -e "s/.*: //g"`
# FFJ
FFJVERSION := git-dcce1a8
FFJDATE := 2011-12-05
REPOSITORY = backfire trunk
export REPOSITORY
PLATFORM = ar71xx atheros
export PLATFORM
COMMUNITY = duesseldorf krefeld neuss solingen wuppertal
export COMMUNITY
# disable for screen flooding, enable for quiet run
MAKEFLAGS += -s --no-print-directory
ifeq ($(OS),Linux)
NUMPROC := $(shell grep -c ^processor /proc/cpuinfo)
else ifeq ($(OS),Darwin)
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
# ------------------------------------
# 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.
# Put your favorite make targets in correct order in this target.
all: help
help:
cat doc/build-HOWTO
test:
cd config && $(MAKE) test-text1-text2-text3
info:
@echo "Freifunk Rheinland Buildroot"
@echo " Version: $(VERSION)"
@echo " Date: $(DATE)"
@echo ''
@echo "Freifunk Jena udp-broadcast"
@echo " Version: $(FFJVERSION)"
@echo " Date: $(FFJDATE)"
@echo ''
@echo "OpenWrt"
@echo " Backfire: $(BACKFIREVERSION)"
@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-backfire fetch-trunk
fetch-backfire: openwrt/backfire/.repo_access
fetch-trunk: openwrt/trunk/.repo_access
.NOTPARALLEL:
openwrt/backfire/.repo_access:
mkdir -p openwrt dl
@echo ' SVN OpenWrt Backfire $(BACKFIREVERSION)'
svn co -q svn://svn.openwrt.org/openwrt/tags/backfire_$(BACKFIREVERSION)/ $(@D)
[[ -h $(@D)/dl ]] || ln -s ../../dl $(@D)/
cat $(@D)/feeds.conf.default feeds.conf > $(@D)/feeds.conf
@echo ' UPDATE OpenWrt Backfire $(BACKFIREVERSION) feeds'
cd $(@D) && ./scripts/feeds update > /dev/null 2&>1
@echo ' INSTALL Freifunk Jena udp-broadcast $(FFJVERSION) in OpenWrt Backfire'
cd $(@D) && ./scripts/feeds install -a -p ffj > /dev/null 2&>1
@echo ' LINK OpenWrt Backfire $(BACKFIREVERSION) packages'
cd $(@D) && $(MAKE) $(MAKEFLAGS) package/symlinks
touch $@
.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)/
cat $(@D)/feeds.conf.default feeds.conf > $(@D)/feeds.conf
@echo ' UPDATE OpenWrt Trunk r$(SVNREVISION) feeds'
cd $(@D) && ./scripts/feeds update > /dev/null 2&>1
@echo ' INSTALL Freifunk Jena udp-broadcast $(FFJVERSION) in OpenWrt Trunk'
cd $(@D) && ./scripts/feeds install -a -p ffj > /dev/null 2&>1
@echo ' LINK OpenWrt Trunk r$(SVNREVISION) packages'
cd $(@D) && $(MAKE) $(MAKEFLAGS) package/symlinks
touch $@
# ------------------------------------
# Update targets
# ------------------------------------
update: update-backfire update-trunk
update-backfire: openwrt/backfire/.update
update-trunk: openwrt/trunk/.update
.NOTPARALLEL:
openwrt/backfire/.update:
mkdir -p openwrt dl
@echo ' SVN OpenWrt Backfire $(BACKFIREVERSION) (update)'
cd $(@D) && svn update -q
cat $(@D)/feeds.conf.default feeds.conf > $(@D)/feeds.conf
@echo ' UPDATE OpenWrt Backfire $(BACKFIREVERSION) feeds'
cd $(@D) && ./scripts/feeds update > /dev/null 2&>1
@echo ' INSTALL Freifunk Jena udp-broadcast $(FFJVERSION) (update)'
cd $(@D) && ./scripts/feeds install -a -p ffj > /dev/null 2&>1
@echo ' LINK OpenWrt Backfire $(BACKFIREVERSION) packages'
cd $(@D) && $(MAKE) $(MAKEFLAGS) package/symlinks
touch $(@D).repo_access
.NOTPARALLEL:
openwrt/trunk/.update:
mkdir -p openwrt dl
@echo ' SVN OpenWrt Trunk r$(SVNREVISION) (update)'
cd $(@D) && svn update -q -r $(SVNREVISION)
cat $(@D)/feeds.conf.default feeds.conf > $(@D)/feeds.conf
@echo ' UPDATE OpenWrt Trunk r$(SVNREVISION) feeds'
cd $(@D) && ./scripts/feeds update > /dev/null 2&>1
@echo ' INSTALL Freifunk Jena udp-broadcast $(FFJVERSION) (update)'
cd $(@D) && ./scripts/feeds install -a -p ffj > /dev/null 2&>1
@echo ' LINK OpenWrt Trunk r$(SVNREVISION) packages'
cd $(@D) && $(MAKE) $(MAKEFLAGS) package/symlinks
touch $(@D).repo_access
# ------------------------------------
# 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
# format image/($repo)/openwrt-$(platform)-$(model)
.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/%: config/$$(REPO)-$$(PLAT)-$$(MODEL).config \
openwrt/$$(REPO)/.repo_access
@echo ' BUILD OpenWrt $(REPO) for $(PLAT) in $(MODEL)'
cp $< openwrt/$(REPO)/.config
-rm -r openwrt/$(REPO)/files
# not needed, make gets rid of old files by itself
#-rm -r openwrt/$(REPO)/bin/$(PLAT)
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/
#./name_firmware openwrt/$(REPO)
echo $(DATE)_$(VERSION)`[ -n "$$(git status --porcelain)" ] && \
echo -n "-modified"`_$(REPO)-`[[ "$(REPO)" == "trunk" ]] && \
echo $(SVNREVISION) || echo $(BACKFIREVERSION)` > openwrt/$(REPO)/files/etc/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)`[ -n "$$(git status --porcelain)" ] && echo -n "-modified"`_$(REPO)/g" \
-e "s/buildSystem/`uname -n`/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
# It’s all about this command :-) disable for dry run
cd openwrt/$(REPO) && $(MAKE) -j$(NUMPROC)
mkdir -p $@
#mv openwrt/$(REPO)/bin/$(PLAT)/ $@/
rsync -a openwrt/$(REPO)/bin/$(PLAT)/ $@/