#
# Makefile for TkMan
#    Tom Phelps (phelps@ACM.org)
#
# You also need the companion filter RosettaMan, available from:
#    ftp://ftp.cs.berkeley.edu/ucb/people/phelps/tcltk/rman.tar.Z
#
#   It's helpful to read the README file first.
#   You should read over *all* parts of this file,
#      down to the "you shouldn't modify" line.
#   TkMan has been built successfully by many people
#      on many different flavors of UNIX, including these:
#      SunOS, Sun Solaris, Hewlett-Packard HP-UX, AT&T System V, 
#      OSF/1, DEC Ultrix, SGI IRIX, Linux, SCO, IBM AIX, FreeBSD, BSDI.
#      Before you report a problem in getting TkMan installed 
#      on your machine, double check that you haven't
#      overlooked something important in this Makefile.
#      and check the home site (same as RosettaMan's above) to make
#      sure you're working with the latest version.
#   If you make tkman (`tkman'--all lowercase--refers to the 
#      executable) and subsequently find you need to change variables 
#      in the Makefile, make sure that these changes aren't being 
#      overridden in ~/.tkman.
#   Don't forget the interesting extensions in the contrib directory.
#

# SYSTEM-SPECIFIC NOTES
#
# SGI IRIX/System V, SCO UNIX and Solaris users should check the
#    contrib directory for system-specific configuration files.
# IBM AIX'ers should convert InfoExplorer format man pages to
#    the standard /usr/man/cat* format as described in
#    section 7 of the document /usr/lpp/bos/bsdadm
#    or in the FAQ for the comp.unix.aix newsgroup.
# BSDI users should replace makewhatis with some freely available
#    version of mkwhatis--one that puts whatis files in the right place,
#    though this isn't essential (don't ask me where to find such
#    a mkwhatis; check archie for freely available man page tool suites)


# minimum versions of Tcl and Tk, for your information (don't modify these values)
mintcl = 7.5
mintk = 4.1



### you need to localize the paths on these lines

WISH = /usr/sww/tcl-7.5/bin/wish
#WISH = /home/orodruin/h/bair/phelps/bin/sun4/wish4.2
#WISH = /usr/local/bin/wish


# the executable `tkman' is placed in BINDIR
# this should be a directory that's in your bin PATH
BINDIR = /home/orodruin/h/bair/phelps/bin
#BINDIR = /usr/local/bin

# directory in which to place the manual page.  The help information
# is maintained in HTML, from which the [tn]roff version is 
# automatically generated.
MANDIR = /home/orodruin/h/bair/phelps/man/man1
#MANDIR = /usr/sww/X11/man/man1
#MANDIR = /usr/local/man/man1


# list of common printers, in addition to default printer (PRINTER or LPDEST)
# (individual users can edit this list in the Preferences panel)
#printers = "lws483a kp"
printers = ""



# # # MACHINE DEPENDENCIES # # #

manformat = {tbl | neqn | nroff -man }
# col performs the line overlays implied by reverse line-feeds,
# but seems to kill international characters, such as u-with-umlaut
#manformat = {tbl | neqn | nroff -man | col }
# alternatives
#manformat = {groff -Tascii -te -mandoc}
# Ultrix users should uncomment the following line
#manformat = {tbl | nroff -man }
# for BSDI
#manformat = {tbl | eqn -Tascii | nroff -man }

# almost always, name of section starts at index three (zero-based), in form "man<name>"
dirnameindex = 3
# apparently SCO names it man directories "man.<name>"
#dirnameindex = 4


# if you have GNU's zip, use it!
# Especially if you're working in a herterogeneous environment
# (give gzip -q option because we don't want a GZIP environment variable
#  with -v spitting out non-error statistics to stderr)

zcat = "gzip -dcfq"
compress = "gzip -q"
zlist = {gz z Z}

# gzip works everywhere and produces the smallest compressed files.
# If you don't have it try these:

# SGI users can use pcat instead of gzcat (though gzcat works great)

#zcat = pcat
#compress = "pack -f"
#zlist = z

# HP-UX needs these variations, if gzip isn't available

