#
# Makefile for TkMan
#   It's helpful to read the README file first.
#
# Tom Phelps (phelps@cs.Berkeley.EDU)
#


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

# Tk's wish MUST be compiled with Tcl 7.0/Tk 3.3
WISH = /usr/sww/X11/bin/wish
# the executable `tkman' is placed here
BINDIR = /home/yew/yew5/users/phelps/bin



# # # MACHINE DEPENDENCIES # # #

manformat = {tbl | neqn | nroff -man | col}
#  alternatively
#manformat = {groff -Tascii -te -man}
# Ultrix users should uncomment the following line
#manformat = {tbl | nroff -man | col}


# if you have GNU's zip, use it!
# Especially if you're working in a herterogeneous environment

ZCAT = gzcat
COMPRESS = gzip

# gzcat and gzip for work everyone.  If you don't have them try these:

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

#ZCAT = pcat
#COMPRESS = pack

# HP-UX needs these variations

#ZCAT = "zcat < "
#COMPRESS = compress

# if nothing else, use these

#ZCAT = zcat
#COMPRESS = compress



### if you have GNU gcc v2.x, use these definitions

CC = gcc
# if you don't have gcc v2.x, try -O for CFLAGS
CFLAGS = -O2 -finline-functions

### if you just have a standard UNIX, use these instead of GNU
### CC must be an ANSI C compiler

#CC = cc
#CFLAGS = -O


### these lines are probably fine

INSTALL = install
manprint = {psroff -man}
# alternatives
#manprint = {troff -man}
#manprint = {groff -man -l}
#manprint = {groff -Tascii -te}
# printing string for preformatted pages without [tn]roff source
catprint = lpr
#catprint = enscript

mandir = man
# if you have only formatted man pages, uncomment the following line
#mandir = cat
# if you have some formatted pages without unformatted counterparts,
# uncomment the following line
#mandir = {{man,cat}}



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

version = 1.5
tkman = tkman-$(version)
srcs = tkman.tcl bs2tk.c
objs = tkman bs2tk
libs = searchbox.tcl taputils.tcl
aux = README-tkman Makefile
bitmaps = 
distrib = $(srcs) $(libs) $(bitmaps) $(aux) contrib


all: tkman bs2tk

tkman: tkman.tcl $(libs) Makefile
	echo '#!$(WISH) -f' > tkman
	echo 'set manx(version) $(version)' >> tkman
	echo 'set man(zcat) $(ZCAT)' >> tkman
	echo 'set man(compress) $(COMPRESS)' >> tkman
	echo 'set man(format) $(manformat)' >> tkman
	echo 'set man(print) $(manprint)' >> tkman
	echo 'set man(catprint) $(catprint)' >> tkman
	echo 'set man(mandir) $(mandir)' >> tkman
	egrep -v '^[ \t]*#' searchbox.tcl >> tkman
	egrep -v '^[ \t]*#' taputils.tcl >> tkman
	egrep -v '^[ \t]*#' tkman.tcl >> tkman
	chmod +x tkman

bs2tk: bs2tk.c
	$(CC) $(CFLAGS) bs2tk.c -o bs2tk

debug: tkman
	$(CC) -g -Wall bs2tk.c -o bs2tk

profile: bs2tk.c
	# no TCL profiling (yet?)
	$(CC) -pg bs2tk.c -o bs2tk

install: tkman bs2tk
	$(INSTALL) -c tkman $(BINDIR)
	$(INSTALL) -s bs2tk $(BINDIR)

test: tkman bs2tk
	cp tkman $(BINDIR)
	install -s bs2tk $(BINDIR)/sparc
	tkman -debug

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

clean:
	rm -f $(objs)

tar:
	rm -rf $(tkman)*
	mkdir $(tkman)
	cp -R $(distrib) $(tkman)
	rm $(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
	rm -rf $(tkman)
	@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
