From b8a4e831e1d5bdd17335b2c530f65799a9b52906 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 25 Apr 2014 11:39:41 +0100 Subject: [PATCH 1/1] Add to git. --- .cvsignore | 1 + INSTALL | 80 +++++++ Makefile+ | 229 ++++++++++++++++++++ README | 7 + README.Solaris | 16 ++ README.make+_for_bundles | 38 ++++ c.mk | 32 +++ check_funcs.sh | 52 +++++ check_gnu_tar.sh | 29 +++ check_headers.sh | 49 +++++ check_lib.sh | 50 +++++ check_progs.sh | 43 ++++ configure | 66 ++++++ configure.mk | 32 +++ configure_end.sh | 20 ++ configure_start.sh | 72 +++++++ default_goal.mk | 17 ++ dist.mk | 72 +++++++ doc/make+-book.xml | 541 +++++++++++++++++++++++++++++++++++++++++++++++ doc/make+-man.xml | 30 +++ install_dynamic_lib.sh | 31 +++ install_static_lib.sh | 19 ++ link_dynamic.sh | 39 ++++ link_static.sh | 22 ++ main.mk | 86 ++++++++ make+ | 95 +++++++++ make+-skeleton | 135 ++++++++++++ make_rpm_spec.sh | 71 +++++++ make_website.sh | 21 ++ release.sh | 21 ++ rpm.mk | 36 ++++ run_tests.sh | 33 +++ test.mk | 15 ++ website.mk | 30 +++ 34 files changed, 2130 insertions(+) create mode 100644 .cvsignore create mode 100644 INSTALL create mode 100644 Makefile+ create mode 100644 README create mode 100644 README.Solaris create mode 100644 README.make+_for_bundles create mode 100644 c.mk create mode 100755 check_funcs.sh create mode 100755 check_gnu_tar.sh create mode 100755 check_headers.sh create mode 100755 check_lib.sh create mode 100755 check_progs.sh create mode 100755 configure create mode 100644 configure.mk create mode 100755 configure_end.sh create mode 100755 configure_start.sh create mode 100644 default_goal.mk create mode 100644 dist.mk create mode 100644 doc/make+-book.xml create mode 100644 doc/make+-man.xml create mode 100755 install_dynamic_lib.sh create mode 100755 install_static_lib.sh create mode 100755 link_dynamic.sh create mode 100755 link_static.sh create mode 100644 main.mk create mode 100755 make+ create mode 100755 make+-skeleton create mode 100755 make_rpm_spec.sh create mode 100755 make_website.sh create mode 100755 release.sh create mode 100644 rpm.mk create mode 100644 run_tests.sh create mode 100644 test.mk create mode 100644 website.mk diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..1964f99 --- /dev/null +++ b/.cvsignore @@ -0,0 +1 @@ +build-* \ No newline at end of file diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..7a8b097 --- /dev/null +++ b/INSTALL @@ -0,0 +1,80 @@ +Installing make+ +---------------- + +Make+ is entirely self-hosting! But don't worry, it's easy to build and +install make+ even if you don't already have make+ installed. Follow the +steps below to build, install or make a package. + +1. Quick installation for the impatient: + + MAKEPLUS_HOME=`pwd`; export MAKEPLUS_HOME + PATH=$MAKEPLUS_HOME:$PATH + ./configure [--prefix=/usr --sysconfdir=/etc] + make+ + su + make+ install + exit + unset MAKEPLUS_HOME + +Step by step instructions follow: + +2. Set the MAKEPLUS_HOME environment variable to point to the make+ + source files. + + Make sure you are in the unpacked make+ source directory and type: + + MAKEPLUS_HOME=`pwd` + export MAKEPLUS_HOME + + If you are using CSH, type: + + setenv MAKEPLUS_HOME `pwd` + + Note that those are backquotes (`) around the pwd. + + To check this, type: + + echo $MAKEPLUS_HOME + + which should show the full path to the unpacked source directory. + + Similarly you also need to update your PATH so that the 'make+' + program can be found: + + PATH=$MAKEPLUS_HOME:$PATH + +3. Configure the paths used by make+. Normally you would do: + + ./configure + + This will install make+ entirely under the /usr/local directory. To + install under /usr and with the configuration file in /etc, do: + + ./configure --prefix=/usr --sysconfdir=/etc + +4. Run make+ to have it build itself: + + make+ + +5. To perform a straightforward install, you'll need to be root (but + you don't need to be root yet if all you want to do is build an RPM). + To become root, type: + + su + + you will probably be asked for the root password. + +6. Type: + + make+ install + exit + +7. If you prefer, you can build an RPM of make+: + + make+ rpm + + The RPM will end up under build-*/makeplus-*.rpm + +8. Remove the MAKEPLUS_HOME environment variable. + + unset MAKEPLUS_HOME diff --git a/Makefile+ b/Makefile+ new file mode 100644 index 0000000..3ebe693 --- /dev/null +++ b/Makefile+ @@ -0,0 +1,229 @@ +# -*- 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.3 +VERSION := $(VERSION_MAJOR).$(VERSION_MINOR) + +SUMMARY := Advanced build system for GNU make +COPYRIGHT := Public Domain +AUTHOR := Richard W.M. Jones + +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 + +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 %> + +

makeplus - $(SUMMARY)

+ +

+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. +

+ +

Download

+ +

Source code

+ + + +

Binary packages

+ + + +

News

+ +

+Fri Mar 28 14:25:31 GMT 2003: +Fixed case where 'uname -m' has spaces, which would cause +the build directory name to contain spaces. Fixed the RPM spec +file (autogenerated) so that when building make+, make+ builds +itself using itself (thanks to ksonney at redhat.com for +identifying this problem). +

+ +

+Sat Mar 1 14:28:35 GMT 2003: +Make+ now supports a separate ./configure +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). +

+ +

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

