-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile.am
249 lines (179 loc) · 7.16 KB
/
Makefile.am
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
ACLOCAL_AMFLAGS = -I build-aux
AM_DISTCHECK_CONFIGURE_FLAGS = --enable-developer-mode
.ONESHELL:
.SECONDARY:
.SECONDEXPANSION:
.DELETE_ON_ERROR:
docdir = $(datarootdir)/doc/$(TRANSFORMED_PACKAGE_NAME)
licensedir = $(datarootdir)/licenses/$(TRANSFORMED_PACKAGE_NAME)
datadir = $(datarootdir)/$(TRANSFORMED_PACKAGE_NAME)
pkgdatadir = $(datadir)
# Since we can't use $(wildcard ...) in automake file lists, we generate a file
# with a script that builds our dynamic file lists instead. This is tricky,
# because if we just include the file automake will flatten this include. By
# using $(wildcard ...) to include it (the very function we couldn't use because
# of the race condition it creates) we actually keep it from being flattened and
# hence evaluated when we want it to be. Since the file always exists (see
# BUILT_SOURCES and EXTRA_DIST) this doesn't induce a race.
include $(wildcard $(top_srcdir)/Makefile-distfiles)
lang_key_files = rules/en.mk rules/tr.mk
reverse_lang_key_files = $(patsubst %.mk,%-reversed.mk,$(lang_key_files))
dist_doc_DATA = README.md CHANGELOG.md
dist_license_DATA = LICENSE.md
dist_man_MANS =
nobase_data_DATA = rules/casile.mk $(reverse_lang_key_files)
nobase_dist_data_DATA = rules/rules.mk rules/functions.mk rules/translation.mk rules/utilities.mk $(lang_key_files)
nobase_dist_data_DATA += rules/ebooks.mk rules/mdbook.mk rules/renderings.mk rules/zola.mk
nobase_dist_pkgdata_DATA = $(LUALIBRARIES)
_casile_libs = src/lib.rs src/cli.rs src/config.rs src/i18n.rs src/ui.rs src/ui_indicatif.rs src/ui_ascii.rs
_casile_modules = src/make/mod.rs src/run/mod.rs src/setup/mod.rs src/status/mod.rs
_casile_assets = assets/en-US/cli.ftl assets/tr-TR/cli.ftl
bin_PROGRAMS = casile
casile_SOURCES = src/main.rs $(_casile_libs) $(_casile_modules) $(_casile_assets)
EXTRA_casile_SOURCES = tests/cli.rs
EXTRA_DIST = package.json yarn.lock requirements.txt
EXTRA_DIST += build-aux/action-updater.js build-aux/cargo-updater.js build-aux/git-version-gen
EXTRA_DIST += Dockerfile build-aux/bootstrap-docker.sh build-aux/docker-fontconfig.conf hooks/build
BUILT_SOURCES = Makefile-distfiles
CLEANFILES =
DISTCLEANFILES = @AMINCLUDE@
# A classical use of the autoconf-archive include macro would expand
# INC_AMINCLUDE here, but the perl script that inlines include statements
# runs before the automake that organizes logic and performs substitution.
# Consequentially with a substitution here it becomes impossible to use
# automake conditionals and substitutions in the included Makefile fragments.
# By entering the expanded value directly we are ready in time for the inlining
# functionality and hence can use conditionals in included makefile fragments.
include $(top_srcdir)/aminclude.am
Makefile-distfiles: $(wildcard .version .tarball-version)
$(SHELL) build-aux/list-distfiles.sh > $@
# use :read !git ls-files <pattern> to repopulate <pattern>_DATA vars
povdir = $(datadir)
dist_pov_DATA = $(POVDATA)
xmldir = $(datadir)
dist_xml_DATA = $(XMLDATA)
sildir = $(datadir)
dist_sil_DATA = $(SILDATA)
svgdir = $(datadir)
dist_svg_DATA = $(SVGDATA)
m4dir = $(datadir)
dist_m4_DATA = casile.m4
yamldir = $(datadir)
dist_yaml_DATA = casile.yml
templatesdir = $(datadir)
dist_templates_DATA = \
editorconfig \
gitlab-ci.yml \
luacheckrc \
luarc.json \
zola_book.html \
zola_series.html \
zola_style.sass
namesdir = $(datadir)
dist_names_DATA = $(NAMESDATA)
seddir = $(datadir)
dist_sed_DATA = $(SEDDATA)
vimdir = $(datadir)
dist_vim_DATA = $(VIMDATA)
datalibdir = $(datadir)/lib
dist_datalib_DATA = $(DATALIBLIBS)
scriptlibdir = $(datadir)/lib
dist_scriptlib_SCRIPTS = $(SCRIPTLIBLIBS)
scriptsdir = $(datadir)/scripts
dist_scripts_SCRIPTS = $(SCRIPTSSCRIPTS)
fontsdir = $(datadir)/fonts
dist_fonts_DATA = $(FONTSDATA)
filtersdir = $(datadir)/pandoc-filters
dist_filters_DATA = $(PANDOCFILTERS)
classesdir = $(datadir)/classes
dist_classes_DATA = $(SILECLASSFILES)
packagesdir = $(datadir)/packages
dist_packages_DATA = $(SILEPACKAGEFILES)
layoutsdir = $(datadir)/layouts
dist_layouts_DATA = $(SILELAYOUTFILES)
assetsdir = $(datadir)
nobase_dist_assets_DATA = $(ASSETDATA)
CLEANFILES += $(bin_PROGRAMS) $(dist_scripts_SCRIPTS)
CARGO_FEATURE_ARGS = --all-features
%-reversed.mk: %.mk
$(AWK) -F' := ' '/^_/ { gsub(/_/, "", $$1); print "__" $$2 " := " $$1 }' < $< > $@
luarc.json: .luarc.json
cp $< $@
.PHONY: clean-embedded-assets
clean-embedded-assets:
[[ ! -e .git ]] || $(GIT) clean -dxf assets
dist-hook: dist-hook-yarn
.PHONY: dist-hook-yarn
dist-hook-yarn:
$(YARN) install --production --frozen-lockfile --modules-folder "$(distdir)/node_modules"
install-data-hook:
$(YARN) install --production --frozen-lockfile --modules-folder "$(DESTDIR)$(datadir)/node_modules"
uninstall-hook:
rm -rf "$(DESTDIR)$(datadir)/node_modules"
all: init
.PHONY:
init: node_modules
node_modules: yarn.lock
$(YARN) install --frozen-lockfile
yarn.lock: package.json
$(YARN) install
dist: casile-$(VERSION).md
casile-%.md: CHANGELOG.md
$(SED) -e '/\.\.\.v$*/,/\.\.\.v/!d' $< | \
$(SED) -e '1,3d;N;$$!P;$$!D;$$d' | \
$(or $(filter cat,$(TYPOS)),$(TYPOS) --write-changes -) > $@
PHONY_DEVELOPER_TARGETS = checkmake lint luacheck ruff ruff-format stylua typos
PHONY_DEVELOPER_TARGETS += tagrelease release-preview release
PHONY_DEVELOPER_TARGETS += docker docker-dep-check docker-ghcr-to-hub docker-build-push
.PHONY: $(PHONY_DEVELOPER_TARGETS)
if DEVELOPER_MODE
lint: luacheck checkmake ruff ruff-format stylua
luacheck:
$(LUACHECK) .
checkmake:
$(GIT) ls-files 'rules/*.mk' 'rules/*.mk.in' | $(XARGS) -n1 checkmake
ruff:
$(GIT) ls-files '*.py' '*.py.in' | $(XARGS) $(RUFF) check
ruff-format:
$(GIT) ls-files '*.py' '*.py.in' | $(XARGS) $(RUFF) format --check
stylua:
$(STYLUA) --check --respect-ignores -g '!lua-libraries*' -g '!lua_modules/*' -g '*.lua' -g '*.lua.in' .
typos:
$(TYPOS) .
RELTYPE ?=
tagrelease:
test -z $$($(GIT) tag --points-at HEAD) || \
$(GIT) diff-index --quiet --cached HEAD && \
$(GIT) diff-files --quiet && \
$(YARN) run release --preMajor $(and $(RELTYPE),--release-as $(RELTYPE))
release-preview:
$(YARN) run release --preMajor --dry-run $(and $(RELTYPE),--release-as $(RELTYPE))
release: tagrelease
export GHCR_REGISTRY ?= ghcr.io
export GHCR_REPO ?= sile-typesetter/$(TRANSFORMED_PACKAGE_NAME)
export DOCKER_REGISTRY ?= docker.io
export DOCKER_REPO ?= siletypesetter/$(TRANSFORMED_PACKAGE_NAME)
export DOCKER_TAG ?= HEAD
docker: Dockerfile hooks/build .version
./hooks/build $(VERSION)
docker-dep-check: .docker_deps .aur_deps
$(DIFF) -u $^
.docker_deps: hooks/build
$(SHELL) -c 'source <($(SED) -nE "/^(RUN|'"'"')/{s/.*=/echo /;p}" $<)' | \
$(TR) ' ' '\n' | \
$(SORT) > $@
CLEANFILES += .docker_deps
.aur_deps:
$(CURL) -Ls 'https://aur.archlinux.org/cgit/aur.git/plain/.SRCINFO?h=casile-git' | \
$(SED) -nE '/\bdepends =/{s/.*= //;p}' | \
$(GREP) -vxE '(lua-.*|.*\.so|git|glibc)' | \
$(SORT) > $@
CLEANFILES += .aur_deps
docker-ghcr-to-hub:
$(DOCKER) pull $(GHCR_REGISTRY)/$(GHCR_REPO):$(DOCKER_TAG)
$(DOCKER) tag $(GHCR_REGISTRY)/$(GHCR_REPO):$(DOCKER_TAG) $(DOCKER_REGISTRY)/$(DOCKER_REPO):$(DOCKER_TAG)
$(docker_push)
else !DEVELOPER_MODE
$(PHONY_DEVELOPER_TARGETS):
@: $(error "Please reconfigure using --enable-developer-mode to use developer tooling")
endif !DEVELOPER_MODE