diff --git a/Allwmake b/Allwmake
index d2ff4dc17dd401a46605744ed84845f712516e46..240e7e262163cea8812951bc487a842857f1b561 100755
--- a/Allwmake
+++ b/Allwmake
@@ -73,7 +73,12 @@ echo
 applications/Allwmake $targetType $*
 
 # Additional components/modules
-if [ -d "$WM_PROJECT_DIR/modules" ]
+if [ "$FOAM_MODULE_PREFIX" = false ]
+then
+    echo "========================================"
+    echo "OpenFOAM modules disabled (prefix=false)"
+    echo
+elif [ -d "$WM_PROJECT_DIR/modules" ]
 then
     echo "========================================"
     echo "Compile OpenFOAM modules"
@@ -83,6 +88,10 @@ then
     set +e
     export WM_CONTINUE_ON_ERROR=true
 
+    # Default build into OpenFOAM project locations
+    : "${FOAM_MODULE_PREFIX:=${FOAM_LIBBIN%/*}}"
+    export FOAM_MODULE_PREFIX
+
     (cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all)
 fi
 
diff --git a/etc/bashrc b/etc/bashrc
index 7067f2d2268f1155671b263c026a7d2cec79db6b..8920907bba303c1cc901af5496d00297b38a50b6 100644
--- a/etc/bashrc
+++ b/etc/bashrc
@@ -153,7 +153,8 @@ unset FOAM_EXTRA_CFLAGS FOAM_EXTRA_CXXFLAGS FOAM_EXTRA_LDFLAGS
 # Capture values of old directories to be cleaned from PATH, LD_LIBRARY_PATH
 foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \
     $HOME/$WM_PROJECT/$USER $FOAM_USER_APPBIN $FOAM_USER_LIBBIN \
-    $WM_PROJECT_SITE $FOAM_SITE_APPBIN $FOAM_SITE_LIBBIN"
+    $WM_PROJECT_SITE $FOAM_SITE_APPBIN $FOAM_SITE_LIBBIN \
+    $FOAM_MODULE_APPBIN $FOAM_MODULE_LIBBIN"
 
 # [WM_PROJECT_DIR] - Location of this OpenFOAM version
 export WM_PROJECT_DIR="$projectDir"
diff --git a/etc/config.csh/unset b/etc/config.csh/unset
index f11a976df93c44c0f418331d73c9d3ac3fb8cad0..484836fc6e2c0d91ccc1b836106f37010e18ffa3 100644
--- a/etc/config.csh/unset
+++ b/etc/config.csh/unset
@@ -89,6 +89,9 @@ unsetenv FOAM_EXTRA_CFLAGS FOAM_EXTRA_CXXFLAGS FOAM_EXTRA_LDFLAGS
 unsetenv FOAM_EXT_LIBBIN
 unsetenv FOAM_JOB_DIR
 unsetenv FOAM_LIBBIN
+unsetenv FOAM_MODULE_APPBIN
+unsetenv FOAM_MODULE_LIBBIN
+unsetenv FOAM_MODULE_PREFIX
 unsetenv FOAM_MPI
 unsetenv FOAM_RUN
 unsetenv FOAM_SETTINGS
diff --git a/etc/config.sh/unset b/etc/config.sh/unset
index cc2542b07da38d9ad543da0cb6049776705dbb95..01c90886373e9c99e43fafeea50ad48ff6914b92 100644
--- a/etc/config.sh/unset
+++ b/etc/config.sh/unset
@@ -76,6 +76,9 @@ unset FOAM_EXTRA_CFLAGS FOAM_EXTRA_CXXFLAGS FOAM_EXTRA_LDFLAGS
 unset FOAM_EXT_LIBBIN
 unset FOAM_JOB_DIR
 unset FOAM_LIBBIN
+unset FOAM_MODULE_APPBIN
+unset FOAM_MODULE_LIBBIN
+unset FOAM_MODULE_PREFIX
 unset FOAM_MPI
 unset FOAM_RUN
 unset FOAM_SETTINGS
