From a2441ac8c77d09651f4418bdb96bffea43066108 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Wed, 22 Mar 2000 11:16:03 +0100
Subject: [PATCH] patch::: 1.3.37.jcn2

1.3.37.jcn2
===========

* Fixed srcdir build, so that you can do:

      tar xzf releases/lilypond-x.y.z
      mkdir <build>
      cd <build>
      ../lilypond-x.y.z/configure
      make

  as with any other gnu package.  All build output goes to <build>/out.

* Changed and fixed use of different configurations, and different output
  directories.  Finally, you can use different configurations alongside
  eachother.  From make/stepmake.make:

      # Use alternate configurations alongside eachother:
      #
      #     ./configure --enable-configsuffix=debug
      #     make conf=debug
      #
      # uses config-debug.make and config-debug.h; output goes to out-debug.
      #

      # Use same configuration, but different output directory:
      #
      #     make out=WWW
      #
      # uses config.make and config.h; output goes to out-WWW.
      #
---
 CHANGES                                   | 32 ++++++++++++
 VERSION                                   |  2 +-
 aclocal.m4                                | 61 +++++++++++++++--------
 buildscripts/set-lily.sh                  |  4 +-
 config.make.in                            |  2 +
 lily/GNUmakefile                          |  2 -
 ly/params.ly                              | 10 ++--
 make/mutopia-targets.make                 |  2 +-
 make/srcdir.make.in                       | 43 ++++++++++++++++
 make/stepmake.make                        | 48 +++++++++++++++---
 make/toplevel.make.in                     | 10 ++--
 stepmake/CHANGES                          |  3 ++
 stepmake/aclocal.m4                       | 59 +++++++++++++++-------
 stepmake/config.make.in                   |  2 +
 stepmake/configure.in                     |  2 +-
 stepmake/make/srcdir.make.in              | 43 ++++++++++++++++
 stepmake/make/stepmake.make               | 48 +++++++++++++++---
 stepmake/stepmake/c++-vars.make           |  3 +-
 stepmake/stepmake/executable-targets.make |  2 +-
 stepmake/stepmake/executable-vars.make    |  3 +-
 stepmake/stepmake/generic-targets.make    |  9 ++--
 stepmake/stepmake/generic-vars.make       |  3 +-
 stepmake/stepmake/library-targets.make    |  4 +-
 stepmake/stepmake/toplevel-targets.make   |  2 +-
 24 files changed, 315 insertions(+), 84 deletions(-)
 create mode 100644 make/srcdir.make.in
 create mode 100644 stepmake/make/srcdir.make.in

diff --git a/CHANGES b/CHANGES
index 48793fd84a..d0aa853b82 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,35 @@
+1.3.37.jcn2
+===========
+
+* Fixed srcdir build, so that you can do:
+
+      tar xzf releases/lilypond-x.y.z
+      mkdir <build>
+      cd <build>
+      ../lilypond-x.y.z/configure
+      make
+
+  as with any other gnu package.  All build output goes to <build>/out.
+
+* Changed and fixed use of different configurations, and different output
+  directories.  Finally, you can use different configurations alongside
+  eachother.  From make/stepmake.make:
+
+      # Use alternate configurations alongside eachother:
+      #
+      #     ./configure --enable-configsuffix=debug
+      #     make conf=debug
+      #
+      # uses config-debug.make and config-debug.h; output goes to out-debug.
+      #
+
+      # Use same configuration, but different output directory:
+      #
+      #     make out=WWW
+      #
+      # uses config.make and config.h; output goes to out-WWW.
+      #
+
 1.3.37.jcn1
 ===========
 
diff --git a/VERSION b/VERSION
index bda133cd29..5289c4ce6a 100644
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
 PATCH_LEVEL=37
-MY_PATCH_LEVEL=jcn1
+MY_PATCH_LEVEL=jcn2
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
diff --git a/aclocal.m4 b/aclocal.m4
index 92908e0e0a..53d9704aed 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,9 +1,3 @@
-dnl WARNING WARNING WARNING WARNING
-dnl do not edit! this is aclocal.m4, generated from stepmake/aclocal.m4
-dnl WARNING WARNING WARNING WARNING
-dnl do not edit! this is aclocal.m4, generated from stepmake/aclocal.m4
-dnl WARNING WARNING WARNING WARNING
-dnl do not edit! this is aclocal.m4, generated from stepmake/aclocal.m4
 dnl aclocal.m4   -*-shell-script-*-
 dnl StepMake subroutines for configure.in
 
