Hello community,

here is the log from the commit of package netsurf-buildsystem for 
openSUSE:Factory checked in at 2020-08-29 20:33:51
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/netsurf-buildsystem (Old)
 and      /work/SRC/openSUSE:Factory/.netsurf-buildsystem.new.3399 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "netsurf-buildsystem"

Sat Aug 29 20:33:51 2020 rev:3 rq:829743 version:1.9

Changes:
--------
--- /work/SRC/openSUSE:Factory/netsurf-buildsystem/netsurf-buildsystem.changes  
2014-05-24 07:41:06.000000000 +0200
+++ 
/work/SRC/openSUSE:Factory/.netsurf-buildsystem.new.3399/netsurf-buildsystem.changes
        2020-08-29 20:34:16.673261414 +0200
@@ -1,0 +2,17 @@
+Wed Aug 26 12:08:36 UTC 2020 - Tomáš Chvátal <[email protected]>
+
+- Add patch to not expect which to be in /bin:
+  * hardcoded.patch
+
+-------------------------------------------------------------------
+Tue Aug 25 15:32:49 UTC 2020 - Dirk Mueller <[email protected]>
+
+- update to 1.9:
+  * openbsd support
+  * Enable sanitize target for new gccs and clang
+  * cope with Apple clang version
+  * Add support for INCLUDEDIR
+  * Fix Build/HOST confusion
+  * Fix quotation in case expansion for make selection
+
+-------------------------------------------------------------------

Old:
----
  buildsystem-1.1.tar.gz

New:
----
  buildsystem-1.9.tar.gz
  hardcoded.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ netsurf-buildsystem.spec ++++++
--- /var/tmp/diff_new_pack.4mNUkW/_old  2020-08-29 20:34:17.805261891 +0200
+++ /var/tmp/diff_new_pack.4mNUkW/_new  2020-08-29 20:34:17.809261893 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package netsurf-buildsystem
 #
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -12,20 +12,19 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
 %define src_name buildsystem
 Name:           netsurf-buildsystem
-Version:        1.1
+Version:        1.9
 Release:        0
 Summary:        Makefiles shared by NetSurf projects
 License:        MIT
-Group:          Development/Tools
-Url:            http://www.netsurf-browser.org/
+URL:            https://www.netsurf-browser.org/
 Source:         
http://download.netsurf-browser.org/libs/releases/%{src_name}-%{version}.tar.gz
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+Patch0:         hardcoded.patch
 BuildArch:      noarch
 
 %description
@@ -33,15 +32,16 @@
 
 %prep
 %setup -q -n %{src_name}-%{version}
+%autopatch -p1
 
 %build
 
 %install
-make install DESTDIR=%{buildroot} PREFIX=%{_prefix}
+%make_install PREFIX=%{_prefix}
 
 %files
-%defattr(-,root,root)
-%doc COPYING README
+%license COPYING
+%doc README
 %{_datadir}/%{name}
 
 %changelog

++++++ buildsystem-1.1.tar.gz -> buildsystem-1.9.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/buildsystem-1.1/Makefile new/buildsystem-1.9/Makefile
--- old/buildsystem-1.1/Makefile        2014-01-13 01:14:27.000000000 +0100
+++ new/buildsystem-1.9/Makefile        2020-05-24 18:15:42.000000000 +0200
@@ -2,11 +2,11 @@
 #
 # Makefile for NetSurf buildsystem
 #
-# Copyright 2009-1013 John-Mark Bell <[email protected]>
+# Copyright 2009-2015 John-Mark Bell <[email protected]>
 
 # Component settings
 COMPONENT := buildsystem
-COMPONENT_VERSION := 1.1
+COMPONENT_VERSION := 1.9
 
 .PHONY:all usage install dist clean distclean test
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/buildsystem-1.1/citools/jenkins-build.sh 
new/buildsystem-1.9/citools/jenkins-build.sh
--- old/buildsystem-1.1/citools/jenkins-build.sh        2014-01-13 
01:14:27.000000000 +0100
+++ new/buildsystem-1.9/citools/jenkins-build.sh        2020-05-24 
18:15:42.000000000 +0200
@@ -1,5 +1,7 @@
 #!/bin/bash
 #
+# NetSurf continuous integration build script for jenkins
+#
 # Copyright © 2013 Vincent Sanders <[email protected]>
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -20,32 +22,36 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 
-# NetSurf continuius integration build script for jenkins
-#
 # This script may be executed by jenkins jobs that use the core buildsystem
 #
-# Usage: jenkins-build.sh [install|test-install|coverage|static]
+# Usage: jenkins-build.sh [install|test-install|coverage|static|docs]
 #
 # install - build and install
 # test-install - build, test and install
 # coverage - run coverage
 # static - perform a static analysis
 # coverity - perform a coverity scan
+# docs - build doxygen docs
+# sanitize - Run the test suite under ASAN and UBSAN
 
-# TARGET must be in the environment and set correctly
-if [ "x${TARGET}" = "x" ];then
-    echo "TARGET unset"
+# HOST must be in the environment and set correctly
+if [ "x${HOST}" = "x" ];then
+    echo "HOST unset"
     exit 1
 fi
 
 # The target for built artifacts
 #
-# This does mean the artifacts of a target must all be built on the
-#   same jenkins slave instance
-ARTIFACT_HOME=${JENKINS_HOME}/artifacts-${TARGET}
+# This requires the artifacts of a target must all be built on the same
+#  jenkins slave instance.
+ARTIFACT_HOME=${JENKINS_HOME}/artifacts-${HOST}
+
+# Obtain the native build triplet if unset
+if [ "x${BUILD}" = "x" ];then
+    # This assumes the cc on the PATH is the native one.
+    BUILD=$(cc -dumpmachine)
+fi
 
-# Obtain the native target
-NATIVE_TARGET=$(uname -s)
 
 # target defaults
 TARGET_TEST=
@@ -53,113 +59,138 @@
 TARGET_COVERAGE=
 TARGET_STATIC=
 TARGET_COVERITY=
-TARGET_BUILD="release"
+TARGET_DOCS=
 
-# change defaults based on build parameter
+# Which variant is being generated
+VARIANT="release"
+
+# change target build according to parameter
 case "$1" in
     "install")
-       TARGET_INSTALL=${TARGET}
+       TARGET_INSTALL=${HOST}
        ;;
 
     "coverage")
-       TARGET_COVERAGE=${TARGET}
-       TARGET_BUILD="debug"
+       TARGET_COVERAGE=${HOST}
+       VARIANT="debug"
        # need to disable ccache on coverage builds
        export CCACHE=
        ;;
 
     "static")
-       TARGET_STATIC=${TARGET}
-       TARGET_BUILD="debug"
+       TARGET_STATIC=${HOST}
+       VARIANT="debug"
        # need to disable ccache on static builds
        export CCACHE=
        ;;
 
     "coverity")
-       TARGET_COVERITY=${TARGET}
-       TARGET_BUILD="debug"
+       TARGET_COVERITY=${HOST}
+       VARIANT="debug"
        # need to disable ccache on coverity builds
        export CCACHE=
        ;;
 
     "test-install")
        # Perfom test if being executed on native target