diff --git a/etc/cshrc b/etc/cshrc
index 190f30c9daae10dfa2e445436097a5f987bfee28..9d438694e31bcb0477bd1ea71a99d44d6a018491 100644
--- a/etc/cshrc
+++ b/etc/cshrc
@@ -169,6 +169,12 @@ endif
 if ( $?FOAM_SITE_LIBBIN ) then
    set foamOldDirs="$foamOldDirs $FOAM_SITE_LIBBIN"
 endif
+if ( $?FOAM_MODULE_APPBIN ) then
+   set foamOldDirs="$foamOldDirs $FOAM_MODULE_APPBIN"
+endif
+if ( $?FOAM_MODULE_LIBBIN ) then
+   set foamOldDirs="$foamOldDirs $FOAM_MODULE_LIBBIN"
+endif
 
 # [WM_PROJECT_DIR] - Location of this OpenFOAM version
 setenv WM_PROJECT_DIR "$projectDir"
diff --git a/src/Pstream/Allwmake-mpi b/src/Pstream/Allwmake-mpi
index bc36b8cc32d59513628e84c93fe79d94e5816b28..df5f5d0ba351215b609dfdd4912419414069832a 100755
--- a/src/Pstream/Allwmake-mpi
+++ b/src/Pstream/Allwmake-mpi
@@ -1,7 +1,6 @@
 #!/bin/sh
 cd "${0%/*}" || exit                                # Run from this directory
-# No AllwmakeParseArguments [infinite loop via Allwmake]
-. ${WM_PROJECT_DIR:?}/wmake/scripts/wmake.wmake-args
+. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -no-recursion
 . ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions  # Require wmake functions
 
 #------------------------------------------------------------------------------
diff --git a/src/parallel/decompose/Allwmake-mpi b/src/parallel/decompose/Allwmake-mpi
index 6d89dc5179daf9e62beb2c9c169717620bd2094f..3de2ec5d494a7986c38f7635901bea490aca8627 100755
--- a/src/parallel/decompose/Allwmake-mpi
+++ b/src/parallel/decompose/Allwmake-mpi
@@ -1,7 +1,6 @@
 #!/bin/sh
 cd "${0%/*}" || exit                                # Run from this directory
-# No AllwmakeParseArguments [infinite loop via Allwmake]
-. ${WM_PROJECT_DIR:?}/wmake/scripts/wmake.wmake-args
+. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -no-recursion
 . ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions  # Require wmake functions
 . ${WM_PROJECT_DIR:?}/wmake/scripts/have_scotch
 
