###########################################################################
# LPRngTool - An Configuration Tool For
#      LPRng - An Extended Print Spooler System
#
# See LICENSE for conditions of use.
#
###########################################################################
# MODULE: Makefile.in
# PURPOSE: top level Makefile for LPRngTool Software
##########################################################################



####### General configure settings

VERSION=1.3.2
PACKAGE=LPRngTool


OSNAME=gnu
OSVERSION=801

INSTALL=/usr/bin/install -c -o root -g wheel
INSTALL_MAN=

SHELL=/bin/sh
GROUPID=@GROUPID@
USERID=@USERID@

WISH=/usr/local/bin/wish8.3

SRC=.
# prefix
prefix=
# exec prefix
exec_prefix=${prefix}
# for binaries
bindir=${exec_prefix}/bin
# for admin type of binaries
sbindir=${exec_prefix}/sbin
# for the ghostscrip tools
datadir=${prefix}/share
# for the filters
libexecdir=${exec_prefix}/libexec
# for the configuration stuff
sysconfdir=${prefix}/etc
# for the man pages
mandir=${prefix}/man


FILTER_DIR=${libexecdir}/filters
SPOOL_DIR=/var/spool/lpd
IFHP_PATH=${FILTER_DIR}/ifhp
IFHP_CONF=${sysconfdir}/ifhp.conf
PRINTCAP_PATH=${sysconfdir}/printcap
FILEUTIL=/usr/local/bin/file
GZIP=/usr/local/bin/gzip
GS=/usr/local/bin/gs
A2PS=/usr/local/bin/a2ps
MPAGE=/usr/local/bin/mpage
SMBCLIENT=/usr/local/bin/smbclient
LPRNGTOOL_CONF=${sysconfdir}/lprngtool.conf
GSUPDIR=@GSUPDIR@
PAGER=/usr/local/bin/a2ps
NPRINT=NPRINT_NOT_FOUND
PAP=PAP_NOT_FOUND


# what C compiler to use.
CC:=cc
# what command to use to "ranlib" or "lorder" the library.
RANLIB=@RANLIB@

# what C preprocessor to use.
CPP:=cc -E
CPPFLAGS=

CFLAGS:=-fno-common -I. -I${SRC}/src

LDCC=
LDFLAGS=



###  END OF CONFIGURE EDITS ###

SCRIPTS= postinstall.bsdi postinstall.freebsd postinstall.generic postinstall.linux postinstall.solaris
PROGS=lprngtool lprngtool.conf
FILTERS= atalkprint ncpprint smbprint
FILTERDATA = printerdb testpage.asc testpage.ps testpage-a4.ps

all: $(PROGS) $(FILTERS) $(FILTERDATA) ./postinstall
.PHONEY: all clean configure dist distclean install send tar update

$(SCRIPTS): header
	cat header ${SRC}/$@.sh >$@
	chmod 755 $@;

header: Makefile
	@echo "#!/bin/sh" >$@
	@echo PREFIX=$(prefix) >>$@
	@echo SYSCONFDIR=$(sysconfdir) >>$@
	@echo LPRNGTOOL_CONF=$(LPRNGTOOL_CONF) >>$@
	@echo MANDIR=$(mandir) >>$@
	@echo "VERSION=$(VERSION)" >>$@

# we set up the postinstall to be used
./postinstall: $(SCRIPTS) Makefile
	OSNAME=gnu; case "gnu" in \
	 *linux* ) OSNAME=linux;; \
	 *freebsd* ) OSNAME=freebsd;; \
	 *solaris* ) OSNAME=solaris;; \
	esac; \
	if test -f postinstall.$${OSNAME} ; then s=postinstall.$${OSNAME} ; else s=postinstall.generic; fi; \
	echo POSTINSTALL "'$$s'"; cp $$s postinstall;


.SUFFIXES: .script

lprngtool: lprngtool.script Makefile
lprngtool.conf: lprngtool.conf.script Makefile

