#
# dip		Dialup IP connection support program.
#		Makefile for LINUX.
#
# Version:	@(#)Makefile.LINUX	1.30	08/18/94
#
# Author:	Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
#		Copyright 1988-1993 MicroWalt Corporation
#	
# Modified:     Uri Blumenthal, <uri@watson.ibm.com>
#               Copyright 1994 IBM T. J. Watson Research Center
#
#		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.
#

# If you want to include S/Key authentication, un-comment the next
# 2 lines. You will need libskey.a from the skey-linux-1.1b package
# (available on sunsite.unc.edu in
# /pub/Linux/system/Network/sunacm/Programs/User/skey)
# If libskey.a is not in /usr/lib then add the path to it in the 
# SKEYLIB define below.
# Some of S/Key sources is here in skey directory, probably enough
# to build libskey.a, but I haven't tested it...
#
# If you're retarded and insist on binary locks - you may try
# -DHAVE_V2_LOCKFILES=1 flag. I haven't debugged it and will
# not accept any complains if this doesn't work as you
# would like (:-). I don't use it myself, won't test
# it and won't care.
#
# If you have all your locks in /var/lock, as FSSTND recommends (and
# that's exactly what I don't follow :-) - you'd need to define
# -DFSSTND and add this define to CFLAGS or such.

# Enable either one only, or none of the following.
# If you use SecureID card, enable this:
SECUREID=-DSECUREID
SECUREIDLIB=
# If you have SNK-004 card, enable this:
#SNK=-DSNK
#SNKLIB=

# if you don't want skey support just comment out the following line
SKEYDEF	= -DSKEY

ifdef SKEYDEF
SKEYLIB	= -L./skey -lskey
# if you want to build the skey library with shadow password support,
# enable this:
#SHADOW = -DSHADOW
endif

CC	= gcc

# If you wish, add -g flag to the next line
CFLAGS	= -DLINUX $(SKEYDEF) $(SECUREID) -pipe -O6 -Wall -DFSSTND \
          -I/usr/src/linux/include

#LD	= ld
LD	= $(CC)

#LDFLAGS	= -Wl,-qmagic
#LDFLAGS= -Wl,-verbose -Wl,-qmagic
#LDFLAGS = -v -s

# THE FOLLOWING 6 LINES SHOULDN'T BE USED, UNLESS YOU REDEFINE LD!
# For a.out
#SYSBOBJS = /usr/lib/crt0.o
#SYSEOBJS =
# For ELF
#SYSBOBJS = /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o
#SYSEOBJS = /usr/lib/crtend.o /usr/lib/crtn.o

#LIBS	= `$(CC) --print-libgcc-file-name` -lc

# Object modules.
OBJS	= main.o config.o daemon.o tty.o attach.o term.o \
	  modem.o command.o login.o 

PROTOS	= slip.o ppp.o termp.o

BASEDIR = ${DEBDIR}

.c.o:		dip.h $<
		$(CC) $(CFLAGS) -c $<


all:		dip
	-@echo "DIP is built successfully."

install:	all
#	-@cp /usr/sbin/dip ./dip-
	install -c -o root -g dip -m 4754 -s dip ${BASEDIR}/usr/sbin
	( cd ${BASEDIR}/usr/sbin && ln -sf dip diplogin && ln -sf dip diplogini )
	install -c -o root -g root -m 0644 dip.8 ${BASEDIR}/usr/man/man8
	install -c -o root -g root -m 0644 diplogin.8 ${BASEDIR}/usr/man/man8
	install -c -o root -g root -m 0644 diplogini.8 ${BASEDIR}/usr/man/man8
	install -o root -g root -m 755 -d ${BASEDIR}/usr/doc/netstd/dip
	install -o root -g root -m 0644 README* ${BASEDIR}/usr/doc/netstd/dip
	gzip -9fv ${BASEDIR}/usr/doc/netstd/dip/*
	install -o root -g root -m 755 -d ${BASEDIR}/usr/doc/netstd/examples/dip
	install -o root -g root -m 0644 samples/* ${BASEDIR}/usr/doc/netstd/examples/dip
	-@echo "DIP is installed. Now please install/configure /etc/diphosts."

dip:		protocols.a $(OBJS)
ifdef SKEYDEF
		(cd skey && make "SHADOW=$(SHADOW)" linux)
endif
		$(LD) $(LDFLAGS) -o dip $(SYSBOBJS) $(OBJS) protocols.a \
		$(SKEYLIB) $(SECUREIDLIB) $(SNKLIB) $(LIBS) $(SYSEOBJS)

protocols.a:	$(PROTOS)
		ar rcs protocols.a $(PROTOS)

clean:
ifdef SKEYDEF
		(cd skey && make clean)
endif
		rm -f core *.o *.a dip

clobber:	clean
		rm -f dip

depend:
	gccmakedep $(DEPFLAGS) -- $(CFLAGS) -- *.c

dummy:

# End of Makefile.
# DO NOT DELETE

