diff --git a/Allwmake-modules b/Allwmake-modules index ed57ffe524..5d87347730 100755 --- a/Allwmake-modules +++ b/Allwmake-modules @@ -1,6 +1,6 @@ #!/bin/sh cd "${0%/*}" || exit # Run from this directory -set -- -no-recursion "$@" # Parse arguments only +set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake # Run from OPENFOAM top-level directory only wmake -check-dir "$WM_PROJECT_DIR" 2>/dev/null || { @@ -33,7 +33,7 @@ case "$FOAM_MODULE_PREFIX" in ;; (*) # Use wmake -all instead of Allwmake to allow for overrides - ( cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all ) + ( cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all $* ) esac #------------------------------------------------------------------------------ diff --git a/Allwmake-plugins b/Allwmake-plugins index 33ab65246f..c943927d4f 100755 --- a/Allwmake-plugins +++ b/Allwmake-plugins @@ -1,6 +1,6 @@ #!/bin/sh cd "${0%/*}" || exit # Run from this directory -set -- -no-recursion "$@" # Parse arguments only +set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake # Run from OPENFOAM top-level directory only wmake -check-dir "$WM_PROJECT_DIR" 2>/dev/null || { @@ -33,7 +33,7 @@ case "$FOAM_MODULE_PREFIX" in ;; (*) # Use wmake -all instead of Allwmake to allow for overrides - ( cd "$WM_PROJECT_DIR/plugins" 2>/dev/null && wmake -all ) + ( cd "$WM_PROJECT_DIR/plugins" 2>/dev/null && wmake -all $* ) esac #------------------------------------------------------------------------------ diff --git a/applications/test/00-dummy/library/Allwclean-mpi b/applications/test/00-dummy/library/Allwclean-mpi index d238e435a1..f885e7c11f 100755 --- a/applications/test/00-dummy/library/Allwclean-mpi +++ b/applications/test/00-dummy/library/Allwclean-mpi @@ -1,6 +1,6 @@ #!/bin/sh -cd "${0%/*}" || exit # Run from this directory -. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions +cd "${0%/*}" || exit # Run from this directory +. "${WM_PROJECT_DIR:?}"/wmake/scripts/wmakeFunctions # Need wmake functions #------------------------------------------------------------------------------ diff --git a/applications/test/00-dummy/library/Allwmake-mpi b/applications/test/00-dummy/library/Allwmake-mpi index 0cb6911896..a5082cf712 100755 --- a/applications/test/00-dummy/library/Allwmake-mpi +++ b/applications/test/00-dummy/library/Allwmake-mpi @@ -1,8 +1,9 @@ #!/bin/sh cd "${0%/*}" || exit # Run from this directory -set -- -no-recursion "$@" # Parse arguments only -. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions +set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake + +. "${WM_PROJECT_DIR:?}"/wmake/scripts/AllwmakeParseArguments +. "${WM_PROJECT_DIR:?}"/wmake/scripts/wmakeFunctions # Need wmake functions #------------------------------------------------------------------------------ # Environment diff --git a/src/Allwmake b/src/Allwmake index 3700e0b7e0..04f82ffe97 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -20,6 +20,7 @@ echo Compile OpenFOAM libraries echo ======================================== #------------------------------------------------------------------------------ +# Base libraries wmakeLnInclude -u OpenFOAM wmakeLnInclude -u OSspecific/"${WM_OSTYPE:-POSIX}" @@ -49,10 +50,13 @@ esac wmake $targetType OpenFOAM +# Frequently needed, even for minimal programs wmake $targetType fileFormats wmake $targetType surfMesh wmake $targetType meshTools +#------------------------------------------------------------------------------ + wmake $targetType finiteArea wmake $targetType finiteVolume wmake $targetType fused/finiteVolume diff --git a/src/Allwmake-base b/src/Allwmake-base new file mode 100755 index 0000000000..ad25cfc185 --- /dev/null +++ b/src/Allwmake-base @@ -0,0 +1,64 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from OPENFOAM src/ directory only +set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake + +wmake -check-dir "$WM_PROJECT_DIR/src" 2>/dev/null || { + echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR/src" + echo " Check your OpenFOAM environment and installation" + exit 1 +} +if [ -f "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments ] +then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments || \ + echo "Argument parse error" +else + echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect" + echo " Check your OpenFOAM environment and installation" + exit 1 +fi + +echo ======================================== +echo Compile OpenFOAM base libraries +echo ======================================== + +#------------------------------------------------------------------------------ + +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 +(Mingw*) + # Pstream/OpenFOAM cyclic dependency + # 1st pass: link as Pstream as single .o object + WM_MPLIB=dummy Pstream/Allwmake libo + FOAM_LINK_DUMMY_PSTREAM=libo wmake $targetType OpenFOAM + + # 2nd pass: link Pstream.{dll,so} against libOpenFOAM.{dll,so} + Pstream/Allwmake $targetType $* + + # Force relink libOpenFOAM.{dll,so} against libPstream.{dll,so} + OpenFOAM/Alltouch 2>/dev/null + ;; +(*) + Pstream/Allwmake $targetType $* + ;; +esac + +wmake $targetType OpenFOAM + +# Frequently needed, even for minimal programs +wmake $targetType fileFormats +wmake $targetType surfMesh +wmake $targetType meshTools + +#------------------------------------------------------------------------------ + +echo ======================================== +echo Done OpenFOAM base libraries +echo ======================================== + +#------------------------------------------------------------------------------ diff --git a/src/Pstream/Allwmake-mpi b/src/Pstream/Allwmake-mpi index 9a109189ed..8fc4801135 100755 --- a/src/Pstream/Allwmake-mpi +++ b/src/Pstream/Allwmake-mpi @@ -1,8 +1,8 @@ #!/bin/sh cd "${0%/*}" || exit # Run from this directory -set -- -no-recursion "$@" # Parse arguments only -. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions +set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake +. "${WM_PROJECT_DIR:?}"/wmake/scripts/AllwmakeParseArguments +. "${WM_PROJECT_DIR:?}"/wmake/scripts/wmakeFunctions # Need wmake functions #------------------------------------------------------------------------------ # Environment diff --git a/src/parallel/decompose/Allwmake-mpi b/src/parallel/decompose/Allwmake-mpi index 2f5b994173..73e25ce7b6 100755 --- a/src/parallel/decompose/Allwmake-mpi +++ b/src/parallel/decompose/Allwmake-mpi @@ -1,9 +1,9 @@ #!/bin/sh cd "${0%/*}" || exit # Run from this directory -set -- -no-recursion "$@" # Parse arguments only -. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions -. ${WM_PROJECT_DIR:?}/wmake/scripts/have_scotch +set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake +. "${WM_PROJECT_DIR:?}"/wmake/scripts/AllwmakeParseArguments +. "${WM_PROJECT_DIR:?}"/wmake/scripts/wmakeFunctions # Need wmake functions +. "${WM_PROJECT_DIR:?}"/wmake/scripts/have_scotch #------------------------------------------------------------------------------ # Environment diff --git a/wmake/scripts/AllwmakeParseArguments b/wmake/scripts/AllwmakeParseArguments index 7403dbcdc8..6274100b2c 100644 --- a/wmake/scripts/AllwmakeParseArguments +++ b/wmake/scripts/AllwmakeParseArguments @@ -89,7 +89,8 @@ USAGE #------------------------------------------------------------------------------ unset wmakeOpt_frontend wmakeOpt_frontend_arg wmakeOpt_nonRecursive -unset wmakeOpt_debug wmakeOpt_log wmakeOpt_openmp wmakeOpt_strict wmakeOpt_queue +unset wmakeOpt_debug wmakeOpt_log wmakeOpt_openmp wmakeOpt_strict +unset wmakeOpt_all wmakeOpt_queue for arg in "$@" do @@ -99,7 +100,7 @@ do case "$arg" in ('') continue ;; # Empty argument, ignore it - -h | -help*) + -h | -help* | --help*) usage ;; @@ -123,6 +124,17 @@ do # Pass onwards to other Allwmake scripts ;; + -all=*) + # Alternative entry point to ./Allwmake + wmakeOpt_all="$arg" + if [ -z "${wmakeOpt_all##*=}" ] + then + echo "ignoring -all=... (missing filename)" 1>&2 + unset wmakeOpt_all + fi + continue # Argument handled, remove it + ;; + -build-root=*) # Alternative location for build intermediates export FOAM_BUILDROOT="${arg#*=}" @@ -222,15 +234,18 @@ done if [ -z "$wmakeOpt_nonRecursive" ] then + # wmake -all=FILE or wmake -all + : "${wmakeOpt_all:=-all}" + if [ -z "$wmakeOpt_log" ] then - exec wmake $wmakeOpt_frontend "$wmakeOpt_frontend_arg" -all \ + exec wmake $wmakeOpt_frontend "$wmakeOpt_frontend_arg" "$wmakeOpt_all" \ $wmakeOpt_debug $wmakeOpt_strict $wmakeOpt_queue $wmakeOpt_openmp $* exit $? # Unneeded, but just in case something went wrong else - echo "Logging wmake -all output to '$wmakeOpt_log'" 1>&2 + echo "Logging wmake output to '$wmakeOpt_log'" 1>&2 echo 1>&2 - exec wmake $wmakeOpt_frontend "$wmakeOpt_frontend_arg" -all \ + exec wmake $wmakeOpt_frontend "$wmakeOpt_frontend_arg" "$wmakeOpt_all" \ $wmakeOpt_debug $wmakeOpt_strict $wmakeOpt_queue $wmakeOpt_openmp $* 2>&1 | \ /usr/bin/tee $wmakeOpt_log # Need to cleanup after the tee @@ -256,7 +271,8 @@ fi #------------------------------------------------------------------------------ unset wmakeOpt_frontend wmakeOpt_frontend_arg wmakeOpt_nonRecursive -unset wmakeOpt_debug wmakeOpt_log wmakeOpt_openmp wmakeOpt_strict wmakeOpt_queue +unset wmakeOpt_debug wmakeOpt_log wmakeOpt_openmp wmakeOpt_strict +unset wmakeOpt_all wmakeOpt_queue unset -f usage diff --git a/wmake/wmake b/wmake/wmake index 0f78d955d1..9f889097f4 100755 --- a/wmake/wmake +++ b/wmake/wmake @@ -7,7 +7,7 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2017-2023 OpenCFD Ltd. +# Copyright (C) 2017-2025 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later. @@ -70,6 +70,7 @@ HELP_HEAD if [ -n "$1" ] then cat<&2 + fi ;; # Recursive build all with scheduled queuing -q | -queue | queue) - opt_all=queue + opt_all='-queue' ;; # Parallel compilation on all cores (or specified number of cores) @@ -357,7 +371,7 @@ do # and respective binaries. -update) opt_update=true - : "${opt_all:=all}" # implies 'all', unless previously set + : "${opt_all:=-all}" # implies '-all', unless previously set ;; -show-api | -version | --version) @@ -556,7 +570,7 @@ fi # Extract ccache controls from WM_COMPILE_CONTROL if possible # and when queuing is not active -if [ "$opt_all" != queue ] +if [ "$opt_all" != '-queue' ] then unset opt_ccache @@ -619,11 +633,21 @@ fi # Recurse the source tree to compile "all" targets #------------------------------------------------------------------------------ -if [ "$opt_all" = all ] +if [ "$opt_all" = '-all' ] then unset exitCode - if [ -e Allwmake.override ] + if [ -n "$opt_allwmake" ] + then + if [ -x "./$opt_allwmake" ] + then + ./"$opt_allwmake" -fromWmake $targetType + exitCode="$?" + else + echo "Non-executable file: ./$opt_allwmake" 1>&2 + exitCode=1 + fi + elif [ -e Allwmake.override ] then if [ -x Allwmake.override ] then @@ -679,7 +703,7 @@ fi # Recurse source tree to compile "all" targets using wmakeCollect #------------------------------------------------------------------------------ -if [ "$opt_all" = queue ] +if [ "$opt_all" = '-queue' ] then [ "$opt_update" = true ] || wmakeLnIncludeAll $parOpt @@ -700,15 +724,18 @@ then collectName="${collectName////_}" # Path as unique name fi + # Forward with -all or -all=FILE + opt_all="-all${opt_allwmake:+=}${opt_allwmake}" + ## echo "collect: $buildRoot/$collectName" 1>&2 ( export WM_COLLECT_DIR="$buildRoot/$collectName" export WM_SCHEDULER="$WM_DIR/wmakeCollect" trap '$WM_SCHEDULER -kill' TERM INT "$WM_SCHEDULER" -clean \ - && wmake -all objects \ + && wmake "$opt_all" objects \ && "$WM_SCHEDULER" # Make with assembled makefile - ) && wmake -all + ) && wmake "$opt_all" exit $? fi