Index: Makefile
==================================================================
--- Makefile
+++ Makefile
@@ -1,61 +1,28 @@
 #!/usr/bin/make
 #
+#### The directory in which Makefile fragments are stored.
+#
+MAKEDIR = ./make
+
 #### The toplevel directory of the source tree.  Fossil can be built
 #    in a directory that is separate from the source tree.  Just change
 #    the following to point from the build directory to the src/ folder.
 #
 SRCDIR = ./src
 
-#### The directory into which object code files should be written.
-#
+#### Any site-specific pre-defined settings go here.  Settings in this file are
+#    intended to direct the compilation below.
 #
-OBJDIR = ./obj
-
-#### C Compiler and options for use in building executables that
-#    will run on the platform that is doing the build.  This is used
-#    to compile code-generator programs as part of the build process.
-#    See TCC below for the C compiler for building the finished binary.
-#
-BCC = gcc -g -O2
+-include config.mk				# Configure if present.
+ifndef CONFIG_MK_COMPLETE
+  include $(MAKEDIR)/linux-gcc-config.mk	# Default to linux-gcc.
+endif
 
-#### The suffix to add to executable files.  ".exe" for windows.
-#    Nothing for unix.
-#
-E =
-
-#### C Compile and options for use in building executables that 
-#    will run on the target platform.  This is usually the same
-#    as BCC, unless you are cross-compiling.  This C compiler builds
-#    the finished binary for fossil.  The BCC compiler above is used
-#    for building intermediate code-generator tools.
-#
-#TCC = gcc -O6
-#TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage
-TCC = gcc -g -Os -Wall
-
-# To add support for HTTPS
-TCC += -DFOSSIL_ENABLE_SSL
-
-#### Extra arguments for linking the finished binary.  Fossil needs
-#    to link against the Z-Lib compression library.  There are no
-#    other dependencies.  We sometimes add the -static option here
-#    so that we can build a static executable that will run in a
-#    chroot jail.
-#
-LIB = -lz $(LDFLAGS)
-# If you're on OpenSolaris:
-# LIB += lsocket
-# Solaris 10 needs:
-# LIB += -lsocket -lnsl
-# My assumption is that the Sol10 flags will work for Sol8/9 and possibly 11.
-# 
-# If using HTTPS:
-LIB += -lcrypto -lssl
-
-#### Tcl shell for use in running the fossil testsuite.
+#### The Tcl shell to run for test suites.
 #
 TCLSH = tclsh
 
 # You should not need to change anything below this line
 ###############################################################################
 include $(SRCDIR)/main.mk
+

DELETED Makefile.w32
Index: Makefile.w32
==================================================================
--- Makefile.w32
+++ Makefile.w32
@@ -1,71 +0,0 @@
-#!/usr/bin/make
-#
-#### The toplevel directory of the source tree.  Fossil can be built
-#    in a directory that is separate from the source tree.  Just change
-#    the following to point from the build directory to the src/ folder.
-#
-SRCDIR = ./src
-OBJDIR = ./wobj
-
-#### C Compiler and options for use in building executables that
-#    will run on the platform that is doing the build.  This is used
-#    to compile code-generator programs as part of the build process.
-#    See TCC below for the C compiler for building the finished binary.
-#
-BCC = gcc -g -O2
-
-#### The suffix to add to executable files.  ".exe" for windows.
-#    Nothing for unix.
-#
-E = .exe
-
-#### Enable HTTPS support via OpenSSL (links to libssl and libcrypto)
-#
-# FOSSIL_ENABLE_SSL=1
-
-#### Enable HTTPS support via OpenSSL (links to libssl and libcrypto)
-#
-# FOSSIL_ENABLE_SSL=1
-
-#### C Compile and options for use in building executables that 
-#    will run on the target platform.  This is usually the same
-#    as BCC, unless you are cross-compiling.  This C compiler builds
-#    the finished binary for fossil.  The BCC compiler above is used
-#    for building intermediate code-generator tools.
-#
-#TCC = gcc -O6
-#TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage
-#TCC = gcc -g -Os -Wall
-#TCC = gcc -g -Os -Wall -DFOSSIL_I18N=0 -L/usr/local/lib -I/usr/local/include
-TCC = gcc -Os -Wall -DFOSSIL_I18N=0 -L/mingw/lib -I/mingw/include
-
-# With HTTPS support
-ifdef FOSSIL_ENABLE_SSL
-TCC += -DFOSSIL_ENABLE_SSL=1
-endif
-
-#### Extra arguments for linking the finished binary.  Fossil needs
-#    to link against the Z-Lib compression library.  There are no
-#    other dependencies.  We sometimes add the -static option here
-#    so that we can build a static executable that will run in a
-#    chroot jail.
-#
-#LIB = -lz
-#LIB = -lz -lws2_32
-LIB = -lmingwex -lz -lws2_32
-# OpenSSL:
-ifdef FOSSIL_ENABLE_SSL
-LIB += -lcrypto -lssl
-endif
-
-#### Tcl shell for use in running the fossil testsuite.
-#
-TCLSH = tclsh
-
-#### Include a configuration file that can override any one of these settings.
-#
--include config.w32
-
-# You should not need to change anything below this line
-###############################################################################
-include $(SRCDIR)/main.mk

