Skip to content

Commit 2748272

Browse files
authored
Support .exe file extension in Makefile on MSYS2 (#651)
1 parent a25bb3f commit 2748272

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Makefile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,37 @@ 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+
# MSYS2 support (native Windows should use `Makefile.win` instead)
53+
ifeq ($(OS),Windows_NT)
54+
EXE := .exe
55+
WINDOWS := 1
56+
else
57+
EXE :=
58+
WINDOWS :=
59+
endif
60+
5261
.PHONY: all
5362
all: build
5463

5564
include docs.mk
5665

5766
.PHONY: build
58-
build: bin/shards
67+
build: bin/shards$(EXE)
5968

6069
.PHONY: clean
6170
clean: ## Remove build artifacts
6271
clean: clean_docs
63-
rm -f bin/shards
72+
rm -f bin/shards$(EXE)
6473

65-
bin/shards: $(SOURCES) $(TEMPLATES) lib
74+
bin/shards$(EXE): $(SOURCES) $(TEMPLATES) lib
6675
@mkdir -p bin
67-
$(EXPORTS) $(CRYSTAL) build $(FLAGS) src/shards.cr -o bin/shards
76+
$(EXPORTS) $(CRYSTAL) build $(FLAGS) src/shards.cr -o "$@"
6877

6978
.PHONY: install
7079
install: ## Install shards
71-
install: bin/shards man/shards.1.gz man/shard.yml.5.gz
80+
install: bin/shards$(EXE) man/shards.1.gz man/shard.yml.5.gz
7281
$(INSTALL) -m 0755 -d "$(BINDIR)" "$(MANDIR)/man1" "$(MANDIR)/man5"
73-
$(INSTALL) -m 0755 bin/shards "$(BINDIR)"
82+
$(INSTALL) -m 0755 bin/shards$(EXE) "$(BINDIR)"
7483
$(INSTALL) -m 0644 man/shards.1.gz "$(MANDIR)/man1"
7584
$(INSTALL) -m 0644 man/shard.yml.5.gz "$(MANDIR)/man5"
7685

@@ -92,7 +101,7 @@ test_unit: lib
92101

93102
.PHONY: test_integration
94103
test_integration: ## Run integration tests
95-
test_integration: bin/shards
104+
test_integration: bin/shards$(EXE)
96105
$(CRYSTAL) spec ./spec/integration/
97106

98107
lib: shard.lock

0 commit comments

Comments
 (0)