-       TARGET_TEST=${NATIVE_TARGET}
-       TARGET_INSTALL=${TARGET}
+       TARGET_TEST=${BUILD}
+       TARGET_INSTALL=${HOST}
+       ;;
+
+    "docs")
+       TARGET_DOCS=${HOST}
+       ;;
+
+    "sanitize")
+       TARGET_SANITIZE=${HOST}
+       VARIANT="debug"
        ;;
 
     "")
        # default is test only on Linux and install
        # Currently most tests do not work on targets except for Linux
-       # TARGET_TEST=${NATIVE_TARGET}
-       TARGET_TEST="Linux"
-       TARGET_INSTALL=${TARGET}
+       TARGET_TEST="x86_64-linux-gnu"
+       TARGET_INSTALL=${HOST}
        ;;
 
     *)
        cat <<EOF
-Usage: jenkins-build.sh [install|test-install|coverage|static]
+Usage: jenkins-build.sh [install|test-install|coverage|static|docs|sanitize]
 
        install        build and install
        test-install   build, test and install
        coverage       run coverage
        static         perform a static anaysis
        coverity       perform a coverity scan
+       docs           generate doxygen docs
+       sanitize       run the tests under ASAN/UBSAN
 EOF
        exit 1
        ;;
 esac
 
-# currently core buildsystem doesnt use triplets so we need to adjust for that
-# here is also where we can adjust other setting based on target
-case ${TARGET} in
-    "m68k-atari-mint")
-       TARGET_TARGET="atari"
-       ;;
 
-    "m5475-atari-mint")
-       TARGET_TARGET="m5475_atari"
+# adjust tools based on build
+case ${BUILD} in
+
+    amd64-unknown-openbsd*)
+       MAKE=gmake
        ;;
 
-    "powerpc-apple-darwin9")
-       TARGET_TARGET="powerpc_apple_darwin9"
+    x86_64-unknown-openbsd*)
+       MAKE=gmake
        ;;
 
+    x86_64-unknown-freebsd*)
+       MAKE=gmake
+       ;;    
+
+    x86_64-apple-darwin14.5.0*)
+        PATH="/opt/local/bin:/opt/local/sbin:$PATH"
+       MAKE=make
+        ;;
+
     *)
-       TARGET_TARGET=${TARGET}
+       MAKE=make
        ;;
 esac
 
+
 # Ensure the artifact target directory exists
 mkdir -p ${ARTIFACT_HOME}
 
+
 # Configure all build paths relative to prefix
 export PREFIX=${ARTIFACT_HOME}
 export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PREFIX}/lib
 export PATH=${PATH}:${PREFIX}/bin
 
+
 # execute the build steps
 
 # clean target is always first
-make Q= clean TARGET=${TARGET_TARGET} BUILD=${TARGET_BUILD}
+${MAKE} Q= clean HOST=${HOST} VARIANT=${VARIANT}
+
 
 # build as per type requested
-if [ "x${TARGET}" = "x${TARGET_COVERAGE}" ]; then
+if [ "x${HOST}" = "x${TARGET_COVERAGE}" ]; then
     # Coverage Build
-    make Q= TARGET=${TARGET_TARGET} BUILD=${TARGET_BUILD} coverage
-    gcovr -x -r .. -o coverage.xml
+    CFLAGS=-Wno-error ${MAKE} Q= HOST=${HOST} VARIANT=${VARIANT} coverage
+    gcovr -v -x -e 'test/.*' -r . -o coverage.xml
 
-elif [ "x${TARGET}" = "x${TARGET_STATIC}" ]; then
+elif [ "x${HOST}" = "x${TARGET_STATIC}" ]; then
     # static build
     rm -rf clangScanBuildReports
 
-    scan-build -o clangScanBuildReports -v --use-cc clang 
--use-analyzer=/usr/bin/clang make BUILD=debug
+    # build with static analysis without warnings causing errors
+    CFLAGS=-Wno-error scan-build -o clangScanBuildReports -v -v --use-cc clang 
--use-analyzer=/usr/bin/clang ${MAKE} Q= VARIANT=${VARIANT}
 
     # clean up after
-    make Q= clean TARGET=${TARGET_TARGET} BUILD=${TARGET_BUILD}
+    ${MAKE} Q= clean HOST=${HOST} VARIANT=${VARIANT}
+
 
-elif [ "x${TARGET}" = "x${TARGET_COVERITY}" ]; then
+elif [ "x${HOST}" = "x${TARGET_COVERITY}" ]; then
     # coverity build
 
     # Check thses are set
@@ -178,32 +209,43 @@
     
COVERITY_PREFIX=${COVERITY_PREFIX:-/opt/coverity/cov-analysis-linux64-6.6.1}
     COVERITY_VERSION=$(git rev-parse HEAD)
 
-
     export PATH=${PATH}:${COVERITY_PREFIX}/bin
 
     # cleanup before we start
     rm -rf cov-int/ coverity-scan.tar.gz coverity-scan.tar
 
-    cov-build --dir cov-int make Q= TARGET=${TARGET_TARGET} 
BUILD=${TARGET_BUILD}
+    cov-build --dir cov-int ${MAKE} Q= HOST=${HOST} VARIANT=${VARIANT}
 
     tar cf coverity-scan.tar cov-int
 
     gzip -9 coverity-scan.tar
 
-    curl --form "project=${COVERITY_PROJECT}" --form "token=${COVERITY_TOKEN}" 
--form "email=${COVERITY_USER}" --form "[email protected]" --form 
"version=${COVERITY_VERSION}" --form "description=Git Head build" 
http://scan5.coverity.com/cgi-bin/upload.py
+    curl --form "project=${COVERITY_PROJECT}" --form "token=${COVERITY_TOKEN}" 
--form "email=${COVERITY_USER}" --form "[email protected]" --form 
"version=${COVERITY_VERSION}" --form "description=Git Head build" 
"https://scan.coverity.com/builds?project=${COVERITY_PROJECT}";
+
+
+elif [ "x${HOST}" = "x${TARGET_DOCS}" ]; then
+    # Documentation build
+    ${MAKE} Q= HOST=${HOST} VARIANT=${VARIANT} docs
+
+elif [ "x${HOST}" = "x${TARGET_SANITIZE}" ]; then
+    # Sanitize build
+    env UBSAN_OPTIONS=print_stacktrace=1 ${MAKE} Q= HOST=${HOST} 
VARIANT=${VARIANT} sanitize
 
 else
     # Normal build
-    make Q= TARGET=${TARGET_TARGET} BUILD=${TARGET_BUILD}
+    ${MAKE} Q= HOST=${HOST} VARIANT=${VARIANT}
+
 
 fi
 
-# test if appropriate
-if [ "x${TARGET}" = "x${TARGET_TEST}" ]; then
-    make Q= TARGET=${TARGET_TARGET} BUILD=${TARGET_BUILD} test
+
+# run tests if appropriate
+if [ "x${HOST}" = "x${TARGET_TEST}" ]; then
+    ${MAKE} Q= HOST=${HOST} VARIANT=${VARIANT} test
 fi
 