ADDED   make/README.wiki
Index: make/README.wiki
==================================================================
--- make/README.wiki
+++ make/README.wiki
@@ -0,0 +1,14 @@
+The makefile fragments in this "new build" directory are used to provide
+platform-specific builds out-of-the-box with minimal user intervention. They are
+named as <code>PLATFORM-COMPILER-config.mk</code> and are used by copying them
+into the <cite>Fossil</cite> distribution root directory as
+<code>config.mk</code>.
+
+The file <code>linux-gcc-config.mk</code> is the default make file fragment
+brought in by the main <code>Makefile</code> if no <code>config.mk</code> file
+has been copied.
+
+Note: new platform and compiler files are always welcome additions to the
+community. In particular MacOSX build files would be nice to have as well as
+alternative compilers.
+

ADDED   make/freebsd-clang-config.mk
Index: make/freebsd-clang-config.mk
==================================================================
--- make/freebsd-clang-config.mk
+++ make/freebsd-clang-config.mk
@@ -0,0 +1,82 @@
+#### config.mk file for FreeBSD with CLANG.
+#    Copy this file as config.mk in the Fossil root directory to use.
+#    NOTE: You will need to have GNU Make installed to use this.
+#
+
+#### OS-specific configuration for building Fossil on FreeBSD systems.
+#    NOTE: You will need to have GNU Make installed to use this.
+#
+
+#### The suffix to add to executable files.  ".exe" for windows.
+#    Nothing for unix.
+#
+E =
+
+#### The directory into which object code files should be written.
+#
+OBJDIR = ./obj
+
+#### The following variable definitions decide which features are turned on or
+#    of when building Fossil.  Comment out the features which are not needed by
+#    this platform.
+#
+#ENABLE_STATIC = 1	# we want a static build
+ENABLE_SSL = 1		# we are using SSL
+#ENABLE_SOCKET = 1	# we are using libsocket (OpenSolaris and Solaris)
+#ENABLE_NSL = 1		# we are using libnsl library (Solaris)
+ENABLE_I18N = 1		# we are using i18n settings
+
+#### Compiler-specific configuration for users of the GCC compiler suite.
+#
+
+#### C Compiler and options for use in building executables that
+#    will run on the platform that is doing the build.  This is used
+#    to compile code-generator programs as part of the build process.
+#    See TCC below for the C compiler for building the finished binary.
+#
+BCC = clang -g -O2
+
+#### C Compile and options for use in building executables that
+#    will run on the target platform.  This is usually the same
+#    as BCC, unless you are cross-compiling.  This C compiler builds
+#    the finished binary for fossil.  The BCC compiler above is used
+#    for building intermediate code-generator tools.
+#
+TCC = clang -g -Os -Wall
+
+#### Compiler options.
+#    The variables tested are defined in the make/PLATFORM-fragment.mk files.
+#
+ifdef ENABLE_SSL
+  TCC += -DFOSSIL_ENABLE_SSL=1
+endif
+ifndef ENABLE_I18N
+  TCC += -DFOSSIL_I18N=0
+endif
+
+#### Linker dependencies.  Fossil only requires libz as an external dependency.
+#    All other library settings are optional and toggled in platform-specific
+#    make fragments.
+#
+LIB = -lz $(LDFLAGS)
+
+#### Linker options.
+#    The variables tested are defined in the make/PLATFORM-fragment.mk files.
+#
+ifdef ENABLE_STATIC
+  LIB += -static
+endif
+ifdef ENABLE_SSL
+  LIB += -lcrypto -lssl
+endif
+ifdef ENABLE_SOCKET
+  LIB += -lsocket
+endif
+ifdef ENABLE_NSL
+  LIB += -lnsl
+endif
+
+#### Signal that we've used a config.mk file.
+#
+CONFIG_MK_COMPLETE=1
+

