-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
100 lines (82 loc) · 2.2 KB
/
Makefile
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
prefix ?= /usr/local
config ?= release
arch ?=
static ?= false
linker ?=
APPLICATION := rfc-tool
COMPILE_WITH := corral run -- ponyc
FETCH_DEPS_WITH := corral fetch
CLEAN_DEPS_WITH := corral clean
DEPS_DIR := .deps
BUILD_DIR ?= build/$(config)
SRC_DIR := $(APPLICATION)
binary := $(BUILD_DIR)/$(APPLICATION)
ifdef config
ifeq (,$(filter $(config),debug release))
$(error Unknown configuration "$(config)")
endif
endif
ifeq ($(config),release)
PONYC = $(COMPILE_WITH)
else
PONYC = $(COMPILE_WITH) --debug
endif
ifneq ($(arch),)
PONYC += --cpu $(arch)
endif
ifdef static
ifeq (,$(filter $(static),true false))
$(error "static must be true or false)
endif
endif
ifeq ($(static),true)
PONYC += --static
endif
ifneq ($(linker),)
PONYC += --link-ldcmd=$(linker)
endif
# Default to version from `VERSION` file but allowing overridding on the
# make command line like:
# make version="nightly-19710702"
# overridden version *should not* contain spaces or characters that aren't
# legal in filesystem path names
ifndef version
version := $(shell cat VERSION)
ifneq ($(wildcard .git),)
sha := $(shell git rev-parse --short HEAD)
tag := $(version)-$(sha)
else
tag := $(version)
endif
else
foo := $(shell touch VERSION)
tag := $(version)
endif
SOURCE_FILES := $(shell find $(SRC_DIR) -name \*.pony)
VERSION := "$(tag) [$(config)]"
GEN_FILES_IN := $(shell find $(SRC_DIR) -name \*.pony.in)
GEN_FILES = $(patsubst %.pony.in, %.pony, $(GEN_FILES_IN))
%.pony: %.pony.in VERSION
sed s/%%VERSION%%/$(version)/ $< > $@
$(binary): $(GEN_FILES) $(SOURCE_FILES) | $(BUILD_DIR)
$(FETCH_DEPS_WITH)
$(PONYC) -o $(BUILD_DIR) $(SRC_DIR)
install: $(binary)
@echo "install"
mkdir -p $(DESTDIR)$(prefix)/bin
cp $^ $(DESTDIR)$(prefix)/bin
test: $(binary)
test "$(shell $(binary) version)" = "rfc-tool $(shell cat VERSION)"
$(binary) verify tests/rfc-pre.md
$(binary) verify tests/rfc-post.md
$(binary) complete tests/rfc-pre.md \
https://github.com/ponylang/rfcs/pull/0000 \
https://github.com/ponylang/ponyc/issues/0000 \
| diff -B tests/rfc-post.md -
clean:
$(CLEAN_DEPS_WITH)
rm -rf $(BUILD_DIR) $(GEN_FILES)
all: test $(binary)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
.PHONY: all clean install test