Mercurial > octave
changeset 31899:c01849481834
avoid problems with $(shell ...) execution in Makefile
The $(shell ...) variable in GNU Make is expanded early before
Makefile variables are defined or exported. This feature causes
trouble for some of Octave's build system shell scripts that may need
environment variables and that also need to be executed early to
generate lists of dependencies. To work around this problem we can
use configure to substitute the needed variables instead of relying on
the Make environment.
See also the discussion here:
https://octave.discourse.group/t/egrep-warning-egrep-is-obsolescent-using-ggrep-e/3484/37
* find-defun-files.in.sh: Rename from find-defun-files.sh.
* find-files-with-tests.in.sh: Rename from find-files-with-tests.sh.
* build-aux/module.mk: Update.
* configure.ac (AC_CONFIG_FILES): Include find-defun-files.sh and
find-files-with-tests.sh in the list of output files.
* libinterp/module.mk, liboctave/module.mk, scripts/module.mk: Remove
"$(srcdir)/" prefix from invocations or find-defun-files.sh and
find-files-with-tests.sh.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 08 Mar 2023 15:06:45 -0500 |
parents | 0db880f38b1f |
children | b02de57ab5bb |
files | build-aux/find-defun-files.in.sh build-aux/find-defun-files.sh build-aux/find-files-with-tests.in.sh build-aux/find-files-with-tests.sh build-aux/module.mk configure.ac libinterp/module.mk liboctave/module.mk scripts/module.mk |
diffstat | 9 files changed, 117 insertions(+), 112 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build-aux/find-defun-files.in.sh Wed Mar 08 15:06:45 2023 -0500 @@ -0,0 +1,56 @@ +#! /bin/sh + +######################################################################## +## +## Copyright (C) 2009-2023 The Octave Project Developers +## +## See the file COPYRIGHT.md in the top-level directory of this +## distribution or <https://octave.org/copyright/>. +## +## This file is part of Octave. +## +## Octave is free software: you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <https://www.gnu.org/licenses/>. +## +######################################################################## + +set -e + +: ${SED=@SED@} +: ${EGREP=@EGREP@} + +# Some stupid egreps don't like empty elements in alternation patterns, +# so we have to repeat ourselves because some stupid egreps don't like +# empty elements in alternation patterns. + +DEFUN_PATTERN="^[ \t]*DEF(CONSTFUN|CONSTMETHOD|METHOD|METHOD(_|_STATIC_)DLD|METHODX|METHODX(_|_STATIC_)DLD|UN|UN(_|_STATIC_)DLD|UNX|UNX(_|_STATIC_)DLD)[ \t]*\\(" + +srcdir="$1" +if [ "$1" ]; then + shift +fi + +for arg +do + if [ -f "$arg" ]; then + file="$arg" + else + file="$srcdir/$arg" + fi + if [ -f "$file" ]; then + if [ "`$EGREP -l "$DEFUN_PATTERN" $file`" ]; then + echo "$file" | $SED "s,\\$srcdir/,," + fi + fi +done
--- a/build-aux/find-defun-files.sh Wed Mar 08 09:28:28 2023 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -#! /bin/sh - -######################################################################## -## -## Copyright (C) 2009-2023 The Octave Project Developers -## -## See the file COPYRIGHT.md in the top-level directory of this -## distribution or <https://octave.org/copyright/>. -## -## This file is part of Octave. -## -## Octave is free software: you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <https://www.gnu.org/licenses/>. -## -######################################################################## - -set -e - -SED=${SED:-sed} -EGREP=${EGREP:-egrep} - -# Some stupid egreps don't like empty elements in alternation patterns, -# so we have to repeat ourselves because some stupid egreps don't like -# empty elements in alternation patterns. - -DEFUN_PATTERN="^[ \t]*DEF(CONSTFUN|CONSTMETHOD|METHOD|METHOD(_|_STATIC_)DLD|METHODX|METHODX(_|_STATIC_)DLD|UN|UN(_|_STATIC_)DLD|UNX|UNX(_|_STATIC_)DLD)[ \t]*\\(" - -srcdir="$1" -if [ "$1" ]; then - shift -fi - -for arg -do - if [ -f "$arg" ]; then - file="$arg" - else - file="$srcdir/$arg" - fi - if [ -f "$file" ]; then - if [ "`$EGREP -l "$DEFUN_PATTERN" $file`" ]; then - echo "$file" | $SED "s,\\$srcdir/,," - fi - fi -done
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build-aux/find-files-with-tests.in.sh Wed Mar 08 15:06:45 2023 -0500 @@ -0,0 +1,50 @@ +#! /bin/sh + +######################################################################## +## +## Copyright (C) 2013-2023 The Octave Project Developers +## +## See the file COPYRIGHT.md in the top-level directory of this +## distribution or <https://octave.org/copyright/>. +## +## This file is part of Octave. +## +## Octave is free software: you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <https://www.gnu.org/licenses/>. +## +######################################################################## + +set -e + +: ${GREP=@GREP@} +: ${SED=@SED@} + +srcdir="$1" +if [ "$1" ]; then + shift +fi + +for arg +do + if [ -f "$arg" ]; then + file="$arg" + else + file="$srcdir/$arg" + fi + if [ -f "$file" ]; then + if [ "`$GREP -l '^%!' $file`" ]; then + echo "$file" | $SED "s,\\$srcdir/,," + fi + fi +done
--- a/build-aux/find-files-with-tests.sh Wed Mar 08 09:28:28 2023 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -#! /bin/sh - -######################################################################## -## -## Copyright (C) 2013-2023 The Octave Project Developers -## -## See the file COPYRIGHT.md in the top-level directory of this -## distribution or <https://octave.org/copyright/>. -## -## This file is part of Octave. -## -## Octave is free software: you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <https://www.gnu.org/licenses/>. -## -######################################################################## - -set -e - -GREP=${GREP:-grep} -SED=${SED:-sed} - -srcdir="$1" -if [ "$1" ]; then - shift -fi - -for arg -do - if [ -f "$arg" ]; then - file="$arg" - else - file="$srcdir/$arg" - fi - if [ -f "$file" ]; then - if [ "`$GREP -l '^%!' $file`" ]; then - echo "$file" | $SED "s,\\$srcdir/,," - fi - fi -done
--- a/build-aux/module.mk Wed Mar 08 09:28:28 2023 -0800 +++ b/build-aux/module.mk Wed Mar 08 15:06:45 2023 -0500 @@ -3,8 +3,8 @@ %reldir%/OctJavaQry.java \ %reldir%/changelog.tmpl \ %reldir%/check-subst-vars.in.sh \ - %reldir%/find-defun-files.sh \ - %reldir%/find-files-with-tests.sh \ + %reldir%/find-defun-files.in.sh \ + %reldir%/find-files-with-tests.in.sh \ %reldir%/get-source-mtime.sh \ %reldir%/inplace_edit.pl \ %reldir%/mk-hg-id.sh \ @@ -18,6 +18,9 @@ %reldir%/update-bug-status.sh GEN_CONFIG_SHELL += \ + %reldir%/check-subst-vars.in.sh \ + %reldir%/find-defun-files.in.sh \ + %reldir%/find-files-with-tests.in.sh \ %reldir%/subst-config-vals.sh \ %reldir%/subst-cross-config-vals.sh \ %reldir%/subst-script-vals.sh
--- a/configure.ac Wed Mar 08 09:28:28 2023 -0800 +++ b/configure.ac Wed Mar 08 15:06:45 2023 -0500 @@ -3162,6 +3162,8 @@ AC_CONFIG_FILES([ Makefile build-aux/check-subst-vars.sh:build-aux/check-subst-vars.in.sh + build-aux/find-defun-files.sh:build-aux/find-defun-files.in.sh + build-aux/find-files-with-tests.sh:build-aux/find-files-with-tests.in.sh doc/doxyhtml/Doxyfile libgnu/Makefile test/Makefile
--- a/libinterp/module.mk Wed Mar 08 09:28:28 2023 -0800 +++ b/libinterp/module.mk Wed Mar 08 15:06:45 2023 -0500 @@ -169,7 +169,7 @@ $(ULT_PARSER_SRC) LIBINTERP_FOUND_DEFUN_FILES := \ - $(shell $(SHELL) $(srcdir)/build-aux/find-defun-files.sh "$(srcdir)" $(ULT_DIST_SRC)) + $(shell $(SHELL) build-aux/find-defun-files.sh "$(srcdir)" $(ULT_DIST_SRC)) BUILT_IN_DEFUN_FILES := $(OPT_HANDLERS) $(LIBINTERP_FOUND_DEFUN_FILES) @@ -178,7 +178,7 @@ ## Rules to build test files -LIBINTERP_TST_FILES_SRC := $(shell $(SHELL) $(srcdir)/build-aux/find-files-with-tests.sh "$(srcdir)" $(ULT_DIST_SRC) $(DLDFCN_SRC)) +LIBINTERP_TST_FILES_SRC := $(shell $(SHELL) build-aux/find-files-with-tests.sh "$(srcdir)" $(ULT_DIST_SRC) $(DLDFCN_SRC)) LIBINTERP_TST_FILES := $(addsuffix -tst,$(LIBINTERP_TST_FILES_SRC))
--- a/liboctave/module.mk Wed Mar 08 09:28:28 2023 -0800 +++ b/liboctave/module.mk Wed Mar 08 15:06:45 2023 -0500 @@ -108,7 +108,7 @@ $(%canon_reldir%_util_libutil_la_SOURCES) \ $(LIBOCTAVE_TEMPLATE_SRC) -LIBOCTAVE_TST_FILES_SRC := $(shell $(SHELL) $(srcdir)/build-aux/find-files-with-tests.sh "$(srcdir)" $(LIBOCTAVE_TST_SRC)) +LIBOCTAVE_TST_FILES_SRC := $(shell $(SHELL) build-aux/find-files-with-tests.sh "$(srcdir)" $(LIBOCTAVE_TST_SRC)) LIBOCTAVE_TST_FILES := $(addsuffix -tst,$(LIBOCTAVE_TST_FILES_SRC))
--- a/scripts/module.mk Wed Mar 08 09:28:28 2023 -0800 +++ b/scripts/module.mk Wed Mar 08 15:06:45 2023 -0500 @@ -94,7 +94,7 @@ $(GEN_FCN_FILES) \ $(PKG_ADD_FILES) -FCN_FILES_WITH_TESTS = $(shell $(SHELL) $(srcdir)/build-aux/find-files-with-tests.sh "$(srcdir)" $(FCN_FILES) $(GEN_FCN_FILES_IN)) +FCN_FILES_WITH_TESTS = $(shell $(SHELL) build-aux/find-files-with-tests.sh "$(srcdir)" $(FCN_FILES) $(GEN_FCN_FILES_IN)) define PKG_ADD_FILE_TEMPLATE $(1)/PKG_ADD: $$($(2)_FCN_FILES) $$($(2)_GEN_FCN_FILES) $(1)/$(octave_dirstamp) %reldir%/mk-pkg-add.sh