ADDED   make/freebsd-gcc-config.mk
Index: make/freebsd-gcc-config.mk
==================================================================
--- make/freebsd-gcc-config.mk
+++ make/freebsd-gcc-config.mk
@@ -0,0 +1,82 @@
+#### config.mk file for FreeBSD with GCC.
+#    Copy this file as config.mk in the Fossil root directory to use.
+#    NOTE: You will need to have GNU Make installed to use this.
+#
+
+#### OS-specific configuration for building Fossil on FreeBSD systems.
+#    NOTE: You will need to have GNU Make installed to use this.
+#
+
+#### The suffix to add to executable files.  ".exe" for windows.
+#    Nothing for unix.
+#
+E =
+
+#### The directory into which object code files should be written.
+#
+OBJDIR = ./obj
+
+#### The following variable definitions decide which features are turned on or
+#    of when building Fossil.  Comment out the features which are not needed by
+#    this platform.
+#
+#ENABLE_STATIC = 1	# we want a static build
+ENABLE_SSL = 1		# we are using SSL
+#ENABLE_SOCKET = 1	# we are using libsocket (OpenSolaris and Solaris)
+#ENABLE_NSL = 1		# we are using libnsl library (Solaris)
+ENABLE_I18N = 1		# we are using i18n settings
+
+#### Compiler-specific configuration for users of the GCC compiler suite.
+#
+
+#### C Compiler and options for use in building executables that
+#    will run on the platform that is doing the build.  This is used
+#    to compile code-generator programs as part of the build process.
+#    See TCC below for the C compiler for building the finished binary.
+#
+BCC = gcc -g -O2
+
+#### C Compile and options for use in building executables that
+#    will run on the target platform.  This is usually the same
+#    as BCC, unless you are cross-compiling.  This C compiler builds
+#    the finished binary for fossil.  The BCC compiler above is used
+#    for building intermediate code-generator tools.
+#
+TCC = gcc -g -Os -Wall
+
+#### Compiler options.
+#    The variables tested are defined in the make/PLATFORM-fragment.mk files.
+#
+ifdef ENABLE_SSL
+  TCC += -DFOSSIL_ENABLE_SSL=1
+endif
+ifndef ENABLE_I18N
+  TCC += -DFOSSIL_I18N=0
+endif
+
+#### Linker dependencies.  Fossil only requires libz as an external dependency.
+#    All other library settings are optional and toggled in platform-specific
+#    make fragments.
+#
+LIB = -lz $(LDFLAGS)
+
+#### Linker options.
+#    The variables tested are defined in the make/PLATFORM-fragment.mk files.
+#
+ifdef ENABLE_STATIC
+  LIB += -static
+endif
+ifdef ENABLE_SSL
+  LIB += -lcrypto -lssl
+endif
+ifdef ENABLE_SOCKET
+  LIB += -lsocket
+endif
+ifdef ENABLE_NSL
+  LIB += -lnsl
+endif
+
+#### Signal that we've used a config.mk file.
+#
+CONFIG_MK_COMPLETE=1
+

