forked from SynoCommunity/spksrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
196 lines (160 loc) · 5.31 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
# Include framework self-test
include mk/spksrc.test-rules.mk
AVAILABLE_TCS = $(notdir $(wildcard toolchain/syno-*))
AVAILABLE_ARCHS = $(notdir $(subst syno-,/,$(AVAILABLE_TCS)))
SUPPORTED_SPKS = $(sort $(patsubst spk/%/Makefile,%,$(wildcard spk/*/Makefile)))
ifneq ($(firstword $(MAKECMDGOALS)),test)
all: $(SUPPORTED_SPKS)
endif
all-noarch:
@for spk in $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) ; \
do \
grep -q "override ARCH" "$${spk}/Makefile" && $(MAKE) -C $${spk} ; \
done
ifneq ($(firstword $(MAKECMDGOALS)),test)
clean: $(addsuffix -clean,$(SUPPORTED_SPKS))
clean: native-clean cross-clean
endif
dist-clean: clean
dist-clean: kernel-clean toolchain-clean toolkit-clean
native-clean:
@for native in $(dir $(wildcard native/*/Makefile)) ; \
do \
$(MAKE) -C $${native} clean ; \
done
toolchain-clean:
@for tc in $(dir $(wildcard toolchain/*/Makefile)) ; \
do \
$(MAKE) -C $${tc} clean ; \
done
toolkit-clean:
@for tk in $(dir $(wildcard toolkit/*/Makefile)) ; \
do \
$(MAKE) -C $${tk} clean ; \
done
kernel-clean:
@for kernel in $(dir $(wildcard kernel/*/Makefile)) ; \
do \
rm -rf $${kernel}/work* ; \
done
cross-clean:
@for cross in $(dir $(wildcard cross/*/Makefile)) ; \
do \
$(MAKE) -C $${cross} clean ; \
done
spk-clean:
@for spk in $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) ; \
do \
$(MAKE) -C $${spk} clean ; \
done
%: spk/%/Makefile
cd $(dir $^) && env $(MAKE)
native-%: native/%/Makefile
cd $(dir $^) && env $(MAKE)
native-%-clean: native/%/Makefile
cd $(dir $^) && env $(MAKE) clean
# build dependency flat list for all packages
dependency-flat:
@echo $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile)))
@for spk in $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) ; \
do \
echo "$(MAKE) -s -C $${spk} dependency-flat" ; \
$(MAKE) -s -C $${spk} dependency-flat ; \
done
# build dependency tree for all packages
dependency-tree:
@echo $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile)))
@for spk in $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) ; \
do \
echo "$(MAKE) --no-print-directory -C $${spk} dependency-tree" ; \
$(MAKE) --no-print-directory -C $${spk} dependency-tree ; \
done
# build dependency list for all packages
dependency-list:
@echo $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile)))
@for spk in $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) ; \
do \
echo "$(MAKE) -s -C $${spk} dependency-list" ; \
$(MAKE) -s -C $${spk} dependency-list ; \
done
# define a template that instantiates a 'python3-avoton-6.1' -style target for
# every ($2) arch, every ($1) spk
define SPK_ARCH_template =
spk-$(1)-$(2): spk/$(1)/Makefile setup
cd spk/$(1) && env $(MAKE) arch-$(2)
endef
$(foreach arch,$(AVAILABLE_ARCHS),$(foreach spk,$(SUPPORTED_SPKS),$(eval $(call SPK_ARCH_template,$(spk),$(arch)))))
prepare: downloads
@for tc in $(dir $(wildcard toolchain/*/Makefile)) ; \
do \
$(MAKE) -C $${tc} ; \
done
downloads:
@for dl in $(dir $(wildcard cross/*/Makefile)) ; \
do \
$(MAKE) -C $${tc} download ; \
done
natives:
@for n in $(dir $(wildcard native/*/Makefile)) ; \
do \
$(MAKE) -C $${n} ; \
done
native-digests:
@for n in $(dir $(wildcard native/*/Makefile)) ; \
do \
$(MAKE) -C $${n} digests ; \
done
toolchain-digests:
@for tc in $(dir $(wildcard toolchain/*/Makefile)) ; \
do \
$(MAKE) -C $${tc} digests ; \
done
toolkit-digests:
@for tk in $(dir $(wildcard toolkit/*/Makefile)) ; \
do \
$(MAKE) -C $${tk} digests ; \
done
kernel-digests:
@for kernel in $(dir $(wildcard kernel/*/Makefile)) ; \
do \
$(MAKE) -C $${kernel} digests ; \
done
cross-digests:
@for cross in $(dir $(wildcard cross/*/Makefile)) ; \
do \
$(MAKE) -C $${cross} digests ; \
done
jsonlint:
ifeq (,$(shell which jsonlint))
$(error "jsonlint not found, install with: npm install -g jsonlint")
else
find spk/ -not -path "*work*" -regextype posix-extended -regex '.*(\.json|install_uifile\w*|upgrade_uifile\w*|app/config)' -print -exec jsonlint -q -c {} \;
endif
lint: jsonlint
.PHONY: toolchains kernel-modules
toolchains: $(addprefix toolchain-,$(AVAILABLE_ARCHS))
kernel-modules: $(addprefix kernel-,$(AVAILABLE_ARCHS))
toolchain-%:
-@cd toolchain/syno-$*/ && MAKEFLAGS= $(MAKE)
kernel-%:
-@cd kernel/syno-$*/ && MAKEFLAGS= $(MAKE)
setup: local.mk dsm-6.2.4 dsm-7.1
local.mk:
@echo "Creating local configuration \"local.mk\"..."
@echo "PUBLISH_URL =" > $@
@echo "PUBLISH_API_KEY =" >> $@
@echo "DISTRIBUTOR =" >> $@
@echo "DISTRIBUTOR_URL =" >> $@
@echo "REPORT_URL =" >> $@
@echo "DEFAULT_TC =" >> $@
@echo "#PSTAT = on" >> $@
@echo "#PARALLEL_MAKE = max" >> $@
dsm-%: local.mk
@echo "Setting default toolchain version to DSM-$*"
@grep -q "^DEFAULT_TC.*=.*$*.*" local.mk || sed -i "/^DEFAULT_TC =/s/$$/ $*/" local.mk
setup-synocommunity: setup
@sed -i -e "s|PUBLISH_URL\s*=.*|PUBLISH_URL = https://api.synocommunity.com|" \
-e "s|DISTRIBUTOR\s*=.*|DISTRIBUTOR = SynoCommunity|" \
-e "s|DISTRIBUTOR_URL\s*=.*|DISTRIBUTOR_URL = https://synocommunity.com|" \
-e "s|REPORT_URL\s*=.*|REPORT_URL = https://github.com/SynoCommunity/spksrc/issues|" \
local.mk