forked from crystal-lang/crystal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.win
70 lines (58 loc) · 1.75 KB
/
Makefile.win
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
all:
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:
SHELL := cmd.exe
MKDIR = if not exist $1 mkdir $1
RMDIR = if exist $1 rd /S /Q $1
CRYSTAL := ..\bin\crystal.bat# Crystal compiler to use
O := .build# Output directory
BUILDABLE_SOURCES := $(wildcard *.cr llvm/*.cr compiler/*.cr)
NONLINK_SOURCES := $(wildcard sdl/*.cr)
BUILDABLE_BINARIES := $(patsubst %.cr,$(O)/%.exe,$(BUILDABLE_SOURCES))
NONLINK_BINARIES := $(patsubst %.cr,$(O)/%.obj,$(NONLINK_SOURCES))
.PHONY: all
all: build
.PHONY: build
build: $(BUILDABLE_BINARIES) $(NONLINK_BINARIES) ## Build sample binaries
$(O)/%.exe: %.cr
$(call MKDIR,"$(dir $@)")
$(CRYSTAL) build "$<" -o "$@"
$(O)/%.obj: %.cr
$(call MKDIR,"$(dir $@)")
$(CRYSTAL) build --cross-compile "$<" -o "$(patsubst %.obj,%,$@)"
.PHONY: clean
clean: ## Remove build artifacts
$(call RMDIR,"$(O)")
.PHONY: help
help: ## Show this help
@setlocal EnableDelayedExpansion &\
echo. &\
echo targets: &\
(for /F "usebackq tokens=1* delims=:" %%g in ($(MAKEFILE_LIST)) do (\
if not "%%h" == "" (\
set "_line=%%g " &\
set "_rest=%%h" &\
set "_comment=!_rest:* ## =!" &\
if not "!_comment!" == "!_rest!"\
if "!_line:_rest=!" == "!_line!"\
echo !_line:~0,16!!_comment!\
)\
)) &\
echo. &\
echo optional variables: &\
(for /F "usebackq tokens=1,3 delims=?#" %%g in ($(MAKEFILE_LIST)) do (\
if not "%%h" == "" (\
set "_var=%%g " &\
echo !_var:~0,14! %%h\
)\
)) &\
echo. &\
echo recipes: &\
(for /F "usebackq tokens=* delims=" %%g in ($(MAKEFILE_LIST)) do (\
set "_line=%%g" &\
if "!_line:~0,7!" == "## $$ " (\
echo !_name! &\
echo !_line:~2!\
) else if "!_line:~0,3!" == "## "\
set "_name= !_line:~3!"\
))