-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
96 lines (76 loc) · 2.08 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
prefix ?= /usr/local
destdir ?= ${prefix}
config ?= release
arch ?=
static ?= false
linker ?=
BUILD_DIR ?= build/$(config)
SRC_DIR ?= ponydoc
binary := $(BUILD_DIR)/ponydoc
tests_binary := $(BUILD_DIR)/test
ifdef config
ifeq (,$(filter $(config),debug release))
$(error Unknown configuration "$(config)")
endif
endif
PONYC ?= ponyc
ifeq ($(config),release)
PONYC := $(PONYC)
else
PONYC := $(PONYC) --debug
endif
ifneq ($(arch),)
arch_arg := --cpu $(arch)
endif
ifdef static
ifeq (,$(filter $(static),true false))
$(error "static must be true or false)
endif
endif
ifeq ($(static),true)
LINKER += --static
endif
ifneq ($(linker),)
LINKER += --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) -path $(SRC_DIR)/test -prune -o -name \*.pony)
TEST_FILES := $(shell find $(SRC_DIR)/test -name \*.pony -o -name helper.sh)
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)
${PONYC} $(arch_arg) $(LINKER) $(SRC_DIR) -o ${BUILD_DIR}
install: $(binary)
@echo "install"
mkdir -p $(DESTDIR)$(prefix)/bin
cp $^ $(DESTDIR)$(prefix)/bin
$(tests_binary): $(GEN_FILES) $(SOURCE_FILES) $(TEST_FILES) | $(BUILD_DIR)
${PONYC} $(arch_arg) $(LINKER) --debug -o ${BUILD_DIR} $(SRC_DIR)/test
unit-tests: $(tests_binary)
$^
test: unit-tests
clean:
rm -rf $(BUILD_DIR)
all: test $(binary)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
.PHONY: all clean install test unittest integration