-# install
-if [ "x${TARGET}" = "x${TARGET_INSTALL}" ]; then
-    make Q= TARGET=${TARGET_TARGET} BUILD=${TARGET_BUILD} install
+
+# install the output 
+if [ "x${HOST}" = "x${TARGET_INSTALL}" ]; then
+    ${MAKE} Q= HOST=${HOST} VARIANT=${VARIANT} install
 fi
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/buildsystem-1.1/example/libfoo.pc.in 
new/buildsystem-1.9/example/libfoo.pc.in
--- old/buildsystem-1.1/example/libfoo.pc.in    2014-01-13 01:14:27.000000000 
+0100
+++ new/buildsystem-1.9/example/libfoo.pc.in    2020-05-24 18:15:42.000000000 
+0200
@@ -6,5 +6,5 @@
 Name: libfoo
 Description: Pointless example library
 Version: 0.0.1
-Libs: -L${libdir}
+Libs: -L${libdir} LIBRARIES
 Cflags: -I${includedir}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/buildsystem-1.1/makefiles/Makefile.clang 
new/buildsystem-1.9/makefiles/Makefile.clang
--- old/buildsystem-1.1/makefiles/Makefile.clang        2014-01-13 
01:14:27.000000000 +0100
+++ new/buildsystem-1.9/makefiles/Makefile.clang        2020-05-24 
18:15:42.000000000 +0200
@@ -26,13 +26,24 @@
 ARFLG := cru
 
 # Definitions of various attributes
-CFLAGS := $(CFLAGS) -D_ALIGNED="__attribute__((aligned))"
+CFLAGS := $(CFLAGS) -D_ALIGNED="__attribute__((aligned))" -DSTMTEXPR=1
+
+# Extensions for sanitize target
+ifeq ($(MAKECMDGOALS),sanitize)
+  SANCFLAGS ?= -fsanitize=address -fsanitize=undefined -fno-sanitize-recover
+  SANCXXFLAGS ?= -fsanitize=address -fsanitize=undefined -fno-sanitize-recover
+  SANLDFLAGS ?= -fsanitize=address -fsanitize=undefined -fno-sanitize-recover
+
+  CFLAGS := $(CFLAGS) $(SANCFLAGS)
+  CXXFLAGS := $(CXXFLAGS) $(SANCXXFLAGS)
+  LDFLAGS := $(LDFLAGS) $(SANLDFLAGS)
+endif
 
 ###############################################################################
 # Mac OS X Universal Binaries
 ###############################################################################
 
-ifeq ($(TARGET),Darwin)
+ifeq ($(findstring darwin,$(HOST)),darwin)
        ifneq ($(UNIVERSAL),)
                UNIVERSAL_FLAGS := $(foreach arch,$(UNIVERSAL),-arch $(arch) )
                
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/buildsystem-1.1/makefiles/Makefile.gcc 
new/buildsystem-1.9/makefiles/Makefile.gcc
--- old/buildsystem-1.1/makefiles/Makefile.gcc  2014-01-13 01:14:27.000000000 
+0100
+++ new/buildsystem-1.9/makefiles/Makefile.gcc  2020-05-24 18:15:42.000000000 
+0200
@@ -25,7 +25,7 @@
 ARFLG := cru
 
 # Definitions for various attributes
-CFLAGS := $(CFLAGS) -D_ALIGNED="__attribute__((aligned))"
+CFLAGS := $(CFLAGS) -D_ALIGNED="__attribute__((aligned))" -DSTMTEXPR=1
 
 # Extensions for coverage target
 ifeq ($(MAKECMDGOALS),coverage)
@@ -49,9 +49,20 @@
   LDFLAGS := $(LDFLAGS) $(PROFLDFLAGS)
 endif
 
+# Extensions for sanitize target
+ifeq ($(MAKECMDGOALS),sanitize)
+  SANCFLAGS ?= -fsanitize=address -fsanitize=undefined -fno-sanitize-recover
+  SANCXXFLAGS ?= -fsanitize=address -fsanitize=undefined -fno-sanitize-recover
+  SANLDFLAGS ?= -fsanitize=address -fsanitize=undefined -fno-sanitize-recover
+
+  CFLAGS := $(CFLAGS) $(SANCFLAGS)
+  CXXFLAGS := $(CXXFLAGS) $(SANCXXFLAGS)
+  LDFLAGS := $(LDFLAGS) $(SANLDFLAGS)
+endif
+
 # RISC OS module extensions
 ifeq ($(COMPONENT_TYPE),riscos-module)
-  ifneq ($(TARGET),riscos)
+  ifneq ($(HOST),arm-unknown-riscos)
     $(error Attempting to build a RISC OS module for a non-RISC OS target)
   endif
 
@@ -64,7 +75,7 @@
 # Mac OS X Universal Binaries
 ###############################################################################
 
-ifeq ($(TARGET),Darwin)
+ifeq ($(findstring darwin,$(HOST)),darwin)
        ifneq ($(UNIVERSAL),)
                UNIVERSAL_FLAGS := $(foreach arch,$(UNIVERSAL),-arch $(arch) )
                CC_CAN_BUILD_AND_DEP := no
@@ -82,7 +93,7 @@
 ###############################################################################
 
 # Determine if the compiler supports simultaneous build & dep.
-ccvsn := $(shell $(CC) -dumpversion)
+ccvsn := $(shell $(CC) -dumpversion -dumpfullversion)
 # ccvsn = x.y.z
 GCCVER := $(word 1,$(subst ., ,$(ccvsn)))
 # GCCVER = x
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/buildsystem-1.1/makefiles/Makefile.norcroft 
new/buildsystem-1.9/makefiles/Makefile.norcroft
--- old/buildsystem-1.1/makefiles/Makefile.norcroft     2014-01-13 
01:14:27.000000000 +0100
+++ new/buildsystem-1.9/makefiles/Makefile.norcroft     2020-05-24 
18:15:42.000000000 +0200
@@ -38,7 +38,7 @@
 
 # RISC OS module extensions
 ifeq ($(COMPONENT_TYPE),riscos-module)
-  ifneq ($(TARGET),riscos)
+  ifneq ($(HOST),arm-unknown-riscos)
     $(error Attempting to build a RISC OS module for a non-RISC OS target)
   endif
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/buildsystem-1.1/makefiles/Makefile.open64 
new/buildsystem-1.9/makefiles/Makefile.open64
--- old/buildsystem-1.1/makefiles/Makefile.open64       2014-01-13 
01:14:27.000000000 +0100
+++ new/buildsystem-1.9/makefiles/Makefile.open64       2020-05-24 
18:15:42.000000000 +0200
@@ -27,7 +27,7 @@
 ARFLG := cru
 
 # Definitions for various attributes