ADDED   make/linux-clang-config.mk
Index: make/linux-clang-config.mk
==================================================================
--- make/linux-clang-config.mk
+++ make/linux-clang-config.mk
@@ -0,0 +1,80 @@
+#### config.mk file for Linux with CLANG.
+#    Copy this file as config.mk in the Fossil root directory to use.
+#
+
+#### OS-specific configuration for building Fossil on Linux systems.
+#
+
+#### The suffix to add to executable files.  ".exe" for windows.
+#    Nothing for unix.
+#
+E =
+
+#### The directory into which object code files should be written.
+#
+OBJDIR = ./obj
+
+#### The following variable definitions decide which features are turned on or
+#    of when building Fossil.  Comment out the features which are not needed by
+#    this platform.
+#
+#ENABLE_STATIC = 1	# we want a static build
+ENABLE_SSL = 1		# we are using SSL
+#ENABLE_SOCKET = 1	# we are using libsocket (OpenSolaris and Solaris)
+#ENABLE_NSL = 1		# we are using libnsl library (Solaris)
+ENABLE_I18N = 1		# we are using i18n settings
+
+#### Compiler-specific configuration for users of the CLANG compiler suite.
+#
+
+#### C Compiler and options for use in building executables that
+#    will run on the platform that is doing the build.  This is used
+#    to compile code-generator programs as part of the build process.
+#    See TCC below for the C compiler for building the finished binary.
+#
+BCC = clang -g -O2
+
+#### C Compile and options for use in building executables that
+#    will run on the target platform.  This is usually the same
+#    as BCC, unless you are cross-compiling.  This C compiler builds
+#    the finished binary for fossil.  The BCC compiler above is used
+#    for building intermediate code-generator tools.
+#
+TCC = clang -g -Os -Wall
+
+#### Compiler options.
+#    The variables tested are defined in the make/PLATFORM-fragment.mk files.
+#
+ifdef ENABLE_SSL
+  TCC += -DFOSSIL_ENABLE_SSL=1
+endif
+ifndef ENABLE_I18N
+  TCC += -DFOSSIL_I18N=0
+endif
+
+#### Linker dependencies.  Fossil only requires libz as an external dependency.
+#    All other library settings are optional and toggled in platform-specific
+#    make fragments.
+#
+LIB = -lz $(LDFLAGS)
+
+#### Linker options.
+#    The variables tested are defined in the make/PLATFORM-fragment.mk files.
+#
+ifdef ENABLE_STATIC
+  LIB += -static
+endif
+ifdef ENABLE_SSL
+  LIB += -lcrypto -lssl
+endif
+ifdef ENABLE_SOCKET
+  LIB += -lsocket
+endif
+ifdef ENABLE_NSL
+  LIB += -lnsl
+endif
+
+#### Signal that we've used a config.mk file.
+#
+CONFIG_MK_COMPLETE=1
+

