This repository has been archived by the owner on Mar 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGNUmakefile
75 lines (53 loc) · 1.61 KB
/
GNUmakefile
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
CC = clang
CFLAGS += -std=c99
CFLAGS += -D_POSIX_C_SOURCE=200809L
CFLAGS += -Wall -Wextra -Werror -Wsign-conversion
CFLAGS += -Wno-unused-parameter -Wno-unused-function
CFLAGS += -fPIC
CFLAGS += $(shell icu-config --cflags)
LDFLAGS += -shared
LDFLAGS += $(shell icu-config --ldflags-searchpath)
LDLIBS += $(shell icu-config --ldflags-libsonly)
NIF_LIB = priv/icu_nif.so
NIF_SRC = $(wildcard c_src/*.c)
NIF_OBJ = $(subst .c,.o,$(NIF_SRC))
PLATFORM = $(shell uname -s)
ifeq ($(PLATFORM), Linux)
CFLAGS += -I/usr/lib/erlang/usr/include # used on local machines
CFLAGS += -I/usr/local/lib/erlang/usr/include # used in the build container
LDFLAGS += -L/usr/lib/erlang/usr/lib
LDFLAGS += -L/usr/local/lib/erlang/usr/lib
endif
ifeq ($(PLATFORM), Darwin)
CFLAGS += -I/opt/local/lib/erlang/usr/include # macport
CFLAGS += -I/opt/local/include # macport
CFLAGS += -I/usr/local/opt/erlang/usr/include # brew
CFLAGS += -I/usr/local/opt/icu4c/include # brew
LDFLAGS += -arch x86_64 -flat_namespace -undefined suppress
LDFLAGS += -L/opt/local/lib/erlang/usr/lib # macport
LDFLAGS += -L/usr/local/opt/erlang/usr/lib # brew
endif
ifeq ($(PLATFORM), FreeBSD)
CFLAGS += -I/usr/local/lib/erlang/usr/include
CFLAGS += -I/usr/local/include
LDFLAGS += -L/usr/local/lib/erlang/usr/lib
LDFLAGS += -I/usr/local/lib
endif
all: build doc
dialyzer:
rebar3 dialyzer
build: nif
rebar3 compile
test: nif
rebar3 eunit
nif: $(NIF_LIB)
$(NIF_LIB): $(NIF_OBJ)
$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS)
%.o: %.c
$(CC) -o $@ $(CFLAGS) -c $<
doc:
rebar3 edoc
clean:
$(RM) -r _build
$(RM) $(NIF_OBJ)
.PHONY: all dialyzer build test nif doc clean