-CFLAGS := $(CFLAGS) -D_ALIGNED="__attribute__((aligned))"
+CFLAGS := $(CFLAGS) -D_ALIGNED="__attribute__((aligned))" -DSTMTEXPR=1
 
 # Extensions for coverage target
 ifeq ($(MAKECMDGOALS),coverage)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/buildsystem-1.1/makefiles/Makefile.tools 
new/buildsystem-1.9/makefiles/Makefile.tools
--- old/buildsystem-1.1/makefiles/Makefile.tools        2014-01-13 
01:14:27.000000000 +0100
+++ new/buildsystem-1.9/makefiles/Makefile.tools        2020-05-24 
18:15:42.000000000 +0200
@@ -10,17 +10,20 @@
 #
 # Optional inputs:
 #
-# BUILD                        Type of build to perform:
+# BUILD                        Platform we're building on
+# HOST                 Target platform (defaults to build)
+# VARIANT              Type of build to perform:
 #                              release         -       Release build (default)
 #                              debug           -       Debug build
-# OPTCFLAGS            Optional C compiler flags for $(BUILD)
-# OPTCXXFLAGS          Optional C++ compiler flags for $(BUILD)
-# OPTLDFLAGS           Optional linker flags for $(BUILD)
-# TARGET               Target platform (defaults to host)
+# OPTCFLAGS            Optional C compiler flags for $(VARIANT)
+# OPTCXXFLAGS          Optional C++ compiler flags for $(VARIANT)
+# OPTLDFLAGS           Optional linker flags for $(VARIANT)
 # PREFIX               Absolute installation path prefix 
 #                              (defaults to /usr/local)
 # LIBDIR               Library installation directory in ${PREFIX}
 #                              (defaults to lib)
+# INCLUDEDIR   Header installation directory in ${PREFIX}
+#                              (defaults to include)
 #
 
 ###############################################################################
@@ -31,272 +34,176 @@
   $(error COMPONENT_TYPE not set)
 endif
 
-# Default build to release
-ifeq ($(BUILD),)
-  BUILD := release
+# Default variant to release
+ifeq ($(VARIANT),)
+  VARIANT := release
 endif
 
 ###############################################################################
 # Determine path used to load us, so we can locate other makefiles etc
 ###############################################################################
 
+# The directory in which the build system can be found
+#
+# TODO: This should be NS_BUILDSYSTEM_DIR or similar and is not connected
+#       to the BUILD variable.
 NSBUILD := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
 NSSHARED := $(patsubst %/,%,$(dir $(NSBUILD)))
 NSTESTTOOLS := $(NSSHARED)/testtools
 
 ###############################################################################
-# Host/target platform detection
+# Bootstrap default tooling
 ###############################################################################
 
-# Autodetect host if necessary
-ifeq ($(HOST),)
-  HOST := $(shell uname -s)
-endif
+BUILD_CC ?= cc
+
+###############################################################################
+# Host/build platform detection
+###############################################################################
 
-# Simple host sanitisation
+# Autodetect host
 ifeq ($(HOST),)
-  # Don't ask
-  HOST := riscos
-else
-  ifeq ($(HOST),RISC OS)
-    HOST := riscos
+  HOST := $(shell $(CC) -dumpmachine)
+  ifeq ($(HOST),)
+    $(error "Failed to guess HOST")
   endif
+else
+endif
 
-  ifeq ($(HOST),BeOS)
-    HOST := beos
-  endif
-  ifeq ($(HOST),Haiku)
-    HOST := haiku
+# Autodetect build if necessary
+ifeq ($(BUILD),)
+  BUILD := $(shell $(BUILD_CC) -dumpmachine)
+  ifeq ($(BUILD),)
+    $(error "Failed to guess BUILD")
   endif
+endif
 
-  ifeq ($(HOST),AmigaOS)
-    HOST := amiga
-  endif
+ifeq ($(BUILD),$(HOST))
+  # Native build
 
-  ifeq ($(findstring MINGW,$(HOST)),MINGW)
-    HOST := windows
-  endif
+  ifeq ($(HOST),i586-pc-haiku)
+    # Building on+for Haiku
+
+    # Default prefix
+    BEOS_INSTALL_ENV ?= /boot/common
 
-  ifeq ($(HOST),FreeMiNT)
-    HOST := atari
+    # TODO: this assumes GCC
+    CFLAGS := $(CFLAGS) -I$(BEOS_INSTALL_ENV)/include
+    CXXFLAGS := $(CXXFLAGS) -I$(BEOS_INSTALL_ENV)/include
+    LDFLAGS := $(LDFLAGS) -L$(BEOS_INSTALL_ENV)/lib
+
+    PREFIX ?= $(BEOS_INSTALL_ENV)
   endif
-endif
 
-ifeq ($(TARGET),)
-  # Default target to host. Please add exceptions as required.
-  TARGET := $(HOST)
+  ifeq ($(findstring openbsd,$(HOST)),openbsd)
+    # Building on+for OpenBSD
+    CFLAGS := $(CFLAGS) -I$(GCCSDK_INSTALL_ENV)/include -I/usr/local/include
+    CXXFLAGS := $(CXXFLAGS) -I$(GCCSDK_INSTALL_ENV)/include 
-I/usr/local/include
+    LDFLAGS := $(LDFLAGS) -L$(GCCSDK_INSTALL_ENV)/lib -L/usr/local/lib
 
-  ifeq ($(HOST),haiku)
-    # This isn't necessarily correct -- they have differences. However, in the 
-    # general case, this will work. If there are differences that are actually 
-    # important wrt the target platform (as opposed to the build host) then 
-    # we'll just have to introduce a haiku target, too.
-    TARGET := beos
+    FLEX ?= gflex
   endif
-endif
 
-# Sanitise HOST and TARGET
-# TODO: Ideally, we want the equivalent of s/[^A-Za-z0-9]/_/g here
-HOST := $(subst .,_,$(subst -,_,$(subst /,_,$(HOST))))
-TARGET := $(subst .,_,$(subst -,_,$(subst /,_,$(TARGET))))
+  ifeq ($(findstring freebsd,$(HOST)),freebsd)
+    # Building on+for FreeBSD
+    CFLAGS := $(CFLAGS) -I$(GCCSDK_INSTALL_ENV)/include -I/usr/local/include
+    CXXFLAGS := $(CXXFLAGS) -I$(GCCSDK_INSTALL_ENV)/include 
-I/usr/local/include
+    LDFLAGS := $(LDFLAGS) -L$(GCCSDK_INSTALL_ENV)/lib -L/usr/local/lib
+  endif
 
-# Now setup our tooling
-ifeq ($(TARGET),riscos)
-  ifeq ($(HOST),riscos)
-    # Building on native RISC OS
-    GCCSDK_INSTALL_ENV ?= <NSLibs$$Dir>
+  ifeq ($(findstring arwin,$(HOST)),arwin)
+    # Building on+for Mac OS X (Darwin) with MAC ports
+    CFLAGS := $(CFLAGS) -I/opt/local/include
+    CXXFLAGS := $(CXXFLAGS) -I/opt/local/include
+    LDFLAGS := $(LDFLAGS) -L/opt/local/lib
+  endif
 