ADDED   make/linux-gcc-config.mk
Index: make/linux-gcc-config.mk
==================================================================
--- make/linux-gcc-config.mk
+++ make/linux-gcc-config.mk
@@ -0,0 +1,81 @@
+#### config.mk file for Linux with GCC.
+#    Copy this file as config.mk in the Fossil root directory to use.
+#    Note that this is the default configuration for the build system.
+#
+
+#### OS-specific configuration for building Fossil on Linux systems.
+#
+
+#### The suffix to add to executable files.  ".exe" for windows.
+#    Nothing for unix.
+#
+E =
+
+#### The directory into which object code files should be written.
+#
+OBJDIR = ./obj
+
+#### The following variable definitions decide which features are turned on or
+#    of when building Fossil.  Comment out the features which are not needed by
+#    this platform.
+#
+#ENABLE_STATIC = 1	# we want a static build
+ENABLE_SSL = 1		# we are using SSL
+#ENABLE_SOCKET = 1	# we are using libsocket (OpenSolaris and Solaris)
+#ENABLE_NSL = 1		# we are using libnsl library (Solaris)
+ENABLE_I18N = 1		# we are using i18n settings
+
+#### Compiler-specific configuration for users of the GCC compiler suite.
+#
+
+#### C Compiler and options for use in building executables that
+#    will run on the platform that is doing the build.  This is used
+#    to compile code-generator programs as part of the build process.
+#    See TCC below for the C compiler for building the finished binary.
+#
+BCC = gcc -g -O2
+
+#### C Compile and options for use in building executables that
+#    will run on the target platform.  This is usually the same
+#    as BCC, unless you are cross-compiling.  This C compiler builds
+#    the finished binary for fossil.  The BCC compiler above is used
+#    for building intermediate code-generator tools.
+#
+TCC = gcc -g -Os -Wall
+
+#### Compiler options.
+#    The variables tested are defined in the make/PLATFORM-fragment.mk files.
+#
+ifdef ENABLE_SSL
+  TCC += -DFOSSIL_ENABLE_SSL=1
+endif
+ifndef ENABLE_I18N
+  TCC += -DFOSSIL_I18N=0
+endif
+
+#### Linker dependencies.  Fossil only requires libz as an external dependency.
+#    All other library settings are optional and toggled in platform-specific
+#    make fragments.
+#
+LIB = -lz $(LDFLAGS)
+
+#### Linker options.
+#    The variables tested are defined in the make/PLATFORM-fragment.mk files.
+#
+ifdef ENABLE_STATIC
+  LIB += -static
+endif
+ifdef ENABLE_SSL
+  LIB += -lcrypto -lssl
+endif
+ifdef ENABLE_SOCKET
+  LIB += -lsocket
+endif
+ifdef ENABLE_NSL
+  LIB += -lnsl
+endif
+
+#### Signal that we've used a config.mk file.
+#
+CONFIG_MK_COMPLETE=1
+

ADDED   make/mingw32-gcc-config.mk
Index: make/mingw32-gcc-config.mk
==================================================================
--- make/mingw32-gcc-config.mk
+++ make/mingw32-gcc-config.mk
@@ -0,0 +1,98 @@
+#### config.mk file for MinGW32.
+#    Copy this file as config.mk in the Fossil root directory to use.
+#
+
+#### OS-specific configuration for building Fossil on MingGW32 systems.
+#
+
+#### The suffix to add to executable files.
+#
+E = .exe
+
+#### The directory into which object code files should be written.
+#
+OBJDIR = ./wobj
+
+#### MinGW32 can only support the GCC compiler.  Force this.
+#
+COMPILER = gcc
+
+#### The following variable definitions decide which features are turned on or
+#    of when building Fossil.  Comment out the features which are not needed by
+#    this platform.
+#
+ENABLE_STATIC = 1	# we want a static build
+#ENABLE_SSL = 1		# we are using SSL
+#ENABLE_SOCKET = 1	# we are using libsocket (OpenSolaris and Solaris)
+#ENABLE_NSL = 1		# we are using libnsl library (Solaris)
+#ENABLE_I18N = 1	# we are using i18n settings
+
+#### Compiler-specific configuration for users of the GCC compiler suite.
+#
+
+#### C Compiler and options for use in building executables that
+#    will run on the platform that is doing the build.  This is used
+#    to compile code-generator programs as part of the build process.
+#    See TCC below for the C compiler for building the finished binary.
+#
+BCC = gcc -g -O2
+
+#### C Compile and options for use in building executables that
+#    will run on the target platform.  This is usually the same
+#    as BCC, unless you are cross-compiling.  This C compiler builds
+#    the finished binary for fossil.  The BCC compiler above is used
+#    for building intermediate code-generator tools.
+#
+TCC = gcc -g -Os -Wall
+
+#### Compiler options.
+#    The variables tested are defined in the make/PLATFORM-fragment.mk files.
+#
+ifdef ENABLE_SSL
+  TCC += -DFOSSIL_ENABLE_SSL=1
+endif
+ifndef ENABLE_I18N
+  TCC += -DFOSSIL_I18N=0
+endif
+ifdef PLATFORM_SPECIFIC_GCC
+  TCC += $(PLATFORM_SPECIFIC_GCC)
+endif
+
+#### Linker dependencies.  Fossil only requires libz as an external dependency.
+#    All other library settings are optional and toggled in platform-specific
+#    make fragments.
+#
+LIB = -lz $(LDFLAGS)
+
+#### Linker options.
+#    The variables tested are defined in the make/PLATFORM-fragment.mk files.
+#
+ifdef ENABLE_STATIC
+  LIB += -static
+endif
+ifdef ENABLE_SSL
+  LIB += -lcrypto -lssl
+endif
+ifdef ENABLE_SOCKET
+  LIB += -lsocket
+endif
+ifdef ENABLE_NSL
+  LIB += -lnsl
+endif
+ifdef PLATFORM_SPECIFIC_LIB
+  LIB += $(PLATFORM_SPECIFIC_LIB)
+endif
+
+#### These will have to be adjusted for your MinGW32 environment.
+#
+MINGW32_GCC = -L/mingw/lib -I/mingw/include
+#MINGW32_GCC = -L/usr/local/lib -I/usr/local/include
+TCC += $(MINGW32_GCC)
+
+MINGW32_LIB = -lmingwex -lws2_32
+LIB += $(MINGW32_LIB)
+
+#### Signal that we've used a config.mk file.
+#
+CONFIG_MK_COMPLETE=1
+

