#!/bin/sh # Let,s chect environment. For instance what we are on OS=`uname -s` MAC=`uname -m` RELEASE=`uname -r` # Whoarewe ? :) ME=`whoami` echo -n "Operating System Type: " if test "$OS" = Linux; then echo "Linux" elif test "$OS" = FreeBSD; then echo "FreeBSD" elif test "$OS" = OpenBSD; then echo "OpenBSD" elif test "$OS" = NetBSD; then echo "NetBSD" fi echo -n "testing /usr/include/stdio.h..." if(test -f /usr/include/stdio.h); then echo "ok" else exit fi echo -n "testing /usr/include/stdlib.h..." if(test -f /usr/include/stdlib.h); then echo "ok" else exit fi echo -n "testing /usr/include/errno.h..." if(test -f /usr/include/errno.h); then echo "ok" else echo "no" fi if test "$OS" = Linux; then echo -n "testing /usr/include/pcap.h..." if(test -f /usr/include/pcap.h); then echo "ok" else exit fi fi echo -n "testing /usr/include/sys/socket.h..." if(test -f /usr/include/sys/socket.h); then echo "ok" else exit; fi echo -n "testing /usr/include/netinet/in.h..." if(test -f /usr/include/netinet/in.h); then echo "ok" else exit; fi echo -n "testing /usr/include/arpa/inet.h..." if(test -f /usr/include/arpa/inet.h); then echo "ok" else exit fi echo -n "testing /usr/include/netinet/if_ether.h..." if(test -f /usr/include/netinet/if_ether.h); then echo "ok" else exit fi if test "$OS" = Linux; then echo -n "testing /usr/include/libnet.h..." if(test -f /usr/include/libnet.h); then echo "ok" else exit fi elif test "$OS" = FreeBSD || test "$OS" = OpenBSD || test "$OS" = NetBSD; then echo -n "testing ${LOCALBASE}/include/libnet.h..." if(test -f ${LOCALBASE}/include/libnet.h); then echo "ok" else exit fi fi if test "$OS" = FreeBSD || test "$OS" = OpenBSD || test "$OS" = NetBSD; then echo -n "testing ${LOCALBASE}/lib/libnet.a..." if(test -f ${LOCALBASE}/lib/libnet.a); then echo "ok" else echo "can't find required libnet.a static library" exit fi fi if test "$OS" = Linux; then echo -n "testing /usr/lib/libnet.a..." if(test -f /usr/lib/libnet.a); then echo "ok" else echo "can't find required libnet.a static library" exit fi fi if test "$OS" = Linux; then echo -n "testing /usr/lib/libpcap.a..." if(test -f /usr/lib/libpcap.a); then echo "ok" else echo "can't find required libpcap.a static library" exit fi fi echo -n "Writing MakeFile..." echo "#!/usr/bin/make -f" > Makefile echo "LIBNETDEFS = `libnet-config --defines`" >> Makefile echo "LIBNETLIB = `libnet-config --libs`" >> Makefile echo " " >> Makefile echo " " >> Makefile echo "all: kn_arp.c kn_main.c kn_defs.h" >> Makefile echo " gcc ${CFLAGS} -c kn_main.c" >> Makefile if test "$OS" = Linux; then echo " gcc -Wall \$(LIBNETDEFS) -c kn_arp.c" >> Makefile echo " gcc -o knowlan kn_main.o kn_arp.o -lnet -lpcap" >> Makefile echo " " >> Makefile echo " " >> Makefile echo "install: knowlan" >> Makefile echo " /bin/cp knowlan /usr/sbin/knowlan" >> Makefile echo " /bin/chown root.root /usr/sbin/knowlan" >> Makefile echo " /bin/chmod 755 /usr/sbin/knowlan" >> Makefile elif test "$OS" = FreeBSD || test "$OS" = OpenBSD || test "$OS" = NetBSD; then echo " gcc ${CFLAGS} -D__BSD__=1 -D__GLIBC__=1 -I${LOCALBASE}/include/ \$(LIBNETDEFS) -c kn_arp.c" >> Makefile echo " gcc -o knowlan kn_main.o kn_arp.o ${LOCALBASE}/lib/libnet.a -lpcap" >> Makefile echo " " >> Makefile echo " " >> Makefile echo "install: knowlan" >> Makefile echo " /bin/cp knowlan /usr/sbin/knowlan" >> Makefile echo " /bin/chown root.root /usr/sbin/knowlan" >> Makefile echo " /bin/chmod 755 /usr/sbin/knowlan" >> Makefile fi echo "clean:" >> Makefile echo " find ./ -name \"*.o\" -exec rm -rf {} \;" >> Makefile echo " find ./ -name \"knowlan\" -exec rm -rf {} \;" >> Makefile echo " find ./ -name \"*core\" -exec rm -rf {} \;" >> Makefile echo "Done."