-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
106 lines (85 loc) · 2.29 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
101
102
103
104
105
106
prefix ?= /usr/local
destdir ?= $(prefix)
config ?= release
arch ?=
static ?= false
linker ?=
ssl ?= 0.9.0
PONYC_FLAGS ?=
BUILD_DIR ?= build/$(config)
SRC_DIR ?= cmd
binary := $(BUILD_DIR)/ponyup
PONYUP_PLATFORM ?= $(shell cc -dumpmachine)
ifdef config
ifeq (,$(filter $(config),debug release))
$(error Unknown configuration "$(config)")
endif
endif
ifeq ($(config),debug)
PONYC_FLAGS += --debug
endif
ifeq ($(ssl), 3.0.x)
PONYC_FLAGS += -Dopenssl_3.0.x
else ifeq ($(ssl), 1.1.x)
PONYC_FLAGS += -Dopenssl_1.1.x
else ifeq ($(ssl), 0.9.0)
PONYC_FLAGS += -Dopenssl_0.9.0
else
$(error Unknown SSL version "$(ssl)". Must set using 'ssl=FOO')
endif
ifneq ($(arch),)
PONYC_FLAGS += --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)
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)
corral fetch
corral run -- ponyc $(PONYC_FLAGS) $(LINKER) $(SRC_DIR) -o $(BUILD_DIR) -b ponyup
install: $(binary)
@echo "install"
mkdir -p $(DESTDIR)$(prefix)/bin
cp $^ $(DESTDIR)$(prefix)/bin
SOURCE_FILES := $(shell find cmd -name \*.pony)
test: $(binary)
corral fetch
corral run -- ponyc $(PONYC_FLAGS) $(LINKER) test -o $(BUILD_DIR) -b test
env PONYUP_PLATFORM="${PONYUP_PLATFORM}" $(BUILD_DIR)/test --sequential
clean:
corral clean
rm -rf $(BUILD_DIR) $(GEN_FILES)
all: test $(binary)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
.PHONY: all clean install test