diff --git a/wmake/rules/General/module-path-group b/wmake/rules/General/module-path-group
new file mode 100644
index 0000000000000000000000000000000000000000..3ffadd95fe998f14a7b4680342055d84cdba903c
--- /dev/null
+++ b/wmake/rules/General/module-path-group
@@ -0,0 +1,21 @@
+# ----------------------------------------------------------------------------
+# Set defaults for FOAM_MODULE_APPBIN, FOAM_MODULE_LIBBIN
+# based on group locations
+#
+# FOAM_MODULE_APPBIN ?= FOAM_SITE_APPBIN
+# FOAM_MODULE_LIBBIN ?= FOAM_SITE_LIBBIN
+#
+# See: GENERAL_RULES/module-path-prefix
+# ----------------------------------------------------------------------------
+
+include $(GENERAL_RULES)/module-path-prefix
+
+ifeq (,$(strip $(FOAM_MODULE_APPBIN)))
+    FOAM_MODULE_APPBIN = $(FOAM_SITE_APPBIN)
+endif
+
+ifeq (,$(strip $(FOAM_MODULE_LIBBIN)))
+    FOAM_MODULE_LIBBIN = $(FOAM_SITE_LIBBIN)
+endif
+
+# ---------------------------------------------------------------------------
diff --git a/wmake/rules/General/module-path-prefix b/wmake/rules/General/module-path-prefix
new file mode 100644
index 0000000000000000000000000000000000000000..bdc46cc13a3207ec86c2cc0f93bde47dcd6e804b
--- /dev/null
+++ b/wmake/rules/General/module-path-prefix
@@ -0,0 +1,50 @@
+# ----------------------------------------------------------------------------
+# Set defaults for FOAM_MODULE_APPBIN, FOAM_MODULE_LIBBIN
+# based on FOAM_MODULE_PREFIX
+#
+# FOAM_MODULE_APPBIN ?= FOAM_MODULE_PREFIX/bin
+# FOAM_MODULE_LIBBIN ?= FOAM_MODULE_PREFIX/iib
+#
+# ----------------------------------------------------------------------------
+# When compiling additional modules or user code, we need flexibility for
+# the installation locations. The project directories may be read-only etc.
+#
+# For this purpose, introduce three additional make variables:
+#
+# - FOAM_MODULE_PREFIX - default is unset
+# - FOAM_MODULE_APPBIN - default is $(FOAM_MODULE_PREFIX)/bin
+# - FOAM_MODULE_LIBBIN - default is $(FOAM_MODULE_PREFIX)/lib
+#
+# The developer may have an intended default location for a particular module.
+#
+# For default location 'user':
+#   Make/options:       include $(GENERAL_RULES)/module-path-user
+#   Make/files:         LIB = $(FOAM_MODULE_LIBBIN)/libXYZ
+#
+# For default location 'group':
+#   Make/options:       include $(GENERAL_RULES)/module-path-group
+#   Make/files:         LIB = $(FOAM_MODULE_LIBBIN)/libXYZ
+#
+# For default location 'project' (openfoam):
+#   Make/options:       include $(GENERAL_RULES)/module-path-project
+#   Make/files:         LIB = $(FOAM_MODULE_LIBBIN)/libXYZ
+#
+#
+# The module-path-{user,group,project} rules should include module-path-prefix
+# first.
+#
+# ----------------------------------------------------------------------------
+
+ifeq (,$(strip $(FOAM_MODULE_APPBIN)))
+    ifneq (,$(strip $(FOAM_MODULE_PREFIX)))
+        FOAM_MODULE_APPBIN = $(strip $(FOAM_MODULE_PREFIX))/bin
+    endif
+endif
+
+ifeq (,$(strip $(FOAM_MODULE_LIBBIN)))
+    ifneq (,$(strip $(FOAM_MODULE_PREFIX)))
+        FOAM_MODULE_LIBBIN = $(strip $(FOAM_MODULE_PREFIX))/lib
+    endif
+endif
+
+# ---------------------------------------------------------------------------
diff --git a/wmake/rules/General/module-path-project b/wmake/rules/General/module-path-project
new file mode 100644
index 0000000000000000000000000000000000000000..c8a026fce50f918c016f7b966986b5959f21e292
--- /dev/null
+++ b/wmake/rules/General/module-path-project
@@ -0,0 +1,21 @@
+# ----------------------------------------------------------------------------
+# Set defaults for FOAM_MODULE_APPBIN, FOAM_MODULE_LIBBIN
+# based on project locations
+#
+# FOAM_MODULE_APPBIN ?= FOAM_APPBIN
+# FOAM_MODULE_LIBBIN ?= FOAM_LIBBIN
+#
+# See: GENERAL_RULES/module-path-prefix
+# ----------------------------------------------------------------------------
+
+include $(GENERAL_RULES)/module-path-prefix
+
+ifeq (,$(strip $(FOAM_MODULE_APPBIN)))
+    FOAM_MODULE_APPBIN = $(FOAM_APPBIN)
+endif
+
+ifeq (,$(strip $(FOAM_MODULE_LIBBIN)))
+    FOAM_MODULE_LIBBIN = $(FOAM_LIBBIN)
+endif
+
+# ---------------------------------------------------------------------------
diff --git a/wmake/rules/General/module-path-user b/wmake/rules/General/module-path-user
new file mode 100644
index 0000000000000000000000000000000000000000..eab21bfdceef7602b08cb57a99f7ed0b3a34ce70
--- /dev/null
+++ b/wmake/rules/General/module-path-user
@@ -0,0 +1,21 @@
+# ----------------------------------------------------------------------------
+# Set defaults for FOAM_MODULE_APPBIN, FOAM_MODULE_LIBBIN
+# based on user locations
+#
+# FOAM_MODULE_APPBIN ?= FOAM_USER_APPBIN
+# FOAM_MODULE_LIBBIN ?= FOAM_USER_LIBBIN
+#
+# See: GENERAL_RULES/module-path-prefix
+# ----------------------------------------------------------------------------
+
+include $(GENERAL_RULES)/module-path-prefix
+
+ifeq (,$(strip $(FOAM_MODULE_APPBIN)))
+    FOAM_MODULE_APPBIN = $(FOAM_USER_APPBIN)
+endif
+
+ifeq (,$(strip $(FOAM_MODULE_LIBBIN)))
+    FOAM_MODULE_LIBBIN = $(FOAM_USER_LIBBIN)
+endif
+
+# ---------------------------------------------------------------------------
diff --git a/wmake/scripts/AllwmakeParseArguments b/wmake/scripts/AllwmakeParseArguments
index a8f8651c3aa4ab4e35b836f45f35399eb0a6aaf1..09c17f47a8918041b16847929c395c40d4ae7f36 100644
--- a/wmake/scripts/AllwmakeParseArguments
+++ b/wmake/scripts/AllwmakeParseArguments
@@ -28,9 +28,15 @@
 # Parsed options (wmake)
 #     -debug
 #     -q | -queue
+#     -module-prefix=...
+#         Exports FOAM_MODULE_PREFIX value.
+#         Unsets FOAM_MODULE_APPBIN, FOAM_MODULE_LIBBIN.
+#         Handles (user|group|openfoam) or (u|g|o) as per foamEtcFile,
+#         or absolute/relative paths
 #
 # Parsed options (special)
 #     -l | -log | -log=FILE
+#     -prefix=...   same as -module-prefix=...
 #
 #------------------------------------------------------------------------------
 # Check environment
@@ -54,11 +60,15 @@ Executing ${0##*/} is equivalent to
 
    wmake -all [OPTIONS]
 
-With these additional options:
-   -l | -log | -log=name
+With additional options:
+    -l | -log           Tee output to log.\$WM_OPTIONS
+    -log=NAME           Tee output to given filename
+    -prefix=...         Identical to wmake -module-prefix
+    -no-recursion       Prevent recursive call (do NOT call 'wmake -all')
+    -fromWmake          Same as -no-recursion
 
 See
-   wmake -help (or wmake -help-full)
+    wmake -help (or wmake -help-full)
 
 USAGE
     exit 0  # clean exit
@@ -69,7 +79,7 @@ USAGE
 # Parse the arguments and options
 #------------------------------------------------------------------------------
 
-unset fromWmake optDebug optLog optQueue
+unset optDebug optLog optNonRecursive optPrefix optQueue
 
 for arg in "$@"
 do
@@ -80,19 +90,58 @@ do
     -h | -help*)
         usage
         ;;
-    -fromWmake)
-        # If called from wmake (to avoid recursion)
-        fromWmake=true
+
+    -no-recurs* | -fromWmake)
+        # Avoid recursion (eg, if called from wmake)
+        optNonRecursive=true
+        continue    # Handled argument
+        ;;
+
+    -prefix=* | -module-prefix=*)
+        optPrefix="${arg#*=}"
+        case "$optPrefix" in
+        # Prefix: user
+        (u | user)
+            export FOAM_MODULE_PREFIX="${FOAM_USER_LIBBIN%/*}"
+            ;;
+
+        # Prefix: group
+        (g | group)
+            export FOAM_MODULE_PREFIX="${FOAM_SITE_LIBBIN%/*}"
+            ;;
+
+        # Prefix: openfoam (other)
+        (o | openfoam)
+            export FOAM_MODULE_PREFIX="${FOAM_LIBBIN%/*}"
+            ;;
+
+        # Prefix: custom (absolute or relative)
+        (*)
+            export FOAM_MODULE_PREFIX="$optPrefix"
+            : "${FOAM_MODULE_PREFIX:=/usr/local}"  # Default (autoconf)
+
+            # Require absolute path
+            [ "${FOAM_MODULE_PREFIX#/}" != "${FOAM_MODULE_PREFIX}" ] || \
+                FOAM_MODULE_PREFIX="${PWD}/${FOAM_MODULE_PREFIX}"
+            ;;
+        esac
+
+        unset FOAM_MODULE_APPBIN FOAM_MODULE_LIBBIN
+        echo "Module prefix = $FOAM_MODULE_PREFIX" 1>&2
+        continue    # Handled argument
         ;;
