# ------------------------------------------------------------------------
# 	Makefile for manual page files 
# ------------------------------------------------------------------------

prefix  	= @prefix@
mandir  	= @mandir@
sectiondir 	= $(mandir)/mann
srcdir		= @srcdir@
version		= @BLT_VERSION@

instdirs	= $(mandir) $(sectiondir)

MANPAGES	 = BLT.n barchart.n beep.n bgexec.n bitmap.n \
		   bltdebug.n busy.n cutbuffer.n dragdrop.n eps.n \
		   graph.n hierbox.n hiertable.n htext.n spline.n \
		   stripchart.n table.n tabset.n tile.n vector.n \
		   watch.n winop.n

INSTALL  	= @INSTALL@
INSTALL_DATA  	= @INSTALL_DATA@
SHELL    	= /bin/sh
RM		= rm -rf
VPATH		= $(srcdir)

all: man.macros $(MANPAGES)

install: install-dirs install-manuals

install-manuals: $(MANPAGES)
	for i in *.n ; do \
		$(INSTALL_DATA) $$i $(sectiondir); \
	done

install-dirs:
	@for i in $(instdirs) ; do \
	    if test ! -d $$i ; then \
		mkdir $$i ; \
	    fi ; \
	done

.SUFFIXES: .n .man

.man.n: man.macros
	$(RM) $@
	sed -e "/man\.macros/r man.macros" -e '/man\.macros/d' $< > $@

man.macros: man.macros.in
	$(RM) man.macros
	sed -e 's/BLT_VERSION/$(version)/' \
		$(srcdir)/man.macros.in > man.macros		

clean:
	$(RM) man.macros $(MANPAGES)

distclean: clean
	$(RM) $(srcdir)/*.bak $(srcdir)/*\~ $(srcdir)/"#"* Makefile

