Mercurial > octave
changeset 22095:6119019d42f6
move find-defun-files.sh and mkbuiltins to build-aux directory
* build-aux/mk-builtins.sh: Rename from libinterp/mkbuiltins. Update
option processing. Exit immediately on any error.
* build-aux/find-defun-files.sh: Rename from
libinterp/find-defun-files.sh.
* Makefile.am (EXTRA_DIST): Add new files to the list.
* libinterp/module.mk: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 12 Jul 2016 09:12:55 -0400 |
parents | 9203833cab7d |
children | b8f92ea626e7 |
files | Makefile.am build-aux/find-defun-files.sh build-aux/mk-builtins.sh libinterp/find-defun-files.sh libinterp/mkbuiltins libinterp/module.mk |
diffstat | 6 files changed, 270 insertions(+), 256 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile.am Mon Jul 11 18:05:53 2016 -0400 +++ b/Makefile.am Tue Jul 12 09:12:55 2016 -0400 @@ -117,7 +117,9 @@ build-aux/OctJavaQry.java \ build-aux/changelog.tmpl \ build-aux/check-subst-vars.in.sh \ + build-aux/find-defun-files.sh \ build-aux/find-files-with-tests.sh \ + build-aux/mk-builtins.sh \ build-aux/mk-default-qt-settings.in.sh \ build-aux/mk-f77-def.in.sh \ build-aux/mk-hg-id.sh \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build-aux/find-defun-files.sh Tue Jul 12 09:12:55 2016 -0400 @@ -0,0 +1,31 @@ +#! /bin/sh + +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|UN|UN_DLD|UNX|UNX_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/mk-builtins.sh Tue Jul 12 09:12:55 2016 -0400 @@ -0,0 +1,225 @@ +#! /bin/sh +# +# Copyright (C) 1996-2015 John W. Eaton +# +# 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 +# <http://www.gnu.org/licenses/>. + +set -e + +SED=${SED:-sed} + +defun_dld_are_built_in=false +make_header=false +make_source=false + +for arg +do + case "$arg" in + --header) + if $make_source; then + echo "mk-builtins.sh: only one of --header or --source may be specified" 1>&2 + exit 1 + fi + make_header=true + shift + ;; + --source) + if $make_header; then + echo "mk-builtins.sh: only one of --header or --source may be specified" 1>&2 + exit 1 + fi + make_source=true + shift + ;; + --disable-dl) + ## If DLD functions are disabled, then DEFUN_DLD functions are + ## built-in instead of being dynamically loaded so they will also + ## need to be installed. + defun_dld_are_built_in=true + shift + ;; + *) + srcdir="$arg" + shift + if [ "x$1" = "x--" ]; then + shift + break + else + echo "mk-builtins.sh: '--' must separate SRCDIR from other file names" 1>&2 + exit 1 + fi + ;; + esac +done + +if [ $# -eq 0 ]; then + echo "usage: mk-builtins.sh --header|--source [--disable-dl] SRCDIR -- f1 f2 ..." 1>&2 + exit 1 +fi + +if ! $make_header && ! $make_source; then + echo "mk-builtins.sh: one of --header or --source must be specified" 1>&2 + exit 1 +fi + +if $make_header; then + + cat << \EOF +// DO NOT EDIT! Generated automatically by mk-builtins.sh. + +#if ! defined (octave_builtin_defun_decls_h) +#define octave_builtin_defun_decls_h 1 + +#include "octave-config.h" + +#include "ovl.h" + +EOF + + pattern='s/^[ \t]*DEF\(CONSTFUN\|UN\)[ \t]*( *\([^ ,]*\).*$/F\2/p; s/^[ \t]*DEFUNX[ \t]*( *"[^"]*" *, *\([^ ,]*\).*$/\1/p' + + dld_pattern='s/^[ \t]*DEFUN_DLD[ \t]*( *\([^ ,]*\).*$/F\1/p; s/^[ \t]*DEFUNX_DLD[ \t]*( *"[^"]*" *, *\([^ ,]*\).*$/\1/p' + + if $defun_dld_are_built_in; then + pattern="$pattern; $dld_pattern" + fi + + for arg + do + if [ -f $arg ]; then + file="$arg"; + else + file="$srcdir/$arg"; + fi + + ## Generate a list of function names to declare. We could do + ## this in one step, but this way keeps the sed patterns a + ## bit smaller. + + names=`$SED -n -e "$pattern" "$file"` + + for name in $names; do + echo "extern OCTINTERP_API octave_value_list" + echo "$name (const octave_value_list& = octave_value_list (), int = 0);" + echo "" + done + done + + cat << \EOF + +#endif + +EOF + +elif $make_source; then + + cat << \EOF +// DO NOT EDIT! Generated automatically by mk-builtins.sh. + +#if defined (HAVE_CONFIG_H) +# include "config.h" +#endif + +#include "defun.h" +#include "help.h" +#include "ovl.h" +#include "variables.h" +#include "builtin-defun-decls.h" +#include "builtins.h" + +#if defined (quad) +# undef quad +#endif + +EOF + + pattern='s/^ *DEFUN *( *\([^ ,]*\) *,.*$/type=fun;fname=F\1;name=\1/p; s/^ *DEFUNX *( *"\([^"]*\)" *, *\([^ ,]*\) *,.*$/type=fun;fname=\2;name=\1/p; s/^ *DEFCONSTFUN *( *\([^ ,]*\) *,.*$/type=fun;fname=F\1;name=\1;const=true/p; s/^ *DEFALIAS *( *\([^ ,]*\) *, *\([^ )]*\) *).*$/type=alias;alias=\1;name=\2/p' + + dld_pattern='s/^ *DEFUN_DLD *( *\([^ ,]*\) *,.*$/type=fun;fname=F\1;name=\1/p; s/^ *DEFUNX_DLD *( *"\([^"]*\)" *, *\([^ ,]*\) *,.*$/type=fun;fname=\2;name=\1/p' + + if $defun_dld_are_built_in; then + pattern="$pattern; $dld_pattern" + fi + + for arg + do + if [ -f $arg ]; then + file="$arg"; + else + file="$srcdir/$arg"; + fi + + fcn=`echo "$arg" | $SED 's,.*/,,; s/\.\(cc\|cpp\|in\.yy\|ll\)$//; s/-/_/g;'` + echo "static void" + echo "install_${fcn}_fcns (void)" + echo "{" + echo " std::string file = \"$arg\";" + echo "" + + ## Generate a list of shell variable assignment expressions + ## then evaluate them to generate the function calls that + ## install the built-in functions or function aliases. + + info_list=`$SED -n -e "$pattern" "$file"` + + for info in $info_list; do + eval "$info" + + const=false + case $type in + fun) + if $const; then + echo " install_builtin_function ($fname, \"$name\", file, \"external-doc\", true);" + else + echo " install_builtin_function ($fname, \"$name\", file, \"external-doc\");" + fi + unset type fname name const + ;; + alias) + echo " alias_builtin (\"$alias\", \"$name\");" + unset type alias name + ;; + esac + done + + echo "}" + echo "" + done + + cat << \EOF + +void +install_builtins (void) +{ +EOF + + for arg + do + fcn=`echo "$arg" | $SED 's,.*/,,; s/\.\(cc\|cpp\|in\.yy\|ll\)$//; s/-/_/g;'` + echo " install_${fcn}_fcns ();" + done + + cat << \EOF + + install_built_in_docstrings (); +} + +EOF + +fi + +exit 0
--- a/libinterp/find-defun-files.sh Mon Jul 11 18:05:53 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -#! /bin/sh - -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|UN|UN_DLD|UNX|UNX_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/libinterp/mkbuiltins Mon Jul 11 18:05:53 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,211 +0,0 @@ -#! /bin/sh -# -# Copyright (C) 1996-2015 John W. Eaton -# -# 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 -# <http://www.gnu.org/licenses/>. - -if test $# -lt 2; then - echo "usage: mkbuiltins SRCDIR --header|--source [--disable-dl] f1 f2 ..." 1>&2 - exit 1 -fi - -SED=${SED:-sed} - -srcdir="$1" -shift - -make_header=false -make_source=false -case "$1" in - --header) - make_header=true - shift - ;; - --source) - make_source=true - shift - ;; - *) - echo "mkbuiltins: unrecognized option: $1" 1>&2 - exit 1 - ;; -esac - -## If DLD functions are disabled, then DEFUN_DLD functions -## are built-in instead of being dynamically loaded so they will also -## need to be installed. - -defun_dld_are_built_in=false -case "$1" in - --disable-dl) - defun_dld_are_built_in=true - shift - ;; -esac - -if $make_header; then - - cat << \EOF -// DO NOT EDIT! Generated automatically by mkbuiltins. - -#if ! defined (octave_builtin_defun_decls_h) -#define octave_builtin_defun_decls_h 1 - -#include "octave-config.h" - -#include "ovl.h" - -EOF - - pattern='s/^[ \t]*DEF\(CONSTFUN\|UN\)[ \t]*( *\([^ ,]*\).*$/F\2/p; s/^[ \t]*DEFUNX[ \t]*( *"[^"]*" *, *\([^ ,]*\).*$/\1/p' - - dld_pattern='s/^[ \t]*DEFUN_DLD[ \t]*( *\([^ ,]*\).*$/F\1/p; s/^[ \t]*DEFUNX_DLD[ \t]*( *"[^"]*" *, *\([^ ,]*\).*$/\1/p' - - if $defun_dld_are_built_in; then - pattern="$pattern; $dld_pattern" - fi - - for arg - do - if [ -f $arg ]; then - file="$arg"; - else - file="$srcdir/$arg"; - fi - - ## Generate a list of function names to declare. We could do - ## this in one step, but this way keeps the sed patterns a - ## bit smaller. - - names=`$SED -n -e "$pattern" "$file"` - - for name in $names; do - echo "extern OCTINTERP_API octave_value_list" - echo "$name (const octave_value_list& = octave_value_list (), int = 0);" - echo "" - done - done - - cat << \EOF - -#endif - -EOF - -elif $make_source; then - - cat << \EOF -// DO NOT EDIT! Generated automatically by mkbuiltins. - -#if defined (HAVE_CONFIG_H) -# include "config.h" -#endif - -#include "defun.h" -#include "help.h" -#include "ovl.h" -#include "variables.h" -#include "builtin-defun-decls.h" -#include "builtins.h" - -#if defined (quad) -# undef quad -#endif - -EOF - - pattern='s/^ *DEFUN *( *\([^ ,]*\) *,.*$/type=fun;fname=F\1;name=\1/p; s/^ *DEFUNX *( *"\([^"]*\)" *, *\([^ ,]*\) *,.*$/type=fun;fname=\2;name=\1/p; s/^ *DEFCONSTFUN *( *\([^ ,]*\) *,.*$/type=fun;fname=F\1;name=\1;const=true/p; s/^ *DEFALIAS *( *\([^ ,]*\) *, *\([^ )]*\) *).*$/type=alias;alias=\1;name=\2/p' - - dld_pattern='s/^ *DEFUN_DLD *( *\([^ ,]*\) *,.*$/type=fun;fname=F\1;name=\1/p; s/^ *DEFUNX_DLD *( *"\([^"]*\)" *, *\([^ ,]*\) *,.*$/type=fun;fname=\2;name=\1/p' - - if $defun_dld_are_built_in; then - pattern="$pattern; $dld_pattern" - fi - - for arg - do - if [ -f $arg ]; then - file="$arg"; - else - file="$srcdir/$arg"; - fi - - fcn=`echo "$arg" | $SED 's,.*/,,; s/\.\(cc\|cpp\|in\.yy\|ll\)$//; s/-/_/g;'` - echo "static void" - echo "install_${fcn}_fcns (void)" - echo "{" - echo " std::string file = \"$arg\";" - echo "" - - ## Generate a list of shell variable assignment expressions - ## then evaluate them to generate the function calls that - ## install the built-in functions or function aliases. - - info_list=`$SED -n -e "$pattern" "$file"` - - for info in $info_list; do - eval "$info" - - const=false - case $type in - fun) - if $const; then - echo " install_builtin_function ($fname, \"$name\", file, \"external-doc\", true);" - else - echo " install_builtin_function ($fname, \"$name\", file, \"external-doc\");" - fi - unset type fname name const - ;; - alias) - echo " alias_builtin (\"$alias\", \"$name\");" - unset type alias name - ;; - esac - done - - echo "}" - echo "" - done - - cat << \EOF - -void -install_builtins (void) -{ -EOF - - for arg - do - fcn=`echo "$arg" | $SED 's,.*/,,; s/\.\(cc\|cpp\|in\.yy\|ll\)$//; s/-/_/g;'` - echo " install_${fcn}_fcns ();" - done - - cat << \EOF - - install_built_in_docstrings (); -} - -EOF - -else - - echo "mkbuiltins: must specify --header or --source!" 1>&2 - exit 1 - -fi - -exit 0
--- a/libinterp/module.mk Mon Jul 11 18:05:53 2016 -0400 +++ b/libinterp/module.mk Tue Jul 12 09:12:55 2016 -0400 @@ -83,13 +83,11 @@ libinterp/DOCSTRINGS \ libinterp/build-env.in.cc \ libinterp/build-env-features.sh \ - libinterp/find-defun-files.sh \ libinterp/gendoc.pl \ libinterp/genprops.awk \ libinterp/liboctinterp-build-info.in.cc \ libinterp/mk-errno-list \ libinterp/mk-pkg-add \ - libinterp/mkbuiltins \ libinterp/mkops \ libinterp/version.in.h \ $(LIBINTERP_BUILT_DISTFILES) @@ -188,20 +186,20 @@ ULT_DIST_SRC := \ $(filter-out $(GENERATED_PARSER_FILES), $(DIST_SRC)) $(ULT_PARSER_SRC) -FOUND_DEFUN_FILES := \ - $(shell $(SHELL) $(srcdir)/libinterp/find-defun-files.sh "$(srcdir)" $(ULT_DIST_SRC)) +LIBINTERP_FOUND_DEFUN_FILES := \ + $(shell $(SHELL) $(srcdir)/build-aux/find-defun-files.sh "$(srcdir)" $(ULT_DIST_SRC)) -SRC_DEFUN_FILES = $(OPT_HANDLERS) $(FOUND_DEFUN_FILES) +BUILT_IN_DEFUN_FILES = $(OPT_HANDLERS) $(LIBINTERP_FOUND_DEFUN_FILES) DLDFCN_DEFUN_FILES = $(DLDFCN_SRC) if AMCOND_ENABLE_DYNAMIC_LINKING - DEFUN_FILES = $(SRC_DEFUN_FILES) + DEFUN_FILES = $(BUILT_IN_DEFUN_FILES) else - DEFUN_FILES = $(SRC_DEFUN_FILES) $(DLDFCN_DEFUN_FILES) + DEFUN_FILES = $(BUILT_IN_DEFUN_FILES) $(DLDFCN_DEFUN_FILES) endif -ALL_DEFUN_FILES = $(SRC_DEFUN_FILES) $(DLDFCN_DEFUN_FILES) +LIBINTERP_DEFUN_FILES = $(BUILT_IN_DEFUN_FILES) $(DLDFCN_DEFUN_FILES) ## FIXME: The following two variables are deprecated and should be removed ## in Octave version 3.12. @@ -253,14 +251,14 @@ mkbuiltins_dld_opt = --disable-dl endif -libinterp/builtins.cc: $(ALL_DEFUN_FILES) libinterp/mkbuiltins | libinterp/$(octave_dirstamp) +libinterp/builtins.cc: $(LIBINTERP_DEFUN_FILES) build-aux/mk-builtins.sh | libinterp/$(octave_dirstamp) $(AM_V_GEN)rm -f $@-t && \ - $(SHELL) $(srcdir)/libinterp/mkbuiltins "$(srcdir)" --source $(mkbuiltins_dld_opt) $(ALL_DEFUN_FILES) > $@-t && \ + $(SHELL) $(srcdir)/build-aux/mk-builtins.sh --source $(mkbuiltins_dld_opt) "$(srcdir)" -- $(LIBINTERP_DEFUN_FILES) > $@-t && \ mv $@-t $@ -libinterp/builtin-defun-decls.h: $(ALL_DEFUN_FILES) libinterp/mkbuiltins | libinterp/$(octave_dirstamp) +libinterp/builtin-defun-decls.h: $(LIBINTERP_DEFUN_FILES) build-aux/mk-builtins.sh | libinterp/$(octave_dirstamp) $(AM_V_GEN)rm -f $@-t && \ - $(SHELL) $(srcdir)/libinterp/mkbuiltins "$(srcdir)" --header $(mkbuiltins_dld_opt) $(ALL_DEFUN_FILES) > $@-t && \ + $(SHELL) $(srcdir)/build-aux/mk-builtins.sh --header $(mkbuiltins_dld_opt) "$(srcdir)" -- $(LIBINTERP_DEFUN_FILES) > $@-t && \ $(simple_move_if_change_rule) if AMCOND_ENABLE_DYNAMIC_LINKING @@ -274,9 +272,9 @@ DOCSTRING_FILES += libinterp/DOCSTRINGS -libinterp/DOCSTRINGS: $(ALL_DEFUN_FILES) | libinterp/$(octave_dirstamp) +libinterp/DOCSTRINGS: $(LIBINTERP_DEFUN_FILES) | libinterp/$(octave_dirstamp) $(AM_V_GEN)rm -f libinterp/DOCSTRINGS-t && \ - $(PERL) $(srcdir)/libinterp/gendoc.pl "$(srcdir)" $(ALL_DEFUN_FILES) > libinterp/DOCSTRINGS-t && \ + $(PERL) $(srcdir)/libinterp/gendoc.pl "$(srcdir)" $(LIBINTERP_DEFUN_FILES) > libinterp/DOCSTRINGS-t && \ $(call move_if_change_rule,libinterp/DOCSTRINGS-t,$@) OCTAVE_INTERPRETER_TARGETS += \