#
# Copyright (c) 2003-2004 Hajimu UMEMOTO <ume@mahoroba.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Mahoroba: src/dtcpclient/Makefile,v 1.10 2005/12/28 07:29:24 ume Exp $
#

OPSYS!=		uname -s

PREFIX?=	/usr/local

PROG=		dtcpclient
MAN=		dtcpclient.8

BINDIR=		$(PREFIX)/sbin
SCRIPTSDIR=	$(PREFIX)/etc
EXAMPLESDIR=	$(PREFIX)/share/examples/dtcpclient

.if ($(OPSYS) == "NetBSD")
MANDIR=		$(PREFIX)/man
.else
MANDIR=		$(PREFIX)/man/man
.endif

CFLAGS+=	-Wall -DPREFIX=\"$(PREFIX)\"

.if ($(OPSYS) == "FreeBSD")
CFLAGS+=	-DHAVE_MD5
LDADD=		-lmd
.elif ($(OPSYS) == "NetBSD") || ($(OPSYS) == "OpenBSD")
CFLAGS+=	-DHAVE_MD5
.else
LDADD=		-lcrypto
.endif

all:		$(PROG)

realinstall:
	$(INSTALL) -s $(COPY) -o $(BINOWN) -g $(BINGRP) -m 555 \
		dtcpclient $(BINDIR)/dtcpclient
	$(INSTALL) -d $(EXAMPLESDIR)
	$(INSTALL) $(COPY) -o $(BINOWN) -g $(BINGRP) -m 555 \
		dtcpclient.script $(EXAMPLESDIR)/dtcpclient.script
	if [ ! -f $(SCRIPTSDIR)/dtcpclient.script ]; then \
		cp -p $(EXAMPLESDIR)/dtcpclient.script $(SCRIPTSDIR)/; \
	fi

dist:
	@data=`date +%Y%m%d`; \
	rm -rf dtcpclient-$${data}; \
	mkdir dtcpclient-$${data}; \
	cp -p ChangeLog GNUmakefile Makefile dtcpclient.8 dtcpclient.c \
		dtcpclient.script dtcpclient.sh dtcpclient-$${data}; \
	tar cvzf dtcpclient-$${data}.tar.gz dtcpclient-$${data}; \
	rm -rf dtcpclient-$${data}

.include <bsd.prog.mk>
