#   libnet Makefile
#   route|daemon9 <route@infonexus.com>


#   This is kludgey, I know.  I'll fix it later.  Choose one, not both.
DEFINES     =   -DLINUX -D__BSD_SOURCE
#DEFINES     =   -DBSD

#   If defined, the IP header field ip_len and ip_frag are kept in hostbyte
#   order, otherwise they are htons'd into network byte order (as you would
#   expect.  Define this for: OpenBSD < 2.1, FreeBSD, BSDi < 3.0.  Don't
#   for OpenBSD 2.1+, Linux.  If anyone knows of any others please email me.
#   default:    disabled.
DEFINES     +=  #-DBSD_BYTE_SWAP

#   Debugging information
#   default:    disabled.
DEFINES     +=  #-D__DEBUG


INSTALL_LOC =   /usr/local/
LIBNET      =   lib/libnet.a
MAN         =   doc/libnet.3
INCLUDE     =   include/libnet.h

VER         =   0.6
RANLIB      =   /usr/bin/ranlib
CC          =   /usr/bin/gcc
AR          =   /usr/bin/ar
CFLAGS      =   -O3 -funroll-loops -fomit-frame-pointer -pipe -m486 -Wall
OBJECTS     =   src/resolve.o src/socket.o src/checksum.o src/build_ip.o\
		src/build_tcp.o src/build_udp.o src/write_ip.o


.c.o:
	$(CC) $(CFLAGS) $(DEFINES) -c $< -o $@

all: libnet

libnet: $(OBJECTS)
	$(AR) -cr $(LIBNET) $(OBJECTS)
	$(RANLIB) $(LIBNET)

dist:   clean
	@(cd ..; rm libnet-$(VER).tgz; tar cvzf libnet-$(VER).tgz Libnet/)

test:   libnet
	@(cd src/Test; make all)

install: libnet
	install -m 0644 $(LIBNET) $(INSTALL_LOC)lib
	install -m 0644 $(INCLUDE) $(INSTALL_LOC)include
	install -m 0644 $(MAN) $(INSTALL_LOC)man/man3

clean:
	@(rm -f core src/*.o lib/libnet.a)
	@(cd src/Test; make clean)

# EOF
