-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (38 loc) · 1.15 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
JXA_FLAGS = -O3 -m32
JXA_I = -I./include
JXA_AR = llvm-ar-8
JXA_CC = clang-8
JXA_LD = ld.lld-8
LIB_NAME = jxa
NAMES = jxa json_parse json_interface json_find json_free json_print
H_FILES = src/jxa.h include/json.h
STATIC_O_FILES = $(addprefix o/static/, $(addsuffix .o, $(NAMES)))
SHARED_O_FILES = $(addprefix o/shared/, $(addsuffix .o, $(NAMES)))
all: static shared
lib/lib$(LIB_NAME).a: $(STATIC_O_FILES)
$(JXA_AR) rcs $@ $?
o/static/%.o: src/%.c $(H_FILES)
$(JXA_CC) -c $< -o $@ $(JXA_FLAGS) $(JXA_I)
lib/lib$(LIB_NAME).so: $(SHARED_O_FILES)
$(JXA_LD) -s -shared -o $@ $^
o/shared/%.o: src/%.c $(H_FILES)
$(JXA_CC) -fPIC -c $< -o $@ $(JXA_FLAGS) $(JXA_I)
.PHONY: clean dirs \
msg_static dir_static static \
msg_shared dir_shared shared
OUT_DIR = o lib
dirs: $(OUT_DIR)
$(OUT_DIR):
mkdir -p $(OUT_DIR)
dir_static: o/static
dir_shared: o/shared
o/%:
mkdir -p $@
static: dirs msg_static dir_static lib/lib$(LIB_NAME).a
msg_static:
$(info ***** Creating static library... lib$(LIB_NAME).a)
shared: dirs msg_shared dir_shared lib/lib$(LIB_NAME).so
msg_shared:
$(info ***** Creating shared library... lib$(LIB_NAME).so)
clean:
@rm -r $(OUT_DIR)