#zcat = "zcat < "
#compress = compress
#zlist = Z


# if nothing else, use these

#zcat = zcat
#compress = compress
#zlist = Z


shortnames = 0
# if you have an old UNIX with short file names
#shortnames = 1


# pick a printing pipeline for which your platform has all the constituants
manprint = {groff -man -Tps -te -l}
# alternatives
#manprint = {tbl | eqn | troff -man -t | lpr -t}
#manprint = {tbl | eqn | psroff -man}
#manprint = {groff -man -Tascii -te -l}
#manprint = {tbl | eqn | gtroff -Tpsc | psdit | lpr}
# printing string for preformatted pages without [tn]roff source
catprint = lpr
#catprint = "lpr -h"
#catprint = enscript



# # # GLIMPSE # # # 

# OPTIONALLY add full text search of manual pages with Glimpse.
# For more information about Glimpse see http://glimpse.cs.arizona.edu:1994/
# or ftp the glimpse software from cs.arizona.edu:/glimpse
# Glimpse uses indexes of only "2-5%" of the size of the original text,
# indexes that are shared just like the man pages they index,
# and TkMan automates the process of creating the index files,
# so how can you lose?

# BY DEFAULT ON
#glimpse = glimpse
# if your man pages are compressed, as on HP-UX, you can speed searching 
# by examining the glimpse index only, at the expense of less accurate 
# searching (more false positives, but all potential matches are reported)
# (Even if your pages aren't compressed, this speeds up searching dramatically,
# which is why it's the default.)
# If you choose this option, also set glimpseindex to use -o or -b.
glimpse = "glimpse -N"
# IF YOU DON'T WANT TO BOTHER WITH GLIMPSE, you can disable it here
# ALSO DISABLE GLIMPSEINDEX BELOW
#glimpse = ""
# if you have any compressed pages (and aren't using -N), use the -z option
#glimpse = "glimpse -z"
# give the full path, if you'd like
#glimpse = /usr/sww/bin/glimpse
# variations (refer to the Glimpse manual page)
#glimpse = "glimpse -k"
#glimpse = "glimpse -B"

# glimpseindex indexes the manual pages, for each component of one's MANPATH,
# and places the results in a set of files named .glimpse_* in that MANPATH
# component directory.
#
# To create the necessary indexes, simply start up TkMan and
# choose `Rebuild Glimpse Database' under the `Occasionals' menu, assuming
# you have the necessary permissions.  If you don't, someone who does have 
# permission needs to make these indexes, after which they can be shared
# by those with only read-only permission.  Alternatively, choose a unified
# index from Preferences/Misc and place it in a writable directory.
#
# Refer to the Glimpse manual page for more information.
# Before reporting a problem with indexing under TkMan, turn on debugging
# (`-debug' option), obtain the problemmatic glimpseindex command,
# and make sure it works when executed by hand.

#glimpseindex = glimpseindex
# produce a larger index ("7-9%" of source text) allowing faster search w/"-o"
# Need -o or -b if using -N above.
glimpseindex = "glimpseindex -o -B"
# IF YOU DON'T WANT TO BOTHER WITH GLIMPSE, DISABLE IT HERE *ALSO*
#glimpseindex = ""
#glimpseindex = /usr/sww/bin/glimpseindex

# directory in which to place stray man directories added with manDescAdd
# that don't correspond to a directory in MANPATH
# This can't be the same as a component in MANPATH.
glimpsestrays = /tmp
#glimpsestrays = $$env(HOME)/tmp
#glimpsestrays = /private



# # # PUBLIC INSTALLATION # # #

# default MANPATH to use if user doesn't have a MANPATH environment variable set.
# Leave this empty to have TkMan calculate a MANPATH based on a users PATH
# (like Perl man does).
manpathdef = ""
#manpathdef = /usr/man:/usr/local/man
#manpathdef = /usr/man:/usr/local/man:/usr/sww/man:/usr/sww/X11/man
# for SGI
#manpathdef = /usr/share/catman:/usr/share/man:/usr/catman:/usr/man


