Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

makefiles suck

Remove the dependencies on the jungerl build infra.

Fix the compile errors under Linux.
  • Loading branch information...
commit 6c5f1618d8c5cb1c33ebaaf6ce55410384948b09 1 parent 54694ab
@msantos authored
View
6 Emakefile
@@ -0,0 +1,6 @@
+% -*- mode: erlang -*-
+{["src/*"],
+ [{i, "include"},
+ {outdir, "ebin"},
+ debug_info]
+}.
View
35 Makefile
@@ -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
23 c_src/Makefile
@@ -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
5 c_src/tun_drv.c
@@ -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  doc/short-desc
@@ -1 +0,0 @@
-Linux "Universal TUN/TAP device" driver
View
2  src/tuntap.erl
@@ -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]).
Please sign in to comment.
Something went wrong with that request. Please try again.