# Makefile to generate man pages for python scripts

# Modify this to point at the installation
# directory of your choice, then run
# 'make install'
#mandir		= /usr/local/man
mandir		= /home/shared/NetLogger/man/man1
#mandir		= /opt/netlogger/man/man1

prog_path 	= ../../scripts
pypath    	= ../..
templates  	= $(wildcard *.man)
manpages   	= $(templates:.man=.1)
htmlpages   	= $(templates:.man=.html)
htmlstable	= /home/www/htdocs/NetLogger-releases/stable/doc/tools/
htmldev		= /home/www/htdocs/NetLogger-releases/dev/doc/tools/

default: manpages

manpages: $(manpages)

$(manpages): %.1: %.man
	PYTHONPATH=$(pypath) ./help2man.py $(prog_path)/`basename $< .man`

html: $(htmlpages)

style=<style media="screen" type="text/css">@import "style.css";</style>
$(htmlpages): %.html: %.1
#	groff -Thtml -man $< |
	n=`echo $@|cut -f1 -d'.'`;\
	hdr="<div class='header'><a href='http://dsd.lbl.gov/NetLoggerWiki/'><img src='../images/netlogger-logo-transparent.png' alt='NetLogger logo'/></a><h1>$$n</h1></div>" &&\
	rman -f HTML $< |\
		sed -e 'sX</head>X${style}</head>Xg'\
		    -e "sX<body\(.*\)>X<body\1>$${hdr}Xg"\
		>$@

install: $(manpages)
	mkdir -p $(mandir)
	cp *.1 $(mandir)

install-html-stable: html
	cp *.html $(htmlstable)

install-html-dev: html
	cp *.html $(htmldev)

clean:
	rm -f *~ *.html *.1
