forked from erlsci/port-examples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
211 lines (169 loc) · 5.32 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
PROJ = ports
REL_DIR = ./_build/default/rel/$(PROJ)
PROJ_BIN = $(REL_DIR)/bin/$(PROJ)
PRIV = apps/$(PROJ)/priv
PWD = $(shell pwd)
#############################################################################
### General Targets #####################################################
#############################################################################
default: build
build: build-cl build-go build-rust release
clean-all: clean clean-cl clean-go clean-rust
.PHONY: default run release shutdown run-fresh build build-cl build-go build-rust clean-cl clean-go clean-rust
help:
@echo
@echo "To add a new language to this repo, look at the Makefile targets"
@echo "for the other languages already present. Create targets like"
@echo "those (along with a unique VAR for the languages's repo and"
@echo "directory)."
@echo
@echo "Once you've added your targets, run your 'init' target via"
@echo "make. Future updates to your language repo can be pulled in here"
@echo "with your added 'update' target (or you can update all repos with"
@echo "the general-purpose update target)."
@echo
init: \
init-go \
init-lisp \
init-rust
push: \
push-go \
push-lisp \
push-rust
pull: \
pull-go \
pull-lisp \
pull-rust
#############################################################################
### Erlang Targets ######################################################
#############################################################################
$(PROJ_BIN):
@echo '>> Building release ...'
@rebar3 lfe compile
@rebar3 release
release: | $(PROJ_BIN)
run: release
@echo '>> Running application from distribution console ...'
@echo $(PROJ_BIN)
@ERL_AFLAGS="-kernel shell_history enabled" \
GO111MODULE=on GOPATH=$(PWD)/apps/ports/priv/go \
$(PROJ_BIN) console
run-fresh: clean-all build run
shutdown:
@echo '>> Shutting down OTP application ...'
-@$(PROJ_BIN) status || $(PROJ_BIN) stop
@ps aux|grep $(PROJ_BIN)|grep -v grep
clean:
@rebar3 clean
@rm -rf $(REL_DIR)
#############################################################################
### Rust Targets ########################################################
#############################################################################
RUST_REPO = https://github.com/oxur/erlang-ports-example.git
RUST_BASE = $(PRIV)
RUST_PROJ = erlang-ports-example
RUST_DIR = $(RUST_BASE)/ports-example-rs
$(RUST_BASE):
@mkdir -p $(RUST_BASE)
init-rust: $(RUST_BASE)
@echo ">> Setting up Rust example ..."
-@git subtree add \
--prefix $(RUST_DIR) \
$(RUST_REPO) \
main \
--squash
pull-rust:
@echo ">> Updating local Rust example from origin ..."
@git subtree pull \
--m "Updated latest from LFE examples ($(PRIV))." \
--prefix $(RUST_DIR) \
$(RUST_REPO) \
main \
--squash
push-rust:
@echo ">> Updating remote Rust example from local ..."
@git subtree push \
--prefix $(RUST_DIR) \
$(RUST_REPO) \
main
build-rust: | $(RUST_DIR)
@echo ">> Building Rust example ..."
@cd $(RUST_DIR) && $(MAKE)
clean-rust:
@cd $(RUST_DIR) && $(MAKE) clean
#############################################################################
### Go Targets ##########################################################
#############################################################################
GO_REPO = https://github.com/geomyidia/erlang-ports-example.git
GO_BASE = $(PRIV)/go/src/github.com/geomyidia
GO_PROJ = erlang-ports-example
GO_DIR = $(GO_BASE)/$(GO_PROJ)
$(GO_BASE):
@mkdir -p $(GO_BASE)
init-go: $(GO_BASE)
@echo ">> Setting up Go example ..."
-@git subtree add \
--prefix $(GO_DIR) \
$(GO_REPO) \
main \
--squash
pull-go:
@echo ">> Updating Go example ..."
@git subtree pull \
--m "Updated latest from $(PRIV)/go." \
--prefix $(GO_DIR) \
$(GO_REPO) \
main \
--squash
push-go:
@echo ">> Updating Go example ..."
@git subtree push \
--prefix $(GO_DIR) \
$(GO_REPO) \
main
build-go: | $(GO_DIR)
@echo ">> Building Go example ..."
@cd $(GO_DIR) && $(MAKE)
clean-go:
@cd $(GO_DIR) && $(MAKE) clean
clean-build-go: clean-go build-go
#############################################################################
### Common Lisp Targets #################################################
#############################################################################
CL_REPO = https://github.com/cl-axon/erlang-ports-example.git
CL_PROJ = erlang-ports-example
CL_DIR = $(PRIV)/cl-ports-example
init-lisp:
@echo ">> Setting up Common Lisp example ..."
-@git subtree add \
--prefix $(CL_DIR) \
$(CL_REPO) \
main \
--squash
pull-lisp:
@echo ">> Updating Common Lisp example ..."
@git subtree pull \
--m "Updated latest from Lisp $(CL_DIR)." \
--prefix $(CL_DIR) \
$(CL_REPO) \
main \
--squash
push-lisp:
@echo ">> Updating Common Lisp example ..."
@git subtree push \
--prefix $(CL_DIR) \
$(CL_REPO) \
main
fixup-lisp:
@echo ">> Fixing-up Common Lisp example ..."
@git pull origin main --rebase
@git merge -s subtree -Xsubtree="$(CL_DIR)" origin/main --allow-unrelated-histories
build-cl: | $(CL_DIR)
@echo ">> Building Common Lisp example ..."
@cd $(CL_DIR) && $(MAKE)
clean-cl:
@cd $(CL_DIR) && $(MAKE) clean
quicklisp-link:
@echo ">> Linking Common Lisp example to local Quicklisp ..."
@cd apps/ports/priv/cl-ports-example/
@ln -s `pwd` ~/quicklisp/local-projects/