Skip to content

Commit

Permalink
Merge pull request #953 from alerque/less-auto-automake
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque authored Jul 16, 2020
2 parents 25e5123 + f269da7 commit bacaf68
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 57 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ jobs:
.fonts
.sources
key: fonts-${{ hashFiles('Makefile-fonts') }}
- name: Cache Lua Rocks
uses: actions/cache@v2
with:
path: |
lua_modules_dist
key: luarocks-${{ hashFiles('Makefile-luarocks', 'sile-dev-1.rockspec') }}
- name: Fetch Tags
run: git fetch --prune --tags
- name: Install System Dependencies
Expand Down
44 changes: 44 additions & 0 deletions Makefile-luarocks
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
SUPPORTED_LUAS = 5.3 5.2 5.1

LUAROCKS := luarocks --tree lua_modules --lua-version $(LUA_VERSION)

if !SYSTEM_LUAROCKS
nobase_nodist_pkgdata_DATA = $(LUAMODULES)
LUAMODLOCK := sile-dev-1.rockslock
LUAMODSPEC := sile-dev-1.rockspec
genrockslock := $(LUAROCKS) $(LUAROCKSARGS) list --porcelain | awk '{print $$1 " " $$2}'
rocksmatch := cmp -s $(LUAMODLOCK) <($(genrockslock))
endif

.PHONY: installrocks disallow-dist-with-system-luarocks
if !SYSTEM_LUAROCKS
installrocks: $(LUAMODLOCK) $(shell $(rocksmatch) || echo lua_modules)

lua_modules: $(LUAMODSPEC) $(shell $(rocksmatch) || echo force)
if test -e .git; then
$(LUAROCKS) $(LUAROCKSARGS) install --only-deps $<
else
rm -rf lua_modules
cp -a lua_modules_dist lua_modules
$(foreach LUA,$(filter-out $(LUA_VERSION),$(SUPPORTED_LUAS)),
find lua_modules -maxdepth 3 -type d -name "*$(LUA)" -execdir rm -rf {} \;)
fi

$(LUAMODLOCK): lua_modules $(LUAMODSPEC)
$(genrockslock) > $@

sile: installrocks

disallow-dist-with-system-luarocks: ;
else
disallow-dist-with-system-luarocks:
$(error In order to make dist you must configure --without-system-luarocks)
exit 1
endif

.PHONY: lua_modules_dist
lua_modules_dist: LUAROCKS = luarocks --tree lua_modules_dist
lua_modules_dist: $(LUAMODSPEC) force disallow-dist-with-system-luarocks
$(foreach LUA,$(SUPPORTED_LUAS),
$(LUAROCKS) $(LUAROCKSARGS) --lua-version $(LUA) install --only-deps $<)

91 changes: 34 additions & 57 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ else
SUBDIRS = libtexpdf src
endif

SUPPORTED_LUAS = 5.3 5.2 5.1

MANUAL = documentation/sile.pdf

Makefile-distfiles: build-aux/list-dist-files.sh .version
$< 2>/dev/null > $@

include Makefile-distfiles

dist_man_MANS = sile.1
dist_doc_DATA = README.md CHANGELOG.md
bin_SCRIPTS = sile
nobase_dist_pkgdata_DATA = $(filter %.lua %.sil,$(shell find core classes languages packages lua-libraries -type f -print))
EXTRA_DIST = LICENSE spec tests examples documentation sile-dev-1.rockspec build-aux/git-version-gen .version fontconfig.conf
EXTRA_DIST += $(extra_dist) $(MANUAL) $(EXAMPLES)
EXTRA_DIST = LICENSE spec tests examples documentation sile-dev-1.rockspec fontconfig.conf
EXTRA_DIST += .version Makefile-distfiles
EXTRA_DIST += build-aux/git-version-gen build-aux/list-dist-files.sh
EXTRA_DIST += $(LUAMODULESDIST) $(MANUAL) $(EXAMPLES)

SHELL = bash
.ONESHELL:
Expand All @@ -25,39 +29,36 @@ SHELL = bash
.DELETE_ON_ERROR:
am__remove_distdir =

