# -*- Makefile -*-
#
# This is a make+ file. Make+ is a set of scripts which enhance GNU
# make and let you build RPMs, and other package types with just one
# control file.  To build this package you will need to download make+
# from this site: http://www.annexia.org/freeware/makeplus/

PACKAGE		:= makeplus
VERSION_MAJOR	:= 0
VERSION_MINOR 	:= 2.2
VERSION		:= $(VERSION_MAJOR).$(VERSION_MINOR)

SUMMARY		:= Advanced build system for GNU make
COPYRIGHT	:= Public Domain
AUTHOR		:= Richard W.M. Jones <rich@annexia.org>

define DESCRIPTION
Make+ is a set of scripts which enhance GNU make. The scripts replace
the functionality of autoconf, automake, rpm, dpkg and more, allowing
you to build, install, make RPMs, make Debian packages and more, all
from a single maintainable 'Makefile+' script.

Read more at http://www.annexia.org/freeware/makeplus/

The original author is Richard W.M. Jones <rich@annexia.org>

This software has been explicitly placed in the PUBLIC DOMAIN.  You
do not need any sort of license or agreement to use or copy this
software. You may also copyright this software yourself, and/or
relicense it under any terms you want, at any time and at no cost.
This allows you (among other things) to include this software with
other packages so that the user does not need to download and
install make+ separately.
endef

RPM_REQUIRES	:= make >= 3.76, bash
RPM_GROUP	:= Development/Building

CFLAGS		+= -Wall -Werror -g -O2

