#    faucet and hose: network pipe utilities
#    Copyright (C) 1992,1993 Robert Forsman
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# You probably want to change this:
INSTROOT = ${HOME}
INSTBIN = ${INSTROOT}/bin
INSTMAN = ${INSTROOT}/man

# This might be necessary for HPUX
#LDLIBS=-lBSD

# I'm told this is required for Sequent SysV
#LDLIBS=-lsocket -linet -lnsl

# This will be necessary for Sun Solaris (the abomination)
#LDLIBS=-lsocket -lnsl

######################################################################
# CFLAGS
######################################################################

# For SunOS, add -DNO_MEMMOVE.  It doesn't have this very handy function.

# If you don't want to use (or don't have) fcntl(2) try the -DUSE_IOCTL.

# Add -DSYSV if your signal handlers need reinstalling after being called.
# hpux has been known to require this.  I have a feeling Linux needs it. 
# Solaris may or may not.  I haven't experimented enough.

# Add -DNO_SETSID if your system doesn't have the setsid() system call.
# (that system call is used by the -daemon argument to detach faucet from
# the controlling terminal)

# SunOS 4.1.4
CFLAGS = -DUSE_IOCTL -DNO_MEMMOVE $(CDEBUGFLAGS)

# Linux
#CFLAGS = -DUSE_IOCTL -DSYSV $(CDEBUGFLAGS)

# SGI
#CFLAGS = -DSYSV $(CDEBUGFLAGS)

# gcc can handle both at once
CDEBUGFLAGS = -g

######################################################################

FOBJS = faucet.o common.o version.o
HOBJS = hose.o common.o version.o
SOBJS = sockdown.o version.o
GOBJS = getpeername.o version.o

MANPAGES = netpipes.1 faucet.1 hose.1 sockdown.1 getpeername.1
PROGRAMS = faucet hose sockdown getpeername

all	: ${PROGRAMS}

faucet	: ${FOBJS}
	${CC} ${CFLAGS} -o $@ ${FOBJS} ${LDLIBS}

hose	: ${HOBJS}
	${CC} ${CFLAGS} -o $@ ${HOBJS} ${LDLIBS}

sockdown: ${SOBJS}
	${CC} ${CFLAGS} -o $@ ${SOBJS} ${LDLIBS}

getpeername: ${GOBJS}
	${CC} ${CFLAGS} -o $@ ${GOBJS} ${LDLIBS}

install : all
	cp ${PROGRAMS} ${INSTBIN}/
	- rm -f ${INSTBIN}/getsockname
	ln -s getpeername ${INSTBIN}/getsockname
	cp ${MANPAGES} ${INSTMAN}/man1/

clean	:
	rm -f ${FOBJS} ${HOBJS} ${SOBJS} ${GOBJS}

spotless: clean
	rm -f *~ core ${PROGRAMS}
