Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/Makefile
blob: ea332c923162bfc39151ae539b8dfced7c659669 (plain)
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
V=$(shell git describe)
SHELL=/bin/bash
BUILDTOOLVER ?= $(V)

PREFIX = /usr/local
MANDIR = $(PREFIX)/share/man
DATADIR = $(PREFIX)/share/devtools
BUILDDIR = build

rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))

BINPROGS_SRC = $(wildcard src/*.in)
BINPROGS = $(addprefix $(BUILDDIR)/,$(patsubst src/%,bin/%,$(patsubst %.in,%,$(BINPROGS_SRC))))
LIBRARY_SRC = $(call rwildcard,src/lib,*.sh)
LIBRARY = $(addprefix $(BUILDDIR)/,$(patsubst src/%,%,$(patsubst %.in,%,$(LIBRARY_SRC))))
MAKEPKG_CONFIGS=$(wildcard config/makepkg/*)
PACMAN_CONFIGS=$(wildcard config/pacman/*)
GIT_CONFIGS = $(wildcard config/git/*)
SETARCH_ALIASES = $(wildcard config/setarch-aliases.d/*)
MANS = $(addprefix $(BUILDDIR)/,$(patsubst %.asciidoc,%,$(wildcard doc/man/*.asciidoc)))

GENERATED_PACMAN_CONFIGS = \
	core-testing-i486.conf \
	core-testing-i686.conf \
	core-testing-pentium4.conf \
	core-staging-i486.conf \
	core-staging-i686.conf \
	core-staging-pentium4.conf \
	core-staging-with-build-support-i486.conf \
	core-staging-with-build-support-i686.conf \
	core-staging-with-build-support-pentium4.conf \
	extra-i486.conf \
	extra-i686.conf \
	extra-pentium4.conf \
	extra-testing-i486.conf \
	extra-testing-i686.conf \
	extra-testing-pentium4.conf \
	extra-staging-i486.conf \
	extra-staging-i686.conf \
	extra-staging-pentium4.conf \
	extra-staging-with-build-support-i486.conf \
	extra-staging-with-build-support-i686.conf \
	extra-staging-with-build-support-pentium4.conf \
	build-support-staging-with-build-support-i486.conf \
	build-support-staging-with-build-support-i686.conf \
	build-support-staging-with-build-support-pentium4.conf \
	kde-unstable-i486.conf \
	kde-unstable-i686.conf \
	kde-unstable-pentium4.conf \
	gnome-unstable-i486.conf \
	gnome-unstable-i686.conf \
	gnome-unstable-pentium4.conf
GENERATED_MAKEPKG_CONFIGS = \
	i486.conf \
	i686.conf \
	pentium4.conf
GENERATED_PACMAN_CONFIGS := $(addprefix $(BUILDDIR)/pacman.conf.d/,$(GENERATED_PACMAN_CONFIGS))
GENERATED_MAKEPKG_CONFIGS := $(addprefix $(BUILDDIR)/makepkg.conf.d/,$(GENERATED_MAKEPKG_CONFIGS))

COMMITPKG_LINKS = \
	core-testingpkg \
	core-stagingpkg \
	extrapkg \
	extra-testingpkg \
	extra-stagingpkg \
	multilibpkg \
	multilib-testingpkg \
	multilib-stagingpkg \
	kde-unstablepkg \
	gnome-unstablepkg

ARCHBUILD_LINKS = \
	core-testing-i486-build \
	core-testing-i686-build \
	core-testing-pentium4-build \
	core-testing-x86_64-build \
	core-testing-x86_64_v3-build \
	core-staging-i486-build \
	core-staging-i686-build \
	core-staging-pentium4-build \
	core-staging-x86_64-build \
	core-staging-x86_64_v3-build \
	core-staging-x86_64-build \
	core-staging-with-build-support-i486-build \
	core-staging-with-build-support-i686-build \
	core-staging-with-build-support-pentium4-build \
	extra-i486-build \
	extra-i686-build \
	extra-pentium4-build \
	extra-x86_64-build \
	extra-x86_64_v3-build \
	extra-testing-i486-build \
	extra-testing-i686-build \
	extra-testing-pentium4-build \
	extra-testing-x86_64-build \
	extra-testing-x86_64_v3-build \
	extra-staging-i486-build \
	extra-staging-i686-build \
	extra-staging-pentium4-build \
	extra-staging-x86_64-build \
	extra-staging-x86_64_v3-build \
	extra-staging-with-build-support-i486-build \
	extra-staging-with-build-support-i686-build \
	extra-staging-with-build-support-pentium4-build \
	build-support-staging-with-build-support-i486-build \
	build-support-staging-with-build-support-i686-build \
	build-support-staging-with-build-support-pentium4-build \
	multilib-build \
	multilib-testing-build \
	multilib-staging-build \
	kde-unstable-i486-build \
	kde-unstable-i686-build \
	kde-unstable-pentium4-build \
	kde-unstable-x86_64-build \
	gnome-unstable-i486-build \
	gnome-unstable-i686-build \
	gnome-unstable-pentium4-build \
	gnome-unstable-x86_64-build

COMPLETIONS = $(addprefix $(BUILDDIR)/,$(patsubst %.in,%,$(wildcard contrib/completion/*/*)))