-    CC__ := gcc
-    CXX__ := g++
-    CMHG ?= cmunge
-    GENHTML ?= echo
-    LCOV ?= echo
-    PKGCONFIG ?=
-    # On certain versions of RISC OS (<>4 || kernel < 8.75),
-    # the kernel will clean up the current redirection on
-    # OS_Exit, including closing the associated file handles.
-    # This is problematic for UnixLib, as it's invariably using
-    # those filehandles in a pipe between parent and child processes.
-    # This affects us as, anywhere where we shell out and want to
-    # capture the output of the child process may fail.
-    # Fortunately, if we know the child process is built against
-    # UnixLib, then we also know that it won't call OS_Exit when it
-    # exits, instead returning directly to our exit handler (and thus
-    # preserving the redirection). This only works, however, if the
-    # child application is specified using its absolute path, or 
-    # found in Run$Path. In the case of Perl, it does not appear in
-    # Run$Path, so we must invoke it using its absolute path so that
-    # the SharedUnixLibrary successfully detects it as a child process.
-    PERL ?= <Perl$$Dir>.bin.perl
-
-    # This is nasty, but needed because $(CURDIR) will 
-    # contain colons, and thus confuse make mightily
-    $(shell SetMacro Alias$$$(COMPONENT)pwd Set %0 
<FileSwitch$$CurrentFilingSystem>:|<FileSwitch$$<FileSwitch$$CurrentFilingSystem>$$CSD>|mUnset
 Alias$$$(COMPONENT)pwd)
-    $(shell $(COMPONENT)pwd $(COMPONENT)$$Dir)
-    CURDIR := <$(COMPONENT)$$Dir>
+else
+  # Cross compiling
+
+  ifneq ($(NS_ENV_CC),)
+    # If we have a CC specified by env.sh, start with that
+    CC__ := $(NS_ENV_CC)
   else
-    # Cross compiling for RISC OS
-    ifeq ($(origin GCCSDK_INSTALL_ENV),undefined)
-      ifneq ($(realpath /opt/netsurf/arm-unknown-riscos/env),)
-        GCCSDK_INSTALL_ENV := /opt/netsurf/arm-unknown-riscos/env
-      else
-        GCCSDK_INSTALL_ENV := /home/riscos/env
-      endif
+    # Make first-stab at identity of CC
+    CC__ := $(CC)
+    # Improve our guess at the identity of CC
+    # (only if CC was not specified by the user)
+    ifeq ($(origin CC),default)
+      CC__ := $(HOST)-gcc
     endif
+  endif
 
-    ifeq ($(origin GCCSDK_INSTALL_CROSSBIN),undefined)
-      ifneq ($(realpath /opt/netsurf/arm-unknown-riscos/cross/bin),)
-        GCCSDK_INSTALL_CROSSBIN := /opt/netsurf/arm-unknown-riscos/cross/bin
-      else
-        GCCSDK_INSTALL_CROSSBIN := /home/riscos/cross/bin
-      endif
+  # Search the path for the compiler
+  toolpath_ := $(shell /bin/which $(CC__))
+  ifeq ($(toolpath_),)
+    toolpath_ := /opt/netsurf/$(HOST)/cross/bin/
+    CC__  := $(toolpath_)$(HOST)-gcc
+    AR__  := $(toolpath_)$(HOST)-ar
+    CXX__ := $(toolpath_)$(HOST)-g++
+  else
+    CC__ := $(realpath $(toolpath_))
+    toolpath_ := $(dir $(CC__))
+    toolprefix_ := $(subst :,/,$(subst /,-,$(patsubst %/,%,$(dir $(subst 
-,/,$(subst /,:,$(CC__)))))))
+    ifeq ($(origin AR),default)
+      AR__ := $(toolprefix_)-ar
+    endif
+    ifeq ($(origin CXX),default)
+      CXX__ := $(toolprefix_)-g++
     endif
+  endif
+
+  # Compute default SDK path
+  ifeq ($(origin GCCSDK_INSTALL_ENV),undefined)
+    GCCSDK_INSTALL_ENV := $(realpath $(toolpath_)../../env)
+  endif
 
-    AR__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*ar)
-    CC__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
-    CXX__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++)
+  ifeq ($(HOST),arm-unknown-riscos)
+    # Cross compiling for RISC OS
     CMHG ?= PATH="$(GCCSDK_INSTALL_CROSSBIN):$(PATH)" 
$(GCCSDK_INSTALL_CROSSBIN)/cmunge
     GENHTML ?= echo
     LCOV ?= echo
     PKGCONFIG ?= 
PKG_CONFIG_LIBDIR="$(PREFIX)/lib/pkgconfig:$(GCCSDK_INSTALL_ENV)/lib/pkgconfig:$(GCCSDK_INSTALL_ENV)/share/pkgconfig"
 pkg-config
 
     ifneq ($(COMPONENT_TYPE),riscos-module)
-      ifeq ($(origin CC),default)
-        ifneq ($(findstring arm-unknown-riscos-gcc,$(CC__)),)
-          EXEEXT := ,e1f
-        else
-          EXEEXT := ,ff8
-        endif
+      ifneq ($(findstring arm-unknown-riscos-gcc,$(CC__)),)
+        EXEEXT := ,e1f
       else
-        ifneq ($(findstring arm-unknown-riscos-gcc,$(CC)),)
-          EXEEXT := ,e1f
-        else
-          EXEEXT := ,ff8
-        endif
+        EXEEXT := ,ff8
       endif
     else
       EXEEXT := ,ffa
     endif
-  endif
-
-  # TODO: this assumes GCC
-  CFLAGS := $(CFLAGS) -mpoke-function-name -I$(GCCSDK_INSTALL_ENV)/include
-  CXXFLAGS := $(CXXFLAGS) -mpoke-function-name -I$(GCCSDK_INSTALL_ENV)/include
-  LDFLAGS := $(LDFLAGS) -L$(GCCSDK_INSTALL_ENV)/lib
-
-  CMHGFLAGS := -p -tgcc -32bit -apcs 3/32/nonreent/fpe2/noswst/nofpr/nofp
 
-  # Default prefix
-  PREFIX ?= $(GCCSDK_INSTALL_ENV)
-endif
-
-# BeOS-like targets
-ifeq ($(TARGET),beos)
-  ifeq ($(HOST),beos)
-    # Building on BeOS
-    CC__ := gcc
+    # TODO: this assumes GCC
+    CFLAGS := $(CFLAGS) -mpoke-function-name -I$(GCCSDK_INSTALL_ENV)/include
+    CXXFLAGS := $(CXXFLAGS) -mpoke-function-name 
-I$(GCCSDK_INSTALL_ENV)/include
+    LDFLAGS := $(LDFLAGS) -L$(GCCSDK_INSTALL_ENV)/lib
 
-    # No pkg-config
-    PKGCONFIG ?=
+    CMHGFLAGS := -p -tgcc -32bit -apcs 3/32/nonreent/fpe2/noswst/nofpr/nofp
 
     # Default prefix
