Unverified Commit 6de93689 authored by Alexander Færøy's avatar Alexander Færøy
Browse files

Use rebar3 for compilation.

parent 50b00583
.rebar .rebar
ebin ebin
*.beam *.beam
*.o *.o
REBAR=rebar REBAR=rebar3
.PHONY: compile .PHONY: compile
compile: deps compile:
$(REBAR) compile $(REBAR) compile
.PHONY: deps
$(REBAR) get-deps
.PHONY: clean .PHONY: clean
clean: clean:
$(REBAR) clean $(REBAR) clean
# Based on c_src.mk from erlang.mk by Loïc Hoguin <essen@ninenines.eu>
PROJECT ?= enacl_nif
ERTS_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s/erts-~s/include/\", [code:root_dir(), erlang:system_info(version)]).")
ERL_INTERFACE_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, include)]).")
ERL_INTERFACE_LIB_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, lib)]).")
C_SRC_OUTPUT ?= $(CURDIR)/../priv/$(PROJECT).so
# System type and C compiler/flags.
UNAME_SYS := $(shell uname -s)
ifeq ($(UNAME_SYS), Darwin)
CC ?= cc
CFLAGS ?= -O3 -std=c99 -arch x86_64 -finline-functions -Wall -Wmissing-prototypes
CXXFLAGS ?= -O3 -arch x86_64 -finline-functions -Wall
LDFLAGS ?= -arch x86_64 -flat_namespace -undefined suppress
else ifeq ($(UNAME_SYS), FreeBSD)
CC ?= cc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
CXXFLAGS ?= -O3 -finline-functions -Wall
else ifeq ($(UNAME_SYS), Linux)
CC ?= gcc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
CXXFLAGS ?= -O3 -finline-functions -Wall
LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei -lsodium
LDFLAGS += -shared
# Verbosity.
c_verbose_0 = @echo " C " $(?F);
c_verbose = $(c_verbose_$(V))
cpp_verbose_0 = @echo " CPP " $(?F);
cpp_verbose = $(cpp_verbose_$(V))
link_verbose_0 = @echo " LD " $(@F);
link_verbose = $(link_verbose_$(V))
SOURCES := $(shell find $(C_SRC_DIR) -type f \( -name "*.c" -o -name "*.C" -o -name "*.cc" -o -name "*.cpp" \))
OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
COMPILE_C = $(c_verbose) $(CC) $(CFLAGS) $(CPPFLAGS) -c
COMPILE_CPP = $(cpp_verbose) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c
$(link_verbose) $(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT)
%.o: %.c
%.o: %.cc
%.o: %.C
%.o: %.cpp
{erl_opts, [debug_info]}. {erl_opts, [debug_info]}.
{port_env, [ {pre_hooks, [
{"CFLAGS", "$CFLAGS $LIBSODIUM_CFLAGS"}, {compile, "make -C c_src"},
{"LDFLAGS", "$LDFLAGS $LIBSODIUM_LDFLAGS -lsodium"} {clean, "make -C c_src clean"}
]}. ]}.
{port_specs, [{"priv/enacl_nif.so", ["c_src/*.c"]}]}.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment