# Makefile for DDT (Domain Debug Tools)
#
#  Copyright (C) 1992, 1993 PUUG - Grupo Portugues de Utilizadores
#                                  do Sistema UNIX
#                1992, 1993 FCCN - Fundacao para o Desenvolvimento dos Meios
#                                  Nacionais de Calculo Cientifico
#
#  Authors: Jorge Frazao de Oliveira <frazao@puug.pt>
#           Artur Romao <artur@dns.pt>
#
#  This file is part of the DDT package, Version 2.0.
#
#  Permission to use, copy, modify, and distribute this software and its
#  documentation for any purpose and without any fee is hereby granted,
#  provided that the above copyright notice appear in all copies.  Neither
#  PUUG nor FCCN make any representations about the suitability of this
#  software for any purpose.  It is provided "as is" without express or
#  implied warranty.



# =()<DESTDIR= @<DESTDIR>@>()=
DESTDIR= /usr/local/lib/ddt

# =()<MANDIR= @<MANDIR>@>()=
MANDIR= /usr/local/lib/ddt/man

CMD= cmd
MAN= man
DOC= doc
XFER= xfer
CONF= conf

# =()<CACHE= @<CACHE>@ >()=
CACHE= /usr/local/lib/ddt/cache 

TO_SUBST= ${CMD}/ddt.pl ${CMD}/expand ${CMD}/grc ${CMD}/mxc \
        ${CMD}/rmc ${CMD}/rrc ${CMD}/soac \
        ${MAN}/ddt-xfer.1 ${MAN}/grc.1 ${MAN}/mxc.1 ${MAN}/rmc.1 \
        ${MAN}/rrc.1 ${MAN}/soac.1 \
        ${XFER}/Makefile ${XFER}/pathnames.h

all: subst ddt-xfer

ddt-xfer:
	cd ${XFER}; make ${MFLAGS}

clean:
	cd ${XFER}; make ${MFLAGS} clean

install-xfer:
	cd ${XFER}; make ${MFLAGS} install


install-man:
	if [ ! -d ${MANDIR} ]; then mkdir ${MANDIR}; fi
	cp ${MAN}/* ${MANDIR}
	chmod 444 ${MANDIR}/*


install-doc:
	if [ ! -d ${DESTDIR}/doc ]; then mkdir ${DESTDIR}/doc; fi
	cp ${DOC}/* ${DESTDIR}/doc
	chmod 644 ${DESTDIR}/doc/*

install-cmd:
	if [ ! -d ${DESTDIR}/cmd ]; then mkdir ${DESTDIR}/cmd; fi
	cp ${CMD}/* ${DESTDIR}/cmd
	chmod 755 ${DESTDIR}/cmd/*


mkdir:
	if [ ! -d ${DESTDIR} ]; then mkdir ${DESTDIR}; fi

install: mkdir install-cmd install-doc install-man install-xfer
	chown -R root ${DESTDIR}


subst:
	${CONF}/subst.sh -f ${CONF}/config ${TO_SUBST}
