Permalink
Browse files

makefiles suck

Remove the dependencies on the jungerl build infra.

Fix the compile errors under Linux.
  • Loading branch information...
1 parent 54694ab commit 6c5f1618d8c5cb1c33ebaaf6ce55410384948b09 @msantos committed Dec 31, 2009
Showing with 45 additions and 27 deletions.
  1. +6 −0 Emakefile
  2. +34 −1 Makefile
  3. +0 −23 c_src/Makefile
  4. +4 −1 c_src/tun_drv.c
  5. +0 −1 doc/short-desc
  6. +1 −1 src/tuntap.erl
View
@@ -0,0 +1,6 @@
+% -*- mode: erlang -*-
+{["src/*"],
+ [{i, "include"},
+ {outdir, "ebin"},
+ debug_info]
+}.
View
@@ -1,2 +1,35 @@
-include ../../support/subdir.mk
+
+ERL=erl
+CC=gcc
+
+ERL_LIB=/media/opt/local/lib/erlang
+ARCH=-m32
+CFLAGS=-g -Wall
+CPPFLAGS=-I$(ERL_LIB)/usr/include
+#LDFLAGS=-L$(ERL_LIB)/lib -lpcap -lerl_interface -lei -lpthread
+
+TUN_DRV_SO = priv/tun_drv.so
+TUNCTL = priv/tunctl
+
+
+all: erl $(TUN_DRV_SO) $(TUNCTL)
+
+erl:
+ @$(ERL) -noinput +B \
+ -eval 'case make:all() of up_to_date -> halt(0); error -> halt(1) end.'
+
+$(TUN_DRV_SO): tun_drv.o
+ ld -G -o $@ c_src/$<
+
+tun_drv.o: c_src/tun_drv.c
+ $(CC) $(CFLAGS) -o c_src/$@ -c -fpic $(CPPFLAGS) $<
+
+$(TUNCTL): c_src/tunctl.c
+ $(CC) $(CFLAGS) -o $@ $<
+
+clean:
+ -rm $(TUN_DRV_SO) $(TUNCTL) c_src/*.o ebin/*.beam
+
+.INTERMEDIATE: tun_drv.o
+
View
@@ -1,23 +0,0 @@
-include ../../../support/include.mk
-
-CFLAGS += -I $(ERL_C_INCLUDE_DIR) -I../../../support
-
-TUN_DRV_SO = ../priv/tun_drv.so
-TUNCTL = ../priv/tunctl
-
-all: $(TUN_DRV_SO) $(TUNCTL)
-
-$(TUN_DRV_SO): tun_drv.o
- ld -G -o $@ $<
-
-tun_drv.o: tun_drv.c
- $(CC) $(CFLAGS) -o $@ -c -fpic $(ERL_INCLUDE) $<
-
-$(TUNCTL): tunctl.c
- $(CC) $(CFLAGS) -o $@ $<
-
-clean:
- -rm $(TUN_DRV_SO) $(TUNCTL)
-
-.INTERMEDIATE: tun_drv.o
-
View
@@ -14,11 +14,15 @@
#include <net/if.h>
#include <sys/ioctl.h>
#include <assert.h>
+#include <string.h>
#include <linux/if_tun.h>
#include "erl_driver.h"
+#define sys_alloc malloc
+#define sys_free free
+
#define REPLY_ERROR 0
#define REPLY_OK 1
@@ -201,7 +205,6 @@ static ErlDrvData tun_start(ErlDrvPort port, char *args)
int fd;
int mode;
- char dev_name[IFNAMSIZ];
state = (struct tun_state*) sys_alloc(sizeof(struct tun_state));
if (state == NULL) {
View
@@ -1 +0,0 @@
-Linux "Universal TUN/TAP device" driver
View
@@ -64,7 +64,7 @@ open_tuntap(Type, Dev) ->
tap -> "tap"
end,
DevArg = if Dev == undefined -> "";
- list(Dev) -> " " ++ Dev
+ is_list(Dev) -> " " ++ Dev
end,
open_port({spawn, "tun_drv "++TypeName++DevArg}, [binary]).

0 comments on commit 6c5f161

Please sign in to comment.