+
     -k | -keep-going | -non-stop)
         # Keep going, ignoring errors
         export WM_CONTINUE_ON_ERROR=true
         continue    # Permanently remove arg
         ;;
+
     -l | -log)
         optLog="log.${WM_OPTIONS:-build}"
         continue    # Permanently remove arg
         ;;
+
     -log=*)
         optLog="${arg##*=}"
         if [ -d "$optLog" ]
@@ -104,17 +153,20 @@ do
         fi
         continue    # Permanently remove arg
         ;;
+
     -debug)
         optDebug="-debug"
         continue    # Permanently remove arg
         ;;
+
     -q | -queue)
         optQueue="-queue"
         continue    # Permanently remove arg
         ;;
+
     lib | libo | libso | dep | objects)
         # Target type
-        targetType=$arg
+        targetType="$arg"
         ;;
     esac
 
@@ -127,7 +179,7 @@ done
 # Execute wmake -all if not called from wmake
 #------------------------------------------------------------------------------
 
-if [ -z "$fromWmake" ]
+if [ -z "$optNonRecursive" ]
 then
     if [ -z "$optLog" ]
     then
@@ -140,7 +192,7 @@ then
         # Need to cleanup after the tee
         rc=$? # Error code from tee (not wmake), but not entirely important
         echo "Done logging to '$optLog'" 1>&2
-        exit $rc
+        exit "$rc"
     fi
 fi
 
@@ -159,7 +211,7 @@ fi
 # Cleanup local variables and functions
 #------------------------------------------------------------------------------
 
-unset fromWmake optDebug optLog optQueue
+unset optNonRecursive optDebug optLog optPrefix optQueue
 unset -f usage
 
 