@@ -138,9 +132,14 @@ AC_DEFUN(AC_STEPMAKE_DATADIR, [
 AC_DEFUN(AC_STEPMAKE_END, [
     AC_OUTPUT($CONFIGFILE.make:config.make.in)
 
-    rm -f GNUmakefile
-    cp make/toplevel.make.in ./GNUmakefile
-    chmod 444 GNUmakefile
+    rm -f $srcdir/GNUmakefile
+    cp $srcdir/make/toplevel.make.in $srcdir/GNUmakefile
+    chmod 444 $srcdir/GNUmakefile
+    if test "$builddir" != "."; then
+        rm -f GNUmakefile
+    	cp $srcdir/make/srcdir.make.in GNUmakefile
+    	chmod 444 GNUmakefile
+    fi
 ])
 
 AC_DEFUN(AC_STEPMAKE_GXX, [
@@ -192,19 +191,43 @@ AC_DEFUN(AC_STEPMAKE_INIT, [
     AC_MSG_CHECKING(Package)
     if test "x$PACKAGE" = "xSTEPMAKE"; then
 	AC_MSG_RESULT(Stepmake package!)
-	(cd stepmake; rm -f stepmake; ln -s ../stepmake .)
-	(cd stepmake; rm -f bin; ln -s ../bin .)
+
+	#if test "x$builddir" != "x"; then
+	#    builddir="../$builddir"
+	#else
+	#    builddir=..
+	#fi
+	if test "$srcdir" != "."; then
+	    absolute_builddir="`pwd`"
+	    package_absolute_builddir="`dirname $absolute_builddir`"
+	    package_srcdir="`dirname  $srcdir`"
+	    builddir="`dirname $package_srcdir`/`basename $package_absolute_builddir`/`basename $absolute_builddir`"
+	else
+	    builddir=.
+	fi
+
+	(cd stepmake 2>/dev/null || mkdir stepmake)
+	(cd stepmake; rm -f stepmake; ln -s ../$srcdir/stepmake .)
+	(cd stepmake; rm -f bin; ln -s ../$srcdir/bin .)
 	AC_CONFIG_AUX_DIR(bin)
 	stepmake=stepmake
     else
         AC_MSG_RESULT($PACKAGE)
+
+	if test "$srcdir" != "."; then
+	    absolute_builddir="`pwd`"
+	    builddir="`dirname  $srcdir`/`basename $absolute_builddir`"
+	else
+	    builddir=.
+	fi
+
 	AC_MSG_CHECKING(for stepmake)
 	# Check for installed stepmake
 	if test -d $stepmake; then
 	    AC_MSG_RESULT($stepmake)
 	else
-	    stepmake='$(depth)'/stepmake
-	    AC_MSG_RESULT(./stepmake  ($datadir/stepmake not found))
+	    stepmake='$(depth)'/$srcdir/stepmake
+	    AC_MSG_RESULT($srcdir/stepmake  ($datadir/stepmake not found))
 	fi
 	AC_CONFIG_AUX_DIR(\
 	  $HOME/usr/local/share/stepmake/bin\
@@ -216,9 +239,11 @@ AC_DEFUN(AC_STEPMAKE_INIT, [
 	  /usr/share/stepmake/bin\
 	  /usr/lib/stepmake/bin\
 	  stepmake/bin\
+	  $srcdir/stepmake/bin\
 	)
     fi
 
+    AC_SUBST(builddir)
     AC_SUBST(stepmake)
     AC_SUBST(package)
     AC_SUBST(PACKAGE)
@@ -236,8 +261,6 @@ AC_DEFUN(AC_STEPMAKE_INIT, [
 
     AUTOGENERATE="This file was automatically generated by configure"
     AC_SUBST(AUTOGENERATE)
-    absolute_builddir="`pwd`"
-    AC_SUBST(absolute_builddir)
 
     STATE_VECTOR=`ls make/STATE-VECTOR 2>/dev/null`
     if test "x$STATE_VECTOR" != "x"; then
@@ -248,13 +271,9 @@ AC_DEFUN(AC_STEPMAKE_INIT, [
     CONFIGSUFFIX=
     AC_ARG_ENABLE(config,
     [  enable-config=FILE      put configure settings in config-FILE.make],
-    [CONFIGSUFFIX=$enableval])
+    [CONFIGSUFFIX=-$enableval])
 
-    if test "$CONFIGSUFFIX" != "" ; then
-	CONFIGFILE=config-$CONFIGSUFFIX
-    else
-	CONFIGFILE=config
-    fi
+    CONFIGFILE=config$CONFIGSUFFIX
     AC_SUBST(CONFIGSUFFIX)
      
     AC_CANONICAL_HOST
diff --git a/buildscripts/set-lily.sh b/buildscripts/set-lily.sh
index 7383d63087..fad30f18d3 100755
--- a/buildscripts/set-lily.sh
+++ b/buildscripts/set-lily.sh
@@ -100,5 +100,5 @@ echo Starting configuration
 echo
 (set -x; TEX_TFMDIR=$TEX_TFMDIR ./configure --prefix=$prefix --enable-debugging --enable-printing --enable-checking --disable-optimise)
 
-echo "making tags in background"
-make TAGS >& log &
+echo "Making tags in background..."
+make TAGS > /dev/null 2>&1 &
diff --git a/config.make.in b/config.make.in
index 91b7accc01..a0d9338300 100644
--- a/config.make.in
+++ b/config.make.in
@@ -21,8 +21,10 @@ CONFIGSUFFIX = @CONFIGSUFFIX@
 MAKEINFO = @MAKEINFO@
 ICFLAGS = @ICFLAGS@
 ILDFLAGS = @ILDFLAGS@
+builddir = @builddir@
 libdir = @libdir@
 prefix = @prefix@
+srcdir = @srcdir@
 TEXPREFIX = @TEXPREFIX@
 TEXDIR = @TEXDIR@
 MFDIR = @MFDIR@
diff --git a/lily/GNUmakefile b/lily/GNUmakefile
index 37456760c9..16218df88e 100644
--- a/lily/GNUmakefile
+++ b/lily/GNUmakefile
@@ -21,5 +21,3 @@ $(outdir)/my-lily-lexer.o: $(outdir)/parser.hh
 $(outdir)/lexer.o: $(outdir)/parser.hh
 $(outdir)/lily-version.o: $(outdir)/version.hh
 
-
-
diff --git a/ly/params.ly b/ly/params.ly
index a0f86cdf28..e0382e13e8 100644
--- a/ly/params.ly
+++ b/ly/params.ly
@@ -51,21 +51,23 @@ space):
 
                = arithmetic_multiplier * arithmetic_basicspace
 
-   { choose: arithmetic_multiplier = 0.9*quartwidth (why?)}
+   { choose: arithmetic_multiplier = 1.0*quartwidth (why?)}
 
-               = 0.9*quartwidth * arithmetic_basicspace
+               = quartwidth * arithmetic_basicspace
 
    =>	       
 
-   arithmetic_basicspace = 2/0.9 = 2.2
+   arithmetic_basicspace = 2/1 = 2
 
 If you want to space your music wider, use something like:
 
    arithmetic_basicspace = 4.;
 
 %}
+% We use 0.9*\quartwidth, because 1.0 seems to wide.
+% We don't adjust arithmetic_basicspace accordingly (why not?)
 arithmetic_multiplier = 0.9 * \quartwidth ;
-arithmetic_basicspace = 2.2;
+arithmetic_basicspace = 2.0;
 
 
 #'Stem_tremolo::beam-width = 1.5 * \quartwidth ; 
diff --git a/make/mutopia-targets.make b/make/mutopia-targets.make
index 769b7ab8fe..15a0e4cf73 100644
--- a/make/mutopia-targets.make
+++ b/make/mutopia-targets.make
@@ -7,7 +7,7 @@ local-WWW: $(ly_examples) $(fly_examples) $(ps_examples) $(png_examples)
 #	$(footify) $(outdir)/index.html
 
 local-web:
-	$(MAKE) CONFIGSUFFIX=www local-WWW
+	$(MAKE) conf=www local-WWW
 
 convert-mudela: local-convert-mudela
 	$(LOOP)
diff --git a/make/srcdir.make.in b/make/srcdir.make.in
new file mode 100644
index 0000000000..3b460a7989
--- /dev/null
+++ b/make/srcdir.make.in
@@ -0,0 +1,43 @@
+# -*-Makefile-*-
+# specific srcdir makefile for LilyPond  
+
+depth=.
+
+# Don't try to outsmart us, you puny computer!
+ifeq (0,${MAKELEVEL})
+  MAKE:=$(MAKE) --no-builtin-rules
+endif
+
+# Use alternate configurations alongside eachother:
+#
+#     ./configure --enable-configsuffix=debug
+#     make conf=debug
+#
+# uses config-debug.make and config-debug.h; output goes to out-debug.
+#
+ifdef conf
+  CONFIGSUFFIX=-$(conf)
+endif
+
+# Use same configuration, but different output directory:
+#
+#     make out=WWW
+#
+# uses config.make and config.h; output goes to out-WWW.
+#
+ifdef out
+  outbase=out-$(out)
+else
+  outbase=out$(CONFIGSUFFIX)
+endif
+
+config = config$(CONFIGSUFFIX).make
+
+include $(config)
+
+SRCDIR=$(MAKE) -C $(srcdir) builddir=$(builddir) $@
+
+default: all
+
+%:
+	$(SRCDIR)
diff --git a/make/stepmake.make b/make/stepmake.make
index 47b5cd6a90..c43fd0ffd6 100644
--- a/make/stepmake.make
+++ b/make/stepmake.make
@@ -8,24 +8,56 @@ ifeq (0,${MAKELEVEL})
 endif
 .SUFFIXES:
 
+# Use alternate configurations alongside eachother:
+#
+#     ./configure --enable-configsuffix=debug
+#     make conf=debug
+#
+# uses config-debug.make and config-debug.h; output goes to out-debug.
+#
+ifdef conf
+  CONFIGSUFFIX=-$(conf)
+endif
 
-ifndef config
-  configuration=config
+# Use same configuration, but different output directory:
+#
+#     make out=WWW
+#
+# uses config.make and config.h; output goes to out-WWW.
+#
+ifdef out
+  outbase=out-$(out)
 else
-  configuration=config-$(config)
+  outbase=out$(CONFIGSUFFIX)
 endif
 
-include $(depth)/$(configuration).make
+ifdef config
+  configuration=$(config)
+else
+  ifeq ($(builddir),.)
+    configuration=$(depth)/config$(CONFIGSUFFIX).make
+  else
+    # user package
+    configuration=$(depth)/$(builddir)/config$(CONFIGSUFFIX).make
+    # stepmake package
+    #configuration=$(depth)/../$(builddir)/stepmake/config$(CONFIGSUFFIX).make
+  endif
+endif
 
-ifdef CONFIGSUFFIX
-outdir=out-$(CONFIGSUFFIX)
+include $(configuration)
+
+ifeq ($(builddir),.)
+  outroot=.
 else
-outdir=out
+  outroot=$(depth)/$(builddir)/$(patsubst $(shell cd $(depth); pwd)%,%,$(shell cd .; pwd))
 endif
 
+outdir=$(outroot)/$(outbase)
+config_h=$(depth)/$(builddir)/config$(CONFIGSUFFIX).h
+
 # user package
 stepdir = $(stepmake)/stepmake
-# for stepmake packageg
+# for stepmake package
 # stepdir = $(depth)/stepmake
 
 STEPMAKE_TEMPLATES := generic $(STEPMAKE_TEMPLATES) 
diff --git a/make/toplevel.make.in b/make/toplevel.make.in
index c8a102b841..08713d0059 100644
--- a/make/toplevel.make.in
+++ b/make/toplevel.make.in
@@ -9,7 +9,7 @@ depth = .
 # descent order into subdirectories:
 #
 SUBDIRS = scripts buildscripts  flower lily mf midi2ly po debian \
-	Documentation ly input tex make mutopia intl stepmake\
+	Documentation ly input tex make mutopia intl $(builddir)/stepmake\
 	ps  scm
 #
 
@@ -34,16 +34,16 @@ fonts:
 
 
 htmldoc: 
-	$(MAKE) CONFIGSUFFIX='www' local-WWW
-	$(MAKE) CONFIGSUFFIX='www' -C Documentation WWW
+	$(MAKE) out='www' local-WWW
+	$(MAKE) out='www' -C Documentation WWW
 	rm -f `find . -name \*.html~ -print`
 	$(footify-all-command)
 	find `find Documentation -type d -name 'out-www'` -not -name '*dvi' -not -name '*ly' -not -name '*tex' -not -name '*.ps' -not -name 'out-www'  > wwwlist
 	tar cfz $(outdir)/htmldoc.tar.gz  `cat wwwlist` `ls *.png $(ERRORLOG)`  index.html
 
 examples:
-	$(MAKE) CONFIGSUFFIX='www' -C input WWW
-	$(MAKE) CONFIGSUFFIX='www' -C mutopia WWW
+	$(MAKE) out='www' -C input WWW
+	$(MAKE) out='www' -C mutopia WWW
 	$(footify-all-command)
 	$(PYTHON) $(buildscripts)/mutopia-index.py -o short-examples.html input/
 	$(PYTHON) $(buildscripts)/mutopia-index.py -o long-examples.html mutopia/
diff --git a/stepmake/CHANGES b/stepmake/CHANGES
index 92b1569541..980c358324 100644
--- a/stepmake/CHANGES
+++ b/stepmake/CHANGES
@@ -1,3 +1,6 @@
+pl 82
+	- allow srcdir builds
+
 pl 81
 	- Yodl-free (tm)
 	- bf: package-zet: too many symlinks
diff --git a/stepmake/aclocal.m4 b/stepmake/aclocal.m4
index d0f44c8d77..53d9704aed 100644
--- a/stepmake/aclocal.m4
+++ b/stepmake/aclocal.m4
@@ -1,7 +1,3 @@
-dnl WARNING WARNING WARNING WARNING
-dnl do not edit! this is aclocal.m4, generated from stepmake/aclocal.m4
-dnl WARNING WARNING WARNING WARNING
-dnl do not edit! this is aclocal.m4, generated from stepmake/aclocal.m4
 dnl aclocal.m4   -*-shell-script-*-
 dnl StepMake subroutines for configure.in
 
@@ -136,9 +132,14 @@ AC_DEFUN(AC_STEPMAKE_DATADIR, [
 AC_DEFUN(AC_STEPMAKE_END, [
     AC_OUTPUT($CONFIGFILE.make:config.make.in)
 
-    rm -f GNUmakefile
-    cp make/toplevel.make.in ./GNUmakefile
-    chmod 444 GNUmakefile
+    rm -f $srcdir/GNUmakefile
+    cp $srcdir/make/toplevel.make.in $srcdir/GNUmakefile
+    chmod 444 $srcdir/GNUmakefile
+    if test "$builddir" != "."; then
+        rm -f GNUmakefile
+    	cp $srcdir/make/srcdir.make.in GNUmakefile
+    	chmod 444 GNUmakefile
+    fi
 ])
 
 AC_DEFUN(AC_STEPMAKE_GXX, [
@@ -190,19 +191,43 @@ AC_DEFUN(AC_STEPMAKE_INIT, [
     AC_MSG_CHECKING(Package)
     if test "x$PACKAGE" = "xSTEPMAKE"; then
 	AC_MSG_RESULT(Stepmake package!)
-	(cd stepmake; rm -f stepmake; ln -s ../stepmake .)
-	(cd stepmake; rm -f bin; ln -s ../bin .)
+
+	#if test "x$builddir" != "x"; then
+	#    builddir="../$builddir"
+	#else
+	#    builddir=..
+	#fi
+	if test "$srcdir" != "."; then
+	    absolute_builddir="`pwd`"
+	    package_absolute_builddir="`dirname $absolute_builddir`"
+	    package_srcdir="`dirname  $srcdir`"
+	    builddir="`dirname $package_srcdir`/`basename $package_absolute_builddir`/`basename $absolute_builddir`"
+	else
+	    builddir=.
+	fi
+
+	(cd stepmake 2>/dev/null || mkdir stepmake)
+	(cd stepmake; rm -f stepmake; ln -s ../$srcdir/stepmake .)
+	(cd stepmake; rm -f bin; ln -s ../$srcdir/bin .)
 	AC_CONFIG_AUX_DIR(bin)
 	stepmake=stepmake
     else
         AC_MSG_RESULT($PACKAGE)
+
+	if test "$srcdir" != "."; then
+	    absolute_builddir="`pwd`"
+	    builddir="`dirname  $srcdir`/`basename $absolute_builddir`"
+	else
+	    builddir=.
+	fi
+
 	AC_MSG_CHECKING(for stepmake)
 	# Check for installed stepmake
 	if test -d $stepmake; then
 	    AC_MSG_RESULT($stepmake)
 	else
-	    stepmake='$(depth)'/stepmake
-	    AC_MSG_RESULT(./stepmake  ($datadir/stepmake not found))
+	    stepmake='$(depth)'/$srcdir/stepmake
+	    AC_MSG_RESULT($srcdir/stepmake  ($datadir/stepmake not found))
 	fi
 	AC_CONFIG_AUX_DIR(\
 	  $HOME/usr/local/share/stepmake/bin\
@@ -214,9 +239,11 @@ AC_DEFUN(AC_STEPMAKE_INIT, [
 	  /usr/share/stepmake/bin\
 	  /usr/lib/stepmake/bin\
 	  stepmake/bin\
+	  $srcdir/stepmake/bin\
 	)
     fi
 
+    AC_SUBST(builddir)
     AC_SUBST(stepmake)
     AC_SUBST(package)
     AC_SUBST(PACKAGE)
@@ -234,8 +261,6 @@ AC_DEFUN(AC_STEPMAKE_INIT, [
 
     AUTOGENERATE="This file was automatically generated by configure"
     AC_SUBST(AUTOGENERATE)
-    absolute_builddir="`pwd`"
-    AC_SUBST(absolute_builddir)
 
     STATE_VECTOR=`ls make/STATE-VECTOR 2>/dev/null`
     if test "x$STATE_VECTOR" != "x"; then
@@ -246,13 +271,9 @@ AC_DEFUN(AC_STEPMAKE_INIT, [
     CONFIGSUFFIX=
     AC_ARG_ENABLE(config,
     [  enable-config=FILE      put configure settings in config-FILE.make],
-    [CONFIGSUFFIX=$enableval])
+    [CONFIGSUFFIX=-$enableval])
 
-    if test "$CONFIGSUFFIX" != "" ; then
-	CONFIGFILE=config-$CONFIGSUFFIX
-    else
-	CONFIGFILE=config
-    fi
+    CONFIGFILE=config$CONFIGSUFFIX
     AC_SUBST(CONFIGSUFFIX)
      
     AC_CANONICAL_HOST
diff --git a/stepmake/config.make.in b/stepmake/config.make.in
index 5eb062aaf0..7fb382ef89 100644
--- a/stepmake/config.make.in
+++ b/stepmake/config.make.in
@@ -21,8 +21,10 @@ CONFIGSUFFIX = @CONFIGSUFFIX@
 MAKEINFO = @MAKEINFO@
 ICFLAGS = @ICFLAGS@
 ILDFLAGS = @ILDFLAGS@
+builddir = @builddir@
 libdir = @libdir@
 prefix = @prefix@
+srcdir = @srcdir@
 TEXPREFIX = @TEXPREFIX@
 TEXDIR = @TEXDIR@
 MFDIR = @MFDIR@
diff --git a/stepmake/configure.in b/stepmake/configure.in
index 296e9fbae0..e4907b1a8c 100644
--- a/stepmake/configure.in
+++ b/stepmake/configure.in
@@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script.
 
 # Bootstrap the init proces.  List a file identifies your package.
 AC_INIT(make/stepmake.lsm.in)
-AC_CONFIG_HEADER($CONFIGFILE.hh:config.hh.in)
+AC_CONFIG_HEADER($CONFIGFILE.h:config.hh.in)
 
 # Bootstrap StepMake configure
 AC_STEPMAKE_INIT
diff --git a/stepmake/make/srcdir.make.in b/stepmake/make/srcdir.make.in
new file mode 100644
index 0000000000..edd1640265
--- /dev/null
+++ b/stepmake/make/srcdir.make.in
@@ -0,0 +1,43 @@
+# -*-Makefile-*-
+# specific srcdir makefile for StepMake
+
+depth=..
+
+# Don't try to outsmart us, you puny computer!
+ifeq (0,${MAKELEVEL})
+  MAKE:=$(MAKE) --no-builtin-rules
+endif
+
+# Use alternate configurations alongside eachother:
+#
+#     ./configure --enable-configsuffix=debug
+#     make conf=debug
+#
+# uses config-debug.make and config-debug.h; output goes to out-debug.
+#
+ifdef conf
+  CONFIGSUFFIX=-$(conf)
+endif
+
+# Use same configuration, but different output directory:
+#
+#     make out=WWW
+#
+# uses config.make and config.h; output goes to out-WWW.
+#
+ifdef out
+  outbase=out-$(out)
+else
+  outbase=out$(CONFIGSUFFIX)
+endif
+
+config = config$(CONFIGSUFFIX).make
+
+include $(config)
+
+SRCDIR=$(MAKE) -C $(srcdir) builddir=$(builddir) $@
+
+default: all
+
+%:
+	$(SRCDIR)
diff --git a/stepmake/make/stepmake.make b/stepmake/make/stepmake.make
index 3c7dade6d7..1130415d69 100644
--- a/stepmake/make/stepmake.make
+++ b/stepmake/make/stepmake.make
@@ -8,24 +8,56 @@ ifeq (0,${MAKELEVEL})
 endif
 .SUFFIXES:
 
+# Use alternate configurations alongside eachother:
+#
+#     ./configure --enable-configsuffix=debug
+#     make conf=debug
+#
+# uses config-debug.make and config-debug.h; output goes to out-debug.
+#
+ifdef conf
+  CONFIGSUFFIX=-$(conf)
+endif
 
-ifndef config
-  configuration=config
+# Use same configuration, but different output directory:
+#
+#     make out=WWW
+#
+# uses config.make and config.h; output goes to out-WWW.
+#
+ifdef out
+  outbase=out-$(out)
 else
-  configuration=config-$(config)
+  outbase=out$(CONFIGSUFFIX)
 endif
 
-include $(depth)/$(configuration).make
+ifdef config
+  configuration=$(config)
+else
+  ifeq ($(builddir),.)
+    configuration=$(depth)/config$(CONFIGSUFFIX).make
+  else
+    # user package
+    # configuration=$(depth)/$(builddir)/config$(CONFIGSUFFIX).make
+    # stepmake package
+    configuration=$(depth)/../$(builddir)/stepmake/config$(CONFIGSUFFIX).make
+  endif
+endif
 
-ifdef CONFIGSUFFIX
-outdir=out-$(CONFIGSUFFIX)
+include $(configuration)
+
+ifeq ($(builddir),.)
+  outroot=.
 else
-outdir=out
+  outroot=$(depth)/$(builddir)/$(patsubst $(shell cd $(depth); pwd)%,%,$(shell cd .; pwd))
 endif
 
+outdir=$(outroot)/$(outbase)
+config_h=$(depth)/$(builddir)/config$(CONFIGSUFFIX).h
+
 # user package
 # stepdir = $(stepmake)/stepmake
-# for stepmake packageg
+# for stepmake package
 stepdir = $(depth)/stepmake
 
 STEPMAKE_TEMPLATES := generic $(STEPMAKE_TEMPLATES) 
diff --git a/stepmake/stepmake/c++-vars.make b/stepmake/stepmake/c++-vars.make
index e273cc7a48..119a35b546 100644
--- a/stepmake/stepmake/c++-vars.make
+++ b/stepmake/stepmake/c++-vars.make
@@ -6,8 +6,7 @@
 # EXTRA_CXXFLAGS= -Wall -Winline -W -Wmissing-prototypes -Wmissing-declarations -Wconversion
 EXTRA_CXXFLAGS= -Wall  -W -Wmissing-prototypes -Wmissing-declarations -Wconversion
 
-
- CXXFLAGS = $(ICFLAGS) $(DEFINES) $(addprefix -I,$(INCLUDES)) $(USER_CFLAGS) $(EXTRA_CFLAGS) $(MODULE_CFLAGS) $($(PACKAGE)_CFLAGS) $($(PACKAGE)_CXXFLAGS) $(USER_CXXFLAGS) $(EXTRA_CXXFLAGS) $(MODULE_CXXFLAGS)
+CXXFLAGS = $(ICFLAGS) $(DEFINES) $(addprefix -I,$(INCLUDES)) $(USER_CFLAGS) $(EXTRA_CFLAGS) $(MODULE_CFLAGS) $($(PACKAGE)_CFLAGS) $($(PACKAGE)_CXXFLAGS) $(USER_CXXFLAGS) $(EXTRA_CXXFLAGS) $(MODULE_CXXFLAGS)
 CXX_OUTPUT_OPTION = $< -o $@
 DO_CXX_COMPILE=$(DODEP) $(CXX) -c $(CXXFLAGS) $(CXX_OUTPUT_OPTION)
 
diff --git a/stepmake/stepmake/executable-targets.make b/stepmake/stepmake/executable-targets.make
index 85d77ef212..66e33173a6 100644
--- a/stepmake/stepmake/executable-targets.make
+++ b/stepmake/stepmake/executable-targets.make
@@ -5,7 +5,7 @@
 
 default: $(EXECUTABLE)
 
-$(EXECUTABLE): $(depth)/config.h $(O_FILES) $(outdir)/version.hh
+$(EXECUTABLE): $(outdir)/config.h $(O_FILES) $(outdir)/version.hh
 	$(foreach a, $(MODULE_LIBS), $(MAKE) -C $(a) && ) true
 	$(LD_COMMAND) $(O_FILES) $(LOADLIBES) $(USER_LDFLAGS)
 
diff --git a/stepmake/stepmake/executable-vars.make b/stepmake/stepmake/executable-vars.make
index 117bfc5a5c..784f8f603f 100644
--- a/stepmake/stepmake/executable-vars.make
+++ b/stepmake/stepmake/executable-vars.make
@@ -1,5 +1,6 @@
 # empty
 LDFLAGS = $(ILDFLAGS) $(EXTRA_LDFLAGS) $(MODULE_LDFLAGS) $($(PACKAGE)_LDFLAGS)
 
-MODULE_LIBES =$(addsuffix /$(outdir)/library.a, $(MODULE_LIBS))
+## urg, silly name: library.a
+MODULE_LIBES =$(addprefix $(outdir)/../, $(addsuffix /$(outbase)/library.a, $(MODULE_LIBS)))
 LOADLIBES = $(MODULE_LIBES) $($(PACKAGE)_LIBES) $(EXTRA_LIBES)
diff --git a/stepmake/stepmake/generic-targets.make b/stepmake/stepmake/generic-targets.make
index f886881856..98e0724d1a 100644
--- a/stepmake/stepmake/generic-targets.make
+++ b/stepmake/stepmake/generic-targets.make
@@ -3,9 +3,7 @@
 
 .PHONY : all clean config default dist doc doc++  exe help html lib TAGS\
 	 po
-# VPATH=$(outdir)/		#ugh?
-# target all:
-#
+
 all:	 default
 	$(LOOP)
 
@@ -127,6 +125,9 @@ $(outdir)/VERSION: $(depth)/VERSION
 $(outdir)/version.hh: $(outdir)/VERSION
 	$(PYTHON) $(step-bindir)/make-version.py $< > $@
 
+$(outdir)/config.h: $(config_h)
+	cp $< $@
+
 # should this be in Rules?
 configure: configure.in aclocal.m4
 	autoconf 
@@ -166,7 +167,7 @@ include $(stepdir)/package.make
 include $(outdir)/dummy.dep $(DEP_FILES)
 
 $(outdir)/dummy.dep:
-	-mkdir $(outdir)
+	-mkdir -p $(outdir)
 	touch $(outdir)/dummy.dep
 
 
diff --git a/stepmake/stepmake/generic-vars.make b/stepmake/stepmake/generic-vars.make
index b9aacf192f..3fe7ed8dfb 100644
--- a/stepmake/stepmake/generic-vars.make
+++ b/stepmake/stepmake/generic-vars.make
@@ -84,7 +84,8 @@ date := $(shell date +%x)	#duplicated?
 #
 ARFLAGS = ru
 
-INCLUDES =  $(depth) include $(outdir) $($(PACKAGE)_INCLUDES) $(MODULE_INCLUDES)
+#INCLUDES =  $(depth)/$(builddir) include $(outdir) $($(PACKAGE)_INCLUDES) $(MODULE_INCLUDES)
+INCLUDES = include $(outdir) $($(PACKAGE)_INCLUDES) $(MODULE_INCLUDES)
 
 # urg: for windows ?
 # LOADLIBES = $(MODULE_LIBES) $($(PACKAGE)_LIBES) $(EXTRA_LIBES) -lstdc++
diff --git a/stepmake/stepmake/library-targets.make b/stepmake/stepmake/library-targets.make
index ce12f8ff11..ad32b20874 100644
--- a/stepmake/stepmake/library-targets.make
+++ b/stepmake/stepmake/library-targets.make
@@ -4,11 +4,11 @@
 
 default: $(LIBRARY)
 
-$(outdir)/library.a: $(depth)/config.h $(O_FILES) $(MODULE_LIBES)
+$(outdir)/library.a: $(outdir)/config.h $(O_FILES) $(MODULE_LIBES)
 	$(AR_COMMAND) $(O_FILES)
 	$(RANLIB_COMMAND)
 
-$(SHAREDLIBRARY):  $(depth)/config.h  $(O_FILES) $(MODULE_LIBES)
+$(SHAREDLIBRARY):  $(outdir)/config.h $(O_FILES) $(MODULE_LIBES)
 	$(LD_COMMAND) $(O_FILES) -o $@.$(VERSION)
 	rm -f $@
 	ln -sf $(outdir)/$(LIB_PREFIX)$(NAME).so.$(VERSION) $@.$(MAJOR_VERSION)
diff --git a/stepmake/stepmake/toplevel-targets.make b/stepmake/stepmake/toplevel-targets.make
index faf6124c8f..eb763be8af 100644
--- a/stepmake/stepmake/toplevel-targets.make
+++ b/stepmake/stepmake/toplevel-targets.make
@@ -26,7 +26,7 @@ index.html: check-top-web NEWS
 	$(sed-version) < Documentation/topdocs/$(outdir)/topweb.html > $@
 
 WWW-clean: local-WWW-clean
-	$(MAKE) CONFIGSUFFIX='www' clean
+	$(MAKE) out='www' clean
 
 local-WWW-clean:
 
-- 
2.39.5