+ +

+Sat Feb 8 17:00:47 GMT 2003: +Ported to Solaris, OpenBSD and FreeBSD (thanks to +Jeremy Sowden +and Richard Baker +for help and equipment). Configuration information logged +to config.log file. Separate config.mk +file for Makefile-specific configuration. +

+ +

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

+ +

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

+ +

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

+ +

+Sun Dec 8 12:46:46 GMT 2002: 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 pthrlib. +

+ +

+Sun Dec 8 11:28:28 GMT 2002: make+ on its own now +correctly runs the all target. +

+ +

+Sun Dec 8 10:50:11 GMT 2002: Fixed +several bugs in make+-skeleton. +

+ +<% 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 diff --git a/README b/README new file mode 100644 index 0000000..8921868 --- /dev/null +++ b/README @@ -0,0 +1,7 @@ +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. + +To find out how to install make+, please read the accompanying INSTALL +file. \ No newline at end of file diff --git a/README.Solaris b/README.Solaris new file mode 100644 index 0000000..2de2244 --- /dev/null +++ b/README.Solaris @@ -0,0 +1,16 @@ +It is possible to install and use make+ on Solaris. Make sure, however, +that you have installed the GNU software from http://www.sunfreeware.com/, +in particular these packages: + +make +fileutils +gzip +bash +grep + +You may also need to ensure that the GNU versions of the tools are first +in the PATH, for example by doing: + +export PATH=/usr/local/bin:$PATH + +Rich, 2003/01/14 diff --git a/README.make+_for_bundles b/README.make+_for_bundles new file mode 100644 index 0000000..7d837d4 --- /dev/null +++ b/README.make+_for_bundles @@ -0,0 +1,38 @@ +README for make+ +---------------- + +This package uses 'make+' - the sane replacement for autoconf/automake. + +Bundled along with this package you should find a makeplus-NNN/ +subdirectory. This contains the version of makeplus which was used +when this package was created. You now have three choices: + +1. If you already have a recent version of make+ installed on your +computer, then just ignore this subdirectory. You should be able to +build this package just by doing: + + ./configure + make+ + make+ test + make+ install # As root + +2. If you do not have make+ installed or you want to use the bundled +version of make+ because it is newer, then you can do: + + MAKEPLUS_HOME=`pwd`/makeplus-* ; export MAKEPLUS_HOME + + oldpath=$PATH + PATH=$MAKEPLUS_HOME:$PATH ; export PATH + + ./configure + make+ + make+ test + make+ install # As root + + PATH=$oldpath + +3. Or you can go to the website to download the latest version of +make+, install it and then proceed with the instructions in (1) +above. The website is: + + http://www.annexia.org/freeware/makeplus/ diff --git a/c.mk b/c.mk new file mode 100644 index 0000000..856bdff --- /dev/null +++ b/c.mk @@ -0,0 +1,32 @@ +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +# General C compilation variables. +CC ?= gcc +CFLAGS += -I. -I.. +LIBS += +SETENV ?= /usr/bin/env +CONF_ENV = CC="$(CC)" CFLAGS="$(CFLAGS)" + +# Link scripts. +MP_LINK_STATIC = $(MAKEPLUS_HOME)/link_static.sh +MP_LINK_DYNAMIC = $(MAKEPLUS_HOME)/link_dynamic.sh +MP_INSTALL_STATIC_LIB = $(MAKEPLUS_HOME)/install_static_lib.sh +MP_INSTALL_DYNAMIC_LIB = $(MAKEPLUS_HOME)/install_dynamic_lib.sh + +# Compile object files for dynamic linking. +.c.lo: + $(CC) $(CFLAGS) -fPIC -c $< -o $@ + +.SUFFIXES: .lo \ No newline at end of file diff --git a/check_funcs.sh b/check_funcs.sh new file mode 100755 index 0000000..3fd351d --- /dev/null +++ b/check_funcs.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +require=$1 +shift + +for func in "$@"; do + sym=`echo $func | tr -- '-.[a-z]' '__[A-Z]'` + have= + + # Try to compile and link a short program which references this + # symbol. If the symbol exists in the library then this ought to + # succeed. + rm -f mp-check_func + echo "char $func(); char (*f) ();int main(){f = $func;return 0;}" \ + > mp-check_func.c + echo "mp-check_func.c:" >>config.log + cat mp-check_func.c >>config.log + echo $CC $CFLAGS mp-check_func.c -o mp-check_func $LIBS >>config.log + $CC $CFLAGS mp-check_func.c -o mp-check_func $LIBS >>config.log 2>&1 + if [ $? -eq 0 ]; then + if [ -f mp-check_func ]; then + have=y + fi + fi + rm -f mp-check_func* + + if [ "x$have" = "xy" ]; then + echo "#define HAVE_$sym 1" >> config.h + echo "HAVE_$sym := 1" >> config.mk + else + if [ "x$require" = "xy" ]; then + echo "configure: function $func is required; not found" + exit 1 + fi + echo "/* #define HAVE_$sym 1 */" >> config.h + echo "# HAVE_$sym := 1" >> config.mk + fi +done diff --git a/check_gnu_tar.sh b/check_gnu_tar.sh new file mode 100755 index 0000000..ff167b5 --- /dev/null +++ b/check_gnu_tar.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +# XXX More thought required here. Much of dist.mk makes assumptions +# that we have a non-losing tar. This is why you can't build distributions +# on Solaris yet. + +tar --help > mp-check_gnu_tar 2>&1 +if head -1 mp-check_gnu_tar | grep -q GNU >/dev/null 2>&1; then + echo 'HAVE_GNU_TAR := 1' >> config.mk + echo '#define HAVE_GNU_TAR 1' >> config.h +else + echo '# HAVE_GNU_TAR := 1' >> config.mk + echo '/* #define HAVE_GNU_TAR 1 */' >> config.h +fi +rm -f mp-check_gnu_tar diff --git a/check_headers.sh b/check_headers.sh new file mode 100755 index 0000000..1c363d2 --- /dev/null +++ b/check_headers.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +require=$1 +shift + +for hdr in "$@"; do + sym=`echo $hdr | tr -- '-./[a-z]' '___[A-Z]'` + have= + + # Try to compile a short program which includes this file. + rm -f mp-check_header.o + echo "#include <$hdr>" > mp-check_header.c + echo "mp-check_header.c:" >>config.log + cat mp-check_header.c >>config.log + echo $CC $CFLAGS -E mp-check_header.c >>config.log + $CC $CFLAGS -E mp-check_header.c >>config.log 2>&1 + if [ $? -eq 0 ]; then + have='y' + fi + rm -f mp-check_header* + + if [ "x$have" = "xy" ]; then + echo "#define HAVE_$sym 1" >> config.h + echo "HAVE_$sym := 1" >> config.mk + else + if [ "x$require" = "xy" ]; then + echo "configure: header file <$hdr> is required; not found" + echo "configure: You may need to do:" + echo "configure: CFLAGS=-I/path/to/header; export CFLAGS" + exit 1 + fi + echo "/* #define HAVE_$sym 1 */" >> config.h + echo "# HAVE_$sym := 1" >> config.mk + fi +done diff --git a/check_lib.sh b/check_lib.sh new file mode 100755 index 0000000..f51a43e --- /dev/null +++ b/check_lib.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +require=$1 +func=$2 +lib=$3 + +sym=`echo $lib | tr -- '-.[a-z]' '__[A-Z]'` +have= + +# Try to compile and link a short program which references this +# symbol. If the symbol exists in the library then this ought to +# succeed. +rm -f mp-check_lib +echo "char $func();int main(){(void)&$func;return 0;}" > mp-check_lib.c +echo "mp-check_lib.c:" >>config.log +cat mp-check_lib.c >>config.log +echo $CC $CFLAGS mp-check_lib.c -o mp-check_lib -l$lib $LIBS >>config.log +$CC $CFLAGS mp-check_lib.c -o mp-check_lib -l$lib $LIBS >>config.log 2>&1 +if [ $? -eq 0 ]; then + if [ -f mp-check_lib ]; then + have=y + fi +fi +rm -f mp-check_lib* + +if [ "x$have" = "xy" ]; then + echo "#define HAVE_LIB$sym 1" >> config.h + echo "LIBS := \$(LIBS) -l$lib" >> config.mk +else + if [ "x$require" = "xy" ]; then + echo "configure: library $lib containing function $func is required" + exit 1 + fi + echo "/* #define HAVE_LIB$sym 1 */" >> config.h + echo "# LIBS := \$(LIBS) -l$lib" >> config.mk +fi diff --git a/check_progs.sh b/check_progs.sh new file mode 100755 index 0000000..34589a0 --- /dev/null +++ b/check_progs.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +require=$1 +shift + +for prog in "$@"; do + sym=`echo $prog | tr -- '-./[a-z]' '___[A-Z]'` + have= + + # Find out if the program exists. The trick here is not to actually + # run the program. + if which $prog >> config.log 2>&1; then + have=y + fi + + if [ "x$have" = "xy" ]; then + echo "#define HAVE_$sym 1" >> config.h + echo "HAVE_$sym := 1" >> config.mk + else + if [ "x$require" = "xy" ]; then + echo "configure: program $prog is required; not found" + echo "configure: You may need to do:" + echo "configure: PATH=/path/to/program:\$PATH; export PATH" + exit 1 + fi + echo "/* #define HAVE_$sym 1 */" >> config.h + echo "# HAVE_$sym := 1" >> config.h + fi +done diff --git a/configure b/configure new file mode 100755 index 0000000..04d9db0 --- /dev/null +++ b/configure @@ -0,0 +1,66 @@ +#!/bin/sh - +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let you build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +mp_options="" + +usage () +{ + cat <. +# +# 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. + +# Configuration scripts. +MP_CONFIGURE_START = $(SETENV) $(CONF_ENV) $(MAKEPLUS_HOME)/configure_start.sh +MP_CONFIGURE_END = $(SETENV) $(CONF_ENV) $(MAKEPLUS_HOME)/configure_end.sh + +MP_CHECK_HEADERS = $(SETENV) $(CONF_ENV) $(MAKEPLUS_HOME)/check_headers.sh n +MP_CHECK_HEADER = $(MP_CHECK_HEADERS) +MP_CHECK_FUNCS = $(SETENV) $(CONF_ENV) $(MAKEPLUS_HOME)/check_funcs.sh n +MP_CHECK_LIB = $(SETENV) $(CONF_ENV) $(MAKEPLUS_HOME)/check_lib.sh n +MP_CHECK_PROGS = $(SETENV) $(CONF_ENV) $(MAKEPLUS_HOME)/check_progs.sh n +MP_CHECK_PROG = $(MP_CHECK_PROGS) +MP_REQUIRE_HEADERS = $(SETENV) $(CONF_ENV) $(MAKEPLUS_HOME)/check_headers.sh y +MP_REQUIRE_HEADER = $(MP_REQUIRE_HEADERS) +MP_REQUIRE_FUNCS = $(SETENV) $(CONF_ENV) $(MAKEPLUS_HOME)/check_funcs.sh y +MP_REQUIRE_LIB = $(SETENV) $(CONF_ENV) $(MAKEPLUS_HOME)/check_lib.sh y +MP_REQUIRE_PROGS = $(SETENV) $(CONF_ENV) $(MAKEPLUS_HOME)/check_progs.sh y +MP_REQUIRE_PROG = $(MP_REQUIRE_PROGS) + +MP_CHECK_GNU_TAR = $(SETENV) $(CONF_ENV) $(MAKEPLUS_HOME)/check_gnu_tar.sh diff --git a/configure_end.sh b/configure_end.sh new file mode 100755 index 0000000..21abbe0 --- /dev/null +++ b/configure_end.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +set -e + +echo >> config.h +echo "#endif /* MP_CONFIG_H */" >> config.h diff --git a/configure_start.sh b/configure_start.sh new file mode 100755 index 0000000..0a0c1ab --- /dev/null +++ b/configure_start.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +set -e + +# Check the 'config.mk' file doesn't exist. If it does exist then this +# is a serious problem because it will override command line arguments +# (which, when doing a configure, we want). The user really ought to be +# running the ./configure shell script which removes this file. +if [ -f config.mk ]; then + echo "configure: config.mk: file found (which is an error)" + echo "configure: Before running 'make+ configure', you must remove this" + echo "configure: file, or the build directory. You could also do:" + echo "configure: ./configure [--help]" + exit 1 +fi + +rm -f config.h config.log + +cat > config.h < config.mk <. +# +# 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. + +_mp_all: all + +.PHONY: _mp_all \ No newline at end of file diff --git a/dist.mk b/dist.mk new file mode 100644 index 0000000..d37173f --- /dev/null +++ b/dist.mk @@ -0,0 +1,72 @@ +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +# The user can add more exclude patterns by adding to or overriding +# this variable. Each pattern is a wildcard passed to the -X option +# of tar. +MP_DIST_EXCLUDE = build-* makeplus-* CVS .\#* *~ *.old core + +# Default name for the source distribution. +MP_SRC_DIST = $(PACKAGE)-$(VERSION).tar.gz + +# Default name for the binary distribution. +MP_BIN_DIST = $(PACKAGE)-$(VERSION).bin.tar.gz + +# Default name for the binary manifest. +MP_BIN_MANIFEST = MANIFEST.bin + +# If set then bundle a copy of make+ with source distributions. +# (Note: Doesn't work on platforms with losing non-GNU 'tar'). +MP_BUNDLE = 1 + +# Build a source distribution. +dist: mp-dist.ex + rm -rf $(PACKAGE)-$(VERSION) + rm -f $(MP_SRC_DIST) + mkdir $(PACKAGE)-$(VERSION) + tar -cf - -X mp-dist.ex $(EXTRA_DIST) -C .. . | \ + tar -xf - -C $(PACKAGE)-$(VERSION) + if [ -n "$(MP_BUNDLE)" -a -r "$(MAKEPLUS_HOME)/makeplus.tar.gz" ]; \ + then \ + gzip -d -c $(MAKEPLUS_HOME)/makeplus.tar.gz | \ + tar -xf - -C $(PACKAGE)-$(VERSION); \ + cp $(MAKEPLUS_HOME)/README.make+_for_bundles \ + $(PACKAGE)-$(VERSION)/README.make+; \ + fi + tar -cf - $(PACKAGE)-$(VERSION) | gzip --best > $(MP_SRC_DIST) + rm -rf $(PACKAGE)-$(VERSION) + rm mp-dist.ex + +mp-dist.ex: + @for ex in $(MP_DIST_EXCLUDE); do echo $$ex; done > mp-dist.ex + +# Build a binary distribution. +# XXX What's the standard name for this target? +bindist: + rm -rf mp-bindist + rm -f $(MP_BIN_DIST) + mkdir mp-bindist + $(MAKE) -f $(srcdir)/$(_mp_makefile) DESTDIR=mp-bindist install + tar -cf - -C mp-bindist . | gzip --best > $(MP_BIN_DIST) + rm -rf mp-bindist + +# Build a manifest for the binary distribution. +mp_manifest_bin: + rm -rf mp-bindist + mkdir mp-bindist + $(MAKE) -f $(srcdir)/$(_mp_makefile) DESTDIR=mp-bindist install + find mp-bindist \! -type d | sed 's|^mp-bindist||' > $(MP_BIN_MANIFEST) + rm -rf mp-bindist + +.PHONY: dist bindist mp_manifest_bin diff --git a/doc/make+-book.xml b/doc/make+-book.xml new file mode 100644 index 0000000..27ed5e2 --- /dev/null +++ b/doc/make+-book.xml @@ -0,0 +1,541 @@ + + + <application>make+</application> users manual + + + Richard + W.M. + Jones + + + + 21st December 2002 + 1.0 + + + + make+ is an advanced build system + designed to replace the functionality of + autoconf, + automake, and packaging systems + such as rpm. Using a single control + file, maintainers and end users can build and install the + program, build RPMs, Debian packagages and other package + formats, and maintain a website. + make+ is just a set of GNU + make snippets and shell scripts, + making it simple to maintain and extend. + + + + + make+ + make + automake + autoconf + rpm + deb + dpkg + package + + + + + Introduction + + + make+ is an advanced build system + designed to replace the functionality of + autoconf, + automake, and packaging systems such + as rpm. Using a single control file, + maintainers and end users can build and install the program, + build RPMs, Debian packagages and other package formats, and + maintain a website. + + + + At the same time, make+ is just a set + of GNU make snippets and shell + scripts, making it simple to maintain and extend. + + + + This manual explains how to convert your own package to use + make+. If you have been presented + with a package which contains a Makefile+ + file and you want to know how to use make+ to + build and install this package, then please read the + make+(1) manual page. + + + + + + <application>make+</application> theory of operation + + + A make+-enabled package + contains a single file called Makefile+ + located in the top-level source directory. + make+ should never + be used recursively, so you will not need more than + one Makefile+ file even if your + package source contains subdirectories. + + + + make+ has the notion of a "pristine" + source directory. This means that + make+ should never create + intermediate files (object files, Java class files and the like) + directly in the source directory. Instead, + make+ creates a build directory + before it starts to store intermediate build files. Normally + this directory is called something like + build-i686-unknown-linux but it may, of + course, be something different on your particular machine and + operating system. + + + + The make+ command is a shell script + which performs the following steps: + + + + + Creates the build directory if it doesn't exist already. + + + Change into the build directory, ie. + cd build-foo-bar + + + Set the GNU make environment + variable MAKEFILES. This causes GNU + make to load the + make+ library first. + + + Run gmake -f ../Makefile+. Because + MAKEFILES has been set, GNU make will + first load the make+ library, + and second load Makefile+ from the + top level of the source directory. + + + + + Because make+ runs in the + build subdirectory, intermediate files shouldn't + pollute the source directory. For this reason, + make+ can use a very + simple scheme when it builds a source tarball of + the package: it just treats every file in the source + directory as a source file, ignoring only the + build subdirectory itself and files with names + like foo~ and CVS. + + + + + + Compiling a package which has been converted to use + <application>make+</application> + + + If you have been given an application which has been + converted to use make+ already + and you just want to compile it, then you're likely to + read the generic INSTALL file and + follow those instructions. This chapter explains the + steps needed to compile an application, but also covers + what's happening "behind the scenes" at each step. + + + + The basic steps for compiling a make+-enabled + application are: + + + + + Configure the application using + ./configure + + + Compile the application by typing + make+ + + + Run any supplied tests by typing + make+ test + + + Install the application (as root) with + make+ install + + + + + But what is actually happening at each step? + + + + Configuration + + + The configuration step sets up the installation paths and then + examines the system looking for required and optional programs + and libraries. + + + + We can imagine a fictional C debugging library. This requires + the GNU bfd library to read + executables. In addition, if the Linux-specific + backtrace function is present in + libc, then our fictional library + can present more readable stack traces when a program + crashes. The configure step for this library would first + examine the system looking for the GNU + bfd library. If not found, it would + stop with an error, telling the user that they must install + this library. It would then look for the + backtrace function, but if this function + was not present, it would not be a fatal error. + + + + During the configuration step is also the point where we + specify where we want to install the program. Normally + users will be interested in setting the prefix + variable which controls the overall location of the + installation. It defaults to /usr/local + which causes most files to be installed in subdirectories + of this directory, but some users will want to change + the prefix, commonly to /usr. + + + + The result of the configuration step is three files in the + build directory: + + + + + config.h + + A C/C++ header file describing the capabilities + of the system. For our imaginary debugging library + the C header file might look like this: + + + +/* Generated automatically by make+. */ + +#ifndef MP_CONFIG_H +#define MP_CONFIG_H + +#define PACKAGE "foo" +#define VERSION "0.0.1" +#define HAVE_LIBBFD 1 +#define HAVE_BACKTRACE 1 + +#endif /* MP_CONFIG_H */ + + + + Happily we can see that this platform has both the + required GNU bfd and the optional backtrace + function. + + + + + + config.mk + + This file is a Makefile + fragment which is included directly the next time + that make+ runs (ie. it + is included when we do the compile, test and + install steps). + + + + The purpose of this file is threefold. Firstly to + define the LIBS variable, which + is built on the fly as a result of detecting + required and optional libraries. Secondly to + save the installation paths (the prefix + and related paths). Thirdly to save the results + of the configuration tests in a way which is accessible + to the Makefile+. + + + + An extract from the config.mk + file for our fictional debugging library: + + + +prefix = /usr +bindir = /usr/bin +sbindir = /usr/sbin +libexecdir = /usr/libexec + # + # many lines omitted + # +LIBS = -lbfd + +HAVE_LIBBFD = 1 +HAVE_BACKTRACE = 1 + + + + + + + config.log + + + This file logs every command issued during the + configuration step, and is very useful for + debugging problems. + + + + + + + make+-enabled applications come + with a simple configure script. This is not + just a convenience (users are used to typing + ./configure --prefix=/usr). It also removes + the old config.mk file before running + make+ configure, which is essential to + ensure that any previous installation paths do not + accidentally take precedence. + + + + + + Compiling and testing + + + The application's Makefile+ file + contains all and test + targets, and, just like an ordinary + Makefile, running + make+ all or make+ test + just executes these targets. However, recall from + the theory of + operation chapter, before the application's + Makefile+ runs, the + make+ library is loaded + first. Thus the application's all and + test targets may - if they want - + use macros and scripts from make+. + + + + As an example, here is a typical test + target, which makes use of the make+ + library's MP_RUN_TESTS macro: + + + +test: test_hash test_matvec test_pool + $(MP_RUN_TESTS) $^ + +test_hash: test_hash.o + $(CC) $(CFLAGS) $^ -o $@ $(LIBS) +test_matvec: test_matvec.o + $(CC) $(CFLAGS) $^ -o $@ $(LIBS) +test_pool: test_pool.o + $(CC) $(CFLAGS) $^ -o $@ $(LIBS) + + + + + + Installing + + + The application's Makefile+ file contains + an ordinary install target which is run + directly when the user does make+ install. + The purpose of the install target is + to do whatever is necessary to install the program, but + in practice this means doing two things: + + + + + Making the installation directories. + + + Copying the program into the installation directories. + + + + + Here is an example install target. + The first four commands are concerned with creating the + installation directories. The last five commands are concerned + with copying the built program (in this case, a library) to + the installation directories. Notice the use of several + make+ macros. + + + +install: + install -d $(DESTDIR)$(libdir) + install -d $(DESTDIR)$(pkgincludedir) + install -d $(DESTDIR)$(man3dir) + install -d $(DESTDIR)$(datadir)/rws/symtabs/ + + $(MP_INSTALL_STATIC_LIB) libc2lib.a + $(MP_INSTALL_DYNAMIC_LIB) libc2lib.so + install -m 0644 $(HEADERS) $(DESTDIR)$(pkgincludedir) + install -m 0644 *.3 $(DESTDIR)$(man3dir) + install -m 0644 *.syms $(DESTDIR)$(datadir)/rws/symtabs/ + + + + $(DESTDIR) must be prefixed onto every + install path. Normally it is empty, and so has no + effect. However when doing packaged builds (building RPMs for + example) it can be used to create a "fake root". + + + + $(libdir), etc., are standard paths + for particular directories. For example if the prefix + is /usr/local and we are building + on Linux, then + $(libdir) will expand to + /usr/local/lib and + $(man3dir) to + /usr/local/share/man/man3. + + + + + + + + Converting a package to use <application>make+</application> + + + Converting a package to use make+ + is simple in principle. Step one is to create a file + called Makefile+ and place it in + the top level directory of your package. Step two is + to remove whatever existing build system you were + using before - Makefile, + configure.in, config.*, + Makefile.am and so on. Of course + step two is optional! + + + + make+ comes with a handy + shell script called make+-skeleton + which can help you to create your Makefile+ + file. You should run this in the top-level directory + of your package. A typical interaction will go like this: + + + +$ make+-skeleton + +What is the name of your package? foo + +Now I'm going to ask you for the initial version number for this +package. Version numbers have two parts: the MAJOR part and the +MINOR part. + +The MAJOR part is a single number (eg 3). It is used (for example) +for versioning libraries. + +The MINOR part is two numbers separated by a single DOT (eg 1.0) +This is the incremental release of the library. + +If you library is version 3.1.0 then the MAJOR part would be + 3 +and the MINOR part would be + 1.0 + +What is the MAJOR part of the version? 0 +What is the MINOR part of the version? 0.1 + +I've written a Makefile+ file for you. You'll need to edit this file. +Start by searching for all the 'XXX's and replacing them as necessary. + + + + + This creates the initial Makefile+ + for a package called foo at + version 0.0.1. The Makefile+ file + will start like this: + + + + <filename>Makefile+</filename> skeleton file + +# -*- 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 := foo +VERSION_MAJOR := 0 +VERSION_MINOR := 0.1 +VERSION := $(VERSION_MAJOR).$(VERSION_MINOR) + +SUMMARY := XXX A ONE LINE SUMMARY OF YOUR PACKAGE +COPYRIGHT := XXX ONE LINE COPYRIGHT OR LICENSE +AUTHOR := XXX YOUR NAME AND EMAIL ADDRESS + + + + + Your first step should be to edit this file, search through for + XXX and replace these as desired. (The + following sections will help you to write each part of the + file). + + + + You should familiarise yourself with the + theory + of operation of make+ + too, particularly remembering that the + Makefile+ rules are run + in the build subdirectory, not in the source + directory. + + + + Configuration + + + + + + + + + + + + + + diff --git a/doc/make+-man.xml b/doc/make+-man.xml new file mode 100644 index 0000000..ef7ab4f --- /dev/null +++ b/doc/make+-man.xml @@ -0,0 +1,30 @@ + + + make+ + 1 + + + + make+ + build system + + + + + make+ + + target + + + + Description + + For each file that is a directory, ls lists + the contents of the directory; for each file that is an ordinary + file, ls repeats its name and any other + information requested. + + + diff --git a/install_dynamic_lib.sh b/install_dynamic_lib.sh new file mode 100755 index 0000000..d5642c2 --- /dev/null +++ b/install_dynamic_lib.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +set -e + +library="$1" +soname="$1.$VERSION_MAJOR" +filename="$1.$VERSION_MAJOR.$VERSION_MINOR" + +base_library=`basename "$library"` +base_soname=`basename "$soname"` +base_filename=`basename "$filename"` + +install -m 0755 "$filename" "$DESTDIR$libdir" +cd "$DESTDIR$libdir" +rm -f "$base_soname" "$base_library" +ln -s "$base_filename" "$base_soname" +ln -s "$base_soname" "$base_library" diff --git a/install_static_lib.sh b/install_static_lib.sh new file mode 100755 index 0000000..d61891c --- /dev/null +++ b/install_static_lib.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +set -e + +install -m 0644 "$1" $DESTDIR$libdir diff --git a/link_dynamic.sh b/link_dynamic.sh new file mode 100755 index 0000000..306e8e2 --- /dev/null +++ b/link_dynamic.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +set -e + +# Find the name of the linker -soname option. +# XXX This is wrong: during the configure stage we should work out +# which Solaris linker we are using (gcc has it as a hard-coded path) +# and choose the appropriate option. +soname_opt=-soname +if [ `uname` = "SunOS" ]; then + soname_opt=-h +fi + +library="$1"; shift + +soname="$library.$VERSION_MAJOR" +filename="$library.$VERSION_MAJOR.$VERSION_MINOR" + +base_soname=`basename "$soname"` +base_filename=`basename "$filename"` + +gcc -shared -Wl,$soname_opt,"$base_soname" -o "$filename" "$@" +rm -f "$soname" "$library" +ln -s "$base_filename" "$soname" +ln -s "$base_soname" "$library" diff --git a/link_static.sh b/link_static.sh new file mode 100755 index 0000000..7125e2e --- /dev/null +++ b/link_static.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +set -e + +library="$1"; shift + +ar rc $library "$@" +ranlib $library diff --git a/main.mk b/main.mk new file mode 100644 index 0000000..ba5bc12 --- /dev/null +++ b/main.mk @@ -0,0 +1,86 @@ +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +# This is a hack to make GNU make recognise '_mp_all (all)' as the +# default goal. +include $(MAKEPLUS_HOME)/default_goal.mk + +# Set the VPATH because builds always happen in a subdirectory. +VPATH := .. +srcdir := $(shell cd .. && pwd) + +# Directories. +prefix ?= /usr/local +bindir = $(prefix)/bin +sbindir = $(prefix)/sbin +libexecdir = $(prefix)/libexec +datadir = $(prefix)/share +sysconfdir = $(prefix)/etc +sharedstatedir = $(prefix)/com +localstatedir = $(prefix)/var +libdir = $(prefix)/lib +infodir = $(prefix)/info +includedir = $(prefix)/include +pkgdatadir = $(datadir)/$(PACKAGE) +docdir = $(datadir)/doc/$(PACKAGE)-$(VERSION) +pkgetcdir = $(sysconfdir)/$(PACKAGE) +pkglibdir = $(libdir)/$(PACKAGE) +pkgincludedir = $(includedir)/$(PACKAGE) +ifneq ($(shell uname), FreeBSD) +manprefix = $(datadir) +else +manprefix = $(prefix) +endif +mandir = $(manprefix)/man +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +man3dir = $(mandir)/man3 +man4dir = $(mandir)/man4 +man5dir = $(mandir)/man5 +man6dir = $(mandir)/man6 +man7dir = $(mandir)/man7 +man8dir = $(mandir)/man8 +manndir = $(mandir)/mann +manldir = $(mandir)/manl + +# If the configuration file exists, include it (from the build directory). +-include config.mk + +# Include the other parts of this makefile. +include $(MAKEPLUS_HOME)/configure.mk +include $(MAKEPLUS_HOME)/c.mk +include $(MAKEPLUS_HOME)/dist.mk +include $(MAKEPLUS_HOME)/rpm.mk +include $(MAKEPLUS_HOME)/test.mk +include $(MAKEPLUS_HOME)/website.mk + +# Clean rule (removes files and links in the build directory and removes +# editor backup files from the source directory). +clean: + [ -f $(srcdir)/$(_mp_makefile) ] + find . \( -type f -o -type l \) -print | xargs rm -f + find .. -name '*~' -print | xargs rm -f + +# Distclean rule (does a clean and additionally removes the build directory). +distclean: clean + cd .. && rm -rf $(_mp_builddir) + +# Force target. +_mp_force: + +# Export everything. +.EXPORT_ALL_VARIABLES: + +# Phony targets. +.PHONY: clean configure distclean diff --git a/make+ b/make+ new file mode 100755 index 0000000..ae8c280 --- /dev/null +++ b/make+ @@ -0,0 +1,95 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let you build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +# The control file. XXX Parse and remove the -f option. +_mp_makefile="Makefile+"; export _mp_makefile + +# Check the control file exists in the current directory. You can only +# run make+ from the top level source directory, the one which contains +# Makefile+. You should not be doing anything recursive with make+. +if [ ! -r "$_mp_makefile" ]; then + echo "make+: $_mp_makefile: file not found or not readable" + echo "You should always run make+ from the top-level source" + echo "directory, the one which contains the Makefile+ file." + exit 1 +fi + +# Find a suitable copy of GNU make. You can override this test +# by setting the $MAKE option. +if [ "x$MAKE" = "x" ]; then + if sh -c 'gmake --version' 2>/dev/null | grep -q 'GNU Make'; then + MAKE=gmake + elif sh -c 'make --version' 2>/dev/null | grep -q 'GNU Make'; then + MAKE=make + else + echo "make+: I cannot find a copy of GNU make. Please set the \$MAKE" + echo "environment variable to point to the GNU make binary." + fi +fi + +# Check for a sufficiently recent version of GNU make. +if $MAKE --version | grep -q '^GNU Make .*3\.'; then + # make is up-to-date + : +else + echo "make+: Your 'make' is not GNU make (or not a recent version)" + echo "Please install a recent version of GNU make." + exit 1 +fi + +# Check that either MAKEPLUS_HOME or /etc/make+.conf exists, and run it. +if [ "x$MAKEPLUS_HOME" = "x" ]; then + for d in /etc /usr/etc /usr/local/etc; do + if [ -f $d/make+.conf ]; then + . $d/make+.conf + break + fi + done +fi + +# Check MAKEPLUS_HOME looks reasonable. +if [ ! -f "$MAKEPLUS_HOME/main.mk" ]; then + echo "make+: MAKEPLUS_HOME environment variable not set correctly." + echo "This environment variable should point to the installation" + echo "directory for make+ (eg. /usr/share/makeplus). You would normally" + echo "do this by creating a file called /etc/make+.conf containing" + echo " export MAKEPLUS_HOME=/usr/share/makeplus" + echo "or you can set it as an environment variable each time you run" + echo "make+." + exit 1 +fi + +# Set MAKEFILES. +MAKEFILES=$MAKEPLUS_HOME/main.mk; export MAKEFILES + +# Construct a suitable target architecture. +# XXX Cross compiling. +arch=`uname -m` +os=`uname -s | tr 'A-Z' 'a-z'` +hw=`( uname -i 2>/dev/null || echo "unknown" ) | tr -cd 'A-Za-z0-9'` +_mp_builddir=build-$arch-$hw-$os; export _mp_builddir + +# Create the build directory. +# XXX +mkdir -p $_mp_builddir +cd $_mp_builddir + +# Create the directories under the build directory. +(cd .. && find . -type d -a \! -name CVS) | grep -v $_mp_builddir | + xargs mkdir -p + +# Run GNU make from the build directory. +$MAKE -f ../$_mp_makefile "$@" diff --git a/make+-skeleton b/make+-skeleton new file mode 100755 index 0000000..2c99287 --- /dev/null +++ b/make+-skeleton @@ -0,0 +1,135 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +set -e + +# Check that either MAKEPLUS_HOME or /etc/make+.conf exists, and run it. +if [ "x$MAKEPLUS_HOME" = "x" ]; then + for d in /etc /usr/etc /usr/local/etc; do + if [ -f $d/make+.conf ]; then + . $d/make+.conf + break + fi + done +fi + +# Overwrite 'configure' with the latest version. This file is never +# important, even in autoconf-based installations. +cp $MAKEPLUS_HOME/configure . +chmod 0755 configure + +# Check 'Makefile+' does not exist in the current directory. +if [ -f "Makefile+" ]; then + echo "There is already a file 'Makefile+' in the current directory." + echo "I won't overwrite this file. Remove this file and rerun me." + exit 1 +fi + +# Get the name of the package. +echo -n "What is the name of your package? " +read PACKAGE + +# Get the version number. +echo +echo "Now I'm going to ask you for the initial version number for this" +echo "package. Version numbers have two parts: the MAJOR part and the" +echo "MINOR part." +echo +echo "The MAJOR part is a single number (eg 3). It is used (for example)" +echo "for versioning libraries." +echo +echo "The MINOR part is two numbers separated by a single DOT (eg 1.0)" +echo "This is the incremental release of the library." +echo +echo "If you library is version 3.1.0 then the MAJOR part would be" +echo " 3" +echo "and the MINOR part would be" +echo " 1.0" +echo + +echo -n "What is the MAJOR part of the version? " +read VERSION_MAJOR + +echo -n "What is the MINOR part of the version? " +read VERSION_MINOR + +# Create the Makefile+ file. + +cat > Makefile+ < +XXX PUT YOUR WEBSITE HERE. IF YOU DON\'T WANT TO MANAGE A WEBSITE WITH +XXX MAKE+ THEN JUST DELETE THIS SECTION AND THE upload_website RULE. + +endef + +upload_website: + scp \$(PACKAGE)-\$(VERSION).tar.gz \$(PACKAGE)-\$(VERSION)-1.*.rpm \\ + \$(PACKAGE)-\$(VERSION).bin.tar.gz \\ + you@yourmachine.example.com:/var/www/html/\$(PACKAGE)/files + scp index.html you@yourmachine.example.com:/var/www/html/\$(PACKAGE)/ + +.PHONY: build configure test upload_website +EOF + +echo +echo "I've written a Makefile+ file for you. You'll need to edit this file." +echo "Start by searching for all the 'XXX's and replacing them as necessary." diff --git a/make_rpm_spec.sh b/make_rpm_spec.sh new file mode 100755 index 0000000..458ec6f --- /dev/null +++ b/make_rpm_spec.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +# This RPM builder is not very smart at the moment. It should know more +# about libraries and building separate -devel and -doc packages at least. + +set -e + +manifest=$1; shift + +cat <. +# +# 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. + +set -e + +cat <. +# +# 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. + +set -e + +make+ clean ||: +./configure --prefix=/usr --sysconfdir=/etc +make+ all dist bindist rpm mp_website upload_website diff --git a/rpm.mk b/rpm.mk new file mode 100644 index 0000000..fba356d --- /dev/null +++ b/rpm.mk @@ -0,0 +1,36 @@ +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +# Build an RPM +rpm: mp-rpm.spec + @rm -rf mp-rpm + @mkdir mp-rpm + @mkdir mp-rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS} + @mkdir mp-rpm/RPMS/{i386,i486,i586,i686,noarch} + $(MAKE) -f $(srcdir)/$(_mp_makefile) \ + MP_SRC_DIST=mp-rpm/SOURCES/$(PACKAGE)-$(VERSION).tar.gz dist + @cp mp-rpm.spec mp-rpm/SPECS/$(PACKAGE)-$(VERSION).spec + rpmbuild -ba --define _topdir\ `pwd`/mp-rpm --clean \ + mp-rpm/SPECS/$(PACKAGE)-$(VERSION).spec + @mv mp-rpm/RPMS/*/*.rpm mp-rpm/SRPMS/*.rpm . + @rm -rf mp-rpm mp-rpm.spec + +# Build the spec file. +mp-rpm.spec: $(srcdir)/$(_mp_makefile) + $(MAKE) -f $< prefix=/usr sysconfdir=/etc localstatedir=/var \ + MP_BIN_MANIFEST=mp-MANIFEST.bin mp_manifest_bin + $(MAKEPLUS_HOME)/make_rpm_spec.sh mp-MANIFEST.bin > $@ + @rm mp-MANIFEST.bin + +.PHONY: rpm \ No newline at end of file diff --git a/run_tests.sh b/run_tests.sh new file mode 100644 index 0000000..e62f2d5 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +set -e + +total=0 +failed=0 + +for f in "$@"; do + total=`expr $total + 1` + echo "$f:" + ./"$f" || failed=`expr $failed + 1` +done + +if [ $failed -gt 0 ]; then + echo "Failed tests: $failed/$total" + exit 1 +else + echo "All tests completed successfully." +fi diff --git a/test.mk b/test.mk new file mode 100644 index 0000000..7a64af8 --- /dev/null +++ b/test.mk @@ -0,0 +1,15 @@ +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +MP_RUN_TESTS = $(MAKEPLUS_HOME)/run_tests.sh diff --git a/website.mk b/website.mk new file mode 100644 index 0000000..0bf0c21 --- /dev/null +++ b/website.mk @@ -0,0 +1,30 @@ +# This is make+. Make+ is a set of scripts which enhance GNU make and +# let ou build RPMs, and other packages types with just one control +# file. Read more at http://www.annexia.org/freeware/makeplus/ +# +# The original author is Richard W.M. Jones . +# +# 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. + +# This module contains code for building a website and uploading +# a whole release (source, binary, RPMs, website, etc.) to your server. + +# mp_release is the main target. It builds everything and uploads it. +# The only thing you need to do is change the version number before +# running it. +mp_release: + cd $(srcdir) && $(MAKEPLUS_HOME)/release.sh + +# This target just rebuilds the website (index.html). +mp_website: index.html + +index.html: $(srcdir)/$(_mp_makefile) + $(MAKEPLUS_HOME)/make_website.sh > $@ + +.PHONY: mp_release mp_website -- 1.8.3.1