CPAN-Maker-Bootstrapper

 view release on metacpan or  search on metacpan

share/perl.mk  view on Meta::CPAN

	$(NO_ECHO)test -e "$(PERLCRITICRC)" \
	  || { echo "ERROR: $(PERLCRITICRC) not found"; exit 1; }; \
	if [[ -z "$(PERLCRITIC)" ]]; then \
	  echo "ERROR: perlcritic not found - install with: cpanm Perl::Critic"; \
	  exit 1; \
	fi; \
	echo >&2 "Critiquing...$<"; \
	$(PERLCRITIC) --profile="$(PERLCRITICRC)" $< 1>&2 \
	  || { echo "ERROR: $< fails perlcritic"; rm -f "$@"; exit 1; }; \
	touch "$@"
else
	$(NO_ECHO)touch "$@"
endif

%.pl.tdy: %.pl
ifneq ($(tidy_on),)
	$(NO_ECHO)test -e "$(PERLTIDYRC)" \
	  || { echo "ERROR: $(PERLTIDYRC) not found"; exit 1; }; \
	if [[ -z "$(PERLTIDY)" ]]; then \
	  echo "ERROR: perltidy not found - install with: cpanm Perl::Tidy"; \
	  exit 1; \
	fi; \
	echo >&2 "Checking tidiness...$<"; \
	$(PERLTIDY) --profile="$(PERLTIDYRC)" $<; \
	diff -q "$<" "$<.tdy" 2>/dev/null 2>&1 \
	  || { echo "ERROR: $< is not tidy - run: make tidy"; rm -f "$<.tdy" "$@"; exit 1; }; \
	rm -f "$<.tdy"; \
	touch "$@"
else
	$(NO_ECHO)touch "$@"
endif

%.pl.crit: %.pl
ifneq ($(critic_on),)
	$(NO_ECHO)test -e "$(PERLCRITICRC)" \
	  || { echo "ERROR: $(PERLCRITICRC) not found"; exit 1; }; \
	if [[ -z "$(PERLCRITIC)" ]]; then \
	  echo "ERROR: perlcritic not found - install with: cpanm Perl::Critic"; \
	  exit 1; \
	fi; \
	$(PERLCRITIC) --profile="$(PERLCRITICRC)" $< \
	  || { echo "ERROR: $< fails perlcritic"; rm -f "$@"; exit 1; }; \
	touch "$@"
else
	$(NO_ECHO)touch "$@"
endif

# ------------------------------------------------------------------
# pattern rules - always depend on sentinels
# ------------------------------------------------------------------

%.pm: %.pm.in
	$(NO_ECHO)module_tmp="$$(mktemp)"; \
	local_cleanfiles="$$module_tmp"; \
	trap 'rm -f $$local_cleanfiles' EXIT; \
	sed -e 's/[@]PACKAGE_VERSION[@]/$(VERSION)/' \
	    -e 's/[@]MODULE_NAME[@]/$(MODULE_NAME)/' $< > "$$module_tmp"; \
	$(run_podextract); \
	rm -f "$@"; \
	cp "$$module_tmp" "$@"; \
	chmod -w "$@"; \
	$(if $(syntax_on),$(check_syntax_pm))

%.pl: %.pl.in
	$(NO_ECHO)rm -f "$@"; \
	sed -e 's/[@]PACKAGE_VERSION[@]/$(VERSION)/' \
	    -e 's/[@]MODULE_NAME[@]/$(MODULE_NAME)/' $< > "$@"; \
	chmod +x "$@"; \
	chmod -w "$@"; \
	$(if $(syntax_on),$(check_syntax_pl))

# ------------------------------------------------------------------
# convenience targets
# ------------------------------------------------------------------

.PHONY: tidy critic lint

tidy: ## run perltidy on all source files
	$(NO_ECHO)if [[ -z "$(PERLTIDYRC)" ]]; then \
	  echo "ERROR: PERLTIDYRC not set - add perltidyrc to your config or set PERLTIDYRC=path"; \
	  exit 1; \
	fi; \
	test -e "$(PERLTIDYRC)" \
	  || { echo "ERROR: $(PERLTIDYRC) not found"; exit 1; }; \
	if [[ -z "$(PERLTIDY)" ]]; then \
	  echo "ERROR: perltidy not found - install with: cpanm Perl::Tidy"; \
	  exit 1; \
	fi; \
	$(MAKE) $(PERL_MODULES) $(PERL_BIN_FILES) SYNTAX_CHECKING=on PERLTIDYRC="" PERLCRITICRC=""; \
        FILE_LIST=$$(find lib bin -name '*.p[lm].in'); \
	for f in $$FILE_LIST; do \
	  echo "tidying: $$f"; \
	  $(PERLTIDY) --profile="$(PERLTIDYRC)" "$$f"; \
	  mv "$$f.tdy" "$$f"; \
	done

critic: ## run perlcritic on all source files
	$(NO_ECHO)if [[ -z "$(PERLCRITICRC)" ]]; then \
	  echo "ERROR: PERLCRITICRC not set - add perlcriticrc to your config or set PERLCRITICRC=path"; \
	  exit 1; \
	fi; \
	test -e "$(PERLCRITICRC)" \
	  || { echo "ERROR: $(PERLCRITICRC) not found"; exit 1; }; \
	if [[ -z "$(PERLCRITIC)" ]]; then \
	  echo "ERROR: perlcritic not found - install with: cpanm Perl::Critic"; \
	  exit 1; \
	fi; \
	$(MAKE) SYNTAX_CHECKING=on PERLTIDYRC="" PERLCRITICRC=""; \
        PERL_SCRIPTS=$$(find bin/ -name '*.pl'); \
	$(PERLCRITIC) --profile="$(PERLCRITICRC)" $(PERL_MODULES); \
	test -n "$$PERL_SCRIPTS" && $(PERLCRITIC) --profile="$(PERLCRITICRC)" $$PERL_SCRIPTS

lint: ## run all linting tools (tidy + critic)
	$(NO_ECHO)$(MAKE) tidy critic

# custom make rules
-include project.mk



( run in 0.699 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )