From 9423d2bd834984c862e9506b1e040223b261eb75 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Thu, 3 Sep 2020 13:32:17 +0200
Subject: [PATCH] CONFIG: improve support for compiler/link options (#1830)

- introduce WM_COMPILE_CONTROL variable to convey control information
  into the build rules.

  The convention (as per spack):
      - '+' to select a feature
      - '~' to deselect a feature

  Eg, to select the gold linker, and disable openmp
  (spaces are not required):

      WM_COMPILE_CONTROL="+gold ~openmp"

CONFIG: accept FOAM_EXTRA_LDFLAGS for AMD, gold, Mingw linkers

CONFIG: generalize PROJECT_LIBS (-ldl used almost universally)
---
 applications/test/00-dummy/Make/options            | 11 ++++-------
 applications/test/00-dummy/dummy/Make/options      |  7 +++----
 applications/test/CompactIOList/Make/options       |  5 ++---
 applications/test/ListOps/Make/options             |  5 ++---
 applications/test/ListOps2/Make/options            |  5 ++---
 applications/test/Polynomial/Make/options          |  5 ++---
 applications/test/Random/Make/options              |  5 ++---
 applications/test/dynamicLibrary/Make/options      |  4 ++--
 applications/test/foamToMetisGraph/Make/options    |  5 ++---
 applications/test/globalMeshData/Make/options      |  5 ++---
 .../test/polynomialEqns/cubicEqn/Make/options      |  5 ++---
 .../test/polynomialEqns/linearEqn/Make/options     |  5 ++---
 .../test/polynomialEqns/quadraticEqn/Make/options  |  5 ++---
 applications/test/wmake1/Make/options              |  4 ++--
 .../foamyMesh/conformalVoronoi2DMesh/Make/options  |  5 ++---
 .../mesh/manipulation/objToVTK/Make/options        |  5 ++---
 .../OSspecific/addr2line/Make/options              |  5 ++---
 .../miscellaneous/foamDictionary/Make/options      |  5 ++---
 .../miscellaneous/foamHasLibrary/Make/options      |  5 ++---
 .../miscellaneous/foamListTimes/Make/options       |  5 ++---
 .../miscellaneous/foamRestoreFields/Make/options   |  5 ++---
 .../miscellaneous/profilingSummary/Make/options    |  5 ++---
 etc/bashrc                                         |  5 +++++
 etc/config.csh/unset                               | 14 +++++++-------
 etc/config.sh/unset                                | 14 ++++++++------
 etc/cshrc                                          |  5 +++++
 src/Allwmake                                       |  6 +++---
 src/ODE/Make/options                               |  5 ++---
 src/OpenFOAM/Make/options                          |  9 +++++----
 src/Pstream/dummy/Make/options                     |  6 +++---
 src/Pstream/mpi/Make/options                       |  1 +
 src/dummyThirdParty/MGridGen/Make/options          |  5 ++---
 src/lagrangian/distributionModels/Make/options     |  5 ++---
 .../molecularMeasurements/Make/options             |  5 ++---
 src/parallel/decompose/ptscotchDecomp/Make/options |  2 +-
 src/parallel/decompose/scotchDecomp/Make/options   |  2 +-
 src/rigidBodyDynamics/Make/options                 |  5 ++---
 src/thermophysicalModels/specie/Make/options       |  5 ++---
 wmake/makefiles/general                            |  2 +-
 wmake/rules/General/Amd/link-c++                   |  7 +++++--
 wmake/rules/General/Clang/link-c++                 |  7 +++++--
 wmake/rules/General/Clang/link-gold-c++            | 10 ++++++++++
 wmake/rules/General/Gcc/link-gold-c++              |  9 +++++++--
 wmake/rules/General/Pgi/link-c++                   |  7 +++++--
 wmake/rules/General/transform                      |  2 +-
 wmake/rules/darwin64Clang/general                  |  9 ++++-----
 wmake/rules/linux64Amd/general                     |  4 ++--
 wmake/rules/linux64Clang/c++                       |  8 +++++++-
 wmake/rules/linux64Clang/general                   |  8 ++++++--
 wmake/rules/linux64Cray/general                    | 10 +++++++---
 wmake/rules/linux64Gcc/c++                         |  8 +++++++-
 wmake/rules/linux64Gcc/general                     |  8 ++++++--
 wmake/rules/linux64Icc/general                     |  8 ++++++--
 wmake/rules/linux64Mingw/c++                       |  7 ++++---
 wmake/rules/linux64Mingw/general                   |  3 ++-
 wmake/rules/linux64Pgi/general                     |  8 ++++++--
 wmake/rules/linuxARM64Arm/general                  |  8 ++++++--
 wmake/rules/linuxARM64Clang/general                |  8 ++++++--
 wmake/rules/linuxARM64Fujitsu/general              | 11 ++++++-----
 wmake/rules/linuxARM64Gcc/general                  |  8 ++++++--
 wmake/rules/linuxARM7Gcc/general                   |  8 ++++++--
 wmake/rules/linuxClang/c++                         |  8 +++++++-
 wmake/rules/linuxClang/general                     |  8 ++++++--
 wmake/rules/linuxGcc/c++                           |  8 +++++++-
 wmake/rules/linuxGcc/general                       |  8 ++++++--
 wmake/rules/linuxIA64Gcc/general                   |  8 ++++++--
 wmake/rules/linuxIA64Icc/general                   |  7 ++++++-
 wmake/rules/linuxIcc/general                       |  8 ++++++--
 wmake/rules/linuxPPC64Gcc/general                  |  8 ++++++--
 wmake/rules/linuxPPC64leGcc/general                |  8 ++++++--
 wmake/rules/solaris64Gcc/general                   |  6 +++++-
 71 files changed, 280 insertions(+), 175 deletions(-)
 create mode 100644 wmake/rules/General/Clang/link-gold-c++

diff --git a/applications/test/00-dummy/Make/options b/applications/test/00-dummy/Make/options
index 48247685e4d..a717db36c39 100644
--- a/applications/test/00-dummy/Make/options
+++ b/applications/test/00-dummy/Make/options
@@ -1,9 +1,6 @@
-/* Without the normal defaults */
-PROJECT_INC     =
-PROJECT_LIBS    =
-
+/* Without the normal project defaults */
+PROJECT_INC =
+PROJECT_LIBS =
 
 EXE_INC = -Idummy
-
-EXE_LIBS = \
-    -lOpenFOAM-dummy
+EXE_LIBS = -lOpenFOAM-dummy
diff --git a/applications/test/00-dummy/dummy/Make/options b/applications/test/00-dummy/dummy/Make/options
index 1f01bba39be..8ce0038ce82 100644
--- a/applications/test/00-dummy/dummy/Make/options
+++ b/applications/test/00-dummy/dummy/Make/options
@@ -1,6 +1,6 @@
-/* Without the normal defaults */
-PROJECT_INC     =
-PROJECT_LIBS    =
+/* Without the normal project defaults */
+PROJECT_INC =
+PROJECT_LIBS =
 
 EXE_INC = \
     -DWM_ARCH=\"$(WM_ARCH)\"  \
@@ -8,5 +8,4 @@ EXE_INC = \
     -DWM_COMPILE_OPTION=\"$(WM_COMPILE_OPTION)\" \
     -DWM_OPTIONS=\"$(WM_OPTIONS)\"
 
-
 /* LIB_LIBS = */
diff --git a/applications/test/CompactIOList/Make/options b/applications/test/CompactIOList/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/test/CompactIOList/Make/options
+++ b/applications/test/CompactIOList/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/ListOps/Make/options b/applications/test/ListOps/Make/options
index 51903c0ce4f..18e6fe47afa 100644
--- a/applications/test/ListOps/Make/options
+++ b/applications/test/ListOps/Make/options
@@ -1,3 +1,2 @@
-EXE_INC = /*-DFULLDEBUG -O0 -g*/ \
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/ListOps2/Make/options b/applications/test/ListOps2/Make/options
index 51903c0ce4f..18e6fe47afa 100644
--- a/applications/test/ListOps2/Make/options
+++ b/applications/test/ListOps2/Make/options
@@ -1,3 +1,2 @@
-EXE_INC = /*-DFULLDEBUG -O0 -g*/ \
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/Polynomial/Make/options b/applications/test/Polynomial/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/test/Polynomial/Make/options
+++ b/applications/test/Polynomial/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/Random/Make/options b/applications/test/Random/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/test/Random/Make/options
+++ b/applications/test/Random/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/dynamicLibrary/Make/options b/applications/test/dynamicLibrary/Make/options
index 75c7356f1c6..18e6fe47afa 100644
--- a/applications/test/dynamicLibrary/Make/options
+++ b/applications/test/dynamicLibrary/Make/options
@@ -1,2 +1,2 @@
-EXE_INC =
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/foamToMetisGraph/Make/options b/applications/test/foamToMetisGraph/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/test/foamToMetisGraph/Make/options
+++ b/applications/test/foamToMetisGraph/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/globalMeshData/Make/options b/applications/test/globalMeshData/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/test/globalMeshData/Make/options
+++ b/applications/test/globalMeshData/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/polynomialEqns/cubicEqn/Make/options b/applications/test/polynomialEqns/cubicEqn/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/test/polynomialEqns/cubicEqn/Make/options
+++ b/applications/test/polynomialEqns/cubicEqn/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/polynomialEqns/linearEqn/Make/options b/applications/test/polynomialEqns/linearEqn/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/test/polynomialEqns/linearEqn/Make/options
+++ b/applications/test/polynomialEqns/linearEqn/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/polynomialEqns/quadraticEqn/Make/options b/applications/test/polynomialEqns/quadraticEqn/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/test/polynomialEqns/quadraticEqn/Make/options
+++ b/applications/test/polynomialEqns/quadraticEqn/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/wmake1/Make/options b/applications/test/wmake1/Make/options
index 75c7356f1c6..18e6fe47afa 100644
--- a/applications/test/wmake1/Make/options
+++ b/applications/test/wmake1/Make/options
@@ -1,2 +1,2 @@
-EXE_INC =
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoi2DMesh/Make/options b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoi2DMesh/Make/options
index 79be6f3a7dd..6b8588463d9 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoi2DMesh/Make/options
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoi2DMesh/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-LIB_LIBS =
+/* EXE_INC = */
+/* LIB_LIBS = */
diff --git a/applications/utilities/mesh/manipulation/objToVTK/Make/options b/applications/utilities/mesh/manipulation/objToVTK/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/utilities/mesh/manipulation/objToVTK/Make/options
+++ b/applications/utilities/mesh/manipulation/objToVTK/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/utilities/miscellaneous/OSspecific/addr2line/Make/options b/applications/utilities/miscellaneous/OSspecific/addr2line/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/utilities/miscellaneous/OSspecific/addr2line/Make/options
+++ b/applications/utilities/miscellaneous/OSspecific/addr2line/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/utilities/miscellaneous/foamDictionary/Make/options b/applications/utilities/miscellaneous/foamDictionary/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/utilities/miscellaneous/foamDictionary/Make/options
+++ b/applications/utilities/miscellaneous/foamDictionary/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/utilities/miscellaneous/foamHasLibrary/Make/options b/applications/utilities/miscellaneous/foamHasLibrary/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/utilities/miscellaneous/foamHasLibrary/Make/options
+++ b/applications/utilities/miscellaneous/foamHasLibrary/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/utilities/miscellaneous/foamListTimes/Make/options b/applications/utilities/miscellaneous/foamListTimes/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/utilities/miscellaneous/foamListTimes/Make/options
+++ b/applications/utilities/miscellaneous/foamListTimes/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/utilities/miscellaneous/foamRestoreFields/Make/options b/applications/utilities/miscellaneous/foamRestoreFields/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/utilities/miscellaneous/foamRestoreFields/Make/options
+++ b/applications/utilities/miscellaneous/foamRestoreFields/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/utilities/postProcessing/miscellaneous/profilingSummary/Make/options b/applications/utilities/postProcessing/miscellaneous/profilingSummary/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/applications/utilities/postProcessing/miscellaneous/profilingSummary/Make/options
+++ b/applications/utilities/postProcessing/miscellaneous/profilingSummary/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/etc/bashrc b/etc/bashrc
index 8920907bba3..4d67de53246 100644
--- a/etc/bashrc
+++ b/etc/bashrc
@@ -83,6 +83,11 @@ export WM_LABEL_SIZE=32
 # Other is processor or packaging specific (eg, OptKNL)
 export WM_COMPILE_OPTION=Opt
 
+# [WM_COMPILE_CONTROL] - additional control for compiler rules
+#   +gold   : with gold linker
+#   ~openmp : without openmp
+#export WM_COMPILE_CONTROL="+gold"
+
 # [WM_MPLIB] - MPI implementation:
 # = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM |
 #   HPMPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
diff --git a/etc/config.csh/unset b/etc/config.csh/unset
index 484836fc6e2..64c00f8280a 100644
--- a/etc/config.csh/unset
+++ b/etc/config.csh/unset
@@ -47,11 +47,11 @@ unsetenv WM_ARCH
 unsetenv WM_ARCH_OPTION
 unsetenv WM_COMPILER
 unsetenv WM_COMPILER_ARCH
-unsetenv WM_COMPILER_TYPE
 unsetenv WM_COMPILER_LIB_ARCH
+unsetenv WM_COMPILER_TYPE
+unsetenv WM_COMPILE_CONTROL
 unsetenv WM_COMPILE_OPTION
 unsetenv WM_DIR
-unsetenv WM_HOSTS
 unsetenv WM_LABEL_OPTION
 unsetenv WM_LABEL_SIZE
 unsetenv WM_MPLIB
@@ -60,21 +60,21 @@ unsetenv WM_OPTIONS
 unsetenv WM_OSTYPE
 unsetenv WM_PRECISION_OPTION
 unsetenv WM_PROJECT
-unsetenv WM_PROJECT_API
 unsetenv WM_PROJECT_DIR
-unsetenv WM_PROJECT_INST_DIR
 unsetenv WM_PROJECT_SITE
 unsetenv WM_PROJECT_USER_DIR
 unsetenv WM_PROJECT_VERSION
 unsetenv WM_SCHEDULER
 unsetenv WM_THIRD_PARTY_DIR
 
-# Older variables
+# Older, unused variables
+unsetenv WM_HOSTS
+unsetenv WM_PROJECT_API
+unsetenv WM_PROJECT_INST_DIR
 
 # Before 1906
 unsetenv WM_CC WM_CXX WM_CFLAGS WM_CXXFLAGS WM_LDFLAGS
 
-
 #------------------------------------------------------------------------------
 # Unset FOAM_* environment variables
 
@@ -106,7 +106,7 @@ unsetenv FOAM_USER_APPBIN
 unsetenv FOAM_USER_LIBBIN
 unsetenv FOAM_UTILITIES
 
-# Old variables
+# Older, unused variables
 
 # Before 1812
 unsetenv FOAM_INST_DIR
diff --git a/etc/config.sh/unset b/etc/config.sh/unset
index 01c90886373..a38c03cbf6d 100644
--- a/etc/config.sh/unset
+++ b/etc/config.sh/unset
@@ -35,11 +35,12 @@ foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \
 unset WM_ARCH
 unset WM_ARCH_OPTION
 unset WM_COMPILER
-unset WM_COMPILER_TYPE
+unset WM_COMPILER_ARCH
 unset WM_COMPILER_LIB_ARCH
+unset WM_COMPILER_TYPE
+unset WM_COMPILE_CONTROL
 unset WM_COMPILE_OPTION
 unset WM_DIR
-unset WM_HOSTS
 unset WM_LABEL_OPTION
 unset WM_LABEL_SIZE
 unset WM_MPLIB
@@ -48,16 +49,17 @@ unset WM_OPTIONS
 unset WM_OSTYPE
 unset WM_PRECISION_OPTION
 unset WM_PROJECT
-unset WM_PROJECT_API
 unset WM_PROJECT_DIR
-unset WM_PROJECT_INST_DIR
 unset WM_PROJECT_SITE
 unset WM_PROJECT_USER_DIR
 unset WM_PROJECT_VERSION
 unset WM_SCHEDULER
 unset WM_THIRD_PARTY_DIR
 
-# Older variables
+# Older, unused variables
+unset WM_HOSTS
+unset WM_PROJECT_API
+unset WM_PROJECT_INST_DIR
 
 # Before 1906
 unset WM_CC WM_CXX WM_CFLAGS WM_CXXFLAGS WM_LDFLAGS
@@ -93,7 +95,7 @@ unset FOAM_USER_APPBIN
 unset FOAM_USER_LIBBIN
 unset FOAM_UTILITIES
 
-# Old variables
+# Older, unused variables
 
 # Before 1812
 unset FOAM_INST_DIR
diff --git a/etc/cshrc b/etc/cshrc
index 9d438694e31..ef1f205a706 100644
--- a/etc/cshrc
+++ b/etc/cshrc
@@ -83,6 +83,11 @@ setenv WM_LABEL_SIZE 32
 # Other is processor or packaging specific (eg, OptKNL)
 setenv WM_COMPILE_OPTION Opt
 
+# [WM_COMPILE_CONTROL] - additional control for compiler rules
+#   +gold   : with gold linker
+#   ~openmp : without openmp
+#setenv WM_COMPILE_CONTROL "+gold"
+
 # [WM_MPLIB] - MPI implementation:
 # = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM |
 #   HPMPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
diff --git a/src/Allwmake b/src/Allwmake
index f67833062d5..86f16c9d3e3 100755
--- a/src/Allwmake
+++ b/src/Allwmake
@@ -20,6 +20,9 @@ fi
 wmakeLnInclude -u OpenFOAM
 wmakeLnInclude -u OSspecific/"${WM_OSTYPE:-POSIX}"
 
+# Update version info (as required)
+OpenFOAM/Alltouch -check 2>/dev/null
+
 OSspecific/"${WM_OSTYPE:-POSIX}"/Allwmake $targetType $*
 
 case "$WM_COMPILER" in
@@ -37,9 +40,6 @@ Mingw*)
     ;;
 *)
     Pstream/Allwmake $targetType $*
-
-    # Update version info (as required)
-    OpenFOAM/Alltouch -check 2>/dev/null
     ;;
 esac
 
diff --git a/src/ODE/Make/options b/src/ODE/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/src/ODE/Make/options
+++ b/src/ODE/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/src/OpenFOAM/Make/options b/src/OpenFOAM/Make/options
index 3805e3c923d..823ee2ed50a 100644
--- a/src/OpenFOAM/Make/options
+++ b/src/OpenFOAM/Make/options
@@ -1,13 +1,10 @@
-/* Never self-link with WM_PROJECT == OpenFOAM */
-PROJECT_LIBS =
-
 EXE_INC = \
     -I$(OBJECTS_DIR)
 
 LIB_LIBS = \
     $(FOAM_LIBBIN)/libOSspecific.o
 
-ifeq ($(FOAM_LINK_DUMMY_PSTREAM),libo)
+ifeq (libo,$(FOAM_LINK_DUMMY_PSTREAM))
     LIB_LIBS += $(FOAM_LIBBIN)/dummy/libPstream.o
 else
     LIB_LIBS += -L$(FOAM_LIBBIN)/dummy -lPstream
@@ -17,3 +14,7 @@ endif
 EXE_INC += -DHAVE_LIBZ
 
 LIB_LIBS += -lz
+
+
+/* Project lib dependencies. Never self-link (WM_PROJECT == OpenFOAM) */
+PROJECT_LIBS =
diff --git a/src/Pstream/dummy/Make/options b/src/Pstream/dummy/Make/options
index 27ce45328eb..bbfc08f15d4 100644
--- a/src/Pstream/dummy/Make/options
+++ b/src/Pstream/dummy/Make/options
@@ -1,5 +1,5 @@
-EXE_INC =
-
-LIB_LIBS =
+/* EXE_INC = */
+/* LIB_LIBS = */
 
+/* Project lib dependencies */
 PROJECT_LIBS = -L$(FOAM_LIBBIN) -lOpenFOAM
diff --git a/src/Pstream/mpi/Make/options b/src/Pstream/mpi/Make/options
index 7d010be785d..4c2b466f6f0 100644
--- a/src/Pstream/mpi/Make/options
+++ b/src/Pstream/mpi/Make/options
@@ -10,4 +10,5 @@ EXE_INC  = $(PFLAGS) $(PINC) $(c++LESSWARN)
 
 LIB_LIBS = $(PLIBS)
 
+/* Project lib dependencies */
 PROJECT_LIBS = -L$(FOAM_LIBBIN) -lOpenFOAM
diff --git a/src/dummyThirdParty/MGridGen/Make/options b/src/dummyThirdParty/MGridGen/Make/options
index 4c3dd783cb4..18e6fe47afa 100644
--- a/src/dummyThirdParty/MGridGen/Make/options
+++ b/src/dummyThirdParty/MGridGen/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-EXE_LIBS =
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/src/lagrangian/distributionModels/Make/options b/src/lagrangian/distributionModels/Make/options
index 79be6f3a7dd..6b8588463d9 100644
--- a/src/lagrangian/distributionModels/Make/options
+++ b/src/lagrangian/distributionModels/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-LIB_LIBS =
+/* EXE_INC = */
+/* LIB_LIBS = */
diff --git a/src/lagrangian/molecularDynamics/molecularMeasurements/Make/options b/src/lagrangian/molecularDynamics/molecularMeasurements/Make/options
index 79be6f3a7dd..6b8588463d9 100644
--- a/src/lagrangian/molecularDynamics/molecularMeasurements/Make/options
+++ b/src/lagrangian/molecularDynamics/molecularMeasurements/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-LIB_LIBS =
+/* EXE_INC = */
+/* LIB_LIBS = */
diff --git a/src/parallel/decompose/ptscotchDecomp/Make/options b/src/parallel/decompose/ptscotchDecomp/Make/options
index 5d56198ea86..da9e22b8af6 100644
--- a/src/parallel/decompose/ptscotchDecomp/Make/options
+++ b/src/parallel/decompose/ptscotchDecomp/Make/options
@@ -33,6 +33,6 @@ ifeq (,$(findstring windows,$(WM_OSTYPE)))
 endif
 
 /* May require librt, but scotch does not declare the dependency */
-ifeq ($(EXT_SO),.so)
+ifeq (.so,$(EXT_SO))
     LIB_LIBS += -lrt
 endif
diff --git a/src/parallel/decompose/scotchDecomp/Make/options b/src/parallel/decompose/scotchDecomp/Make/options
index 60f174becf5..e269fdd96c6 100644
--- a/src/parallel/decompose/scotchDecomp/Make/options
+++ b/src/parallel/decompose/scotchDecomp/Make/options
@@ -13,6 +13,6 @@ ifeq (,$(findstring windows,$(WM_OSTYPE)))
 endif
 
 /* May require librt, but scotch does not declare the dependency */
-ifeq ($(EXT_SO),.so)
+ifeq (.so,$(EXT_SO))
     LIB_LIBS += -lrt
 endif
diff --git a/src/rigidBodyDynamics/Make/options b/src/rigidBodyDynamics/Make/options
index 79be6f3a7dd..6b8588463d9 100644
--- a/src/rigidBodyDynamics/Make/options
+++ b/src/rigidBodyDynamics/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-LIB_LIBS =
+/* EXE_INC = */
+/* LIB_LIBS = */
diff --git a/src/thermophysicalModels/specie/Make/options b/src/thermophysicalModels/specie/Make/options
index 79be6f3a7dd..6b8588463d9 100644
--- a/src/thermophysicalModels/specie/Make/options
+++ b/src/thermophysicalModels/specie/Make/options
@@ -1,3 +1,2 @@
-EXE_INC =
-
-LIB_LIBS =
+/* EXE_INC = */
+/* LIB_LIBS = */
diff --git a/wmake/makefiles/general b/wmake/makefiles/general
index 2d272b443bb..9ef44faa3d5 100644
--- a/wmake/makefiles/general
+++ b/wmake/makefiles/general
@@ -59,7 +59,7 @@ PROJECT_INC     = \
     -I$(LIB_SRC)/$(WM_PROJECT)/lnInclude \
     -I$(LIB_SRC)/OSspecific/$(WM_OSTYPE)/lnInclude
 
-PROJECT_LIBS    = -l$(WM_PROJECT)
+PROJECT_LIBS    = -l$(WM_PROJECT) -ldl
 
 EXE_INC         =
 EXE_LIBS        =
diff --git a/wmake/rules/General/Amd/link-c++ b/wmake/rules/General/Amd/link-c++
index 7830b08d1e3..cbc13eaa31a 100644
--- a/wmake/rules/General/Amd/link-c++
+++ b/wmake/rules/General/Amd/link-c++
@@ -1,5 +1,8 @@
 LINK_LIBS   = $(c++DBUG) -Wl,--as-needed
 
-LINKLIBSO   = $(CC) $(c++FLAGS) -shared
+LINKLIBSO   = $(CC) $(c++FLAGS) -shared \
+    $(FOAM_EXTRA_LDFLAGS)
 
-LINKEXE     = $(CC) $(c++FLAGS) -L$(FOAM_LIBBIN)/dummy -lPstream
+LINKEXE     = $(CC) $(c++FLAGS) \
+    -L$(FOAM_LIBBIN)/dummy -lPstream \
+    $(FOAM_EXTRA_LDFLAGS)
diff --git a/wmake/rules/General/Clang/link-c++ b/wmake/rules/General/Clang/link-c++
index 27d0c14e091..1713460ec3c 100644
--- a/wmake/rules/General/Clang/link-c++
+++ b/wmake/rules/General/Clang/link-c++
@@ -1,5 +1,8 @@
 LINK_LIBS   = $(c++DBUG)
 
-LINKLIBSO   = $(CC) $(c++FLAGS) -shared $(FOAM_EXTRA_LDFLAGS)
+LINKLIBSO   = $(CC) $(c++FLAGS) -shared \
+    $(FOAM_EXTRA_LDFLAGS)
 
-LINKEXE     = $(CC) $(c++FLAGS) -Xlinker --add-needed $(FOAM_EXTRA_LDFLAGS)
+LINKEXE     = $(CC) $(c++FLAGS) \
+    -Xlinker --add-needed \
+    $(FOAM_EXTRA_LDFLAGS)
diff --git a/wmake/rules/General/Clang/link-gold-c++ b/wmake/rules/General/Clang/link-gold-c++
new file mode 100644
index 00000000000..33f46397a5b
--- /dev/null
+++ b/wmake/rules/General/Clang/link-gold-c++
@@ -0,0 +1,10 @@
+LINK_LIBS   = $(c++DBUG)
+
+LINKLIBSO   = $(CC) $(c++FLAGS) -shared \
+    -fuse-ld=gold \
+    $(FOAM_EXTRA_LDFLAGS)
+
+LINKEXE     = $(CC) $(c++FLAGS) \
+    -fuse-ld=gold \
+    -L$(FOAM_LIBBIN)/dummy -lPstream \
+    $(FOAM_EXTRA_LDFLAGS)
diff --git a/wmake/rules/General/Gcc/link-gold-c++ b/wmake/rules/General/Gcc/link-gold-c++
index a2aefcdca01..33f46397a5b 100644
--- a/wmake/rules/General/Gcc/link-gold-c++
+++ b/wmake/rules/General/Gcc/link-gold-c++
@@ -1,5 +1,10 @@
 LINK_LIBS   = $(c++DBUG)
 
-LINKLIBSO   = $(CC) $(c++FLAGS) -shared -fuse-ld=gold
+LINKLIBSO   = $(CC) $(c++FLAGS) -shared \
+    -fuse-ld=gold \
+    $(FOAM_EXTRA_LDFLAGS)
 
-LINKEXE     = $(CC) $(c++FLAGS) -fuse-ld=gold -L$(FOAM_LIBBIN)/dummy -lPstream
+LINKEXE     = $(CC) $(c++FLAGS) \
+    -fuse-ld=gold \
+    -L$(FOAM_LIBBIN)/dummy -lPstream \
+    $(FOAM_EXTRA_LDFLAGS)
diff --git a/wmake/rules/General/Pgi/link-c++ b/wmake/rules/General/Pgi/link-c++
index 27d0c14e091..1713460ec3c 100644
--- a/wmake/rules/General/Pgi/link-c++
+++ b/wmake/rules/General/Pgi/link-c++
@@ -1,5 +1,8 @@
 LINK_LIBS   = $(c++DBUG)
 
-LINKLIBSO   = $(CC) $(c++FLAGS) -shared $(FOAM_EXTRA_LDFLAGS)
+LINKLIBSO   = $(CC) $(c++FLAGS) -shared \
+    $(FOAM_EXTRA_LDFLAGS)
 
-LINKEXE     = $(CC) $(c++FLAGS) -Xlinker --add-needed $(FOAM_EXTRA_LDFLAGS)
+LINKEXE     = $(CC) $(c++FLAGS) \
+    -Xlinker --add-needed \
+    $(FOAM_EXTRA_LDFLAGS)
diff --git a/wmake/rules/General/transform b/wmake/rules/General/transform
index 89717933d4c..16a4336dee6 100644
--- a/wmake/rules/General/transform
+++ b/wmake/rules/General/transform
@@ -8,7 +8,7 @@ WMKDEP  := $(WMAKE_BIN)/wmkdepend    # 1. Ragel-based
 
 WMKDEP_FLAGS := -eWM_PROJECT_DIR -eWM_THIRD_PARTY_DIR
 
-ifneq ("$(WM_QUIET)","")
+ifneq ("","$(WM_QUIET)")
     E=@
     define QUIET_MESSAGE
         @echo "    $1: $2";
diff --git a/wmake/rules/darwin64Clang/general b/wmake/rules/darwin64Clang/general
index eea19222602..c305312685b 100644
--- a/wmake/rules/darwin64Clang/general
+++ b/wmake/rules/darwin64Clang/general
@@ -1,7 +1,5 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 ## include $(GENERAL_RULES)/Clang/openmp
 
@@ -10,9 +8,10 @@ include $(GENERAL_RULES)/standard
 COMP_OPENMP = -DUSE_OMP -Xpreprocessor -fopenmp
 LINK_OPENMP = -lomp
 # ----
-# Or disable
-# include $(GENERAL_RULES)/no-openmp
-# ----
+
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
 
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linux64Amd/general b/wmake/rules/linux64Amd/general
index b823785ea41..b5a12f5447d 100644
--- a/wmake/rules/linux64Amd/general
+++ b/wmake/rules/linux64Amd/general
@@ -1,9 +1,9 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/no-openmp
 
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+# -----------------------------------------------------------------------------
diff --git a/wmake/rules/linux64Clang/c++ b/wmake/rules/linux64Clang/c++
index fb9e8ef3d33..d782519cf56 100644
--- a/wmake/rules/linux64Clang/c++
+++ b/wmake/rules/linux64Clang/c++
@@ -11,4 +11,10 @@ cxxtoo      = $(Ctoo)
 cctoo       = $(Ctoo)
 cpptoo      = $(Ctoo)
 
-include $(GENERAL_RULES)/Clang/link-c++
+ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/Clang/link-gold-c++
+else
+    include $(GENERAL_RULES)/Clang/link-c++
+endif
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/linux64Clang/general b/wmake/rules/linux64Clang/general
index 9ada28972dd..c5a32b88080 100644
--- a/wmake/rules/linux64Clang/general
+++ b/wmake/rules/linux64Clang/general
@@ -1,9 +1,13 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Clang/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+# -----------------------------------------------------------------------------
diff --git a/wmake/rules/linux64Cray/general b/wmake/rules/linux64Cray/general
index f8a6558ce7c..2e122dfeb8b 100644
--- a/wmake/rules/linux64Cray/general
+++ b/wmake/rules/linux64Cray/general
@@ -1,9 +1,13 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
-# include $(GENERAL_RULES)/Gcc/openmp
+## include $(GENERAL_RULES)/Gcc/openmp
+
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
 
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+# -----------------------------------------------------------------------------
diff --git a/wmake/rules/linux64Gcc/c++ b/wmake/rules/linux64Gcc/c++
index 866280a3513..389a1ec4a38 100644
--- a/wmake/rules/linux64Gcc/c++
+++ b/wmake/rules/linux64Gcc/c++
@@ -11,4 +11,10 @@ cxxtoo      = $(Ctoo)
 cctoo       = $(Ctoo)
 cpptoo      = $(Ctoo)
 
-include $(GENERAL_RULES)/Gcc/link-c++
+ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/Gcc/link-gold-c++
+else
+    include $(GENERAL_RULES)/Gcc/link-c++
+endif
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/linux64Gcc/general b/wmake/rules/linux64Gcc/general
index e510b17575c..e6e61435eab 100644
--- a/wmake/rules/linux64Gcc/general
+++ b/wmake/rules/linux64Gcc/general
@@ -1,9 +1,13 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Gcc/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/linux64Icc/general b/wmake/rules/linux64Icc/general
index 0d41c462f2b..1c132e3ad2b 100644
--- a/wmake/rules/linux64Icc/general
+++ b/wmake/rules/linux64Icc/general
@@ -1,9 +1,13 @@
 CPP        = /lib/cpp -traditional-cpp $(GFLAGS)
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Icc/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+# -----------------------------------------------------------------------------
diff --git a/wmake/rules/linux64Mingw/c++ b/wmake/rules/linux64Mingw/c++
index fe562de17a0..aebb7a88312 100644
--- a/wmake/rules/linux64Mingw/c++
+++ b/wmake/rules/linux64Mingw/c++
@@ -19,7 +19,7 @@ LINK_LIBS   = $(c++DBUG)
 # Using "-Wl,--no-undefined,--enable-runtime-pseudo-reloc"
 # does not forgive undefined symbols during linking
 
-LINKLIBSO   = $(CC) $(c++FLAGS) \
+LINKLIBSO   = $(CC) $(c++FLAGS) -shared \
     -Wl,--output-def=$(LIB).def \
     -Wl,--out-implib=$(LIB).dll.a \
     -Wl,--no-undefined \
@@ -27,9 +27,10 @@ LINKLIBSO   = $(CC) $(c++FLAGS) \
     -Wl,--enable-auto-import \
     -Wl,--enable-auto-image-base \
     -Wl,--strip-all \
-    -shared
+    $(FOAM_EXTRA_LDFLAGS)
 
 LINKEXE     = $(CC) $(c++FLAGS) \
     -Wl,--enable-auto-import \
     -Wl,--strip-all \
-    -Wl,--force-exe-suffix
+    -Wl,--force-exe-suffix \
+    $(FOAM_EXTRA_LDFLAGS)
diff --git a/wmake/rules/linux64Mingw/general b/wmake/rules/linux64Mingw/general
index b63818537a1..16e514aa18b 100644
--- a/wmake/rules/linux64Mingw/general
+++ b/wmake/rules/linux64Mingw/general
@@ -6,7 +6,8 @@ LD      = x86_64-w64-mingw32-ld
 AR      = x86_64-w64-mingw32-ar
 RANLIB  = x86_64-w64-mingw32-ranlib
 
-PROJECT_LIBS = -l$(WM_PROJECT) -L$(FOAM_LIBBIN)/dummy -lPstream
+PROJECT_LIBS = -l$(WM_PROJECT) \
+    -L$(FOAM_LIBBIN)/dummy -lPstream
 
 include $(GENERAL_RULES)/standard
 
diff --git a/wmake/rules/linux64Pgi/general b/wmake/rules/linux64Pgi/general
index 91cca018b67..5cfb798fac4 100644
--- a/wmake/rules/linux64Pgi/general
+++ b/wmake/rules/linux64Pgi/general
@@ -1,9 +1,13 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 ## include $(GENERAL_RULES)/Pgi/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+# -----------------------------------------------------------------------------
diff --git a/wmake/rules/linuxARM64Arm/general b/wmake/rules/linuxARM64Arm/general
index 9ada28972dd..c5a32b88080 100644
--- a/wmake/rules/linuxARM64Arm/general
+++ b/wmake/rules/linuxARM64Arm/general
@@ -1,9 +1,13 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Clang/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+# -----------------------------------------------------------------------------
diff --git a/wmake/rules/linuxARM64Clang/general b/wmake/rules/linuxARM64Clang/general
index 9ada28972dd..c5a32b88080 100644
--- a/wmake/rules/linuxARM64Clang/general
+++ b/wmake/rules/linuxARM64Clang/general
@@ -1,9 +1,13 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Clang/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+# -----------------------------------------------------------------------------
diff --git a/wmake/rules/linuxARM64Fujitsu/general b/wmake/rules/linuxARM64Fujitsu/general
index 34cc312f0ba..87084f464af 100644
--- a/wmake/rules/linuxARM64Fujitsu/general
+++ b/wmake/rules/linuxARM64Fujitsu/general
@@ -1,7 +1,5 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 ## include $(GENERAL_RULES)/Clang/openmp
 
@@ -10,9 +8,12 @@ include $(GENERAL_RULES)/standard
 COMP_OPENMP = -DUSE_OMP -fopenmp
 LINK_OPENMP = -lfjomp
 # ----
-# Or disable
-# include $(GENERAL_RULES)/no-openmp
-# ----
+
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
 
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+# -----------------------------------------------------------------------------
diff --git a/wmake/rules/linuxARM64Gcc/general b/wmake/rules/linuxARM64Gcc/general
index fad7e3b14df..8349c8abfde 100644
--- a/wmake/rules/linuxARM64Gcc/general
+++ b/wmake/rules/linuxARM64Gcc/general
@@ -1,10 +1,14 @@
 CPP         = cpp -traditional-cpp $(GFLAGS)
 LD          = ld
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Gcc/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/linuxARM7Gcc/general b/wmake/rules/linuxARM7Gcc/general
index c56a7353ca5..676a1fd1f1f 100644
--- a/wmake/rules/linuxARM7Gcc/general
+++ b/wmake/rules/linuxARM7Gcc/general
@@ -1,10 +1,14 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 LD         = ld
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Gcc/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/linuxClang/c++ b/wmake/rules/linuxClang/c++
index 3f1f6bbd98b..437fbedef7d 100644
--- a/wmake/rules/linuxClang/c++
+++ b/wmake/rules/linuxClang/c++
@@ -11,4 +11,10 @@ cxxtoo      = $(Ctoo)
 cctoo       = $(Ctoo)
 cpptoo      = $(Ctoo)
 
-include $(GENERAL_RULES)/Clang/link-c++
+ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/Clang/link-gold-c++
+else
+    include $(GENERAL_RULES)/Clang/link-c++
+endif
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/linuxClang/general b/wmake/rules/linuxClang/general
index 04529b376a0..e4c9500563a 100644
--- a/wmake/rules/linuxClang/general
+++ b/wmake/rules/linuxClang/general
@@ -1,10 +1,14 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 LD         = ld -melf_i386
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Clang/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+# -----------------------------------------------------------------------------
diff --git a/wmake/rules/linuxGcc/c++ b/wmake/rules/linuxGcc/c++
index 1738c442457..a15e5eedea0 100644
--- a/wmake/rules/linuxGcc/c++
+++ b/wmake/rules/linuxGcc/c++
@@ -11,4 +11,10 @@ cxxtoo      = $(Ctoo)
 cctoo       = $(Ctoo)
 cpptoo      = $(Ctoo)
 
-include $(GENERAL_RULES)/Gcc/link-c++
+ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/Gcc/link-gold-c++
+else
+    include $(GENERAL_RULES)/Gcc/link-c++
+endif
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/linuxGcc/general b/wmake/rules/linuxGcc/general
index f52d4b26a9d..0745ac61143 100644
--- a/wmake/rules/linuxGcc/general
+++ b/wmake/rules/linuxGcc/general
@@ -1,10 +1,14 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 LD         = ld -melf_i386
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Gcc/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/linuxIA64Gcc/general b/wmake/rules/linuxIA64Gcc/general
index 3c8d2d7f619..3fbd967720d 100644
--- a/wmake/rules/linuxIA64Gcc/general
+++ b/wmake/rules/linuxIA64Gcc/general
@@ -1,10 +1,14 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Gcc/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/X
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/linuxIA64Icc/general b/wmake/rules/linuxIA64Icc/general
index eee8f6f6948..b75dd9190ad 100644
--- a/wmake/rules/linuxIA64Icc/general
+++ b/wmake/rules/linuxIA64Icc/general
@@ -1,10 +1,15 @@
 CPP        = /lib/cpp -traditional-cpp $(GFLAGS) -DICC_IA64_PREFETCH
-
 GLIBS      =
 
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Icc/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/X
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/linuxIcc/general b/wmake/rules/linuxIcc/general
index 615ceefae22..fdbf49352ca 100644
--- a/wmake/rules/linuxIcc/general
+++ b/wmake/rules/linuxIcc/general
@@ -1,10 +1,14 @@
 CPP        = /lib/cpp -traditional-cpp $(GFLAGS)
 LD         = ld -melf_i386
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Icc/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/linuxPPC64Gcc/general b/wmake/rules/linuxPPC64Gcc/general
index 6648c166215..6fa4c18591d 100644
--- a/wmake/rules/linuxPPC64Gcc/general
+++ b/wmake/rules/linuxPPC64Gcc/general
@@ -1,11 +1,15 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 LD         = ld -m elf64ppc
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Gcc/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/X
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/linuxPPC64leGcc/general b/wmake/rules/linuxPPC64leGcc/general
index 567c0cee834..84b07b0fbb7 100644
--- a/wmake/rules/linuxPPC64leGcc/general
+++ b/wmake/rules/linuxPPC64leGcc/general
@@ -1,11 +1,15 @@
 CPP        = cpp -traditional-cpp $(GFLAGS)
 LD         = ld -m elf64lppc
 
-PROJECT_LIBS = -l$(WM_PROJECT) -ldl
-
 include $(GENERAL_RULES)/standard
 include $(GENERAL_RULES)/Gcc/openmp
 
+ifneq (,$(findstring ~openmp,$(WM_COMPILE_CONTROL)))
+    include $(GENERAL_RULES)/no-openmp
+endif
+
 include $(DEFAULT_RULES)/X
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/solaris64Gcc/general b/wmake/rules/solaris64Gcc/general
index bbf1b69bc2b..de1c65aa61f 100644
--- a/wmake/rules/solaris64Gcc/general
+++ b/wmake/rules/solaris64Gcc/general
@@ -1,10 +1,14 @@
 CPP        = /lib/cpp
 LD         = ld -64
 
-PROJECT_LIBS = -l$(WM_PROJECT) -lnsl -lsocket -L$(FOAM_LIBBIN)/dummy -lPstream
+PROJECT_LIBS = -l$(WM_PROJECT) \
+    -lnsl -lsocket \
+    -L$(FOAM_LIBBIN)/dummy -lPstream
 
 include $(GENERAL_RULES)/standard
 
 include $(DEFAULT_RULES)/X
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
+
+#------------------------------------------------------------------------------
-- 
GitLab