#
#   $Id: Makefile.in,v 1.2 1999/05/27 02:32:18 dugsong Exp $
#
#   Libnet makefile
#   (c) 1998, 1999  Mike D. Schiffman <mike@infonexus.com>
#                   route|daemon9 <route@infonexus.com>
#                                
#   @configure_input@

#   Enabled:    Dumps debugging info and verbose error information.
#   Disabled:   Doesn't.
#   default:    disabled.
DEFINES     +=  #-D__DEBUG 
prefix      =   @prefix@
srcdir      =   @srcdir@

LIBNET      =   libnet
LIBPWRITE   =   libpwrite
LIB         =   lib/$(LIBNET).a
MAN         =   doc/$(LIBNET).3
INCLUDE     =   include/$(LIBNET).h
INCLUDE-H   =   include/$(LIBNET)/$(LIBNET)-headers.h
INCLUDE-F   =   include/$(LIBNET)/$(LIBNET)-functions.h
INCLUDE-S   =   include/$(LIBNET)/$(LIBNET)-structures.h
INCLUDE-M   =   include/$(LIBNET)/$(LIBNET)-macros.h
INCLUDE-A   =   include/$(LIBNET)/$(LIBNET)-asn1.h
DEFINES     +=  @DEFS@
RANLIB      =   @RANLIB@
AR          =   @AR@
LN          =   @LN@
CC          =   @CC@
ENSUREDIR   =   $(srcdir)/ensure-dir.sh
INSTALL     =   $(srcdir)/install-sh
CFLAGS      =   @CFLAGS@
CPPFLAGS    =   @CPPFLAGS@
OBJECTS     =   src/resolve.o src/socket.o src/checksum.o src/prand.o\
		src/version.o src/error.o src/write_ip.o src/insert_ipo.o\
		src/insert_tcpo.o src/error.o src/@LL_INT_TYPE@.o src/packet_mem.o\
	        src/build_ip.o src/build_tcp.o src/build_udp.o src/build_arp.o\
		src/build_ethernet.o src/build_icmp.o src/build_igmp.o\
		src/build_dns.o src/build_snmp.o src/build_rip.o src/asn1.o\
		src/hex_dump.o src/stubs.o src/if_addr.o src/arp.o src/route.o

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

all: libnet

libnet: version.h $(OBJECTS)
	$(AR) -cr $(LIB) $(OBJECTS)
	$(RANLIB) $(LIB)

version.o: version.h
version.h: ./VERSION
	@rm -f $@
	sed -e 's/.*/#define VERSION "&"/' ./VERSION > $@

test:   libnet
	cd test; make

util:   libnet
	cd util; make

install: libnet
	$(ENSUREDIR) $(DESTDIR)$(prefix) 755
	$(ENSUREDIR) $(DESTDIR)@LIB_PREFIX@ 755
	$(ENSUREDIR) $(DESTDIR)@INC_PREFIX@$(LIBNET) 755
	$(ENSUREDIR) $(DESTDIR)@INC_PREFIX@ 755
	$(ENSUREDIR) $(DESTDIR)@MAN_PREFIX@ 755
	$(ENSUREDIR) $(DESTDIR)@BIN_PREFIX@ 755
	$(INSTALL) -c -m 0644 $(LIB) $(DESTDIR)@LIB_PREFIX@
	rm -f $(DESTDIR)@LIB_PREFIX@$(LIBPWRITE)
	$(LN) -sf $(DESTDIR)@LIB_PREFIX@$(LIBNET).a $(DESTDIR)@LIB_PREFIX@$(LIBPWRITE)
	$(INSTALL) -c -m 0644 $(INCLUDE) $(DESTDIR)@INC_PREFIX@
	$(INSTALL) -c -m 0644 $(INCLUDE-H) $(DESTDIR)@INC_PREFIX@$(LIBNET)
	$(INSTALL) -c -m 0644 $(INCLUDE-F) $(DESTDIR)@INC_PREFIX@$(LIBNET)
	$(INSTALL) -c -m 0644 $(INCLUDE-S) $(DESTDIR)@INC_PREFIX@$(LIBNET)
	$(INSTALL) -c -m 0644 $(INCLUDE-M) $(DESTDIR)@INC_PREFIX@$(LIBNET)
	$(INSTALL) -c -m 0644 $(INCLUDE-A) $(DESTDIR)@INC_PREFIX@$(LIBNET)
	$(INSTALL) -c -m 0644 $(MAN) $(DESTDIR)@MAN_PREFIX@

clean:
	rm -f *.core src/*.o $(LIB)
	if test -f test/Makefile; then \
	    cd test && make clean; \
	fi
	if test -f util/Makefile; then \
	    cd util && make clean; \
	fi
	if test -f support/bpf-lkm/etherspoof; then \
	    cd support/bpf-lkm/etherspoof && make clean; \
	fi

distclean: clean
	rm -f config.log config.cache config.status Makefile include/config.h \
	version.h support/bpf-lkm/etherspoof
	if test -f test/Makefile; then \
	    cd test && make distclean; \
	fi
	if test -f util/Makefile; then \
	    cd util && make distclean; \
	fi

# EOF