ADDED   make/solaris-gcc-config.mk
Index: make/solaris-gcc-config.mk
==================================================================
--- make/solaris-gcc-config.mk
+++ make/solaris-gcc-config.mk
@@ -0,0 +1,80 @@
+#### config.mk file for Solaris with GCC.
+#    Copy this file as config.mk in the Fossil root directory to use.
+#
+
+#### OS-specific configuration for building Fossil on Solaris systems.
+#
+
+#### The suffix to add to executable files.  ".exe" for windows.
+#    Nothing for unix.
+#
+E =
+
+#### The directory into which object code files should be written.
+#
+OBJDIR = ./obj
+
+#### The following variable definitions decide which features are turned on or
+#    of when building Fossil.  Comment out the features which are not needed by
+#    this platform.
+#
+#ENABLE_STATIC = 1	# we want a static build
+ENABLE_SSL = 1		# we are using SSL
+ENABLE_SOCKET = 1	# we are using libsocket (OpenSolaris and Solaris)
+ENABLE_NSL = 1		# we are using libnsl library (Solaris)
+ENABLE_I18N = 1		# we are using i18n settings
+
+#### Compiler-specific configuration for users of the GCC compiler suite.
+#
+
+#### C Compiler and options for use in building executables that
+#    will run on the platform that is doing the build.  This is used
+#    to compile code-generator programs as part of the build process.
+#    See TCC below for the C compiler for building the finished binary.
+#
+BCC = gcc -g -O2
+
+#### C Compile and options for use in building executables that
+#    will run on the target platform.  This is usually the same
+#    as BCC, unless you are cross-compiling.  This C compiler builds
+#    the finished binary for fossil.  The BCC compiler above is used
+#    for building intermediate code-generator tools.
+#
+TCC = gcc -g -Os -Wall
+
+#### Compiler options.
+#    The variables tested are defined in the make/PLATFORM-fragment.mk files.
+#
+ifdef ENABLE_SSL
+  TCC += -DFOSSIL_ENABLE_SSL=1
+endif
+ifndef ENABLE_I18N
+  TCC += -DFOSSIL_I18N=0
+endif
+
+#### Linker dependencies.  Fossil only requires libz as an external dependency.
+#    All other library settings are optional and toggled in platform-specific
+#    make fragments.
+#
+LIB = -lz $(LDFLAGS)
+
+#### Linker options.
+#    The variables tested are defined in the make/PLATFORM-fragment.mk files.
+#
+ifdef ENABLE_STATIC
+  LIB += -static
+endif
+ifdef ENABLE_SSL
+  LIB += -lcrypto -lssl
+endif
+ifdef ENABLE_SOCKET
+  LIB += -lsocket
+endif
+ifdef ENABLE_NSL
+  LIB += -lnsl
+endif
+
+#### Signal that we've used a config.mk file.
+#
+CONFIG_MK_COMPLETE=1
+