Permalink
Browse files

build system fixes

  • Loading branch information...
1 parent a1a4d3a commit 688abc90a1990b6c16be28909c841c5cbafafc2c @massemanet committed Jan 30, 2010
Showing with 39 additions and 30 deletions.
  1. +0 −1 INSTALL
  2. +1 −0 INSTALL
  3. +0 −24 src/Makefile
  4. +38 −5 src/inotify.erl
View
View
@@ -0,0 +1 @@
+aclocal ; autoconf ; automake --add-missing ; ./configure ; make
View
@@ -1,24 +0,0 @@
-.SUFFIXES: .erl .beam .yrl
-
-LIBS= -l ei
-
-CFLAGS= -Wall
-
-.erl.beam:
- erlc -W $<
-
-.c.o:
- gcc -o $<
-
-MODS = inotify
-
-all: ${MODS:%=%.beam} inotify
-
-inotify: inotify_driver.c erl_comm.c inotify_erlang.c
- gcc -o inotify erl_comm.c inotify_driver.c inotify_erlang.c $(LIBS) $(CFLAGS)
-
-test:
- erl -noshell -eval "inotify:test(), erlang:halt()."
-
-clean:
- rm inotify *.beam
View
@@ -3,13 +3,11 @@
-export([test_start/0, test_end/2, test/0]).
-export([open/0, controlling_process/1, add/3, remove/2, list/0, close/1]).
--define(PORTPROG, "./inotify").
-
start(Controller) when is_pid(Controller) ->
spawn(fun() ->
register(?MODULE, self()),
process_flag(trap_exit, true),
- Port = open_port({spawn, ?PORTPROG},
+ Port = open_port({spawn, executable()},
[{packet, 2}, binary, exit_status]),
loop(Port, Controller)
%% The following is only used for development and testing
@@ -23,7 +21,6 @@ start(Controller) when is_pid(Controller) ->
stop() ->
?MODULE ! stop.
-
test_start() ->
io:format("open~n"),
{ok, F} = open(),
@@ -41,8 +38,9 @@ test_end(F,W) ->
test() ->
%% this is the test file
- Dir = "../test",
+ Dir = "/tmp/inotify/test",
File = "file",
+ filelib:ensure_dir(filename:join(Dir,File)),
io:format("Simplistic test/example~n"),
io:format("Start... "),
start(self()),
@@ -172,3 +170,38 @@ loop(Port, Controller) ->
_Other ->
loop(Port, Controller)
end.
+
+executable() ->
+ Parts = [[filename:dirname(code:which(?MODULE)),"..",c_src],
+ [code:priv_dir(inotify),bin]],
+ try E = take_first(fun to_file/1, Parts),
+ io:fwrite("using: ~p~n",[E]),
+ E
+ catch _:_ -> exit({inotify_binary_not_found,Parts})
+ end.
+
+to_file(Parts) ->
+ true = filelib:is_regular(F=filename:join(Parts++[inotify])),
+ F.
+
+take_first(_,[]) -> exit({take_first,nothing_worked});
+take_first(F,[H|T]) ->
+ try F(H)
+ catch _:_ -> take_first(F,T)
+ end.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

0 comments on commit 688abc9

Please sign in to comment.