#
# Makefile for TkMan
#
# Tom Phelps (phelps@cs.Berkeley.EDU)
#


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

WISH = /usr/sww/X11/bin/wish
LIBDIR = /home/yew/yew5/users/phelps/lib
BINDIR = /home/yew/yew5/users/phelps/bin
# # # IGNORE `INFODIR' until tkinfo support is announced
# INFODIR points to the texinfo files
INFODIR = /usr/sww/lib/emacs/info


# # # MACHINE DEPENDENCIES # # #

### if you're going to be looking at at least some man pages
### formatted on that OS, keep the define for it

MACHFLAGS = -DULTRIX -DSOLARIS

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



### if you have GNU gcc v2.x and gzcat, use these definitions
# if you have an HP you must use gzcat

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


### if you just have a standard UNIX, use these instead of GNU

#CC = cc
#CFLAGS = -O
#ZCAT = zcat


### these lines are probably fine

INSTALL = install
manprint = {psroff -man}
# alternatives
#manprint = {troff -man}
#manprint = {groff -man -l}

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.4
srcs = tkman.tcl bs2tk.c
objs = tkman bs2tk
libs = taputils.tcl
aux = README-tkman Makefile
bitmaps = 
distrib = $(srcs) $(libs) $(bitmaps) $(aux) contrib


all: tkman bs2tk

tkman: tkman.tcl taputils.tcl
	echo '#!$(WISH) -f' > tkman
	echo 'set manx(lib) $(LIBDIR)' >> tkman
	echo 'set manx(version) $(version)' >> tkman
	echo 'set man(zcat) $(ZCAT)' >> tkman
	echo 'set man(infodir) $(INFODIR)' >> tkman
	echo 'set man(format) $(manformat)' >> tkman
	echo 'set man(print) $(manprint)' >> tkman
	echo 'set man(mandir) $(mandir)' >> tkman
	# strip out comments
	egrep -v '^[ \t]*#' tkman.tcl >> tkman
	chmod +x tkman

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

debug: tkman
	echo '#!$(WISH) -f' > tkman.tmp
	echo 'set manx(debug) 1' >> tkman.tmp
	cat tkman >> tkman.tmp
	rm tkman
	mv tkman.tmp tkman
	chmod +x 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 taputils.tcl $(LIBDIR)
	$(INSTALL) -c tkman $(BINDIR)
	$(INSTALL) -s bs2tk $(BINDIR)

test: tkman bs2tk
	cp tkman $(BINDIR)
	cp taputils.tcl $(LIBDIR)
	install -s bs2tk $(BINDIR)/sparc
	tkman

clean:
	rm -f $(objs)

tar:
	rm -f tkman*.tar.[zZ]
	mkdir tkman-$(version)
	cp -R $(distrib) tkman-$(version)
	rm tkman-$(version)/contrib/*~
	gtar chvf tkman-$(version).tar tkman-$(version)
	compress tkman-$(version).tar
#	gzip -9v tkman-$(version).tar
	rm -rf tkman-$(version)
	@echo "*** Did you remember to ci -l first?"

uu: tar
	uuencode tkman-$(version).tar.Z tkman-$(version).tar.Z > tkman-$(version).tar.Z.uu
