# common Makefile lines for the Distributed Checksum Clearinghouse programs

# These rules must be included after the share BSD mk files so that
# the shared files can be happy about defining the main targets

# Copyright (c) 2005 by Rhyolite Software
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE
# BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.

# Rhyolite Software DCC 1.2.74-1.29 $Revision$

# some versions of gmake do not understand ?=
@MAKE_DOT@ifndef INSTALL
INSTALL	=@DCCINSTALL@
@MAKE_DOT@endif

BININSTALL=$(INSTALL) $(SET_BINOWN) -m $(BINMODE) -c

# create the DCC home directory before trying to install files
beforeinstall:$(BINDIR) $(MANDIR)8 depend all
$(BINDIR):
	$(INSTALL) -d $(SET_BINOWN) -m 755 $@

@USE_DCCMANINSTALL@
dccmaninstall:
@MAKE_DOT@ifndef NOMAN
@MAKE_DOT@ifdef MAN8
	sh -c 'for NM in $(MAN8); do \
	  $(INSTALL) -c $(SET_MANOWN) -m $(MANMODE) $$NM $(MANDIR)8@MAN8INST@;\
	  done'
@MAKE_DOT@endif
@MAKE_DOT@endif

$(MANDIR)8:
@MAKE_DOT@ifndef NOMAN
@MAKE_DOT@ifdef MAN8
	$(INSTALL) -d $(SET_MANOWN) -m 755 $(MANDIR)8
@MAKE_DOT@endif
@MAKE_DOT@endif


# ensure that even systems with neither the BSD nor the gmake dependency
#   mechanisms rebuild things when the main parameter file changes.
@MAKE_DOT@ifdef SRCS
$(SRCS:.c=.o):${DEPTH}/include/dcc_config.h
# ensure that adding a kludge.h file or otherwise changing included files
#   rebuilds dependencies in systems with .depend files
.depend:$(DEPTH)/include/dcc_config.h
@MAKE_DOT@endif


@MAKE_DOT@ifndef BUNDLE_BUILD
all:	depend

@MAKE_DOT@else
.SUFFIXES:.0 .8 .html .txt
.8.0::
	sed -e `sed -n -e 's/^#define RHYOLITE_VERSION .\([.0-9]*\).*/s@RHYOLITE_VERSION@\1@g/p' ${DEPTH}/include/dcc_defs.h` $*.8 | groff -mtty-char -Tascii -mdoc > $@

.0.html:
	${DEPTH}/misc/dccman2html -m ${DEPTH}/misc/man2html -t $* -o $@

.html.txt:
	lynx -dump $*.html \
	    | sed -e 's/\[[0-9]*\]//g' -e '/^References/,$$d' \
		-e '/^ *CAPTION:/,/^ *MANGRP/d' \
		-e '/^ *[0-9]/{' -e h -e 's/.*//' -e G -e } > $@
@MAKE_DOT@endif