diff --git a/wmake/scripts/wmake.cmake-args b/wmake/scripts/wmake.cmake-args
deleted file mode 100644
index 1c618e5664b72a164e5ab282999fe419eefe44d8..0000000000000000000000000000000000000000
--- a/wmake/scripts/wmake.cmake-args
+++ /dev/null
@@ -1,120 +0,0 @@
-#----------------------------------*-sh-*--------------------------------------
-# =========                 |
-# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-#  \\    /   O peration     |
-#   \\  /    A nd           | www.openfoam.com
-#    \\/     M anipulation  |
-#------------------------------------------------------------------------------
-#     Copyright (C) 2020 OpenCFD Ltd.
-#------------------------------------------------------------------------------
-# License
-#     This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
-#
-# File
-#     wmake/scripts/wmake.cmake-args
-#
-# Description
-#     Special-purpose argument parser (eg, for Allwmake scripts)
-#     that handles -prefix=... and some other simpler tasks
-#
-# Usage
-#     # Parse the arguments by sourcing this script
-#     . ${WM_PROJECT_DIR:?}/wmake/scripts/wmake.cmake-args
-#
-# Options
-#     -prefix=...
-#     Exports CMAKE_INSTALL_PREFIX value.
-#     Handles u(ser), g(roup), o(ther) short-cuts (see foamEtcFile),
-#     absolute or relative paths
-#
-#     -j | -jN | -j N
-#     Compile using all or specified N cores/hyperthreads
-#
-#------------------------------------------------------------------------------
-
-# NB: nArgs to track the current processing position to avoid wraparound
-# when checking for optional parameters (eg, the -j processing)
-
-nArgs="$#"
-for arg in "$@"
-do
-    shift; nArgs="$((nArgs - 1))"               # Drop argument
-
-    case "$arg" in
-
-    # Install prefix: user
-    -prefix=u | -prefix=user)
-        export CMAKE_INSTALL_PREFIX="${FOAM_USER_LIBBIN%/*}"
-        echo "Install prefix = user ($CMAKE_INSTALL_PREFIX)" 1>&2
-        continue    # Handled argument
-        ;;
-
-    # Install prefix: group
-    -prefix=g | -prefix=group)
-        export CMAKE_INSTALL_PREFIX="${FOAM_SITE_LIBBIN%/*}"
-        echo "Install prefix = group ($CMAKE_INSTALL_PREFIX)" 1>&2
-        continue    # Handled argument
-        ;;
-
-    # Install prefix: other/openfoam
-    -prefix=o | -prefix=other | -prefix=openfoam)
-        export CMAKE_INSTALL_PREFIX="${FOAM_LIBBIN%/*}"
-        echo "Install prefix = openfoam ($CMAKE_INSTALL_PREFIX)" 1>&2
-        continue    # Handled argument
-        ;;
-
-    # Install prefix: custom
-    -prefix=*)
-        export CMAKE_INSTALL_PREFIX="${arg#*=}"
-        : "${CMAKE_INSTALL_PREFIX:=/usr/local}"  # Default as per autoconf
-
-        # Require as absolute path
-        [ "${CMAKE_INSTALL_PREFIX#/}" != "${CMAKE_INSTALL_PREFIX}" ] || \
-            CMAKE_INSTALL_PREFIX="${PWD}/${CMAKE_INSTALL_PREFIX}"
-
-        echo "Install prefix = $CMAKE_INSTALL_PREFIX" 1>&2
-        continue    # Handled argument
-        ;;
-
-    # Parallel compilation (all or specified number of cores)
-    -j)
-        export WM_NCOMPPROCS=0
-        if [ "$nArgs" -gt 0 ]
-        then
-            case "$1" in
-            [0-9]*)
-                if WM_NCOMPPROCS="$(expr 0 + "$1" 2>/dev/null)"
-                then
-                    shift; nArgs="$((nArgs - 1))"   # Drop argument
-                fi
-                ;;
-            esac
-        fi
-        if [ "${WM_NCOMPPROCS:=0}" -le 0 ]
-        then
-            WM_NCOMPPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \
-                WM_NCOMPPROCS=1
-        fi
-
-        echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
-        continue    # Handled argument
-        ;;
-
-    # Parallel compilation (specified number of cores)
-    -j[0-9]*)
-        export WM_NCOMPPROCS="${arg#-j}"
-        if [ "${WM_NCOMPPROCS:=0}" -le 0 ]
-        then
-            WM_NCOMPPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \
-                WM_NCOMPPROCS=1
-        fi
-
-        echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
-        continue    # Handled argument
-        ;;
-    esac
-
-    set -- "$@" "$arg"     # Reinsert unhandled argument
-done
-
-#------------------------------------------------------------------------------
diff --git a/wmake/scripts/wmake.wmake-args b/wmake/scripts/wmake.wmake-args
deleted file mode 100644
index 87d449502648aec8c33810d1bfd55c34ed273b36..0000000000000000000000000000000000000000
--- a/wmake/scripts/wmake.wmake-args
+++ /dev/null
@@ -1,90 +0,0 @@
-#----------------------------------*-sh-*--------------------------------------
-# =========                 |
-# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-#  \\    /   O peration     |
-#   \\  /    A nd           | www.openfoam.com
-#    \\/     M anipulation  |
-#------------------------------------------------------------------------------
-#     Copyright (C) 2020 OpenCFD Ltd.
-#------------------------------------------------------------------------------
-# License
-#     This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
-#
-# File
-#     wmake/scripts/wmake.wmake-args
-#
-# Description
-#     Reduced argument parser (eg, for scripts using wmake)
-#     that handles some common parameters
-#
-# Usage
-#     # Parse the arguments by sourcing this script
-#     . ${WM_PROJECT_DIR:?}/wmake/scripts/wmake.wmake-args
-#
-# Options
-#     -s | -silent | -quiet
-#     Exports WM_QUIET=true
-#
-#     -j | -jN | -j N
-#     Compile using all or specified N cores/hyperthreads
-#
-#------------------------------------------------------------------------------
-
-# NB: nArgs to track the current processing position to avoid wraparound
-# when checking for optional parameters (eg, the -j processing)
-
-nArgs="$#"
-for arg in "$@"
-do
-    shift; nArgs="$((nArgs - 1))"               # Drop argument
-
-    case "$arg" in
-
-    # Silent operation
-    -s | -silent | -quiet)
-        export WM_QUIET=true
-        continue    # Handled argument
-        ;;
-
-    # Parallel compilation (all or specified number of cores)
-    -j)
-        export WM_NCOMPPROCS=0
-        if [ "$nArgs" -gt 0 ]
-        then
-            case "$1" in
-            [0-9]*)
-                if WM_NCOMPPROCS="$(expr 0 + "$1" 2>/dev/null)"
-                then
-                    shift; nArgs="$((nArgs - 1))"   # Drop argument
-                fi
-                ;;
-            esac
-        fi
-        if [ "${WM_NCOMPPROCS:=0}" -le 0 ]
-        then
-            WM_NCOMPPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \
-                WM_NCOMPPROCS=1
-        fi
-
-        echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
-        continue    # Handled argument
-        ;;
-
-    # Parallel compilation (specified number of cores)
-    -j[0-9]*)
-        export WM_NCOMPPROCS="${arg#-j}"
-        if [ "${WM_NCOMPPROCS:=0}" -le 0 ]
-        then
-            WM_NCOMPPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \
-                WM_NCOMPPROCS=1
-        fi
-
-        echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
-        continue    # Handled argument
-        ;;
-    esac
-
-    set -- "$@" "$arg"     # Reinsert unhandled argument
-done
-
-#------------------------------------------------------------------------------
diff --git a/wmake/wmake b/wmake/wmake
index b411cf8ab28562aa2d64f498f7957588521d5a8b..89f0fcd06191a0ef4f51163eb7fec765f1cdfd82 100755
--- a/wmake/wmake
+++ b/wmake/wmake
@@ -51,6 +51,7 @@
 #
 # Environment
 #     FOAM_EXTRA_CFLAGS FOAM_EXTRA_CXXFLAGS FOAM_EXTRA_LDFLAGS
