Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
71 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
*.so | ||
*.o | ||
*.swp | ||
rebar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,15 @@ | ||
OTPROOT=/Users/schacon/projects/otp | ||
INCLUDES = -I$(OTPROOT)/erts/emulator/beam/ | ||
REBAR=$(shell which rebar || echo ./rebar) | ||
|
||
# OS X flags. | ||
GCCFLAGS = -O3 -fPIC -bundle -flat_namespace -undefined suppress -fno-common -Wall -m32 | ||
all: compile | ||
|
||
LIBS = -lz -lgit2 | ||
./rebar: | ||
erl -noshell -s inets start \ | ||
-eval 'httpc:request(get, {"http://hg.basho.com/rebar/downloads/rebar", []}, [], [{stream, "./rebar"}])' \ | ||
-s init stop | ||
chmod +x ./rebar | ||
|
||
# Linux Flags | ||
#GCCFLAGS = -O3 -fPIC -shared -fno-common -Wall | ||
|
||
CFLAGS = $(GCCFLAGS) $(INCLUDES) | ||
LDFLAGS = $(GCCFLAGS) $(LIBS) | ||
|
||
OBJECTS = geef.o | ||
|
||
DRIVER = geef.so | ||
BEAM = geef.beam | ||
|
||
all: $(DRIVER) $(BEAM) | ||
|
||
clean: | ||
rm -f *.o *.beam $(DRIVER) | ||
|
||
$(DRIVER): $(OBJECTS) | ||
gcc -o $@ $^ $(LDFLAGS) | ||
|
||
$(BEAM): geef.erl | ||
erlc $^ | ||
compile: $(REBAR) | ||
@$(REBAR) compile | ||
|
||
clean: $(REBAR) | ||
@$(REBAR) clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{application, geef, | ||
[ | ||
{description, ""}, | ||
{vsn, "0.0.1"}, | ||
{modules, [ | ||
geef | ||
]}, | ||
{registered, []}, | ||
{applications, [ | ||
kernel, | ||
stdlib | ||
]}, | ||
{env, []} | ||
]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{so_name, "geef.so"}. | ||
|
||
{port_envs, [ | ||
{"DRV_LDFLAGS", "$DRV_LDFLAGS -lz -lgit2"}, | ||
|
||
%% OS X Leopard flags for 64-bit | ||
{"darwin9.*-64$", "CXXFLAGS", "-m64"}, | ||
{"darwin9.*-64$", "LDFLAGS", "-arch x86_64"}, | ||
|
||
%% OS X Snow Leopard flags for 32-bit | ||
{"darwin10.*-32$", "CXXFLAGS", "-m32"}, | ||
{"darwin10.*-32$", "LDFLAGS", "-arch i386"} | ||
]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-module(geef). | ||
-export([start/0, hex_to_raw/1, object_exists/2]). | ||
|
||
start() -> | ||
case code:priv_dir(geef) of | ||
{error, bad_name} -> | ||
SoName = filename:join("priv", geef); | ||
Dir -> | ||
SoName = filename:join(Dir, geef) | ||
end, | ||
io:format("Hey There: ~s~n", [SoName]), | ||
erlang:load_nif(SoName, 0). | ||
|
||
hex_to_raw(_Val) -> | ||
nif_error(?LINE). | ||
|
||
object_exists(_Val, _Val2) -> | ||
nif_error(?LINE). | ||
|
||
nif_error(Line) -> | ||
exit({nif_not_loaded,module,?MODULE,line,Line}). |