-    BEOS_INSTALL_ENV ?= /boot/home/config
-  else
-    ifeq ($(HOST),haiku)
-      # Building on Haiku
-
-      # Default prefix
-      BEOS_INSTALL_ENV ?= /boot/common
-    else
-      # TODO: more sensible default
-      BEOS_INSTALL_ENV ?= /home/jmb/haiku/env
-      BEOS_INSTALL_CROSSBIN ?= /home/jmb/haiku/haiku/generated/cross-tools/bin
-
-      CC__ := $(wildcard $(BEOS_INSTALL_CROSSBIN)/*gcc)
-      CXX__ := $(wildcard $(BEOS_INSTALL_CROSSBIN)/*g++)
-      AR__ := $(wildcard $(BEOS_INSTALL_CROSSBIN)/*ar)
-
-      PKGCONFIG := 
PKG_CONFIG_LIBDIR="$(PREFIX)/lib/pkgconfig:$(BEOS_INSTALL_ENV)/lib/pkgconfig:$(BEOS_INSTALL_ENV)/share/pkgconfig"
 pkg-config
-    endif
+    PREFIX ?= $(GCCSDK_INSTALL_ENV)
   endif
 
-  # TODO: this assumes GCC
-  CFLAGS := $(CFLAGS) -I$(BEOS_INSTALL_ENV)/include
-  CXXFLAGS := $(CXXFLAGS) -I$(BEOS_INSTALL_ENV)/include
-  LDFLAGS := $(LDFLAGS) -L$(BEOS_INSTALL_ENV)/lib
-
-  PREFIX ?= $(BEOS_INSTALL_ENV)
-endif
-
-# Windows
-ifeq ($(TARGET),windows)
-  ifeq ($(HOST),windows)
-    # Building on Windows
-    CC__ := gcc
-    CXX__ := g++
-    AR__ := ar
-
-    PKGCONFIG ?=
-  else
+  ifeq ($(HOST),i686-w64-mingw32)
     # Cross compiling for Windows -- assumes mingw toolchain
-
-    ifeq ($(origin GCCSDK_INSTALL_ENV),undefined)
-      ifneq ($(realpath /opt/netsurf/i686-w64-mingw32/env),)
-        GCCSDK_INSTALL_ENV := /opt/netsurf/i686-w64-mingw32/env
-      else
-        GCCSDK_INSTALL_ENV := /usr/local/mingw
-      endif
-    endif
-
-    ifeq ($(origin GCCSDK_INSTALL_CROSSBIN),undefined)
-      ifneq ($(realpath /opt/netsurf/i686-w64-mingw32/cross/bin),)
-        GCCSDK_INSTALL_CROSSBIN := /opt/netsurf/i686-w64-mingw32/cross/bin
-        AR__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*ar)
-        CC__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
-        CXX__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++)
-      else
-        GCCSDK_INSTALL_CROSSBIN := /usr/local/mingw/bin
-        CC__ := i586-mingw32msvc-gcc
-        CXX__ := i586-mingw32msvc-g++
-        AR__ := i586-mingw32msvc-ar
-      endif
-    endif
-
     GENHTML ?= echo
     LCOV ?= echo
     PKGCONFIG ?= 
PKG_CONFIG_LIBDIR="$(PREFIX)/lib/pkgconfig:$(GCCSDK_INSTALL_ENV)/lib/pkgconfig:$(GCCSDK_INSTALL_ENV)/share/pkgconfig"
 pkg-config
 
-  endif
+    # TODO: this assumes GCC
+    CFLAGS := $(CFLAGS) -U__STRICT_ANSI__ -I$(GCCSDK_INSTALL_ENV)/include
+    CXXFLAGS := $(CXXFLAGS) -U__STRICT_ANSI__ -I$(GCCSDK_INSTALL_ENV)/include
+    LDFLAGS := $(LDFLAGS) -L$(GCCSDK_INSTALL_ENV)/lib
 
-  # TODO: this assumes GCC
-  CFLAGS := $(CFLAGS) -U__STRICT_ANSI__ -I$(GCCSDK_INSTALL_ENV)/include
-  CXXFLAGS := $(CXXFLAGS) -U__STRICT_ANSI__ -I$(GCCSDK_INSTALL_ENV)/include
-  LDFLAGS := $(LDFLAGS) -L$(GCCSDK_INSTALL_ENV)/lib
-
-  # Default prefix
-  PREFIX ?= $(GCCSDK_INSTALL_ENV)
-endif
+    # Default prefix
+    PREFIX ?= $(GCCSDK_INSTALL_ENV)
+  endif
 
-# AmigaOS (3/4; m68k/ppc: we can treat them identically)
-ifeq ($(findstring amiga,$(TARGET)),amiga)
-  ifeq ($(findstring amiga,$(HOST)),amiga)
-    # Building on AmigaOS
-    # Nothing to do, as we assume the default tooling works
-  else
+  # AmigaOS (3/4; m68k/ppc: we can treat them identically)
+  ifeq ($(findstring amigaos,$(HOST)),amigaos)
     # Cross compiling for AmigaOS
-
-    ifeq ($(TARGET),amigaos3)
-      GCCSDK_INSTALL_ENV ?= /opt/netsurf/m68k-unknown-amigaos/env
-      GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/m68k-unknown-amigaos/cross/bin
-    else
-      GCCSDK_INSTALL_ENV ?= /opt/netsurf/ppc-amigaos/env
-      GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/ppc-amigaos/cross/bin
-    endif
-
-    AR__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*ar)
-    CC__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
-    CXX__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++)
-
     PKGCONFIG ?= 
PKG_CONFIG_LIBDIR="$(PREFIX)/lib/pkgconfig:$(GCCSDK_INSTALL_ENV)/lib/pkgconfig:$(GCCSDK_INSTALL_ENV)/share/pkgconfig"
 pkg-config
 
     # TODO: this assumes GCC
@@ -304,26 +211,18 @@
     CXXFLAGS := $(CXXFLAGS) -U__STRICT_ANSI__ -I$(GCCSDK_INSTALL_ENV)/include
     LDFLAGS := $(LDFLAGS) -L$(GCCSDK_INSTALL_ENV)/lib
 
+    ifeq ($(HOST),m68k-unknown-amigaos)
+        CFLAGS += -fomit-frame-pointer -m68020
+    endif
+
     PREFIX ?= $(GCCSDK_INSTALL_ENV)
   endif
-endif
 
-# FreeMiNT / atari 
-ifeq ($(TARGET),atari)
-  ifeq ($(HOST),atari)
-    # Building on FreeMiNT
-    # Nothing to do, as we assume the default tooling works
-  else
+  ifeq ($(HOST),m68k-atari-mint)
     # Cross compiling for FreeMiNT
 
     ATARIARCH ?= 68020-60
 
-    GCCSDK_INSTALL_ENV ?= /opt/netsurf/m68k-atari-mint/env
-    GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/m68k-atari-mint/cross/bin
-    CC__ := $(GCCSDK_INSTALL_CROSSBIN)/m68k-atari-mint-gcc
-    CXX__ := $(GCCSDK_INSTALL_CROSSBIN)/m68k-atari-mint-g++
-    AR__ := $(GCCSDK_INSTALL_CROSSBIN)/m68k-atari-mint-ar
-
     ifeq ($(ATARIARCH),68000)
        ARCHFLAGS := 
        ARCHDIR :=
@@ -343,22 +242,9 @@
 
     PREFIX ?= $(GCCSDK_INSTALL_ENV)
   endif
-endif
-
-# FreeMiNT / m5475_atari 
-ifeq ($(TARGET),m5475_atari)
-  ifeq ($(HOST),m5475_atari)
-    # Building on FreeMiNT
-    # Nothing to do, as we assume the default tooling works
-  else
-    # Cross compiling for FreeMiNT
-
-    GCCSDK_INSTALL_ENV ?= /opt/netsurf/m5475-atari-mint/env
-    GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/m5475-atari-mint/cross/bin
-    CC__ := $(GCCSDK_INSTALL_CROSSBIN)/m5475-atari-mint-gcc
-    CXX__ := $(GCCSDK_INSTALL_CROSSBIN)/m5475-atari-mint-g++
-    AR__ := $(GCCSDK_INSTALL_CROSSBIN)/m5475-atari-mint-ar
 
+  ifeq ($(HOST),m5475-atari-mint)
+    # Cross compiling for FreeMiNT (m5475)
     CFLAGS := $(CFLAGS) -U__STRICT_ANSI__ -I$(GCCSDK_INSTALL_ENV)/include 
$(ARCHFLAGS)
     CXXFLAGS := $(CXXFLAGS) -U__STRICT_ANSI__ -I$(GCCSDK_INSTALL_ENV)/include 
$(ARCHFLAGS)
     LDFLAGS := $(LDFLAGS) -L$(GCCSDK_INSTALL_ENV)/lib/m5475
@@ -373,6 +259,9 @@
 # Default libdir
 LIBDIR ?= lib
 
+# Default includedir
+INCLUDEDIR ?= include
+
 ###############################################################################
 # Tool defaults
 ###############################################################################
@@ -385,15 +274,7 @@
 
 GENHTML ?= genhtml
 
-ifeq ($(HOST),$(TARGET))
-  HOST_CC ?= $(CC)
-
-  HOST_CXX ?= $(CXX)
-else
-  HOST_CC ?= cc
-
-  HOST_CXX ?= c++
-endif
+BUILD_CXX ?= c++
 
 INSTALL ?= install
 
@@ -420,6 +301,10 @@
 
 XSLTPROC ?= xsltproc
 
+FLEX ?= flex
+
+BISON ?= bison
+
 ###############################################################################
 # Override defaulted tools
 ###############################################################################
@@ -483,7 +368,7 @@
   ccvsn := $(shell $(CC) --version 2>&1)
   ifeq ($(ccvsn),)
     # Version string is blank
-    ifeq ($(HOST),riscos)
+    ifeq ($(BUILD),arm-unknown-riscos)
       # For some reason we never see the output of SCL apps, so might be
       # Norcroft.  However it might also be a GCC linked against a buggy
       # UnixLib.
@@ -493,6 +378,11 @@
     endif
   endif
 
+  ifeq ($(findstring lcc:,$(ccvsn)),lcc:)
+    # MCST LCC pretends to be gcc
+    toolchain := gcc
+  endif
+
   # "Norcroft ..."
   ifeq ($(word 1,$(ccvsn)),Norcroft)
     toolchain := norcroft
@@ -510,6 +400,10 @@
     # (ie, Debian, Apple, etc)
     toolchain := clang
   endif
+  ifeq ($(word 2,$(ccvsn)),LLVM)
+    # Apple version is "Apple LLVM" to be differntly awkward
+    toolchain := clang
+  endif
   ifeq ($(word 1,$(ccvsn)),Open64)
     toolchain := open64
   endif
@@ -519,6 +413,25 @@
   $(error Unable to detect toolchain)
 endif
 
+# Detect if the toolchain ought to support sanitizers
+SANITIZE_OK=no
+ifeq ($(toolchain),gcc)
+  GCC_VERSION := $(shell $(CC) -dumpversion -dumpfullversion)
+  GCC_MAJOR := $(word 1,$(subst ., ,$(GCC_VERSION)))
+  ifeq ($(shell expr $(GCC_MAJOR) \>= 6),1)
+    SANITIZE_OK=yes
+  endif
+else ifeq ($(toolchain),clang)
+  SANITIZE_OK=yes
+endif
+
+# And fail if we can't sanitize and yet the user asked for it
+ifeq ($(MAKECMDGOALS),sanitize)
+  ifeq ($(SANITIZE_OK),no)
+    $(error Unable to build with sanitizers enabled, compiler not compatible
+  endif
+endif
+
 # TODO: It would be nice to avoid this hard-coded path
 include $(NSBUILD)/Makefile.$(toolchain)
 
@@ -526,7 +439,7 @@
 # Default assembler/compiler/linker/archiver flags
 ###############################################################################
 
-ifeq ($(BUILD),release)
+ifeq ($(VARIANT),release)
   OPTCFLAGS ?= $(CCDEF)NDEBUG $(CCOPT)
   OPTCXXFLAGS ?= $(CXXDEF)NDEBUG $(CXXOPT)
 else
@@ -542,10 +455,8 @@
 # TODO: This assumes that the C compiler can cope with assembler
 ASFLAGS ?= $(CCAS)
 
-CFLAGS := $(CFLAGS) $(OPTCFLAGS) $(CCDEF)BUILD_TARGET_$(TARGET) 
$(CCDEF)BUILD_HOST_$(HOST)
-CXXFLAGS := $(CXXFLAGS) $(OPTCXXFLAGS) \
-               $(CXXDEF)BUILD_TARGET_$(TARGET) $(CXXDEF)BUILD_HOST_$(HOST)
-
+CFLAGS := $(CFLAGS) $(OPTCFLAGS)
+CXXFLAGS := $(CXXFLAGS) $(OPTCXXFLAGS)
 ASFLAGS := $(ASFLAGS) $(CFLAGS)
 LDFLAGS := $(LDFLAGS) $(OPTLDFLAGS)
 
@@ -570,6 +481,12 @@
 endif
 
 
################################################################################
+# Documentation defaults
+################################################################################
+
+DOXYCONF ?= docs/Doxyfile
+
+################################################################################
 # Package config macros
 
################################################################################
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/buildsystem-1.1/makefiles/Makefile.top 
new/buildsystem-1.9/makefiles/Makefile.top
--- old/buildsystem-1.1/makefiles/Makefile.top  2014-01-13 01:14:27.000000000 
+0100
+++ new/buildsystem-1.9/makefiles/Makefile.top  2020-05-24 18:15:42.000000000 
+0200
@@ -2,7 +2,7 @@
 #
 # Expected inputs:
 #
-# BUILD                        Type of build to perform:
+# VARIANT              Type of build to perform:
 #                              release         -       Release build
 #                              debug           -       Debug build
 # COMPONENT            Name of the component (sans leading "lib" iff a library)
@@ -12,18 +12,20 @@
 #                              lib-static      -       Static library
 #                              lib-shared      -       Shared library
 #                              riscos-module   -       RISC OS module
-# TARGET               Target platform identifier
 #
 # Optional inputs:
 #
-# BUILDDIR             Directory to build into (defaults to 
-#                      build-$(HOST)-$(TARGET)-$(BUILD)-$(COMPONENT_TYPE))
+# BUILD                        Build platform identifier
+# HOST                 Target host platform identifier, defaults to BUILD
+# BUILDDIR             Directory to place built output into (defaults to
+#                      build-$(BUILD)-$(HOST)-$(VARIANT)-$(COMPONENT_TYPE))
+#                       This is not related to the BUILD platform identifier
 # CC_CAN_BUILD_AND_DEP Flag whether $(CC) is capable of calculating dependency
 #                      information at the same time as compiling sources.
 #                      Set to "yes" if it can.
 # DESTDIR              Sandboxed FS root (e.g. for packaging)
-# HOST                 Host platform identifier
 # REQUIRED_PKGS                List of required pkg-config packages
+# REQUIRED_LIBS         List of required libraries to add to pkg-config
 #
 # The client may also override all toolchain settings, including:
 #
@@ -46,6 +48,7 @@
 # test                 Build and run test suite, using current settings.
 # coverage             Determine test suite coverage (requires lcov)
 # profile              Build with profiling support enabled (requires gprof)
+# sanitize              Build and run test suite, using ASAN and UBSAN
 # docs                 Produce documentation (requires doxygen)
 # dist                  Produce release tarball from latest git tag
 # clean                        Clean the build
@@ -80,13 +83,13 @@
 endif
 
 # Target platform must be defined by the client
-ifeq ($(TARGET),)
-  $(error TARGET not defined)
+ifeq ($(HOST),)
+  $(error HOST not defined)
 endif
 
-# Build type, too
-ifeq ($(BUILD),)
-  $(error BUILD not defined)
+# Build variant, too
+ifeq ($(VARIANT),)
+  $(error VARIANT not defined)
 endif
 
 ##############################################################################
@@ -109,11 +112,10 @@
 ##############################################################################
 
 # Build directory
-BUILDDIR ?= build-$(HOST)-$(TARGET)-$(BUILD)-$(COMPONENT_TYPE)
+BUILDDIR ?= build-$(BUILD)-$(HOST)-$(VARIANT)-$(COMPONENT_TYPE)
 
 # Build tree subdirs
 COVERAGEDIR := $(BUILDDIR)/coverage
-DOCDIR := $(BUILDDIR)/docs
 
 # Determine if we want to build testcases
 ifeq ($(MAKECMDGOALS),test)
@@ -122,6 +124,8 @@
   WANT_TEST := yes
 else ifeq ($(MAKECMDGOALS),coverage)
   WANT_TEST := yes
+else ifeq ($(MAKECMDGOALS),sanitize)
+  WANT_TEST := yes
 else
   WANT_TEST := no
 endif
@@ -230,12 +234,15 @@
        $(Q)$(GENHTML) -o $(COVERAGEDIR) --num-spaces 2 \
                $(COVERAGEDIR)/$(COMPONENT).info
 
+# Build and test sanitizers
+sanitize: test
+
 # Build for profiling
 profile: __partial_clean test
 
 # Compile documentation
-docs: $(BUILDDIR)/stamp
-       $(Q)$(DOXYGEN) build/Doxyfile
+docs: $(DOXYCONF) $(BUILDDIR)/stamp
+       $(Q)$(DOXYGEN) $<
 
 # Distribution
 # This constructs a distribution tar from the last git tag. It ensures
@@ -280,7 +287,9 @@
 __comma := ,
 __empty := 
 __space := $(empty) $(empty)
+__dashl := $(empty) -l$(empty)
 __required = $(if $(REQUIRED_PKGS),Requires: $(subst $(__space),$(__comma) 
,$(strip $(REQUIRED_PKGS))),)
+__libraries = $(if $(REQUIRED_LIBS),-l$(subst $(__space),$(__dashl),$(strip 
$(REQUIRED_LIBS))),)
 
 # Install a pkg-config control file ($1) to the specified location ($2)
 define install_pkgconfig
@@ -291,8 +300,10 @@
                -e 's#MAJOR#$(major-version)#' \
                -e 's#MINOR#$(minor-version)#' \
                -e 's#PATCH#$(patch-version)#' \
+               -e 's#INCLUDEDIR#$(INCLUDEDIR)#' \
                -e 's#VERSION#$(COMPONENT_VERSION)#' \
                -e 's#REQUIRED#$(__required)#' \
+               -e 's#LIBRARIES#$(__libraries)#' \
                $1 >$(BUILDDIR)/$(1:.in=)
        $(INSTALL) $(INSTALLFLAGS) -m 644 $(BUILDDIR)/$(1:.in=) \
                $2/$(1:.in=)
@@ -387,7 +398,6 @@
 $(BUILDDIR)/stamp:
        $(Q)$(MKDIR) $(MKDIRFLAGS) $(BUILDDIR)
        $(Q)$(MKDIR) $(MKDIRFLAGS) $(COVERAGEDIR)
-       $(Q)$(MKDIR) $(MKDIRFLAGS) $(DOCDIR)
        $(Q)$(TOUCH) $(TOUCHFLAGS) $(BUILDDIR)/stamp
 
 $(OUTPUT): $(BUILDDIR)/stamp $(OBJECTS)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/buildsystem-1.1/testtools/testrunner.pl 
new/buildsystem-1.9/testtools/testrunner.pl
--- old/buildsystem-1.1/testtools/testrunner.pl 2014-01-13 01:14:27.000000000 
+0100
+++ new/buildsystem-1.9/testtools/testrunner.pl 2020-05-24 18:15:42.000000000 
+0200
@@ -86,7 +86,7 @@
                        # Run testcase
                        run_test("$builddir/$test", 
                                        "$directory/data/$data/$dtest");
-                }
+               }
 
                close(DINDEX);
        } else {
@@ -148,6 +148,8 @@
                                # EOF, so remove handle
                                $selector->remove($fh);
                                next;
+                       } elsif ($len == 1 && $input eq "\n") {
+                               # Skip bare new line.
                        } else {
                                # Split into lines
                                my @lines = split('\n', $input);

++++++ hardcoded.patch ++++++
Index: buildsystem-1.9/makefiles/Makefile.tools
===================================================================
--- buildsystem-1.9.orig/makefiles/Makefile.tools
+++ buildsystem-1.9/makefiles/Makefile.tools
@@ -135,7 +135,7 @@ else
   endif
 
   # Search the path for the compiler
-  toolpath_ := $(shell /bin/which $(CC__))
+  toolpath_ := $(shell which $(CC__))
   ifeq ($(toolpath_),)
     toolpath_ := /opt/netsurf/$(HOST)/cross/bin/
     CC__  := $(toolpath_)$(HOST)-gcc

Reply via email to