Skip to content

Commit cd52acb

Browse files
Refactor Makefile phony declaration (#610)
1 parent f2a18f7 commit cd52acb

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

Makefile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,43 +49,50 @@ INSTALL ?= /usr/bin/install
4949
MOLINILLO_VERSION = $(shell $(CRYSTAL) eval 'require "yaml"; puts YAML.parse(File.read("shard.lock"))["shards"]["molinillo"]["version"]')
5050
MOLINILLO_URL = "https://github.com/crystal-lang/crystal-molinillo/archive/v$(MOLINILLO_VERSION).tar.gz"
5151

52+
.PHONY: all
5253
all: build
5354

5455
include docs.mk
5556

56-
build: ## Build shards
57-
build: phony bin/shards
57+
.PHONY: build
58+
build: bin/shards
5859

60+
.PHONY: clean
5961
clean: ## Remove build artifacts
60-
clean: phony clean_docs
62+
clean: clean_docs
6163
rm -f bin/shards
6264

6365
bin/shards: $(SOURCES) $(TEMPLATES) lib
6466
@mkdir -p bin
6567
$(EXPORTS) $(CRYSTAL) build $(FLAGS) src/shards.cr -o bin/shards
6668

69+
.PHONY: install
6770
install: ## Install shards
68-
install: bin/shards man/shards.1.gz man/shard.yml.5.gz phony
71+
install: bin/shards man/shards.1.gz man/shard.yml.5.gz
6972
$(INSTALL) -m 0755 -d "$(BINDIR)" "$(MANDIR)/man1" "$(MANDIR)/man5"
7073
$(INSTALL) -m 0755 bin/shards "$(BINDIR)"
7174
$(INSTALL) -m 0644 man/shards.1.gz "$(MANDIR)/man1"
7275
$(INSTALL) -m 0644 man/shard.yml.5.gz "$(MANDIR)/man5"
7376

77+
.PHONY: uninstall
7478
uninstall: ## Uninstall shards
75-
uninstall: phony
79+
uninstall:
7680
rm -f "$(BINDIR)/shards"
7781
rm -f "$(MANDIR)/man1/shards.1.gz"
7882
rm -f "$(MANDIR)/man5/shard.yml.5.gz"
7983

84+
.PHONY: test
8085
test: ## Run all tests
8186
test: test_unit test_integration
8287

88+
.PHONY: test_unit
8389
test_unit: ## Run unit tests
84-
test_unit: phony lib
90+
test_unit: lib
8591
$(CRYSTAL) spec ./spec/unit/ $(if $(skip_fossil),--tag ~fossil) $(if $(skip_git),--tag ~git) $(if $(skip_hg),--tag ~hg)
8692

93+
.PHONY: test_integration
8794
test_integration: ## Run integration tests
88-
test_integration: bin/shards phony
95+
test_integration: bin/shards
8996
$(CRYSTAL) spec ./spec/integration/
9097

9198
lib: shard.lock
@@ -98,8 +105,6 @@ shard.lock: shard.yml
98105
man/%.gz: man/%
99106
gzip -c -9 $< > $@
100107

101-
phony:
102-
103108
.PHONY: help
104109
help: ## Show this help
105110
@echo

docs.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ HTML_FILES := docs/shards.html docs/shard.yml.html
88
SHARDS_VERSION := $(shell cat VERSION)
99
SOURCE_DATE_EPOCH := $(shell (git show -s --format=%ct HEAD || stat -c "%Y" Makefile || stat -f "%m" Makefile) 2> /dev/null)
1010

11+
.PHONY: docs
1112
docs: ## Build documentation
1213
docs: manpages
1314

15+
.PHONY: manpages
1416
manpages: ## Generate manpages from adoc
1517
manpages: $(MAN_FILES)
1618

19+
.PHONY: htmlpages
1720
htmlpages: ## Generate HTML files from adoc
1821
htmlpages: $(HTML_FILES)
1922

@@ -23,9 +26,7 @@ man/%.1 man/%.5: docs/%.adoc
2326
docs/%.html: docs/%.adoc
2427
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) $(ASCIIDOC) $(ASCIIDOC_OPTIONS) $< -b html5 -o $@
2528

29+
.PHONY: clean_docs
2630
clean_docs: ## Remove documentation data
27-
clean_docs: phony
2831
rm -f $(MAN_FILES)
2932
rm -rf docs/*.html
30-
31-
phony:

0 commit comments

Comments
 (0)