extra_dist = $(shell find lua_modules_dist -type f -print 2>/dev/null ||:)
if !SYSTEM_LUAROCKS
nobase_nodist_pkgdata_DATA = $(shell find lua_modules -type f -print 2>/dev/null ||:)
LUAROCKS := luarocks --tree lua_modules --lua-version $(LUA_VERSION)
LUAMODLOCK := sile-dev-1.rockslock
LUAMODSPEC := sile-dev-1.rockspec
genrockslock := $(LUAROCKS) $(LUAROCKSARGS) list --porcelain | awk '{print $$1 " " $$2}'
rocksmatch := cmp -s $(LUAMODLOCK) <($(genrockslock))
else
LUAROCKS := luarocks --tree lua_modules_dist --lua-version $(LUA_VERSION)
endif

BUILT_SOURCES = .version

.version: $(shell test -e .git && awk '{print ".git/" $$2}' .git/HEAD)
mv $@{,-prev} || touch $@-prev
mv $@{,-prev} 2>/dev/null || touch $@-prev
( test -e .git && ./build-aux/git-version-gen .tarball-version || echo $(VERSION) ) > $@
cmp -s $@{,-prev} || autoreconf configure.ac --force -W none
sed -i -e '/rm -f/s/ core / /' configure aclocal.m4 ||:

dist-hook: lua_modules_dist $(MANUAL) $(EXAMPLES)
dist-hook: lua_modules_dist | $(MANUAL) $(EXAMPLES)
echo $(VERSION) > $(distdir)/.tarball-version
cp -fa $< $(distdir)/
sed -i -e '/rm -f/s/ core / /' configure aclocal.m4 ||:

_DATA_HOOK_DEPS =
if MANUAL
install-data-hook: $(MANUAL)
rm -f "$(DESTDIR)/$(datarootdir)/$<"
install -Dm644 -t "$(DESTDIR)$(docdir)" $<
_DATA_HOOK_DEPS += $(MANUAL)
endif

if EXAMPLES
_DATA_HOOK_DEPS += $(EXAMPLES)
endif

install-data-hook: $(_DATA_HOOK_DEPS)
:
if MANUAL
rm -f "$(DESTDIR)/$(datarootdir)/$<"
install -Dm644 -t "$(DESTDIR)$(docdir)" $(MANUAL)
endif
if EXAMPLES
install-data-hook: $(EXAMPLES)
install -Dm644 -t "$(DESTDIR)$(docdir)/examples" $^
install -Dm644 -t "$(DESTDIR)$(docdir)/examples" $(EXAMPLES)
endif

# Whether to force tests to run from scratch
Expand Down Expand Up @@ -97,39 +98,13 @@ update_libtexpdf:
gh-pages:
git worktree add -f $@ $@

.PHONY: installrocks
if !SYSTEM_LUAROCKS
installrocks: $(LUAMODLOCK) $(shell $(rocksmatch) || echo lua_modules)

lua_modules: $(LUAMODSPEC) $(shell $(rocksmatch) || echo force)
if test -e .git; then
$(LUAROCKS) $(LUAROCKSARGS) install --only-deps $<
else
rm -rf lua_modules
cp -a lua_modules_dist lua_modules
$(foreach LUA,$(filter-out $(LUA_VERSION),$(SUPPORTED_LUAS)),
find lua_modules -maxdepth 3 -type d -name "*$(LUA)" -execdir rm -rf {} \;)
fi

$(LUAMODLOCK): lua_modules $(LUAMODSPEC)
$(genrockslock) > $@

sile: installrocks
endif

.PHONY: lua_modules_dist
lua_modules_dist: $(LUAMODSPEC) force
$(foreach LUA,$(SUPPORTED_LUAS),
$(LUAROCKS) $(LUAROCKSARGS) --lua-version $(LUA) install --only-deps $<)

DEPDIR := .deps
REGRESSIONSCRIPT := ./tests/regressions.pl
LOCALTESTFONTS := FONTCONFIG_FILE=$(PWD)/fontconfig.conf
SILEFLAGS ?= -m $(DEPDIR)/$(basename $@).d -d versions -f fontconfig

