--- /dev/null
+#!/bin/sh
+
+name="hdw-sniff"
+
+#defaults
+prefix=/usr
+apidir=""
+
+usage() {
+ echo "usage $0 <options>"
+ echo "options:"
+ echo "--prefix=PREFIX specify install prefix"
+ echo "--with-api=DIR specify api dir"
+ echo
+ }
+
+while [ "$1" ]; do
+ case "`echo $1 | awk -F= '{ print $1 }'`" in
+ --prefix) prefix=`echo $1 | awk -F= '{ print $2 }'`; shift;;
+ --help) usage; shift 1;;
+ --with-api) apidir=`echo $1 | awk -F= '{ print $2 }'`; shift;;
+ esac
+done
+
+echo "checking for api stuff ..."
+api_dir="0"
+if [ -z "$apidir" ]; then
+ for i in ../api ../../api; do
+ if [ -f $i/CHANGELOG ]; then
+ api_dir=$i
+ fi
+ done
+else
+ if [ -f $apidir/CHANGELOG ]; then
+ api_dir=$apidir
+ fi
+fi
+if [ "$api_dir" = "0" ]; then
+ echo "api files not found ..."
+ echo "WARNING: your build will fail."
+ echo "please get the api files first (see README file)."
+ api_dir="./"
+fi
+
+GENLIBS="-lm -lncurses -lpcap"
+GENAPI="network.o event.o list.o display.o input.o"
+SRC="main.c parse.c"
+
+echo "creating Makefile"
+
+cat > Makefile << EOF
+# $name Makefile, created `date`
+
+INCLUDEDIR = /usr/include
+CFLAGS = -DDEBUG -O3 -Wall
+LIBS = $GENLIBS
+
+OBJS = $GENAPI
+OBJS2 = $name
+
+links:
+EOF
+
+for i in $GENAPI; do
+ foo="`echo $i | sed 's/\.o//g'`"
+ cat >> Makefile << EOF
+ ln -sf $api_dir/$foo/${foo}.{c,h} .
+EOF
+done
+
+for i in $name; do
+cat >> Makefile << EOF
+
+$i: links \$(OBJS)
+ \$(CC) \$(CFLAGS) -o \$@ \$(OBJS) $SRC \$(LIBS)
+
+EOF
+done
+
+cat >> Makefile << EOF
+all: $name
+
+clean:
+ rm -f \$(OBJS) \$(OBJS2)
+
+remake: clean all
+
+install:
+ mkdir -p $prefix/bin
+ cp $name $prefix/bin
+EOF
+
+echo "done"