-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
44 lines (33 loc) · 1.11 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
PREFIX = $(MIX_APP_PATH)/priv
BUILD = $(MIX_APP_PATH)/obj
TERMBOX_PATH = c_src/termbox
TERMBOX_BUILD = $(MIX_APP_PATH)/termbox_build
ifeq ($(CROSSCOMPILE),)
# Normal build. Set shared library flags according to the platform.
ifeq ($(shell uname),Darwin)
LDFLAGS += -dynamiclib -undefined dynamic_lookup
endif
ifeq ($(shell uname -s),Linux)
LDFLAGS += -fPIC -shared
CFLAGS += -fPIC
endif
else
# Crosscompiled build. Assume Linux flags
LDFLAGS += -fPIC -shared
CFLAGS += -fPIC
endif
NIF_CFLAGS += -I$(ERTS_INCLUDE_DIR) -I$(TERMBOX_PATH)/src
SOURCES = c_src/termbox_bindings.c $(TERMBOX_BUILD)/src/libtermbox.a
calling_from_make:
mix compile
all: $(PREFIX)/termbox_bindings.so
@:
$(TERMBOX_BUILD)/src/libtermbox.%: $(TERMBOX_BUILD)
cd $(TERMBOX_PATH) && CFLAGS="$(CFLAGS)" ./waf configure --prefix=. -o $(TERMBOX_BUILD) && ./waf
$(PREFIX)/termbox_bindings.so: $(SOURCES) $(PREFIX)
$(CC) $(CFLAGS) $(NIF_CFLAGS) $(LDFLAGS) -o $@ $(SOURCES)
$(PREFIX) $(TERMBOX_BUILD):
mkdir -p $@
clean:
rm -rf $(TERMBOX_BUILD) $(PREFIX)/termbox_bindings.so
.PHONY: calling_from_make all clean