-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
37 lines (29 loc) · 1.02 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
SRC = c_src/portaudio_nif.c c_src/portaudio_nif/erl_interop.c
SRC += c_src/portaudio_nif/pa_conversions.c
ERLANG_PATH = $(shell erl -eval 'io:format("~s", [lists:concat([code:root_dir(), "/erts-", erlang:system_info(version), "/include"])])' -s init stop -noshell)
CFLAGS += -pthread -O2 -Wall -g -Ic_src -I$(ERLANG_PATH) --std=c11
KERNEL_NAME := $(shell uname -s)
LIB_NAME = priv/portaudio_nif.so
ifneq ($(CROSSCOMPILE),)
LIB_CFLAGS := -shared -fPIC -fvisibility=hidden
SO_LDFLAGS := -Wl,-soname,libportaudio.so.0
else
ifeq ($(KERNEL_NAME), Linux)
LIB_CFLAGS := -shared -fPIC -fvisibility=hidden
SO_LDFLAGS := -Wl,-soname,libportaudio.so.0
endif
ifeq ($(KERNEL_NAME), Darwin)
LIB_CFLAGS := -dynamiclib -undefined dynamic_lookup
endif
ifeq ($(KERNEL_NAME), $(filter $(KERNEL_NAME),OpenBSD FreeBSD NetBSD))
LIB_CFLAGS := -shared -fPIC
endif
endif
LIB_CFLAGS += -lportaudio
all: $(LIB_NAME)
$(LIB_NAME): $(SRC)
mkdir -p priv
$(CC) $(CFLAGS) $(LIB_CFLAGS) $(SO_LDFLAGS) $^ -o $@
clean:
rm -f $(LIB_NAME)
.PHONY: all clean