+#     FOAM_MODULE_PREFIX
 #
 # See also
 #     wmakeLnInclude, wmakeLnIncludeAll, wmakeCollect, wdep, wrmdep, wrmo,
@@ -81,6 +82,9 @@ if [ -n "$1" ]
 then
 cat<<HELP_FULL
   -debug            Define c++DBUG='-DFULLDEBUG -g -O0' as override
+  -module-prefix=PATH   Specify FOAM_MODULE_PREFIX as absolute/relative path
+  -module-prefix=TYPE   Specify FOAM_MODULE_PREFIX as predefined type
+                        (u,user | g,group | o,openfoam)
   -no-scheduler     Disable scheduled parallel compilation
   -show-api         Print api value (from Make rules)
   -show-ext-so      Print shared library extension (with '.' separator)
@@ -140,6 +144,7 @@ Special targets:
 
 Environment
   FOAM_EXTRA_CFLAGS FOAM_EXTRA_CXXFLAGS FOAM_EXTRA_LDFLAGS
+  FOAM_MODULE_PREFIX
 
 HELP_TAIL_FULL
 else
@@ -226,6 +231,40 @@ do
         -debug)
             optDebug="-DFULLDEBUG -g -O0"
             ;;
+
+        -module-prefix=*)
+            optPrefix="${1#*=}"
+            case "$optPrefix" in
+            # Prefix: user
+            (u | user)
+                export FOAM_MODULE_PREFIX="${FOAM_USER_LIBBIN%/*}"
+                ;;
+
+            # Prefix: group
+            (g | group)
+                export FOAM_MODULE_PREFIX="${FOAM_SITE_LIBBIN%/*}"
+                ;;
+
+            # Prefix: openfoam (other)
+            (o | openfoam)
+                export FOAM_MODULE_PREFIX="${FOAM_LIBBIN%/*}"
+                ;;
+
+            # Prefix: custom (absolute or relative)
+            (*)
+                export FOAM_MODULE_PREFIX="$optPrefix"
+                : "${FOAM_MODULE_PREFIX:=/usr/local}"  # Default (autoconf)
+
+                # Require absolute path
+                [ "${FOAM_MODULE_PREFIX#/}" != "${FOAM_MODULE_PREFIX}" ] || \
+                    FOAM_MODULE_PREFIX="${PWD}/${FOAM_MODULE_PREFIX}"
+                ;;
+            esac
+
+            unset FOAM_MODULE_APPBIN FOAM_MODULE_LIBBIN
+            echo "Module prefix = $FOAM_MODULE_PREFIX" 1>&2
+            ;;
+
         -show-api | -show-ext-so | \
         -show-compile-c   | -show-c   | -show-cflags   | -show-cflags-arch | \
         -show-compile-cxx | -show-cxx | -show-cxxflags | -show-cxxflags-arch )