@ -1,9 +1,24 @@ | |||
.jiffy.dev | |||
*.app | |||
*.beam | |||
*.o | |||
*.so | |||
.eunit | |||
deps | |||
erln8.config | |||
TEST-*.xml | |||
.rebar3 | |||
_* | |||
.eunit | |||
*.o | |||
*.so | |||
*.beam | |||
*.plt | |||
*.swp | |||
*.swo | |||
.erlang.cookie | |||
ebin | |||
log | |||
erl_crash.dump | |||
.rebar | |||
_rel | |||
_deps | |||
_plugins | |||
_tdeps | |||
logs | |||
_build | |||
c_src/env.mk |
@ -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,66 @@ | |||
?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 -I. -Wall -Wmissing-prototypes | |||
CXXFLAGS ?= -O3 -arch x86_64 -I. -Wall | |||
LDFLAGS ?= -arch x86_64 -flat_namespace -undefined suppress | |||
else ifeq ($(UNAME_SYS), FreeBSD) | |||
CC ?= cc | |||
CFLAGS ?= -O3 -std=c99 -finline-functions -I. -Wall -Wmissing-prototypes | |||
CXXFLAGS ?= -O3 -finline-functions -I. -Wall | |||
else ifeq ($(UNAME_SYS), Linux) | |||
CC ?= g++ | |||
CFLAGS ?= -O3 -std=c99 -finline-functions -I. -Wall -Wmissing-prototypes | |||
CXXFLAGS ?= -O3 -finline-functions -I. -Wall | |||
LDFLAGS ?= -lstdc++ | |||
endif | |||
CFLAGS += -fPIC -I$(ERTS_INCLUDE_DIR) -I$(ERL_INTERFACE_INCLUDE_DIR) | |||
CXXFLAGS += -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 | |||
@$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ | |||
%.o: %.cc | |||
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -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 +1,44 @@ | |||
% This file is part of Jiffy released under the MIT license. | |||
% See the LICENSE file for more information. | |||
IsRebar3 = case application:get_key(rebar, vsn) of | |||
{ok, VSN} -> | |||
[VSN1 | _] = string:tokens(VSN, "-"), | |||
[Maj, Min, Patch] = string:tokens(VSN1, "."), | |||
(list_to_integer(Maj) >= 3); | |||
undefined -> | |||
lists:keymember(mix, 1, application:loaded_applications()) | |||
end, | |||
% 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. | |||
case IsRebar3 of | |||
true -> | |||
CONFIG; | |||
false -> | |||
io:format("la~n", []), | |||
ErlOpts = [{d, 'JIFFY_DEV'}], | |||
CONFIG1 = [{eunit_opts, [verbose]}, {plugins, [rebar_gdb_plugin]} | CONFIG], | |||
Proper = [ | |||
{proper, ".*", {git, "git://github.com/manopapad/proper.git", "master"}} | |||
], | |||
ErlOpts = [{d, 'JIFFY_DEV'}], | |||
Proper = [{proper, ".*", {git, "git://github.com/manopapad/proper.git", "master"}}], | |||
ConfigPath = filename:dirname(SCRIPT), | |||
DevMarker = filename:join([ConfigPath, ".jiffy.dev"]), | |||
ConfigPath = filename:dirname(SCRIPT), | |||
DevMarker = filename:join([ConfigPath, ".jiffy.dev"]), | |||
case filelib:is_file(DevMarker) of | |||
true -> | |||
% Don't override existing dependencies | |||
Config0 = case lists:keyfind(deps, 1, CONFIG) of | |||
case filelib:is_file(DevMarker) of | |||
true -> | |||
% Don't override existing dependencies | |||
CONFIG2 = case lists:keyfind(deps, 1, CONFIG1) of | |||
false -> | |||
CONFIG1 ++ [{deps, Proper}]; | |||
{deps, DepsList} -> | |||
lists:keyreplace(deps, 1, CONFIG1, {deps, DepsList ++ Proper}) | |||
end, | |||
case lists:keyfind(erl_opts, 1, CONFIG2) of | |||
false -> | |||
CONFIG2 ++ [{erl_opts, ErlOpts}]; | |||
{erl_opts, Opts} -> | |||
NewOpts = {erl_opts, Opts ++ ErlOpts}, | |||
lists:keyreplace(erl_opts, 1, CONFIG2, NewOpts) | |||
end; | |||
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 | |||
CONFIG1 | |||
end | |||
end. |
@ -0,0 +1 @@ | |||
[]. |