all: binprogs library conf completion man configfiles
binprogs: $(BINPROGS)
library: $(LIBRARY)
completion: $(COMPLETIONS)
configfiles: $(GENERATED_MAKEPKG_CONFIGS) $(GENERATED_PACMAN_CONFIGS)
man: $(MANS)


ifneq ($(wildcard *.in),)
	$(error Legacy in prog file found: $(wildcard *.in) - please migrate to src/*)
endif
ifneq ($(wildcard pacman-*.conf),)
	$(error Legacy pacman config file found: $(wildcard pacman-*.conf) - please migrate to config/pacman/*)
endif
ifneq ($(wildcard makepkg-*.conf),)
	$(error Legacy makepkg config files found: $(wildcard makepkg-*.conf) -  please migrate to config/makepkg/*)
endif
ifneq ($(wildcard setarch-aliases.d/*),)
	$(error Legacy setarch aliase found: $(wildcard setarch-aliases.d/*) - please migrate to config/setarch-aliases.d/*)
endif


edit = sed \
	-e "s|@pkgdatadir[@]|$(DATADIR)|g" \
	-e "s|@buildtoolver[@]|$(BUILDTOOLVER)|g"
GEN_MSG = @echo "GEN $(patsubst $(BUILDDIR)/%,%,$@)"

$(BUILDDIR)/makepkg.conf.d/i486.conf: config/makepkg/x86_64.conf
	@echo "GEN $(notdir $@)"
	@mkdir -p $(dir $@)
	@sed " \
		s,\(["'"'"=]\)x86[-_]64\([-"'"'" ]\),\1i486\2,g; \
		s,-fcf-protection,,g; \
		s,LTOFLAGS=".*",LTOFLAGS=\"-fno-lto\",g; \
		/OPTIONS=/s/ lto/ !lto/; \
	" "$<" > "$@"
	@sed -i 's/--ultra -20/--ultra -19/' "$@"

$(BUILDDIR)/makepkg.conf.d/i686.conf: config/makepkg/x86_64.conf
	@echo "GEN $(notdir $@)"
	@mkdir -p $(dir $@)
	@sed " \
		s,\(["'"'"=]\)x86[-_]64\([-"'"'" ]\),\1i686\2,g; \
		s,-fcf-protection,,g; \
	" "$<" > "$@"
	@sed -i 's/--ultra -20/--ultra -19/' "$@"

$(BUILDDIR)/makepkg.conf.d/pentium4.conf: $(BUILDDIR)/makepkg.conf.d/i686.conf
	@echo "GEN $(notdir $@)"
	@mkdir -p $(dir $@)
	@sed '/^CHOST=/ ! s,\(["=]\)i686\([-" ]\),\1pentium4\2,g' "$<" > "$@"
	@sed -i 's/--ultra -20/--ultra -19/' "$@"

$(BUILDDIR)/pacman.conf.d/%-i486.conf: config/pacman/%.conf
	@echo "GEN $(notdir $@)"
	@mkdir -p $(dir $@)
	@sed " \
	s,/mirrorlist\$$,\032,; \
	/^Architecture = / s/^.*\$$/Architecture = i486/; \
	" "$<" > /tmp/$$.tmp
	@sed -i '/^\[core-staging\]/ i \[staging\]\nInclude = \/etc\/pacman.d\/mirrorlist32\n' /tmp/$$.tmp
	@sed -i '/^\[core-testing\]/ i \[testing\]\nInclude = \/etc\/pacman.d\/mirrorlist32\n' /tmp/$$.tmp
	@cat /tmp/$$.tmp > "$@"

$(BUILDDIR)/pacman.conf.d/%-i686.conf: config/pacman/%.conf
	@echo "GEN $(notdir $@)"
	@mkdir -p $(dir $@)
	@sed " \
	s,/mirrorlist\$$,\032,; \
	/^Architecture = / s/^.*$$/Architecture = i686/ \
	" "$<" > /tmp/$$.tmp
	@sed -i '/^\[core-staging\]/ i \[staging\]\nInclude = \/etc\/pacman.d\/mirrorlist32\n' /tmp/$$.tmp
	@sed -i '/^\[core-testing\]/ i \[testing\]\nInclude = \/etc\/pacman.d\/mirrorlist32\n' /tmp/$$.tmp
	@cat /tmp/$$.tmp > "$@"

$(BUILDDIR)/pacman.conf.d/%-pentium4.conf: config/pacman/%.conf
	@echo "GEN $(notdir $@)"
	@mkdir -p $(dir $@)
	@sed " \
	s,/mirrorlist\$$,\032,; \
	/^Architecture = / s/^.*$$/Architecture = pentium4/ \
	" "$<" > /tmp/$$.tmp
	@sed -i '/^\[core-staging\]/ i \[staging\]\nInclude = \/etc\/pacman.d\/mirrorlist32\n' /tmp/$$.tmp
	@sed -i '/^\[core-testing\]/ i \[testing\]\nInclude = \/etc\/pacman.d\/mirrorlist32\n' /tmp/$$.tmp
	@cat /tmp/$$.tmp > "$@"

define buildInScript
$(1)/%: $(2)%$(3)
	$$(GEN_MSG)
	@mkdir -p $$(dir $$@)
	@$(RM) "$$@"
	@cat $$< | $(edit) >$$@
	@chmod $(4) "$$@"
	@bash -O extglob -n "$$@"
endef

$(eval $(call buildInScript,build/bin,src/,.in,755))
$(eval $(call buildInScript,build/lib,src/lib/,,644))
$(foreach completion,$(wildcard contrib/completion/*),$(eval $(call buildInScript,build/$(completion),$(completion)/,.in,444)))

$(BUILDDIR)/doc/man/%: doc/man/%.asciidoc doc/asciidoc.conf doc/man/include/footer.asciidoc
	$(GEN_MSG)
	@mkdir -p $(BUILDDIR)/doc/man
	@a2x --no-xmllint --asciidoc-opts="-f doc/asciidoc.conf" -d manpage -f manpage --destination-dir=$(BUILDDIR)/doc/man -a pkgdatadir=$(DATADIR) $<

conf:
	@install -d $(BUILDDIR)/makepkg.conf.d
	@cp -a $(MAKEPKG_CONFIGS) $(BUILDDIR)/makepkg.conf.d
	@install -d $(BUILDDIR)/pacman.conf.d
	@cp -a $(PACMAN_CONFIGS) $(BUILDDIR)/pacman.conf.d
	@install -d $(BUILDDIR)/git.conf.d
	@cp -a $(GIT_CONFIGS) $(BUILDDIR)/git.conf.d

clean:
	rm -rf $(BUILDDIR)

install: all
	install -dm0755 $(DESTDIR)$(PREFIX)/bin
	install -dm0755 $(DESTDIR)$(DATADIR)/setarch-aliases.d
	install -dm0755 $(DESTDIR)$(DATADIR)/makepkg.conf.d
	install -dm0755 $(DESTDIR)$(DATADIR)/pacman.conf.d
	install -m0755 ${BINPROGS} $(DESTDIR)$(PREFIX)/bin
	install -dm0755 $(DESTDIR)$(DATADIR)/lib
	cp -ra $(BUILDDIR)/lib/* $(DESTDIR)$(DATADIR)/lib
	cp -a $(BUILDDIR)/git.conf.d -t $(DESTDIR)$(DATADIR)
	for conf in $(notdir $(MAKEPKG_CONFIGS)); do install -Dm0644 $(BUILDDIR)/makepkg.conf.d/$$conf $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done
	for conf in $(notdir $(GENERATED_MAKEPKG_CONFIGS)); do install -Dm0644 $(BUILDDIR)/makepkg.conf.d/$$conf $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done
	for conf in $(notdir $(PACMAN_CONFIGS)); do install -Dm0644 $(BUILDDIR)/pacman.conf.d/$$conf $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done
	for conf in $(notdir $(GENERATED_PACMAN_CONFIGS)); do install -Dm0644 $(BUILDDIR)/pacman.conf.d/$$conf $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done
	for a in ${SETARCH_ALIASES}; do install -m0644 $$a -t $(DESTDIR)$(DATADIR)/setarch-aliases.d; done
	for l in ${COMMITPKG_LINKS}; do ln -sf commitpkg $(DESTDIR)$(PREFIX)/bin/$$l; done
	for l in ${ARCHBUILD_LINKS}; do ln -sf archbuild $(DESTDIR)$(PREFIX)/bin/$$l; done
	ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides
	install -Dm0644 $(BUILDDIR)/contrib/completion/bash/devtools $(DESTDIR)$(PREFIX)/share/bash-completion/completions/devtools
	for f in $(notdir $(BINPROGS)); do ln -sf devtools $(DESTDIR)$(PREFIX)/share/bash-completion/completions/$$f; done
	install -Dm0644 $(BUILDDIR)/contrib/completion/zsh/_devtools $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools
	for manfile in $(MANS); do \
		install -Dm644 $$manfile -t $(DESTDIR)$(MANDIR)/man$${manfile##*.}; \
	done;

uninstall:
	for f in $(notdir $(BINPROGS)); do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done
	for f in $(notdir $(LIBRARY)); do rm -f $(DESTDIR)$(DATADIR)/lib/$$f; done
	rm -rf $(DESTDIR)$(DATADIR)/lib
	rm -rf $(DESTDIR)$(DATADIR)/git.conf.d
	for conf in $(notdir $(MAKEPKG_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done
	for conf in $(notdir $(GENERATED_MAKEPKG_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done
	for conf in $(notdir $(PACMAN_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done
	for conf in $(notdir $(GENERATED_PACMAN_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done
	for f in $(notdir $(SETARCH_ALIASES)); do rm -f $(DESTDIR)$(DATADIR)/setarch-aliases.d/$$f; done
	for l in ${COMMITPKG_LINKS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$l; done
	for l in ${ARCHBUILD_LINKS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$l; done
	rm -f $(DESTDIR)$(PREFIX)/share/bash-completion/completions/devtools
	for f in $(notdir $(BINPROGS)); do rm -f $(DESTDIR)$(PREFIX)/share/bash-completion/completions/$$f; done
	rm -f $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools
	rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides
	for manfile in $(notdir $(MANS)); do rm -f $(DESTDIR)$(MANDIR)/man$${manfile##*.}/$${manfile}; done;
	rmdir --ignore-fail-on-non-empty \
		$(DESTDIR)$(DATADIR)/setarch-aliases.d \
		$(DESTDIR)$(DATADIR)/makepkg.conf.d \
		$(DESTDIR)$(DATADIR)/pacman.conf.d \
		$(DESTDIR)$(DATADIR)

tag:
	git cliff --strip=all --unreleased
	@echo "current version: v$(V)"
	@read -r -p "tag version: v" VERSION && \
	sed -E "s|^V=.+|V=$$VERSION|" -i Makefile && \
	git commit --gpg-sign --message "chore(release): version v$$VERSION" Makefile && \
	git tag --sign --message "Version v$$VERSION" v$$VERSION

release: dist
	git push --tags origin master
	git cliff --version >/dev/null
	GITLAB_HOST=gitlab.archlinux.org glab release create v$(V) devtools-$(V).tar.gz* --milestone v$(V) --notes-file <(git cliff --strip=all --latest)

dist:
	git archive --format=tar --prefix=devtools32-$(V)/ v$(V) | gzip > devtools32-$(V).tar.gz
	gpg --detach-sign --use-agent devtools32-$(V).tar.gz

upload:
	scp devtools32-$(V).tar.gz devtools32-$(V).tar.gz.sig sources.archlinux32.org:httpdocs/sources/

check: $(BINPROGS_SRC) $(LIBRARY_SRC) contrib/completion/bash/devtools.in config/makepkg/x86_64.conf contrib/makepkg/PKGBUILD.proto
	shellcheck $^

.PHONY: all binprogs library completion conf man clean install uninstall tag dist upload check
.DELETE_ON_ERROR: