# $FreeBSD: src/usr.sbin/ppp/Makefile,v 1.79 2000/10/31 05:00:25 hosokawa Exp $

PROG=	ppp
SRCS=	acf.c arp.c async.c auth.c bundle.c cbcp.c ccp.c chap.c chat.c \
	command.c datalink.c deflate.c defs.c exec.c filter.c fsm.c hdlc.c \
	iface.c ip.c ipcp.c iplist.c lcp.c link.c log.c lqr.c main.c \
	mbuf.c mp.c pap.c physical.c pred.c probe.c prompt.c proto.c route.c \
	server.c sig.c slcompress.c sync.c systems.c tcp.c throughput.c \
	timer.c tty.c tun.c udp.c vjcomp.c
CFLAGS+=-Wall
OS!=	uname -s
.if ${OS} == FreeBSD 
.if exists(/usr/lib/libz.a) || exists(/usr/lib/aout/libz.a)
LDADD+= -lcrypt -lmd -lutil -lz
.else
LDADD+= -lcrypt -lmd -lutil 
.endif
.else
.if ${OS} == NetBSD
LDADD+= -lcrypt -lutil -lz
.else
LDADD+= -lcrypto -lutil -lz
.endif
.endif
DPADD+=	${LIBCRYPT} ${LIBMD} ${LIBUTIL} ${LIBZ}
.if defined(NOSUID) || defined(PPP_NOSUID)
BINMODE=554
.else
BINMODE=4554
BINOWN=	root
.endif
BINGRP=	network
OS!=	uname -s
.if ${OS} == FreeBSD
MAN8=	ppp.8
.else
MAN=	ppp.8
.endif

.if defined(RELEASE_CRUNCH)
CFLAGS+=-DRELEASE_CRUNCH
.endif

.if defined(NOKLDLOAD) || !exists(/usr/include/sys/module.h)
CFLAGS+=-DNOKLDLOAD
.endif

.if defined(NOINET6) || !exists(/usr/include/netinet6/in6.h)
CFLAGS+=-DNOINET6
.endif

.if defined(NOALIAS) || defined(NONAT)
CFLAGS+=-DNONAT
.else
.if !defined(RELEASE_CRUNCH)
SRCS+=	nat_cmd.c
LDADD+=	-L../libhack -lalias
DPADD+= ${LIBALIAS}
.endif
.endif

.if defined(NOATM) || !exists(/usr/include/netnatm/natm.h) || defined(RELEASE_CRUNCH)
CFLAGS+=-DNOATM
.else
SRCS+=	atm.c
.endif

.if defined(NOSUID) || defined(PPP_NOSUID)
CFLAGS+=-DNOSUID
.else
.if !defined(RELEASE_CRUNCH)
SRCS+=	id.c
.endif
.endif

.if exists(/usr/src/secure) && !defined(NOCRYPT) && !defined(NOSECURE) && !defined(NO_OPENSSL) && !defined(RELEASE_CRUNCH)
DISTRIBUTION=crypto
CFLAGS+=-DHAVE_DES
SRCS+=	chap_ms.c mppe.c
.if defined(LIBCRYPTO)
LDADD+= -lcrypto
.else
LDADD+=	-ldes
.endif
DPADD+= ${LIBCRYPTO}
.endif

.if defined(NORADIUS) || !exists(/usr/include/radlib.h)
CFLAGS+=-DNORADIUS
.else
.if !defined(RELEASE_CRUNCH)
SRCS+=	radius.c
LDADD+=	-lradius
DPADD+= ${LIBRADIUS}
.endif
.endif

.if defined(NOI4B) || (!exists(/usr/include/machine/i4b_rbch_ioctl.h) && !exists(/usr/include/i4b/i4b_rbch_ioctl.h)) || ${MACHINE_ARCH} == "alpha"
CFLAGS+=-DNOI4B
.else
SRCS+=	i4b.c
.endif

.if defined(NONETGRAPH) || !exists(/usr/include/netgraph/ng_pppoe.h)
CFLAGS+=-DNONETGRAPH
.else
SRCS+=	ether.c
LDADD+=	-lnetgraph
DPADD+= ${LIBNETGRAPH}
.endif

.if defined(RELEASE_CRUNCH)
# We must create these objects because crunchgen will link them,
# and we don't want any unused symbols to spoil the final link.
CFLAGS+=-DNONAT -DNORADIUS -DNOI4B -DNOSUID
OBJS+=	chap_ms.o mppe.o id.o nat_cmd.o radius.o
chap_ms.o mppe.o id.o nat_cmd.o radius.o:
	>null_${.PREFIX}.c
	cc -c -o ${.TARGET} null_${.PREFIX}.c
.endif

# To cope with uucplock changes:
# Note, uucplock.c and libutil.h do not really belong here !
CFLAGS+=-I. -I../libhack
SRCS+=uucplock.c
BINDIR=/usr/sbin

.PATH: ${.CURDIR}/../libhack

.include <bsd.prog.mk>
