forked from freifunk-gluon/gluon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
316 lines (228 loc) · 8.85 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
all:
LC_ALL:=C
LANG:=C
export LC_ALL LANG
empty:=
space:= $(empty) $(empty)
GLUONMAKE = $(SUBMAKE) -C $(GLUON_OPENWRTDIR) -f $(GLUONDIR)/Makefile
ifneq ($(OPENWRT_BUILD),1)
GLUONDIR:=${CURDIR}
include $(GLUONDIR)/include/gluon.mk
TOPDIR:=$(GLUON_OPENWRTDIR)
export TOPDIR
update: FORCE
$(GLUONDIR)/scripts/update.sh $(GLUONDIR)
$(GLUONDIR)/scripts/patch.sh $(GLUONDIR)
patch: FORCE
$(GLUONDIR)/scripts/patch.sh $(GLUONDIR)
unpatch: FORCE
$(GLUONDIR)/scripts/unpatch.sh $(GLUONDIR)
update-patches: FORCE
$(GLUONDIR)/scripts/update.sh $(GLUONDIR)
$(GLUONDIR)/scripts/update-patches.sh $(GLUONDIR)
$(GLUONDIR)/scripts/patch.sh $(GLUONDIR)
-include $(TOPDIR)/include/host.mk
_SINGLE=export MAKEFLAGS=$(space);
override OPENWRT_BUILD=1
GREP_OPTIONS=
export OPENWRT_BUILD GREP_OPTIONS
-include $(TOPDIR)/include/debug.mk
-include $(TOPDIR)/include/depends.mk
include $(GLUONDIR)/include/toplevel.mk
define GluonProfile
image/$(1): FORCE
+@$$(GLUONMAKE) $$@
endef
define GluonModel
endef
include $(GLUONDIR)/include/profiles.mk
CheckExternal := test -d $(GLUON_OPENWRTDIR) || (echo 'You don'"'"'t seem to have optained the external repositories needed by Gluon; please call `make update` first!'; false)
all: FORCE
@$(CheckExternal)
+@$(GLUONMAKE) prepare
+@$(GLUONMAKE) images
download prepare images: FORCE
@$(CheckExternal)
+@$(GLUONMAKE) $@
manifest: FORCE
@$(CheckExternal)
[ -n "$(GLUON_BRANCH)" ] || (echo 'Please set GLUON_BRANCH to create a manifest.'; false)
+@$(GLUONMAKE) $@
dirclean: clean
@$(CheckExternal)
+@$(SUBMAKE) -C $(TOPDIR) -r dirclean
cleanall: clean
@$(CheckExternal)
+@$(SUBMAKE) -C $(TOPDIR) -r clean
clean:
@$(CheckExternal)
+@$(GLUONMAKE) clean
else
include $(GLUONDIR)/include/gluon.mk
include $(TOPDIR)/include/host.mk
include rules.mk
include $(INCLUDE_DIR)/depends.mk
include $(INCLUDE_DIR)/subdir.mk
include package/Makefile
include tools/Makefile
include toolchain/Makefile
BOARD := ar71xx
override SUBTARGET := generic
PROFILES :=
PROFILE_PACKAGES :=
gluon_prepared_stamp := $(GLUON_BUILDDIR)/$(BOARD)/prepared
define Profile
$(eval $(call Profile/Default))
$(eval $(call Profile/$(1)))
$(1)_PACKAGES := $(PACKAGES)
endef
define GluonProfile
image/$(1): $(gluon_prepared_stamp)
+$(GLUONMAKE) image PROFILE="$(1)" V=s$(OPENWRT_VERBOSE)
CheckSite := (perl $(GLUON_SITEDIR)/site.conf 2>&1) > /dev/null || (echo 'Your site configuration did not pass validation; please verify yourself with `perl site.conf` and fix the problems.';false)
PROFILES += $(1)
PROFILE_PACKAGES += $(filter-out -%,$($(1)_PACKAGES) $(2) $(GLUON_$(1)_SITE_PACKAGES))
GLUON_$(1)_DEFAULT_PACKAGES := $(2)
GLUON_$(1)_MODELS :=
endef
define GluonModel
GLUON_$(1)_MODELS += $(2)
GLUON_$(1)_MODEL_$(2) := $(3)
endef
include $(INCLUDE_DIR)/target.mk
include $(GLUONDIR)/include/profiles.mk
$(BUILD_DIR)/.prepared: Makefile
@mkdir -p $$(dirname $@)
@touch $@
$(toolchain/stamp-install): $(tools/stamp-install)
$(package/stamp-compile): $(package/stamp-cleanup)
clean: FORCE
rm -rf $(GLUON_BUILDDIR)
refresh_feeds: FORCE
export MAKEFLAGS=V=s$(OPENWRT_VERBOSE); \
export SCAN_COOKIE=; \
scripts/feeds uninstall -a; \
scripts/feeds update -a; \
scripts/feeds install -a
export GLUON_GENERATE := $(GLUONDIR)/scripts/generate.sh
export GLUON_CONFIGURE := $(GLUONDIR)/scripts/configure.pl
feeds: FORCE
( \
[ ! -f $(GLUON_SITEDIR)/modules ] || . $(GLUON_SITEDIR)/modules && for feed in $$GLUON_SITE_FEEDS; do echo src-link $$feed ../../packages/$$feed; done; \
. $(GLUONDIR)/modules && for feed in $$GLUON_FEEDS; do echo src-link $$feed ../../packages/$$feed; done; \
) > feeds.conf
+$(GLUONMAKE) refresh_feeds V=s$(OPENWRT_VERBOSE)
config: FORCE
echo \
'CONFIG_TARGET_$(BOARD)=y' \
'CONFIG_TARGET_ROOTFS_JFFS2=n' \
'CONFIG_BUSYBOX_CONFIG_SHA512SUM=y' \
'CONFIG_ATH_USER_REGD=y' \
'$(patsubst %,CONFIG_PACKAGE_%=m,$(sort $(GLUON_DEFAULT_PACKAGES) $(GLUON_SITE_PACKAGES) $(PROFILE_PACKAGES)))' \
| sed -e 's/ /\n/g' > .config
$(_SINGLE)$(SUBMAKE) defconfig OPENWRT_BUILD=
.config:
+$(GLUONMAKE) config
download: .config FORCE
+$(SUBMAKE) tools/download
+$(SUBMAKE) toolchain/download
+$(SUBMAKE) package/download
+$(SUBMAKE) target/download
toolchain: $(toolchain/stamp-install) $(tools/stamp-install)
include $(INCLUDE_DIR)/kernel.mk
kernel: FORCE
+$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.image TARGET_BUILD=1
+$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.modules TARGET_BUILD=1
packages: $(package/stamp-compile)
$(_SINGLE)$(SUBMAKE) -r package/index
prepare-image: FORCE
rm -rf $(BOARD_KDIR)
mkdir -p $(BOARD_KDIR)
cp $(KERNEL_BUILD_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf $(BOARD_KDIR)/
+$(SUBMAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image -f $(GLUONDIR)/include/Makefile.image prepare KDIR="$(BOARD_KDIR)"
prepare: FORCE
@$(CheckSite)
mkdir -p $(GLUON_IMAGEDIR) $(GLUON_BUILDDIR)/$(BOARD)
echo 'src packages file:../openwrt/bin/$(BOARD)/packages' > $(GLUON_BUILDDIR)/$(BOARD)/opkg.conf
+$(GLUONMAKE) feeds
+$(GLUONMAKE) config
+$(GLUONMAKE) toolchain
+$(GLUONMAKE) kernel
+$(GLUONMAKE) packages
+$(GLUONMAKE) prepare-image
echo "$(GLUON_RELEASE)" > $(gluon_prepared_stamp)
$(gluon_prepared_stamp):
+$(GLUONMAKE) prepare
include $(INCLUDE_DIR)/package-ipkg.mk
# override variables from rules.mk
PACKAGE_DIR = $(GLUON_OPENWRTDIR)/bin/$(BOARD)/packages
PROFILE_BUILDDIR = $(BOARD_BUILDDIR)/$(PROFILE)
PROFILE_KDIR = $(PROFILE_BUILDDIR)/kernel
BIN_DIR = $(PROFILE_BUILDDIR)/images
TMP_DIR = $(PROFILE_BUILDDIR)/tmp
TARGET_DIR = $(PROFILE_BUILDDIR)/root
IMAGE_PREFIX = gluon-$(GLUON_SITE_CODE)-$$(cat $(gluon_prepared_stamp))
OPKG:= \
IPKG_TMP="$(TMP_DIR)/ipkgtmp" \
IPKG_INSTROOT="$(TARGET_DIR)" \
IPKG_CONF_DIR="$(TMP_DIR)" \
IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
$(STAGING_DIR_HOST)/bin/opkg \
-f $(BOARD_BUILDDIR)/opkg.conf \
--force-depends \
--force-overwrite \
--force-postinstall \
--cache $(TMP_DIR)/dl \
--offline-root $(TARGET_DIR) \
--add-dest root:/ \
--add-arch all:100 \
--add-arch $(ARCH_PACKAGES):200
EnableInitscript = ! grep -q '\#!/bin/sh /etc/rc.common' $(1) || bash ./etc/rc.common $(1) enable
enable_initscripts: FORCE
cd $(TARGET_DIR) && ( export IPKG_INSTROOT=$(TARGET_DIR); \
$(foreach script,$(wildcard $(TARGET_DIR)/etc/init.d/*), \
$(call EnableInitscript,$(script)); \
) : \
)
# Generate package list
$(eval $(call merge-lists,INSTALL_PACKAGES,DEFAULT_PACKAGES $(PROFILE)_PACKAGES GLUON_DEFAULT_PACKAGES GLUON_SITE_PACKAGES GLUON_$(PROFILE)_DEFAULT_PACKAGES GLUON_$(PROFILE)_SITE_PACKAGES))
package_install: FORCE
$(OPKG) update
$(OPKG) install $(PACKAGE_DIR)/libc_*.ipk
$(OPKG) install $(PACKAGE_DIR)/kernel_*.ipk
$(OPKG) install $(INSTALL_PACKAGES)
+$(GLUONMAKE) enable_initscripts
rm -f $(TARGET_DIR)/usr/lib/opkg/lists/* $(TARGET_DIR)/tmp/opkg.lock
image: FORCE
rm -rf $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(PROFILE_KDIR)
mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(TARGET_DIR)/tmp $(GLUON_IMAGEDIR)/factory $(GLUON_IMAGEDIR)/sysupgrade
cp -r $(BOARD_KDIR) $(PROFILE_KDIR)
+$(GLUONMAKE) package_install
$(call Image/mkfs/prepare)
$(_SINGLE)$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 IMG_PREFIX="$(IMAGE_PREFIX)-$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))" \
PROFILE="$(PROFILE)" KDIR="$(PROFILE_KDIR)" TARGET_DIR="$(TARGET_DIR)" BIN_DIR="$(BIN_DIR)" TMP_DIR="$(TMP_DIR)"
$(foreach model,$(GLUON_$(PROFILE)_MODELS), \
rm -f $(GLUON_IMAGEDIR)/factory/gluon-*-$(GLUON_$(PROFILE)_MODEL_$(model)).bin && \
rm -f $(GLUON_IMAGEDIR)/sysupgrade/gluon-*-$(GLUON_$(PROFILE)_MODEL_$(model))-sysupgrade.bin && \
\
cp $(BIN_DIR)/$(IMAGE_PREFIX)-$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))-$(model)-factory.bin $(GLUON_IMAGEDIR)/factory/$(IMAGE_PREFIX)-$(GLUON_$(PROFILE)_MODEL_$(model)).bin && \
cp $(BIN_DIR)/$(IMAGE_PREFIX)-$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))-$(model)-sysupgrade.bin $(GLUON_IMAGEDIR)/sysupgrade/$(IMAGE_PREFIX)-$(GLUON_$(PROFILE)_MODEL_$(model))-sysupgrade.bin && \
) :
call_image/%: FORCE
+$(GLUONMAKE) $(patsubst call_image/%,image/%,$@)
images: $(patsubst %,call_image/%,$(PROFILES)) ;
manifest: FORCE
mkdir -p $(GLUON_IMAGEDIR)/sysupgrade
(cd $(GLUON_IMAGEDIR)/sysupgrade && echo 'BRANCH=$(GLUON_BRANCH)' && echo && ($(foreach profile,$(PROFILES), \
$(foreach model,$(GLUON_$(profile)_MODELS), \
for file in gluon-*-'$(GLUON_$(profile)_MODEL_$(model))-sysupgrade.bin'; do \
[ -e "$$file" ] && echo \
'$(GLUON_$(profile)_MODEL_$(model))' \
"$$(echo "$$file" | sed -n -r -e 's/^gluon-$(call regex-escape,$(GLUON_SITE_CODE))-(.*)-$(call regex-escape,$(GLUON_$(profile)_MODEL_$(model)))-sysupgrade\.bin$$/\1/p')" \
"$$(sha512sum "$$file" | awk '{print $$1}')" \
"$$file" && break; \
done; \
) \
) :)) > $(GLUON_IMAGEDIR)/sysupgrade/$(GLUON_BRANCH).manifest
.PHONY: all images prepare clean cleanall
endif