# HG changeset patch # User John W. Eaton # Date 1457395595 18000 # Node ID 3fb2bdea47a563ee86c72f03b2b0fac7e9dc605d # Parent 9773a1c2b55fe732c640d299ce64f69ba9060ecf check substituted variables against current make variables * build-aux/check-subst-vars.in.sh: New script. * Makefile.am (EXTRA_DIST): Include it in the list. (GEN_CONFIG_SHELL, AUTOCONF_SUBST_VARS, ALL_SUBST_VARS): New variables. (config-vars, make-vars, check-subst-vars): New targets. (CLEANFILES): Include config-vars and make-vars in the list. * configure.ac (AUTOCONF_SUBST_VARS): Define and substitute. (OCTAVE_CONFIG_FILES): Include build-aux/check-subst-vars.sh in the list of generated files. * build-aux/common.mk: Use := to define version and api_version. diff -r 9773a1c2b55f -r 3fb2bdea47a5 Makefile.am --- a/Makefile.am Mon Mar 07 19:07:25 2016 -0500 +++ b/Makefile.am Mon Mar 07 19:06:35 2016 -0500 @@ -46,6 +46,7 @@ NEWS \ README \ build-aux/OctJavaQry.class \ + build-aux/check-subst-vars.in.sh \ build-aux/find-files-with-tests.sh \ build-aux/mk-default-qt-settings.in.sh \ build-aux/mk-f77-def.in.sh \ @@ -63,6 +64,25 @@ run-octave.in \ $(BUILT_DISTFILES) +GEN_CONFIG_SHELL = \ + build-aux/mk-default-qt-settings.sh \ + build-aux/mk-f77-def.sh \ + build-aux/mk-mxarray-h.sh \ + build-aux/mk-version-h.sh \ + build-aux/subst-config-vals.sh \ + build-aux/subst-cross-config-vals.sh \ + build-aux/subst-default-vals.sh \ + build-aux/subst-f77-isnan-macro.sh \ + build-aux/subst-script-vals.sh + +AUTOCONF_SUBST_VARS = @AUTOCONF_SUBST_VARS@ +ALL_SUBST_VARS = \ + $(AUTOCONF_SUBST_VARS) \ + abs_top_builddir \ + abs_top_srcdir \ + api_version \ + version + DIRSTAMP_FILES = octave_dirstamp = $(am__leading_dot)octave-dirstamp @@ -173,7 +193,9 @@ noinst_SCRIPTS = run-octave CLEANFILES += \ - $(BUILT_SOURCES) + $(BUILT_SOURCES) \ + config-vars \ + make-vars DISTCLEANFILES += \ .gdbinit \ @@ -214,6 +236,23 @@ $(AM_V_GEN)$(MKDIR_P) bits && \ $(INSTALL_HEADER) $< $@ +config-vars: $(GEN_CONFIG_SHELL) + $(AM_V_GEN)rm -f $@-t $@ && \ + $(SED) -n 's/ *"$$/"/; s/^\([A-Za-z_][A-Za-z0-9_]*\)=" *\(.*\)" *$$/\1 \2/p' $^ | sort -u > $@-t && \ + mv $@-t $@ + +## We always have to create this file because values for Make variables +## may be passed on the command line. + +make-vars: + $(file >$@-t) $(foreach v, $(ALL_SUBST_VARS), $(file >>$@-t,$(v) $(value $(v)))) + $(AM_V_GEN)mv $@-t $@ +.PHONY: make-vars + +check-subst-vars: build-aux/check-subst-vars.sh make-vars config-vars + @$(SHELL) -f build-aux/check-subst-vars.sh make-vars config-vars +.PHONY: check-subst-vars + ## If we aren't trying to fix stl_algo.h, then try to ensure that ## there isn't a stray copy sitting in the build tree. diff -r 9773a1c2b55f -r 3fb2bdea47a5 build-aux/check-subst-vars.in.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build-aux/check-subst-vars.in.sh Mon Mar 07 19:06:35 2016 -0500 @@ -0,0 +1,68 @@ +#! /bin/sh +# +# Copyright (C) 2016 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 +# . + +: ${AWK=@AWK@} +: ${SED=@SED@} + +if test $# -ne 2; then + echo "usage: check-subst-vars.sh make-vars-file config-vars-file" 2>&1 + exit 1 +fi + +awk_script="check-subst-vars-$$.awk" + +trap "rm -f $awk_script; exit 1" 1 2 15 + +make_vars="$1" +config_vars="$2" + +## Generate awk script to check variable consitency. + +cat << EOF > $awk_script +BEGIN { + status = 0; +EOF + +while read var val; do + val=`echo "$val" | $SED 's/"/\\\\"/g'` + echo "make_vars[\"$var\"] = \"$val\";" >> $awk_script +done < $make_vars + +cat << EOF >> $awk_script +} { + line = \$0; + idx = index (line, " "); + var = substr (line, 1, idx-1); + val = substr (line, idx+1); + if (val != make_vars[var]) + { + printf ("error: mismatch for configuration variable '%s'\n", var); + printf (" value set in configuration files: %s\n", val); + printf (" value set in Make: %s\n", make_vars[var]); + status = 1; + } +} END { + exit status; +} +EOF + +## Execute it. + +$AWK -f $awk_script $config_vars 1>&2 diff -r 9773a1c2b55f -r 3fb2bdea47a5 build-aux/common.mk --- a/build-aux/common.mk Mon Mar 07 19:07:25 2016 -0500 +++ b/build-aux/common.mk Mon Mar 07 19:06:35 2016 -0500 @@ -5,8 +5,8 @@ export SHELL export PERL -version = ${OCTAVE_VERSION} -api_version = ${OCTAVE_API_VERSION} +version := ${OCTAVE_VERSION} +api_version := ${OCTAVE_API_VERSION} ## AM_LIBTOOLFLAGS = --silent diff -r 9773a1c2b55f -r 3fb2bdea47a5 configure.ac --- a/configure.ac Mon Mar 07 19:07:25 2016 -0500 +++ b/configure.ac Mon Mar 07 19:06:35 2016 -0500 @@ -3378,11 +3378,15 @@ ### Do the substitutions in Makefiles and other scripts that ### hold configuration info. +AUTOCONF_SUBST_VARS="`echo $ac_subst_vars`" + +AC_SUBST(AUTOCONF_SUBST_VARS) AC_SUBST(ac_config_files) AC_SUBST(ac_config_headers) AC_CONFIG_FILES([ Makefile + build-aux/check-subst-vars.sh:build-aux/check-subst-vars.in.sh doc/doxyhtml/Doxyfile libgnu/Makefile]) @@ -3395,15 +3399,15 @@ [$SHELL $srcdir/build-aux/move-if-change oct-conf-post.h-tmp oct-conf-post.h]) OCTAVE_CONFIG_MOVE_IF_CHANGE_FILES([ + build-aux/mk-default-qt-settings.sh + build-aux/mk-f77-def.sh build-aux/mk-mxarray-h.sh build-aux/mk-version-h.sh build-aux/subst-config-vals.sh build-aux/subst-cross-config-vals.sh build-aux/subst-default-vals.sh build-aux/subst-f77-isnan-macro.sh - build-aux/subst-script-vals.sh - build-aux/mk-default-qt-settings.sh - build-aux/mk-f77-def.sh]) + build-aux/subst-script-vals.sh]) AC_OUTPUT