#
# Makefile for ICMPush v2.2
# Tested on Linux 2.0.35, 2.2.1 (gcc v2.7.2.3) and Solaris 2.5.1 SPARC
# (gcc v2.7.2.3)
#

# Compiler
CC = gcc

# Install directory
INST_DIR  = /usr/local/bin

# English man directory
MAN_DIR = /usr/local/man/man8

# Program Language. 
# If you need spanish uncomment the next variable, else other English.
#LNG = -DSPANISH

# Compiler flags
CCFLAGS = -Wall -O3 $(LNG)

# If you get problems with the message "undefined reference to __inet_aton"
# you has replaced the original "includes" with the "includes" that
# comes with the bind 8.1.2 distribution, then you must put the
# complete path to the library.
# Leave this variable blank else other.
LIBBINDDIR =
# LIBBINDIR = /usr/local/lib/libbind.a


######################################################################
# From here to the end is not necessary to modify. Thanx :)
# 
LIBSOLARIS = -lsocket -lresolv -lnsl
SOURCES = icmpush.c help.c version.c parser.c mtu.c
OBJS =  icmpush.o  help.o version.o parser.o mtu.o
default:
	@echo ""
	@echo "  To compile the ICMPush program for Linuz:"
	@echo "            make linuz"
	@echo ""
	@echo "  To compile the ICMPush program for Solaris:"
	@echo "            make solaris"
	@echo ""
	@echo "  To delete object files, executables and *~:"
	@echo "            make clean"
	@echo ""
	@echo "  To install the ICMPush executable file and the man page:"
	@echo "            make install"
	@echo ""
	@echo "  Enjoy!  ;)"
	@echo ""
	@echo " Slayer."

linuz:	icmp-lin cuenta-prog

icmp-lin:	
	$(CC)  $(CCFLAGS) -DLINUX -D_BIT_FIELDS_LTOH -c $(SOURCES)
	$(CC)  $(CCFLAGS) -o  icmpush   $(OBJS)   $(LIBBINDDIR)

cuenta-prog:	
	$(CC)  $(CCFLAGS) -c  cuenta.c
	$(CC)  $(CCFLAGS) -o  cuenta   cuenta.o

solaris:	icmp-sol cuenta-prog

icmp-sol:	
	$(CC)  $(CCFLAGS) -DSOLARIS -c  $(SOURCES)
	$(CC)  $(CCFLAGS) -o  icmpush  $(OBJS)  $(LIBBINDDIR)  $(LIBSOLARIS)

install:
	cp icmpush $(INST_DIR)
	cp icmpush.8 $(MAN_DIR)

clean:	
	@rm -f icmpush cuenta *.o *~