TESTSRCS ?= $(wildcard tests/*.sil tests/*.xml)
TESTPDFS = $(addsuffix .pdf,$(basename $(TESTSRCS)))
EXPECTEDS ?= $(filter $(addsuffix .expected,$(basename $(TESTSRCS))),$(wildcard tests/*.expected))
EXPECTEDS ?= $(filter $(addsuffix .expected,$(basename $(TESTSRCS))),$(TESTEXPECTS))
ACTUALS = $(addsuffix .actual,$(basename $(EXPECTEDS)))

check: selfcheck
Expand All @@ -156,7 +131,8 @@ luarocks-lint: $(LUAMODSPEC)
luacheck:
luacheck -j$(shell nproc) -q .

busted: $(wildcard spec/*_spec.lua)
.PHONY: busted
busted: | $(_INSTALL) all
set -f; IFS=';'
if SYSTEM_LUAROCKS
packagecpath=(./{,core/}?.$(SHARED_LIB_EXT))
Expand All @@ -170,8 +146,7 @@ endif
.PHONY: docs
docs: $(MANUAL)

EXAMPLESSRCS = $(basename $(wildcard examples/*.sil) examples/docbook/article-template.xml)
EXAMPLES = $(addsuffix .pdf,$(EXAMPLESSRCS))
EXAMPLES = $(addsuffix .pdf,$(basename $(EXAMPLESSRCS)))

.PHONY: examples
examples: $(EXAMPLES)
Expand All @@ -197,11 +172,10 @@ if !SYSTEM_LUAROCKS
_INSTALL = installrocks
endif
_FORCED = $(and $(SILE_COVERAGE)$(CLEAN),force)
_MAKE_DEPS = $(wildcard $(DEPDIR)/$*.d)
_TEST_DEPS = $(and $(filter tests/%,$@),$(addprefix .fonts/,$(TESTFONTFILES)))
_DOCS_DEPS = $(and $(filter docs/%,$@),$(addprefix .fonts/,$(DOCSFONTFILES)))
_EXAM_DEPS = $(and $(filter examples/%,$@),$(addprefix .fonts/,$(EXAMFONTFILES)))
patterndeps = $(_FORCED) $(_TEST_DEPS) $(_EXAM_DEPS) $(_DOCS_DEPS) | $(DEPDIRS) $(_MAKE_DEPS) $(_INSTALL) all
patterndeps = $(_FORCED) $(_TEST_DEPS) $(_EXAM_DEPS) $(_DOCS_DEPS) | $(DEPDIRS) $(_INSTALL) all

%.pdf: %.sil $$(patterndeps)
$(runsile)
Expand Down Expand Up @@ -353,7 +327,10 @@ include $(wildcard $(DEPFILES))
# Actual rules for downloading test fonts are in a separate file
include Makefile-fonts

CLEANFILES = $(bin_SCRIPTS) $(dist_man_MANS) $(DEPFILES) $(ACTUALS) $(TESTPDFS) $(MANUAL)
# All LuaRocks handling stuff consolidated
include Makefile-luarocks

CLEANFILES = $(bin_SCRIPTS) $(dist_man_MANS) $(DEPFILES) $(ACTUALS) $(TESTPDFS) $(MANUAL) Makefile-distfiles

.PHONY: docker
docker: Dockerfile build-aux/docker-entrypoint.sh
Expand Down
2 changes: 2 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ if [ ! -f "libtexpdf/configure.ac" ] && [ -e ".git" ]; then
git submodule update --init --recursive --remote
fi

touch -d @0 Makefile-distfiles

autoreconf --install -W none

# See discussion in https://github.com/sile-typesetter/sile/issues/82 and
Expand Down
24 changes: 24 additions & 0 deletions build-aux/list-dist-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -e

echo -n "nobase_dist_pkgdata_DATA ="
find core classes languages packages lua-libraries -type f -name '*.lua' -printf ' %p'
find classes -type f -name '*.sil' -printf ' %p'

echo -ne "\nLUAMODULES ="
find lua_modules -type f -not -name '*~' -printf ' %p' ||:

echo -ne "\nLUAMODULESDIST ="
find lua_modules_dist -type f -not -name '*~' -printf ' %p' ||:

echo -ne "\nTESTSRCS ?="
find tests -maxdepth 1 -type f -name '*.sil' -printf ' %p'
find tests -maxdepth 1 -type f -name '*.xml' -printf ' %p'

echo -ne "\nTESTEXPECTS ?="
find tests -maxdepth 1 -type f -name '*.expected' -printf ' %p'

echo -ne "\nEXAMPLESSRCS ="
find examples -maxdepth 1 -type f -name '*.sil' -printf ' %p'
find examples/docbook -maxdepth 1 -type f -name '*.xml' -printf ' %p'

0 comments on commit bacaf68

Please sign in to comment.