EXTRA_DIST	:= doc/*.html doc/*.1

all:	build

configure:
	$(MP_CONFIGURE_START)
	$(MP_CHECK_GNU_TAR)
	$(MP_CONFIGURE_END)

build:	docs

docs:	doc/index.html doc/make+.1 # doc/makeplus.pdf

doc/index.html: doc/make+-book.xml
	rm -f doc/*.html
	-xmlto html -o doc $^

doc/make+.1: doc/make+-man.xml
	-rm -f doc/*.1 ; xmlto man -o doc $^

doc/makeplus.pdf: doc/make+-book.xml
	rm -f $@
	-xmlto pdf -o doc $^

test:

# Avoid recursively distributing self.
MP_BUNDLE := 0

install: dist_for_bundles
	install -d $(DESTDIR)$(bindir)
	install -d $(DESTDIR)$(sysconfdir)
	install -d $(DESTDIR)$(pkgdatadir)
	install -d $(DESTDIR)$(docdir)
	install -d $(DESTDIR)$(man1dir)

	install -m 0755 $(srcdir)/make+ $(srcdir)/make+-skeleton \
		$(DESTDIR)$(bindir)
	echo "MAKEPLUS_HOME=$(pkgdatadir); export MAKEPLUS_HOME" \
		> $(DESTDIR)$(sysconfdir)/make+.conf
	install -m 0755 $(srcdir)/configure $(DESTDIR)$(pkgdatadir)
	install -m 0644 $(srcdir)/*.mk $(DESTDIR)$(pkgdatadir)
	install -m 0755 $(srcdir)/*.sh $(DESTDIR)$(pkgdatadir)
	install -m 0644 $(srcdir)/README $(DESTDIR)$(docdir) ||:
#	# Built docs might be in $(srcdir) or build directory.
	install -m 0644 doc/*.html $(DESTDIR)$(docdir) ||:
	install -m 0644 doc/*.1 $(DESTDIR)$(man1dir)   ||:
	install -m 0644 $(srcdir)/doc/*.html $(DESTDIR)$(docdir) ||:
	install -m 0644 $(srcdir)/doc/*.1 $(DESTDIR)$(man1dir)   ||:
ifdef HAVE_GNU_TAR
#	# We do this so that the MP_BUNDLE option works (see dist.mk).
	install -m 0644 mp-dist_for_bundles.tar.gz \
		$(DESTDIR)$(pkgdatadir)/$(PACKAGE).tar.gz
	install -m 0644 $(srcdir)/README.make+_for_bundles \
		$(DESTDIR)$(pkgdatadir)
	rm mp-dist_for_bundles.tar.gz
endif

# make+ installs a copy of its own distribution so that the MP_BUNDLE
# option works (see dist.mk).
ifdef HAVE_GNU_TAR
dist_for_bundles:
	$(MAKE) -f $(srcdir)/$(_mp_makefile) \
	  MP_SRC_DIST=mp-dist_for_bundles.tar.gz dist
else
dist_for_bundles:

endif

define WEBSITE
<% include page_header.msp %>

<h1>makeplus - $(SUMMARY)</h1>

<p>
Make+ is a set of scripts which enhance GNU make. The scripts replace
the functionality of autoconf, automake, rpm, dpkg and more, allowing
you to build, install, make RPMs, make Debian packages and more, all
from a single maintainable 'Makefile+' script.
</p>

<h1>Download</h1>

<h2>Source code</h2>

<ul>
<li> Latest source release is $(VERSION):
     <a href="$(PACKAGE)-$(VERSION).tar.gz">$(PACKAGE)-$(VERSION).tar.gz</a>
<li> Red Hat 7.x Source RPM package:
     <a href="$(PACKAGE)-$(VERSION)-1.src.rpm">$(PACKAGE)-$(VERSION)-1.src.rpm</a>
</ul>

<h2>Binary packages</h2>

<ul>
<li> Red Hat 7.x RPM package:
     <a href="$(PACKAGE)-$(VERSION)-1.i386.rpm">$(PACKAGE)-$(VERSION)-1.i386.rpm</a>
<li> Binary tarball:
     <a href="$(PACKAGE)-$(VERSION).bin.tar.gz">$(PACKAGE)-$(VERSION).bin.tar.gz</a>
</ul>

<h1>News</h1>

<p>
<b>Sat Mar  1 14:28:35 GMT 2003:</b>
Make+ now supports a separate <code>./configure</code>
scripts, to make it look very much more like autoconf.
Added the ability to check that programs exist on the system.
Libraries, etc., can now be required (the configure step will
fail if they are not present). Make+ can now bundle itself
with your distribution so people don't need to download
make+ separately. More extensive testing on FreeBSD and
Solaris. Manpages install on the right place on FreeBSD
(thanks alane at geeksrus.net).
</p>

<p>
<b>Mon Feb 10 09:00:12 GMT 2003:</b>
Added missing newline at the end of configure_start.sh, which
broke FreeBSD's shell. (Thanks alane at geeksrus.net).
</p>

<p>
<b>Sat Feb  8 17:00:47 GMT 2003:</b>
Ported to Solaris, OpenBSD and FreeBSD (thanks to
<a href="http://www.azazel.net/">Jeremy Sowden</a>
and <a href="http://www.mondaymorning.org/">Richard Baker</a>
for help and equipment). Configuration information logged
to <code>config.log</code> file. Separate <code>config.mk</code>
file for Makefile-specific configuration.
</p>

<p>
<b>Fri Dec 27 10:40:50 GMT 2002:</b>
Multiple patches from Alan E at geekrus dot net which fix compatibility
issues with FreeBSD (manual page location can now be chosen, <code>CC</code>
and <code>CFLAGS</code> variables can be read on the command line).
This is an intermediate release which contains incomplete DocBook
documentation (to be completed properly later).
</p>

<p>
<b>Fri Dec 20 12:28:09 GMT 2002:</b> A patch which corrects the
build directory name on FreeBSD (thanks to Alan E at geeksrus dot
net for this).
</p>

<p>
<b>Mon Dec 16 22:03:32 GMT 2002:</b> Various improvements to building
tar files, binary distributions. This version should work better with
*BSD.
</p>

<p>
<b>Sun Dec  8 12:46:46 GMT 2002:</b> Extra colon in skeleton removed.
'/' in headers no longer breaks the $$(MP_CHECK_HEADERS) rule.
Fixed building of dynamic libraries in subdirectories. Various
extra fixes for <code>pthrlib</code>.
</p>

<p>
<b>Sun Dec  8 11:28:28 GMT 2002:</b> <code>make+</code> on its own now
correctly runs the <code>all</code> target.
</p>

<p>
<b>Sun Dec  8 10:50:11 GMT 2002:</b> Fixed
several bugs in <code>make+-skeleton</code>.
</p>

<% include page_footer.msp %>
endef

upload_website:
	scp $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)-1.*.rpm \
	$(PACKAGE)-$(VERSION).bin.tar.gz \
	rich@10.0.0.248:annexia.org/freeware/makeplus/
	scp index.html rich@10.0.0.248:annexia.org/freeware/makeplus/index.msp

.PHONY:	build configure docs test upload_website
