#========================================================================
# This is a Makefile for the wulf2html application, part of the
# overall wulfware package.  It has a very abbreviated set of targets.
#
# make          alone does nothing as a perl script requires no building
#
# make clean    does nothing (but exists)
# make install  installs application, config files, and a man page
# make printout prints out all source and include files
#
# These two commands execute in the toplevel project directory only.
# make svn      does a svn commit and creates the timestamp $(SVN)
# make sync     does a svn commit and rsyncs to list of hosts
#========================================================================
PROJECT = wulfware
PROGRAM = wulf2html
DIR = $(PROGRAM)
INITD = wulf2html_init.d
LOOPSCRIPT = wulf2html.sh
HTMLHEADER = cluster_header.html
WULFHOSTS = wulfhosts

#========================================================================
# This is essential.  The rpmbuild overrides it, but we have to make
# build "work" when executed only in the source tree directory itself.
# This isn't easy, since the dependences are more than a bit scattered.
# We therefore point to the directory one level up, where we should
# find a ./lib, ./include, ./share and ./bin directory tree from which
# the various dieharder files will actually be assembled into an rpm
# with PREFIX=/usr (for example).
#========================================================================
BUILDROOT=../buildroot
PREFIX=$(BUILDROOT)/usr
ETCDIR=$(BUILDROOT)/etc

SVNTREE = $(HOME)/Src/svn-tree
SVNPATH = $(SVNTREE)/$(PROJECT)
SVNTIME = $(DIR:=.svn.time)

# This is automagically set in the toplevel build.  Do not edit by
# hand.
VERSION_MAJOR=2
VERSION_MINOR=5.0
RELEASE=1

#========================================================================
# List of variants one can make.  all is the default.  We always
# presume the simplest of dependencies and remake if includes change
# for example.
#========================================================================
all:
	echo "Make all does nothing"

#========================================================================
# The only safe place to do commits is in the toplevel directory
#========================================================================
svn:
	(cd ..;make svn)

sync:
	(cd ..;make sync)

#========================================================================
# printout makes an enscript -2r printout of SOURCES and
# and INCFILES.  Use lpr if you don't have enscript
#========================================================================
LPR = enscript -2r
# LPR = lpr
printout:
	$(LPR) $(PROGRAM) $(CONFIG) $(WULFHOSTS)

#========================================================================
#  A standard cleanup target
#========================================================================
clean:
	echo "Clean does nothing"

#========================================================================
# Application installation.
#========================================================================
install :  $(PROGRAM) $(LOOPSCRIPT) $(WULFHOSTS) $(HTMLHEADER)
	(install -d $(PREFIX)/bin; \
	install -m 755 $(PROGRAM) $(PREFIX)/bin; \
	install -d $(ETCDIR); \
	install -d $(ETCDIR)/init.d; \
	install -m 644 $(INITD) $(ETCDIR)/init.d/wulf2html; \
	install -d $(ETCDIR)/wulfware; \
	install -m 644 $(LOOPSCRIPT) $(ETCDIR)/wulfware/; \
	install -m 644 $(WULFHOSTS) $(ETCDIR)/wulfware/; \
	install -m 644 $(HTMLHEADER) $(ETCDIR)/wulfware/; \
	install -d $(PREFIX)/share/man/man1; \
	gzip -c $(PROGRAM).1 > $(PROGRAM).1.gz; \
	install -m 644 $(PROGRAM).1.gz $(PREFIX)/share/man/man1; \
	)