database = $$env(HOME)/.tkmandatabase
# if you want everyone to share a common set of manual pages
# and a common organization of them (as described with tkmandesc
# commands), you can point everyone to a common default database
# (someone, but only one, needs to build it and maintain it--
# this can be the database of the system administrator, for instance)
# A user can subsequently override a global database:
# temporarily with the -database option, or permanently by changing
# his man(database) variable in his ~/.tkman file.
#database = /usr/local/man/.tkmandatabase
#database = ~sysadmin/.tkmandatabase

# If a new user--as indicated by the lack of a ~/.tkman file--runs TkMan,
# you can execute some Tcl code of your own design to customized his 
# environment for the local site.
newuser = ""
#newuser = "exec cp /usr/local/lib/tkman-new.tcl $$env(HOME)/.tkman"
#newuser = "source /usr/local/lib/tkman-new.tcl"



# # # these lines are probably fine

# egrep must understand extended regular expressions
# (in which parentheses are meta characters)
egrep = egrep
sed = sed
#sed = gsed
cp = cp
mv = mv
rm = rm
mkdir = mkdir
chmod = chmod
sort = sort
uniq = uniq


# if you don't want to put RosettaMan (rman) in your PATH, make the name fully qualified
# (that's probably a good idea if `tkman' is installed on a central server)
# RosettaMan is available from ftp://ftp.cs.berkeley.edu/ucb/people/phelps/tcltk/rman.tar.Z
rman = rman
#rman = /home/orodruin/h/bair/phelps/bin/sun4/rman

apropos = {man -k}
# Linux uses a shell script instead:
#apropos = apropos

catsig = {cat[^/]+(/[^/]+)?$$}
# if your flavor of UNIX puts formatted man pages in directories
# ending in manX rather than catX, uncomment the following line
#catsig = {.*}

# list of valid font dpi values
dpis = {* 75 100}
# if the above doesn't work and you're not sure what dpi(s) you have, use "*"
#dpis = *


#
# variables used in this Makefile only and not propagated to executable
#

CP = cp
# or you can use GNU's cp and backup files that are about to be overwritten
#CP = cp -b


#--------------------------------------------------
#
# you shouldn't modify anything below here
#
#--------------------------------------------------

version = 1.8
tkman = tkman-$(version)
srcs = tkman.tcl
objs = tkman
libs = searchbox.tcl taputils.tcl
aux = ANNOUNCE-tkman README-tkman Makefile Copyright scripthead
bitmaps = face.xbm
help = tkman-help.html tkman-help.tcl tkman.1 CHANGES
distrib = $(srcs) $(libs) $(bitmaps) $(aux) contrib $(help)

all: tkman
	@echo
	@echo 'TkMan is compiled in the current directory.'
	@echo 'You can test it by typing "./tkman".'
	@echo 'To install it and the man page, type "make install".'
	@echo


