# Development tasks. Everything runs through the perl that is on PATH — the # library and its suite use only core modules, so there is nothing to install # first. # # make list the targets # make test run the suite with prove # make lint perl -c over the tree, no files touched # make build build the distribution tarball # # This file is a convenience for working in the repository. It is not shipped: # the tarball carries only Makefile.PL, so installing follows the usual # `perl Makefile.PL && make && make test && make install`. That is also why # `build` below hands FIRST_MAKEFILE to Makefile.PL — without it, ExtUtils:: # MakeMaker would write over this file. PERL ?= perl PROVE ?= prove MODULES := $(shell find lib -name '*.pm' | sort) TESTS := $(shell find t -name '*.t' | sort) HELPERS := $(shell find t/lib -name '*.pm' | sort) MM := Makefile.mm VERSION := $(shell $(PERL) -Ilib -MCepis -e 'print $$Cepis::VERSION') .DEFAULT_GOAL := help .PHONY: help test lint format build check clean help: @echo 'Targets:' @echo ' test run the test suite' @echo ' lint perl -c over the tree, plus perlcritic when installed' @echo ' format apply perltidy, when installed (writes)' @echo ' build build Cepis-$(VERSION).tar.gz' @echo ' check lint + test + build, in that order' @echo ' clean remove build artefacts' test: $(PROVE) -l $(TESTS) # Read-only by design, so it is safe in CI and in a pre-commit hook: it reports # what `make format` would change without changing anything. Perl ships no # linter or formatter in its core, and this distribution depends on neither, so # perlcritic is used only when it happens to be installed. lint: @set -e; for f in $(MODULES) $(HELPERS) $(TESTS) Makefile.PL; do \ $(PERL) -Ilib -It/lib -c $$f >/dev/null 2>&1 \ || { echo "syntax error in $$f"; $(PERL) -Ilib -It/lib -c $$f; exit 1; }; \ done @echo 'syntax OK: $(words $(MODULES) $(HELPERS) $(TESTS)) files + Makefile.PL' @if command -v perlcritic >/dev/null 2>&1; then perlcritic --quiet lib t; else \ echo 'perlcritic not installed: perl -c syntax checks only'; fi format: @if command -v perltidy >/dev/null 2>&1; then \ perltidy -b -bext=/ $(MODULES) $(HELPERS) $(TESTS) Makefile.PL; else \ echo 'perltidy not installed: nothing to format with'; fi build: $(PERL) Makefile.PL FIRST_MAKEFILE=$(MM) >/dev/null $(MAKE) -f $(MM) dist # The order matters: lint is the fastest to fail, build the slowest, so a # broken run reports the cheapest problem first. check: lint test build clean: @if [ -f $(MM) ]; then $(MAKE) -f $(MM) distclean >/dev/null 2>&1 || true; fi rm -rf blib Cepis-[0-9]* rm -f $(MM) $(MM).old pm_to_blib MYMETA.yml MYMETA.json META.yml META.json find . -name '*.bak' -delete