# Makefile for wilt

# This file is part of wilt.

# wilt is copyright (c) 1998 by W. L. Estes <wlestes@uncg.edu>

# wilt is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# wilt is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with wilt; see the file COPYING.  If not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

# These variables are for users

prefix=/usr/local
bindir=$(prefix)/bin
mandir=$(prefix)/man
man1dir=$(mandir)/man1

# User configurable variables end here. You should not need to
# alter anything beyond this point.

progname = wilt
version = $(shell sed -n '/version/s/^.* //p' version.texi)
progversion = $(progname)-$(version)
texifiles = README INSTALL
progfiles = $(progname)
manfiles = $(progname).1
miscfiles = COPYING Makefile TODO $(progname).lsm version.texi
specfiles = $(progname).spec $(progversion).spec
distfiles = $(progfiles) $(texifiles) $(manfiles) $(miscfiles) $(specfiles)
maintainerfiles = $(texifiles:%=%.texi)

all: spec

$(texifiles): %:%.texi
	makeinfo --no-split --no-headers --output=$@ $<

install: all
	mkdir -p $(bindir) $(man1dir)
	install -m 555 wilt $(bindir)
	install -m 444 wilt.1 $(man1dir)

clean:
	rm -f *~ \#*

distclean: clean
	rm -f $(texifiles) $(progversion).tar.gz
	rm -rf $(progversion)

mdist: $(maintainerfiles)

mdist dist: all $(distfiles)
	rm -rf $(progversion)
	install -d $(progversion)
	cp -p $(distfiles) \
	`if [ $@ = mdist ] ; then echo $(maintainerfiles) ; fi` \
	$(progversion)
	if [ $@ = dist ] ; then sed 's/@version@/$(version)/' $(progname) \
	> $(progversion)/$(progname) ; fi
	tar zcf $(progversion).tar.gz $(progversion)

spec: $(progname.spec)
	sed 's/@version@/$(version)/' $(progname).spec > $(progversion).spec
