@ -1,43 +0,0 @@ | |||||
REBAR?=./rebar | |||||
all: build | |||||
clean: | |||||
$(REBAR) clean | |||||
rm -rf logs | |||||
rm -rf .eunit | |||||
rm -f test/*.beam | |||||
distclean: clean | |||||
git clean -fxd | |||||
devmarker: | |||||
@touch .jiffy.dev | |||||
depends: devmarker | |||||
@if test ! -d ./deps/proper; then \ | |||||
$(REBAR) get-deps; \ | |||||
fi | |||||
build: depends | |||||
$(REBAR) compile | |||||
eunit: | |||||
$(REBAR) eunit skip_deps=true | |||||
check: build eunit | |||||
%.beam: %.erl | |||||
erlc -o test/ $< | |||||
.PHONY: all clean distclean depends build etap eunit check |
@ -0,0 +1,61 @@ | |||||
ERL ?= erl | |||||
BASEDIR=$(CURDIR) | |||||
PRIVDIR=$(BASEDIR)/../priv | |||||
NIF_DIR=$(BASEDIR) | |||||
NIF_ENV=$(BASEDIR)/env.mk | |||||
NIF_SOURCES := $(shell find $(NIF_DIR) -type f \( -name "*.c" -o -name "*.cc" \)) | |||||
NIF_OBJS=$(addsuffix .o, $(basename $(NIF_SOURCES))) | |||||
NIF_SO=$(PRIVDIR)/jiffy.so | |||||
UNAME_SYS := $(shell uname -s) | |||||
ifeq ($(UNAME_SYS), Darwin) | |||||
CC ?= cc | |||||
CFLAGS ?= -O3 -std=c99 -arch x86_64 -Wall -Wmissing-prototypes | |||||
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 | |||||
endif | |||||
CFLAGS += -fPIC -I$(ERTS_INCLUDE_DIR) -I$(ERL_INTERFACE_INCLUDE_DIR) | |||||
LDLIBS += -L$(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei | |||||
LDFLAGS += -shared | |||||
all: $(NIF_ENV) $(NIF_SO) | |||||
clean: | |||||
@rm -rf $(NIF_SO) $(NIF_OBJS) | |||||
distclean: clean | |||||
@rm -rf $(NIF_ENV) | |||||
$(NIF_SO): $(NIF_OBJS) | |||||
@mkdir -p $(PRIVDIR) | |||||
$(CC) $(NIF_OBJS) $(LDFLAGS) $(LDLIBS) -o $(NIF_SO) | |||||
%.o: %.c | |||||
echo $(NIF_SOURCES) | |||||
@$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ | |||||
$(NIF_ENV): | |||||
@$(ERL) -eval "file:write_file(\"$(NIF_ENV)\", \ | |||||
io_lib:format( \ | |||||
\"ERTS_INCLUDE_DIR ?= ~s/erts-~s/include/~n\" \ | |||||
\"ERL_INTERFACE_INCLUDE_DIR ?= ~s~n\" \ | |||||
\"ERL_INTERFACE_LIB_DIR ?= ~s~n\", \ | |||||
[code:root_dir(), erlang:system_info(version), \ | |||||
code:lib_dir(erl_interface, include), \ | |||||
code:lib_dir(erl_interface, lib)])), \ | |||||
halt()." | |||||
-include $(NIF_ENV) |
@ -1,37 +0,0 @@ | |||||
% This file is part of Jiffy released under the MIT license. | |||||
% See the LICENSE file for more information. | |||||
% Only include PropEr as a dependency when the JIFFY_DEV | |||||
% environment variable is defined. This allows downstream | |||||
% applications to avoid requiring PropEr. | |||||
% | |||||
% This script is based on the example provided with Rebar. | |||||
ErlOpts = [{d, 'JIFFY_DEV'}], | |||||
Proper = [ | |||||
{proper, ".*", {git, "git://github.com/manopapad/proper.git", "master"}} | |||||
], | |||||
ConfigPath = filename:dirname(SCRIPT), | |||||
DevMarker = filename:join([ConfigPath, ".jiffy.dev"]), | |||||
case filelib:is_file(DevMarker) orelse os:getenv("TRAVIS") == "true" of | |||||
true -> | |||||
% Don't override existing dependencies | |||||
Config0 = case lists:keyfind(deps, 1, CONFIG) of | |||||
false -> | |||||
CONFIG ++ [{deps, Proper}]; | |||||
{deps, DepsList} -> | |||||
lists:keyreplace(deps, 1, CONFIG, {deps, DepsList ++ Proper}) | |||||
end, | |||||
Config1 = case lists:keyfind(erl_opts, 1, Config0) of | |||||
false -> | |||||
Config0 ++ [{erl_opts, ErlOpts}]; | |||||
{erl_opts, Opts} -> | |||||
NewOpts = {erl_opts, Opts ++ ErlOpts}, | |||||
lists:keyreplace(erl_opts, 1, Config0, NewOpts) | |||||
end; | |||||
false -> | |||||
CONFIG | |||||
end. |