.script:
	sed  \
	-e 's,[@]GROUPID@,${GROUPID},g' \
	-e 's,[@]PRINTCAP_PATH@,${PRINTCAP_PATH},g' \
	-e 's,[@]FILTER_DIR@,${FILTER_DIR},g' \
	-e 's,[@]SPOOL_DIR@,${SPOOL_DIR},g' \
	-e 's,[@]USERID@,${USERID},g' \
	-e 's,[@]VERSION@,${VERSION},g' \
	-e 's,[@]WISH@,${WISH},g' \
	-e 's,[@]PACKAGE@,${PACKAGE},g' \
	-e 's,[@]VERSION@,${VERSION},g' \
	-e 's,[@]FILEUTIL@,${FILEUTIL},g' \
	-e 's,[@]GS@,${GS},g' \
	-e 's,[@]GZIP@,${GZIP},g' \
	-e 's,[@]A2PS@,${A2PS},g' \
	-e 's,[@]MPAGE@,${MPAGE},g' \
	-e 's,[@]SMBCLIENT@,${SMBCLIENT},g' \
	-e 's,[@]IFHP_PATH@,${IFHP_PATH},g' \
	-e 's,[@]IFHP_CONF@,${IFHP_CONF},g' \
	-e 's,[@]LPRNGTOOL_CONF@,${LPRNGTOOL_CONF},g' \
	-e 's,[@]GSUPDIR@,${GSUPDIR},g' \
	-e 's,[@]PAGER@,${PAGER},g' \
	-e 's,[@]NPRINT@,${NPRINT},g' \
	-e 's,[@]PAP@,${PAP},g' \
	$< >$@.edit
	if grep '#!.*sh' $@.edit >/dev/null ; then \
		chmod 755 $@.edit; \
	fi
	mv $@.edit $@

testpage.ps:
	fig2dev -Lps -zLetter testpage.fig testpage.ps

testpage-a4.ps:
	fig2dev -Lps -zA4 testpage-a4.fig testpage-a4.ps

install: all
	${SRC}/mkinstalldirs ${DESTDIR}${bindir}
	${SRC}/mkinstalldirs ${DESTDIR}${mandir}/man1
	${SRC}/mkinstalldirs ${DESTDIR}$(FILTER_DIR)

	# install lprngtool in ${DESTDIR}${bindir}
	${INSTALL} -c -m 755 lprngtool ${DESTDIR}${bindir}/lprngtool
	${INSTALL} -c -m 644 lprngtool.1 ${DESTDIR}${mandir}/man1/lprngtool.1
	if [ "${POSTINSTALL}" != "NO" ] ; then \
		MAKEINSTALL=YES DESTDIR=$(DESTDIR) $(SHELL) postinstall ; \
	fi;

# should only really copy MINIMUM filters, rest should come from RPMs
	for i in $(FILTERS) ; do \
		${INSTALL} -m 755 $$i ${DESTDIR}$(FILTER_DIR); \
	done

	for i in $(FILTERDATA) ; do \
		${INSTALL} -m 644 $$i ${DESTDIR}$(FILTER_DIR); \
	done


clean:
	rm -f $(PROGS) *.a *.o core errs a.out rewindstdin *.E \#* TAGS errors *~
	rm -f $(SCRIPTS) postinstall ltconfig header lprngtool lprngtool.conf *.edit

distclean: clean
	rm -f config.cache config.h config.log config.status Makefile
	rm -f DISTRIBUTIONS/FreeBSD*/work DISTRIBUTIONS/FreeBSD*/*.tgz ;

configure: configure.in
	autoconf
	autoheader

# use this to make a distribution
tar: distclean configure
	DIR=`pwd | sed 's,.*/,,'`; \
		echo RCS >X; \
		echo X >>X; \
		cd ..; \
		tar zXcf $${DIR}/X $${DIR}.tgz $${DIR}; \
		rm -f $${DIR}/X; \
		md5 $${DIR}.tgz | pgp -fast -u papowell@lprng > $${DIR}.tgz.md5

UPDATE=README configure.in lprngtool.conf.script lprngtool.script \
	DISTRIBUTIONS/*/Makefile DISTRIBUTIONS/*/*.spec

# use this to update the version numbers in files
update:
	if [ -f Makefile ] ; then ci -l Makefile; fi
	DIR=`pwd | sed 's,.*/,,'`; \
	DATE=`date`; VER=`pwd | sed -e 's,.*/,,' -e s/.*-// ` ; echo $${VER} $${DATE}; \
	echo $${DIR} >VERSION; \
	perl -spi -e "\
		s,^DISTNAME=.*,DISTNAME=$${DIR},; \
		s,^PORTNAME=.*,PORTNAME=$(PACKAGE),; \
		s,^PORTVERSION=.*,PORTVERSION=$${VER},; \
		s,package name \".*\",package name \"$${DIR}\",; \
	 if( /^VERSION[:=]/ ){ s/([:=]).*/\$${1}$${VER}/ }  \
	 if( /\s*#*\s*Version\s*[:=]/ ){ s/([:=]).*/\$${1} $${VER}/ }  \
	 if( /\s*#*\s*Last Modified\s*[:=]/ ){ s/([:=]).*/\$${1} $${DATE}/ } \
	" ${UPDATE}

dist: update tar send

send:
	if [ -f ../SENDTO ] ; then cd ..; sh SENDTO ; fi



syntax highlighted by Code2HTML, v. 0.9.1