###########################################################################
# LPRng - An Extended Print Spooler System
#
# Copyright 1988-1997 Patrick Powell, San Diego, California
#     papowell@sdsu.edu
# See LICENSE for conditions of use.
#
###########################################################################
# MODULE: UTILS/Makefile
# PURPOSE: generate utilities
# Makefile.in,v 3.7 1998/03/30 01:54:50 papowell Exp
########################################################################## 

# Manual pages installation Makefile.
#
SRC = @srcdir@
VPATH=${SRC}
INSTALL=@INSTALL@

# change MANEXT to .gz or .Z if you use compressed manpages.
MANEXT =

## fix up prefix to be a make variable
prefix = @prefix@
MAN =		@mandir@
SHELL =		@SHELL@

# Install man pages in compressed form.
# COMPRESS     = compression utility
# COMPRESS_DIR = man compressed directory
# COMPRESS_EXT = man extension for compressed files
COMPRESS_DIR=
COMPRESS_EXT=.gz
COMPRESS=gzip -c

PAGES= cancel.1 checkpc.8 lp.1 lpbanner.1 lpc.8 lpd.8 lpd.conf.5 \
	 lpd.perms.5 lpf.1 lpq.1 lpr.1 lprm.1 lpstat.1 monitor.1 pclbanner.1 \
	 printcap.5 psbanner.1 lprng_certs.1 lprng_index_certs.1
RAW= cancel.n checkpc.n lp.n lpbanner.n lpc.n lpd.n lpd.conf.n \
	 lpd.perms.n lpf.n lpq.n lpr.n lprm.n lpstat.n monitor.n pclbanner.n \
	 printcap.n psbanner.n  lprng_certs.n lprng_index_certs.n


# prefix
prefix=@prefix@
# exec prefix
exec_prefix=@exec_prefix@
# for binaries
bindir=@bindir@
# for admin type of binaries
sbindir=@sbindir@
# for the filters
libexecdir=@libexecdir@
# for the configuration stuff
sysconfdir=@sysconfdir@
# for the man pages
mandir=@mandir@
# top build directory
top_builddir=..

LPD_PERMS_PATH=@LPD_PERMS_PATH@
LPD_CONF_PATH=@LPD_CONF_PATH@
PRINTCAP_PATH=@PRINTCAP_PATH@
LPD_PATH=@LPD_DIR@/lpd
LOCKFILE=@LOCKFILE@
SSL_CA_FILE=@SSL_CA_FILE@
SSL_CA_KEY=@SSL_CA_KEY@
SSL_CERTS_DIR=@SSL_CERTS_DIR@
SSL_SERVER_CERT=@SSL_SERVER_CERT@
SSL_SERVER_PASSWORD=@SSL_SERVER_PASSWORD@

all: ${PAGES}

${PAGES}: ${RAW} Makefile
	for i in ${PAGES} ; do \
		v=`expr "$$i" : "\(.*\).[0-9]"` ; \
		echo ${SRC}/$$i; \
		rm -f $$i; \
		sed \
		 -e "s!_PRINTCAP_PATH_!${PRINTCAP_PATH}!" \
		 -e "s!_LPD_PERMS_PATH_!${LPD_PERMS_PATH}!" \
		 -e "s!_LPD_CONF_PATH_!${LPD_CONF_PATH}!" \
		 -e "s!_LOCKFILE_!${LOCKFILE}!" \
		 -e "s!_SSL_CA_FILE_!${SSL_CA_FILE}!" \
		 -e "s!_SSL_CA_KEY_!${SSL_CA_KEY}!" \
		 -e "s!_SSL_CERTS_DIR_!${SSL_CERTS_DIR}!" \
		 -e "s!_SSL_SERVER_CERT_!${SSL_SERVER_CERT}!" \
		 -e "s!_SSL_SERVER_PASSWORD_!${SSL_SERVER_PASSWORD}!" \
		${SRC}/$$v.n > $$i; \
	done



.PHONY: all clean install ci install.zman

CI=
CO=-kv
update:
	- for i in *.[0-9]; do \
		rcs -l ./$$i; \
		ci $(CI) -l -mUpdate -t-Initial ./$$i; \
	done;

	- VER=`cat ${SRC}/../VERSION`; \
	  for i in *.[0-9]; do \
		sed -e "s/^.ds VE.*/.ds VE $$VER/" ./$$i >/tmp/$$i; \
		cp /tmp/$$i ./$$i; \
	done;

	- for i in *.[0-9]; do \
		ci $(CI) -mUpdate -t-Initial ./$$i; \
		yes | co $(CO) ./$$i; \
	done

# Standard man install target.
#
install:
	for suffix in 1 2 3 4 5 6 7 8 ; do \
	  if ls *.$${suffix} >/dev/null 2>&1 ; then \
	    if [ ! -d $(DESTDIR)$(MAN)/man$${suffix} ] ; then \
		    echo ${SRC}/mkinstalldirs $(DESTDIR)$(MAN)/man$${suffix}; \
		    ${SRC}/mkinstalldirs $(DESTDIR)$(MAN)/man$${suffix}; \
	    fi; \
	    for i in *.$$suffix; do \
		echo   $(INSTALL) -m 644 $$i $(DESTDIR)$(MAN)/man$$suffix/`basename $$i`$(MANEXT); \
		$(INSTALL)   -m 644 $$i $(DESTDIR)$(MAN)/man$$suffix/`basename $$i`$(MANEXT); \
	    done; \
	  fi; \
	done;

uninstall:
	for suffix in 1 2 3 4 5 6 7 8 ; do \
	  if ls *.$${suffix} >/dev/null 2>&1 ; then \
	    for i in *.$$suffix; do \
		echo   rm $(DESTDIR)$(MAN)/man$$suffix/`basename $$i`$(MANEXT); \
		rm   $(DESTDIR)$(MAN)/man$$suffix/`basename $$i`$(MANEXT); \
	    done; \
	  fi; \
	done;
	
realclean mostlyclean distclean:: clean

clean::
	rm -f *.[0-9] ?

TAGS info:

cifast ci:
	if test ! -d RCS ; then mkdir RCS; fi;
	checkin() { \
		(set +e; rcs -l $$1; exit 0); \
		ci $(CI) -l -u -f -mUpdate -t-Initial $$1; \
	}; \
	for i in *.n Makefile.in Makefile; do \
		checkin $$i; \
	done;
