-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
67 lines (44 loc) · 1.28 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
# Target definitions
TARGETS=html twisted python java csharp cocoa
# If the thrift generator for one of the define target does not match the target
# name, add a GEN_<target-name> variable containing the generator to use instead.
GEN_cocoa=cocoa:log_unexpected
GEN_java=java:beans
GEN_twisted=py:twisted
GEN_python=py:new_style
# Configuration variable
SRCS=$(wildcard *.thrift)
DEST=build
TC=thrift
TFLAGS=-strict -recurse
# From here on it's all dynamic, edit these lines only if you know that you're doing
.PHONY=all clean
all: $(TARGETS)
# Command to use to compile a thrift interface
compile = $(TC) --gen $(1) $(TFLAGS) -o temp $(2) ;
# Define the default target names
define GEN_template
GEN_$(1)?=$(1)
endef
$(foreach target,$(TARGETS),$(eval $(call GEN_template,$(target))))
# Create all dynamic targets
define BUILD_template
build/$(1): $$(SRCS)
rm -rf $$@
mkdir -p $$@
rm -rf temp
mkdir -p temp
$$(foreach src,$$(SRCS),$$(call compile,$(GEN_$(1)),$$(src)))
mv temp/*/smaclib $$@ || mv temp/*/* $$@
rm -rf temp
$(1): build/$(1)
endef
$(foreach target,$(TARGETS),$(eval $(call BUILD_template,$(target))))
clean:
rm -rf build
rm -rf temp
rm -f *.tar.gz
dist: all
mv build smac-api
tar czf smac-api-$(shell git tag | tail -n 1).tar.gz smac-api
mv smac-api build