tkman: $(srcs) $(libs) Makefile
	cat scripthead > tkman
	echo 'exec $(WISH) $$0 $${1+"$$@"}' >> tkman
	echo 'set manx(version) $(version)' >> tkman
	echo 'set manx(mintcl) $(mintcl)' >> tkman
	echo 'set manx(mintk) $(mintk)' >> tkman
	echo 'set manx(newuser) $(newuser)' >> tkman
	echo 'set manx(dirnameindex) $(dirnameindex)' >> tkman
	echo 'set man(zcat) $(zcat)' >> tkman
	echo 'set man(compress) $(compress)' >> tkman
	echo 'set man(apropos) $(apropos)' >> tkman
	echo 'set man(glimpse) $(glimpse)' >> tkman
	echo 'set man(glimpseindex) $(glimpseindex)' >> tkman
	echo 'set man(glimpsestrays) $(glimpsestrays)' >> tkman
	echo 'set man(format) $(manformat)' >> tkman
	echo 'set manx(manpathdef) $(manpathdef)' >> tkman
	echo 'set man(printers) $(printers)' >> tkman
	echo 'set man(print) $(manprint)' >> tkman
	echo 'set man(zlist) $(zlist)' >> tkman
	echo 'set man(egrep) $(egrep)' >> tkman
	echo 'set man(sed) $(sed)' >> tkman
	echo 'set man(rm) $(rm)' >> tkman
	echo 'set man(chmod) $(chmod)' >> tkman
	echo 'set man(mkdir) $(mkdir)' >> tkman
	echo 'set man(sort) $(sort)' >> tkman
	echo 'set man(uniq) $(uniq)' >> tkman
	echo 'set man(database) $(database)' >> tkman
	echo 'set man(mv) $(mv)' >> tkman
	echo 'set man(cp) $(cp)' >> tkman
	echo 'set manx(rman) $(rman)' >> tkman
	echo 'set man(catprint) $(catprint)' >> tkman
	echo 'set man(catsig) $(catsig)' >> tkman
	echo 'set man(shortnames) $(shortnames)' >> tkman
	echo 'set man(dpis) $(dpis)' >> tkman
	echo 'set manx(changes) {' >> tkman
	cat CHANGES >> tkman
	echo '}' >> tkman
	echo 'proc manHelpDump {t} {' >> tkman
	cat tkman-help.tcl >> tkman
	echo '}' >> tkman
	echo 'image create bitmap icon -data {' >> tkman
	cat contrib/tkman.bitmap >> tkman
	echo '}' >> tkman
	echo 'image create bitmap face -data {' >> tkman
	cat face.xbm >> tkman
	echo '}' >> tkman
	echo 'set manx(solaris-bindings) {' >> tkman
	cat contrib/solaris_bindings.tcl >> tkman
	echo '}' >> tkman
	echo 'set manx(irix-bindings) {' >> tkman
	cat contrib/irix_bindings.tcl >> tkman
	echo '}' >> tkman
	echo 'set manx(sco-bindings) {' >> tkman
	cat contrib/sco_bindings.tcl >> tkman
	echo '}' >> tkman
	sed -e 's/^[	 ]*//' -e '/^#/d' taputils.tcl searchbox.tcl tkman.tcl >> tkman
	chmod +x tkman

install: tkman
	$(CP) tkman $(BINDIR)
	chmod +rx $(BINDIR)/tkman
	$(CP) tkman.1 $(MANDIR)
	@echo 'You also need RosettaMan to run TkMan.'

test: dox tkman
	cp tkman $(BINDIR)
	tkman -noiconify -debug

sww:
	rm -f tkman $(wildcard ~/bin/tkman)
	tkman

dox: tkman-help.tcl tkman.1 CHANGES ANNOUNCE-tkman

ANNOUNCE-tkman: Announce-tkman
	sed -e /=========/,/bogusline/p -e d Announce-tkman > ANNOUNCE-tkman

tkman-help.tcl: tkman-help.html
	cat ../html/html.dtd tkman-help.html | sgmls | ../html/html2tk.pl > tkman-help.tcl

tkman.1: tkman-help.html
	echo '.TH TkMan 1' > tkman.1
	echo '.SH NAME' >> tkman.1
	echo 'TkMan, tkman \- a graphical manual page browser, with hypertext' >> tkman.1
	cat ../html/html.dtd tkman-help.html | sgmls | ../html/html2man.pl >> tkman.1

clean:
	rm -f $(objs)

tar: dox
	rm -rf $(tkman)*
	mkdir $(tkman)
	cp -R $(distrib) $(tkman)
	rm -f $(tkman)/contrib/*~
	@echo 'gcksum crc   length name' > MANIFEST
	@echo '----------   ------ ----' >> MANIFEST
	@gcksum $(filter-out contrib, $(filter-out %~, $(distrib) $(wildcard contrib/*))) | gtee -a MANIFEST
	mv MANIFEST $(tkman)
	gtar chvf $(tkman).tar $(tkman)
	compress $(tkman).tar
#	gzip -9v $(tkman).tar
	ls -l $(tkman).tar.Z
	rm -rf $(tkman) ANNOUNCE-tkman tkman.1
	@echo "*** Did you remember to ci -l first?"

uu: tar
	gznew $(tkman).tar.Z
	echo 'uudecode, gunzip (from GNU), untar' > $(tkman).tar.gz.uu
	uuencode $(tkman).tar.gz $(tkman).tar.gz >> $(tkman).tar.gz.uu
