From a2a246c18c2acb897c266ae3ab1bfe88253ab0ba Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 29 Apr 2020 12:46:56 -0400 Subject: [PATCH 01/11] Trac #29345: fix most autotools bashisms. Our autotools macros commit two main bashisms: * The use of FOO+="${BAR}" to concatenate the strings FOO and BAR; and * the use of $'\n' as a literal newline character. The first is easy to address, by using FOO="${FOO} ${BAR}". The latter is a bit more tricky, since the "obvious" way to add a newline into the variable FOO is with FOO="... $(printf '\n')", but the specification states that any newlines should be stripped from the end of the subshell's output! To work around that difficulty, this commit reworks the way a few of our variables are constructed. Instead of appending new stuff to the variable followed by a backslash and a newline, we now append the newline followed by some spaces and the new stuff. The end result is more or less the same -- it's the stuff we want separated by newlines and backslashes -- but with one important practical difference. Since the newlines are printed at the beginning (followed by some spaces), the output from e.g. $(printf '\n ') is left untouched. This looks a bit crazy when you see it, but it generates the correct output in the Makefiles. --- configure.ac | 5 ++--- m4/sage_spkg_collect.m4 | 43 +++++++++++++++++++---------------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/configure.ac b/configure.ac index 0d09c6fbc74..b5b39197790 100644 --- a/configure.ac +++ b/configure.ac @@ -447,13 +447,12 @@ SAGE_SPKG_COLLECT() # TODO: fix this in Trac #21524 touch "$SAGE_SRC/bin/sage-env-config" -SAGE_SCRIPTS='\ -' +SAGE_SCRIPTS='' for file in "$SAGE_SRC/bin/"*; do # Skip files with ".in" extension ext=${file##*.} if test "$ext" != in; then - SAGE_SCRIPTS+=" \$(SAGE_LOCAL)${file#$SAGE_SRC} \\"$'\n' + SAGE_SCRIPTS="${SAGE_SCRIPTS} \\$(printf '\n ')\$(SAGE_LOCAL)${file#$SAGE_SRC}" fi done diff --git a/m4/sage_spkg_collect.m4 b/m4/sage_spkg_collect.m4 index 2a128e0b21b..762e4918283 100644 --- a/m4/sage_spkg_collect.m4 +++ b/m4/sage_spkg_collect.m4 @@ -100,34 +100,31 @@ newest_version() { # not required on this platform or that can be taken from the underlying system # installation. Note that this contains packages that are not actually going to # be installed by most users because they are optional/experimental. -SAGE_BUILT_PACKAGES='\ -' +SAGE_BUILT_PACKAGES='' + # The complement of SAGE_BUILT_PACKAGES, i.e., packages that are not required # on this platform or packages where we found a suitable package on the # underlying system. -SAGE_DUMMY_PACKAGES='\ -' +SAGE_DUMMY_PACKAGES='' + # Standard packages -SAGE_STANDARD_PACKAGES='\ -' +SAGE_STANDARD_PACKAGES='' + # List of currently installed and to-be-installed optional packages - filled in SAGE_SPKG_ENABLE #SAGE_OPTIONAL_INSTALLED_PACKAGES # List of optional packages to be uninstalled - filled in SAGE_SPKG_ENABLE #SAGE_OPTIONAL_CLEANED_PACKAGES # List of all packages that should be downloaded -SAGE_SDIST_PACKAGES='\ -' +SAGE_SDIST_PACKAGES='' + # Generate package version and dependency lists SAGE_PACKAGE_VERSIONS="" SAGE_PACKAGE_DEPENDENCIES="" # Lists of packages categorized according to their build rules -SAGE_NORMAL_PACKAGES='\ -' -SAGE_PIP_PACKAGES='\ -' -SAGE_SCRIPT_PACKAGES='\ -' +SAGE_NORMAL_PACKAGES='' +SAGE_PIP_PACKAGES='' +SAGE_SCRIPT_PACKAGES='' SAGE_NEED_SYSTEM_PACKAGES="" @@ -159,7 +156,7 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do message="came preinstalled with the SageMath tarball" ;; standard) - SAGE_STANDARD_PACKAGES+=" $SPKG_NAME \\"$'\n' + SAGE_STANDARD_PACKAGES="${SAGE_STANDARD_PACKAGES} \\$(printf '\n ')${SPKG_NAME}" in_sdist=yes message="will be installed as an SPKG" ;; @@ -202,7 +199,7 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do uninstall_message="$SPKG_TYPE pip package (installed)" fi - SAGE_PACKAGE_VERSIONS+="vers_$SPKG_NAME = $SPKG_VERSION"$'\n' + SAGE_PACKAGE_VERSIONS="${SAGE_PACKAGE_VERSIONS}$(printf '\nvers_')${SPKG_NAME} = ${SPKG_VERSION}" AS_VAR_PUSHDEF([sage_spkg_install], [sage_spkg_install_${SPKG_NAME}])dnl AS_VAR_PUSHDEF([sage_require], [sage_require_${SPKG_NAME}])dnl @@ -213,13 +210,13 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do # "./sage -i SPKG_NAME" will still install the package. AS_VAR_IF([sage_spkg_install], [no], [ dnl We will use the system package (or not required for this platform.) - SAGE_DUMMY_PACKAGES+=" $SPKG_NAME \\"$'\n' + SAGE_DUMMY_PACKAGES="${SAGE_DUMMY_PACKAGES} \\$(printf '\n ')${SPKG_NAME}" AS_VAR_IF([sage_require], [yes], [ message="using system package; SPKG will not be installed" ], [ message="not required on your platform; SPKG will not be installed" ]) ], [ dnl We won't use the system package. - SAGE_BUILT_PACKAGES+=" $SPKG_NAME \\"$'\n' + SAGE_BUILT_PACKAGES="${SAGE_BUILT_PACKAGES} \\$(printf '\n ')${SPKG_NAME}" AS_VAR_SET_IF([sage_use_system], [ AS_VAR_COPY([reason], [sage_use_system]) AS_CASE([$reason], @@ -249,7 +246,7 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do esac if test "$in_sdist" = yes; then - SAGE_SDIST_PACKAGES+=" $SPKG_NAME \\"$'\n' + SAGE_SDIST_PACKAGES="${SAGE_SDIST_PACKAGES} \\$(printf '\n ')${SPKG_NAME}" fi # Determine package source @@ -282,18 +279,18 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do fi fi - SAGE_PACKAGE_DEPENDENCIES+="deps_$SPKG_NAME = $DEPS"$'\n' + SAGE_PACKAGE_DEPENDENCIES="${SAGE_PACKAGE_DEPENDENCIES}$(printf '\ndeps_')${SPKG_NAME} = ${DEPS}" # Determine package build rules case "$SPKG_SOURCE" in pip) - SAGE_PIP_PACKAGES+=" $SPKG_NAME \\"$'\n' + SAGE_PIP_PACKAGES="${SAGE_PIP_PACKAGES} \\$(printf '\n ')${SPKG_NAME}" ;; script) - SAGE_SCRIPT_PACKAGES+=" $SPKG_NAME \\"$'\n' + SAGE_SCRIPT_PACKAGES="${SAGE_SCRIPT_PACKAGES} \\$(printf '\n ')${SPKG_NAME}" ;; normal) - SAGE_NORMAL_PACKAGES+=" $SPKG_NAME \\"$'\n' + SAGE_NORMAL_PACKAGES="${SAGE_NORMAL_PACKAGES} \\$(printf '\n ')${SPKG_NAME}" ;; esac done From bc3ea8e7448a3501a92bf4d800e19303154c6a75 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 29 Apr 2020 13:28:36 -0400 Subject: [PATCH 02/11] Trac #29345: fix one more newline-constant bashism in SAGE_SPKG_ENABLE. This is essentially the same fix used in SAGE_SPKG_COLLECT and in our configure.ac file. It reorders some things to print newlines followed by the stuff we want, rather than the other way around. This prevents the newlines from being stripped out of the subshell's output entirely. This macro was previously using AS_VAR_SET for this purpose, but for clarity I have reduced it to a standard shell-variable definition. The name of the variable itself is not dynamic, and this saves us from needing to think about m4 whitespace quoting and escaping rules. --- build/make/Makefile.in | 6 ++---- m4/sage_spkg_enable.m4 | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/build/make/Makefile.in b/build/make/Makefile.in index da88e97fd84..9034fbaa712 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -85,14 +85,12 @@ STANDARD_PACKAGE_INSTS = \ $(foreach pkgname,$(STANDARD_PACKAGES),$(inst_$(pkgname))) # All optional installed packages (triggers the auto-update) -OPTIONAL_INSTALLED_PACKAGES = \ -@SAGE_OPTIONAL_INSTALLED_PACKAGES@ +OPTIONAL_INSTALLED_PACKAGES = @SAGE_OPTIONAL_INSTALLED_PACKAGES@ OPTIONAL_INSTALLED_PACKAGE_INSTS = \ $(foreach pkgname,$(OPTIONAL_INSTALLED_PACKAGES),$(inst_$(pkgname))) # All previously installed optional packages that are to be uninstalled -OPTIONAL_CLEANED_PACKAGES = \ -@SAGE_OPTIONAL_CLEANED_PACKAGES@ +OPTIONAL_CLEANED_PACKAGES = @SAGE_OPTIONAL_CLEANED_PACKAGES@ OPTIONAL_CLEANED_PACKAGES_CLEANS = $(OPTIONAL_CLEANED_PACKAGES:%=%-clean) # All packages which should be downloaded diff --git a/m4/sage_spkg_enable.m4 b/m4/sage_spkg_enable.m4 index 820ff5cf3a5..c349aab5f9a 100644 --- a/m4/sage_spkg_enable.m4 +++ b/m4/sage_spkg_enable.m4 @@ -19,7 +19,8 @@ AS_HELP_STRING([--disable-]SPKG_NAME, AS_IF([test "$want_spkg" = if_installed], [AS_VAR_SET([want_spkg], $is_installed)]) - AS_VAR_SET([spkg_line], [" ]SPKG_NAME[ \\"$'\n']) + + spkg_line=" \\$(printf '\n ')SPKG_NAME" AS_CASE([$is_installed-$want_spkg], [*-yes], [AS_VAR_APPEND(SAGE_OPTIONAL_INSTALLED_PACKAGES, "$spkg_line")], [yes-no], [AS_VAR_APPEND(SAGE_OPTIONAL_CLEANED_PACKAGES, "$spkg_line")]) From fb475f3311972d819723c0d8f7d8a4cb3036b74c Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 29 Apr 2020 17:08:06 -0400 Subject: [PATCH 03/11] Trac #29345: replace a few obsolete "-a" tests with "-e". The "-a" test in bash means "file exists," but the standard POSIX "-e" is more portable and works in bash anyway, so let's use that. --- src/bin/sage-env | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin/sage-env b/src/bin/sage-env index 51beb29a090..99968a6b5d2 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -463,7 +463,7 @@ unset R_PROFILE if [ -d "$SAGE_LOCAL/lib/R/share" ] ; then R_MAKEVARS_SITE="$SAGE_LOCAL/lib/R/share/Makevars.site" && export R_MAKEVARS_SITE if ! [ -f "$R_MAKEVARS_SITE" ] ; then - if ! [ -a "$R_MAKEVARS_SITE" ] ; then + if ! [ -e "$R_MAKEVARS_SITE" ] ; then echo "## Empty site-wide Makevars file for Sage's R" > "$R_MAKEVARS_SITE" else >&2 echo "Warning: $R_MAKEVARS_SITE exists and is not a file : trouble ahead..." @@ -472,7 +472,7 @@ if [ -d "$SAGE_LOCAL/lib/R/share" ] ; then fi if [ -d "$DOT_SAGE" ] ; then if ! [ -d "$DOT_SAGE/R" ] ; then - if ! [ -a "$DOT_SAGE/R" ] ; then + if ! [ -e "$DOT_SAGE/R" ] ; then mkdir -p "$DOT_SAGE/R" else >&2 echo "Warning: $DOT_SAGE/R exists and is not a directory : trouble ahead..." @@ -480,7 +480,7 @@ if [ -d "$DOT_SAGE" ] ; then fi R_MAKEVARS_USER="$DOT_SAGE/R/Makevars.user" && export R_MAKEVARS_USER if ! [ -f "$R_MAKEVARS_USER" ] ; then - if ! [ -a "$R_MAKEVARS_USER" ] ; then + if ! [ -e "$R_MAKEVARS_USER" ] ; then echo "## Empty user-specific Makevars file for Sage's R" > "$R_MAKEVARS_USER" else >&2 echo "Warning: $R_MAKEVARS_USER exists and is not a file : trouble ahead..." From 305d8cfac37e6b110710d6b0892f00c3abce1a98 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 29 Apr 2020 17:19:46 -0400 Subject: [PATCH 04/11] Trac #29345: replace a bash array with something portable. Instead of storing the output of sage-num-threads.py in a bash array, this commit stores it as a string. There are three "components" to the output, and to get at the first and second components, we now use the POSIX shortest prefix/suffix parameter expansions to strip off the stuff before/after the first/last space. --- src/bin/sage-env | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bin/sage-env b/src/bin/sage-env index 99968a6b5d2..46da767ec79 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -603,9 +603,10 @@ ECLDIR="$SAGE_LOCAL/lib/ecl/" && export ECLDIR # First, figure out the right values for SAGE_NUM_THREADS (default # number of threads) and SAGE_NUM_THREADS_PARALLEL (default number of # threads when parallel execution is asked explicitly). -sage_num_threads_array=(`sage-num-threads.py 2>/dev/null || echo 1 2 1`) -SAGE_NUM_THREADS=${sage_num_threads_array[0]} -SAGE_NUM_THREADS_PARALLEL=${sage_num_threads_array[1]} +sage_num_threads_array=$(sage-num-threads.py 2>/dev/null || echo 1 2 1) +sage_num_threads_array="${sage_num_threads_array% *}" # strip third item +SAGE_NUM_THREADS="${sage_num_threads_array% *}" # keep first item +SAGE_NUM_THREADS_PARALLEL="${sage_num_threads_array#* }" # keep second item export SAGE_NUM_THREADS export SAGE_NUM_THREADS_PARALLEL From d0dff56f6bb004b32f07c067b653f966bd1f7569 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 29 Apr 2020 17:41:21 -0400 Subject: [PATCH 05/11] Trac #29345: replace a few uses of "source" with "." Using "source" to include another script file is a bashism; the portable option is to use the dot "." to do it. --- build/make/Makefile.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build/make/Makefile.in b/build/make/Makefile.in index 9034fbaa712..16396e3e9ec 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -335,7 +335,7 @@ sagelib-build-deps: \ sagelib: sagelib-build-deps $(AM_V_at)if [ -z "$$SAGE_INSTALL_FETCH_ONLY" ]; then \ - cd $(SAGE_SRC) && source bin/sage-env && source $(SAGE_ROOT)/build/bin/sage-build-env-config && \ + cd $(SAGE_SRC) && . bin/sage-env && . $(SAGE_ROOT)/build/bin/sage-build-env-config && \ sage-logger -p 'time $(MAKE) sage' '$(SAGE_LOGS)/sagelib-$(SAGE_VERSION).log'; \ fi @@ -558,14 +558,14 @@ endif # # $(INST)/-: # $(AM_V_at)cd '$SAGE_ROOT' && \\ -# source '$SAGE_ROOT/src/bin/sage-env' && \\ +# . '$SAGE_ROOT/src/bin/sage-env' && \\ # sage-logger -p '$SAGE_ROOT/build/pkgs//spkg-install' '$(SAGE_LOGS)/.log' # # : $(INST)/- # # -clean: # -$(AM_V_at)cd '$SAGE_ROOT' && \\ -# source '$SAGE_ROOT/src/bin/sage-env' && \\ +# . '$SAGE_ROOT/src/bin/sage-env' && \\ # '$SAGE_ROOT/build/pkgs/$PKG_NAME/spkg-uninstall' # Positional arguments: @@ -575,7 +575,7 @@ endif define SCRIPT_PACKAGE_templ $$(INST)/$(1)-$(2): $(3) $(AM_V_at)cd '$$(SAGE_ROOT)' && \ - source '$$(SAGE_ROOT)/src/bin/sage-env' && source '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \ + . '$$(SAGE_ROOT)/src/bin/sage-env' && . '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \ sage-logger -p '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install' '$$(SAGE_LOGS)/$(1).log' touch "$$@" @@ -583,7 +583,7 @@ $(1): $$(INST)/$(1)-$(2) $(1)-clean: -$(AM_V_at)cd '$$(SAGE_ROOT)' && \ - source '$$(SAGE_ROOT)/src/bin/sage-env' && source '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \ + . '$$(SAGE_ROOT)/src/bin/sage-env' && . '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \ '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-uninstall' -rm -f "$$(INST)/$(1)-$(2)" From 5ac420b15ac0e561e5e8f7f64bb9566a1b6e7890 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 29 Apr 2020 17:43:02 -0400 Subject: [PATCH 06/11] Trac #29345: fix some bashisms in sage-env's resolvelinks() function. This function was using bash-specific parameter expansions to find- and-replace substrings. Fortunately, most of the substrings were at the beginning of the big string, where the POSIX shortest-prefix strip, followed by a prepend, accomplishes the same thing. The other instance was replacing multiple slashes by a single slash in a path, which is now implemented with a call to sed. --- src/bin/sage-env | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/bin/sage-env b/src/bin/sage-env index 46da767ec79..f3a005f573a 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -44,12 +44,10 @@ resolvelinks() { # Move stuff from $in to $out while [ -n "$in" ]; do # Normalize $in by replacing consecutive slashes by one slash - while { in_single_slash=${in//\/\//\/}; [ "$in" != "$in_single_slash" ]; }; do - in=$in_single_slash - done + in=$(echo "${in}" | sed 's://*:/:g') # If $in starts with a slash, remove it and set $out to the root - in_without_slash=${in/#\//} + in_without_slash=${in#/} if [ "$in" != "$in_without_slash" ]; then in=$in_without_slash out="/" @@ -71,7 +69,7 @@ resolvelinks() { out="$out$f" # If the new $in starts with a slash, move it to $out - in_without_slash=${in/#\//} + in_without_slash=${in#/} if [ "$in" != "$in_without_slash" ]; then in=$in_without_slash out="$out/" @@ -103,7 +101,8 @@ resolvelinks() { fi # In $in, replace $f by $f_resolved (leave $out alone) - in=${in/#"$f"/"$f_resolved"} + in="${in#${f}}" + in="${f_resolved}${in}" done # Return $out From 0a617950488b3945fb6f494cec8b50e8486bd9dd Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 29 Apr 2020 13:31:14 -0400 Subject: [PATCH 07/11] Trac #29345: don't force SHELL=bash any longer. Our build system (the autotools parts, anyway) are now compatible with any POSIX shell. This commit deletes the hunk of code in configure.ac that insisted on bash. --- configure.ac | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/configure.ac b/configure.ac index b5b39197790..aade46804be 100644 --- a/configure.ac +++ b/configure.ac @@ -28,31 +28,6 @@ AC_PREREQ([2.69]) AC_DEFUN([SAGE_VERSION], m4_esyscmd_s([. src/bin/sage-version.sh && echo $SAGE_VERSION])) AC_INIT([Sage], SAGE_VERSION, [sage-devel@googlegroups.com]) -# The following needs to be immediately after calling AC_INIT -#------------------------------------------------------------ -# We need to run this configure script with bash -if test -z "$BASH_VERSION" -then - CONFIG_SHELL=`command -v bash` - export CONFIG_SHELL - if $CONFIG_SHELL -c "exit 0" - then - exec $CONFIG_SHELL $0 "$@" - else - AC_MSG_NOTICE([The 'bash' shell is needed to build AC_PACKAGE_NAME]) - AC_MSG_NOTICE([All modern systems will have the 'bash' shell installed somewhere]) - if test -d /opt/OpenSource/bin - then - AC_MSG_NOTICE([On HP-UX you may try adding /opt/OpenSource/bin to your path]) - fi - if test -d /opt/pware/bin - then - AC_MSG_NOTICE([On AIX you may try adding /opt/pware/bin to your path]) - fi - AC_MSG_ERROR(['bash' not found]) - fi -fi - AC_COPYRIGHT([GPL version 3]) AC_CONFIG_SRCDIR([configure.ac]) From 5db53186b9ae9a546bc78fc9107cc1af713b7e24 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 8 May 2020 11:57:29 -0400 Subject: [PATCH 08/11] Trac #29345: remove "break" statements from AC_SEARCH_LIBS. The AC_CHECK_HEADERS macro allows you to specify "break" for the action-if-found, but AC_SEARCH_LIBS does not. And zsh especially does not like seeing a "break" statement out of context. --- build/pkgs/mpc/spkg-configure.m4 | 2 +- build/pkgs/mpfr/spkg-configure.m4 | 2 +- build/pkgs/mpir/spkg-configure.m4 | 2 +- build/pkgs/ncurses/spkg-configure.m4 | 4 ++-- build/pkgs/readline/spkg-configure.m4 | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/pkgs/mpc/spkg-configure.m4 b/build/pkgs/mpc/spkg-configure.m4 index 9ec14a7c980..32aca4ada1b 100644 --- a/build/pkgs/mpc/spkg-configure.m4 +++ b/build/pkgs/mpc/spkg-configure.m4 @@ -8,7 +8,7 @@ SAGE_SPKG_CONFIGURE([mpc], [ AC_MSG_RESULT([no]) AC_CHECK_HEADER(mpc.h, [], [sage_spkg_install_mpc=yes]) dnl mpc_cmp_abs appeared in MPC 1.1.0 - AC_SEARCH_LIBS([mpc_cmp_abs], [mpc], [break], [sage_spkg_install_mpc=yes]) + AC_SEARCH_LIBS([mpc_cmp_abs], [mpc], [], [sage_spkg_install_mpc=yes]) fi ], [], [], [ if test x$sage_spkg_install_mpc = xyes; then diff --git a/build/pkgs/mpfr/spkg-configure.m4 b/build/pkgs/mpfr/spkg-configure.m4 index 0d0ef933027..0c15b56df43 100644 --- a/build/pkgs/mpfr/spkg-configure.m4 +++ b/build/pkgs/mpfr/spkg-configure.m4 @@ -8,7 +8,7 @@ SAGE_SPKG_CONFIGURE([mpfr], [ AC_MSG_RESULT([no]) AC_CHECK_HEADER(mpfr.h, [], [sage_spkg_install_mpfr=yes]) dnl mpfr_free_pool appeared in r11922 (Dec 2017) on MPFR svn - AC_SEARCH_LIBS([mpfr_free_pool], [mpfr], [break], [sage_spkg_install_mpfr=yes]) + AC_SEARCH_LIBS([mpfr_free_pool], [mpfr], [], [sage_spkg_install_mpfr=yes]) fi ], [], [], [ if test x$sage_spkg_install_mpfr = xyes; then diff --git a/build/pkgs/mpir/spkg-configure.m4 b/build/pkgs/mpir/spkg-configure.m4 index c4f9c432e2a..01afff14621 100644 --- a/build/pkgs/mpir/spkg-configure.m4 +++ b/build/pkgs/mpir/spkg-configure.m4 @@ -5,7 +5,7 @@ dnl Implement cases for what to do on different options here AC_CHECK_HEADER(gmp.h, [], [sage_spkg_install_mpir=yes]) AC_CHECK_HEADER(gmpxx.h, [], [sage_spkg_install_mpir=yes]) dnl mpq_cmp_z appeared in GMP 6.1.0 and is used by pynac - AC_SEARCH_LIBS([__gmpq_cmp_z], [gmp], [break], + AC_SEARCH_LIBS([__gmpq_cmp_z], [gmp], [], [sage_spkg_install_mpir=yes]) SAGE_MP_LIBRARY=mpir ;; diff --git a/build/pkgs/ncurses/spkg-configure.m4 b/build/pkgs/ncurses/spkg-configure.m4 index 8fe619cbefd..c706d4091d5 100644 --- a/build/pkgs/ncurses/spkg-configure.m4 +++ b/build/pkgs/ncurses/spkg-configure.m4 @@ -2,8 +2,8 @@ SAGE_SPKG_CONFIGURE([ncurses], [ dnl First try checking for ncurses with pkg-config PKG_CHECK_MODULES([NCURSES], [ncurses >= 6.0], [], [AC_CHECK_HEADERS([ncurses.h], - [AC_SEARCH_LIBS([wresize], [ncurses tinfo], [break], - [sage_spkg_install_ncurses=yes])], + [AC_SEARCH_LIBS([wresize], [ncurses tinfo], [], + [sage_spkg_install_ncurses=yes])], [sage_spkg_install_ncurses=yes])], [sage_spkg_install_ncurses=yes]) ]) diff --git a/build/pkgs/readline/spkg-configure.m4 b/build/pkgs/readline/spkg-configure.m4 index 4d82c6d77be..68aab0a36ad 100644 --- a/build/pkgs/readline/spkg-configure.m4 +++ b/build/pkgs/readline/spkg-configure.m4 @@ -11,7 +11,7 @@ SAGE_SPKG_CONFIGURE([readline], [ [AC_CHECK_HEADERS([readline/readline.h], dnl rl_bind_keyseq is not present in macos's readline dnl and is not present in readline version 4 (the one in OpenBSD) - [AC_SEARCH_LIBS([rl_bind_keyseq], [readline], [break], + [AC_SEARCH_LIBS([rl_bind_keyseq], [readline], [], [sage_spkg_install_readline=yes])], [sage_spkg_install_readline=yes])], [sage_spkg_install_readline=yes]) From e810ad1596d527c832bf43d3aac745407c9ba98d Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 8 May 2020 12:02:58 -0400 Subject: [PATCH 09/11] Trac #29345: don't use sage's config.status for the lrcalc build. The lrcalc SPKG has some outdated autotools, and we worked around that in Trac ticket 19725 (commit 75de776ab) with the line, cp "$SAGE_ROOT"/config/config.* . that is intended to import only config.guess and config.sub, judging by the comment above it. However, it's also mistakenly copying in the sage version of config.status, causing build problems when sage was configured with a non-bash shell. --- build/pkgs/lrcalc/spkg-install.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/pkgs/lrcalc/spkg-install.in b/build/pkgs/lrcalc/spkg-install.in index 46b765298c6..d6665bfb427 100644 --- a/build/pkgs/lrcalc/spkg-install.in +++ b/build/pkgs/lrcalc/spkg-install.in @@ -1,7 +1,8 @@ cd src # Use newer version of config.guess and config.sub (see Trac #19725) -cp "$SAGE_ROOT"/config/config.* . +cp "$SAGE_ROOT"/config/config.guess . +cp "$SAGE_ROOT"/config/config.sub . sdh_configure sdh_make From 93c9921cc5ff461cd1f02f441b46cea4400dcd85 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 13 May 2020 16:57:34 -0400 Subject: [PATCH 10/11] Trac #29345: replace the function that populates the CVXOPT_* variables. Our existing function, borrowed from Gentoo, to populate the CVXOPT_* variables from pkg-config was brittle. It didn't handle -lpthread and -lm the way it was intended to, and didn't always work with a non-bash shell. The new version (which has also been upstreamed to Gentoo) should fix both of those problems. It also suppors getting the -L and -I flags from pkg-config in the future, which will likely be necessary to support system installations of some cvxopt dependencies. --- build/pkgs/cvxopt/spkg-install.in | 67 ++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 9 deletions(-) diff --git a/build/pkgs/cvxopt/spkg-install.in b/build/pkgs/cvxopt/spkg-install.in index 980eddf1493..bed0f34ceee 100644 --- a/build/pkgs/cvxopt/spkg-install.in +++ b/build/pkgs/cvxopt/spkg-install.in @@ -1,20 +1,69 @@ cd src -# Stolen from Gentoo -pkg_libs() { - pkg-config --libs-only-l $* | \ - sed -e 's:[ ]-l*\(pthread\|m\)\([ ]\|$\)::g' -e 's:[ ]*$::' | \ - tr ' ' '\n' | sort -u | sed -e "s:^-l\(.*\):\1:g" | \ - tr '\n' ';' | sed -e 's:;$::' -} +# This is a POSIX (non-bash) compatible version of the same function +# in the Gentoo cvxopt package. It's more general than it needs to +# be right now because we may need to use the "L" and "I" modes in +# the future to support system installations of e.g. suitesparse. +# +# The BLAS_LIB and LAPACK_LIB variables (among others) in cvxopt's +# setup.py are passed in as colon-delimited strings. So, for example, +# if your blas "l" flags are "-lblas -lcblas", then cvxopt wants +# "blas;cblas" for BLAS_LIB. +# +# The following function takes a flag type ("l", "L", or "I") as its +# first argument and a list of packages as its remaining arguments. It +# outputs a list of libraries, library paths, or include paths, +# respectively, for the given packages, retrieved using pkg-config and +# deduplicated, in the appropriate format. +# +cvxopt_output() { + FLAGNAME="${1}" + shift + PACKAGES="${@}" + + case "${FLAGNAME}" in + l) PKGCONFIG_MODE="--libs-only-l";; + L) PKGCONFIG_MODE="--libs-only-L";; + I) PKGCONFIG_MODE="--cflags-only-I";; + *) echo "invalid flag name: ${FLAGNAME}"; exit 1;; + esac + + CVXOPT_OUTPUT="" + for PKGCONFIG_ITEM in $(pkg-config ${PKGCONFIG_MODE} ${PACKAGES}); do + # First strip off the leading "-l", "-L", or "-I", and replace + # it with a semicolon... + PKGCONFIG_ITEM=";${PKGCONFIG_ITEM#-${FLAGNAME}}" + # Now check to see if this element is already present in the + # list, and skip it if it is. This eliminates multiple entries + # from winding up in the list when multiple package arguments are + # passed to this function. + if [ "${CVXOPT_OUTPUT}" != "${CVXOPT_OUTPUT%${PKGCONFIG_ITEM}}" ] + then + # It was already the last entry in the list, so skip it. + continue + elif [ "${CVXOPT_OUTPUT}" != "${CVXOPT_OUTPUT%${PKGCONFIG_ITEM};*}" ] + then + # It was an earlier entry in the list. These two cases are + # separate to ensure that we can e.g. find ";m" at the end + # of the list, but that we don't find ";metis" in the process. + continue + fi + + # It isn't in the list yet, so append it. + CVXOPT_OUTPUT="${CVXOPT_OUTPUT}${PKGCONFIG_ITEM}" + done + + # Strip the leading ";" from ";foo;bar" before output. + echo "${CVXOPT_OUTPUT#;}" +} # configure cvxopt by variables # Note that *_INC_DIR variables have to be non-empty. # Compilers don't like "-I ". -export CVXOPT_BLAS_LIB="$(pkg_libs blas)" +export CVXOPT_BLAS_LIB="$(cvxopt_output l blas)" export CVXOPT_BLAS_LIB_DIR="$(pkg-config --variable=libdir blas)" -export CVXOPT_LAPACK_LIB="$(pkg_libs lapack)" +export CVXOPT_LAPACK_LIB="$(cvxopt_output l lapack)" if test "x$SAGE_SUITESPARSE_LOCALINSTALL" != "x"; then export CVXOPT_SUITESPARSE_LIB_DIR="${SAGE_LOCAL}" From 0e66a0abc00d5bf5ac1496e13f4d2f4ef7fe29dc Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 15 May 2020 06:36:41 -0400 Subject: [PATCH 11/11] Trac #29345: add Dima's SPKG patches for ksh compatibility. Without these three patches, the *.pc files for givaro, linbox, and fflas-ffpack cause problems with the ksh shell. Since we are removing the code in configure.ac that sets the shell to bash as part of the same ticket, these patches are needed to avoid introducing new problems. --- .../patches/fix-ksh-pkgconfig.patch | 28 +++++++++++++++++++ .../givaro/patches/fix-ksh-pkgconfig.patch | 27 ++++++++++++++++++ .../linbox/patches/fix-ksh-pkgconfig.patch | 28 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 build/pkgs/fflas_ffpack/patches/fix-ksh-pkgconfig.patch create mode 100644 build/pkgs/givaro/patches/fix-ksh-pkgconfig.patch create mode 100644 build/pkgs/linbox/patches/fix-ksh-pkgconfig.patch diff --git a/build/pkgs/fflas_ffpack/patches/fix-ksh-pkgconfig.patch b/build/pkgs/fflas_ffpack/patches/fix-ksh-pkgconfig.patch new file mode 100644 index 00000000000..fdaed2eebee --- /dev/null +++ b/build/pkgs/fflas_ffpack/patches/fix-ksh-pkgconfig.patch @@ -0,0 +1,28 @@ +From 33a5ec4977f36ce3a24c9ee824d9dd053b8cea04 Mon Sep 17 00:00:00 2001 +From: Dima Pasechnik +Date: Fri, 8 May 2020 15:55:27 +0100 +Subject: [PATCH 1/1] remove 1st and last file in .pc file + +this causes problem if building with ksh, as they remain, causing a broken .pc file. +--- + fflas-ffpack.pc.in | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/fflas-ffpack.pc.in b/fflas-ffpack.pc.in +index a2618d6..e34a744 100644 +--- a/fflas-ffpack.pc.in ++++ b/fflas-ffpack.pc.in +@@ -1,4 +1,3 @@ +-/------------------ fflas-ffpack.pc ------------------------ + prefix=@prefix@ + exec_prefix=@prefix@ + libdir=@prefix@/lib +@@ -11,4 +10,3 @@ Version: @VERSION@ + Requires: givaro >= 4.0.3 + Libs: @PARLIBS@ @PRECOMPILE_LIBS@ @BLAS_LIBS@ + Cflags: -I@includedir@ @BLAS_CFLAGS@ @PARFLAGS@ @PRECOMPILE_FLAGS@ @REQUIRED_FLAGS@ +-\------------------------------------------------------- +\ No newline at end of file +-- +2.26.2 + diff --git a/build/pkgs/givaro/patches/fix-ksh-pkgconfig.patch b/build/pkgs/givaro/patches/fix-ksh-pkgconfig.patch new file mode 100644 index 00000000000..28fd95088c8 --- /dev/null +++ b/build/pkgs/givaro/patches/fix-ksh-pkgconfig.patch @@ -0,0 +1,27 @@ +From 91dcba743e15288abe69966a5f71704d9adcc57c Mon Sep 17 00:00:00 2001 +From: Dima Pasechnik +Date: Fri, 8 May 2020 10:22:57 +0100 +Subject: [PATCH 1/1] remove 1st and last lines in givaro.pc.in + +--- + givaro.pc.in | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/givaro.pc.in b/givaro.pc.in +index 285b854..af38bf3 100644 +--- a/givaro.pc.in ++++ b/givaro.pc.in +@@ -1,4 +1,3 @@ +-/------------------ givaro.pc ------------------------ + prefix=@prefix@ + exec_prefix=@prefix@ + libdir=@prefix@/lib +@@ -11,4 +10,3 @@ Version: @VERSION@ + Requires: + Libs: -L@libdir@ -lgivaro @LIBS@ + Cflags: -I@includedir@ @REQUIRED_FLAGS@ +-\------------------------------------------------------- +\ No newline at end of file +-- +2.26.2 + diff --git a/build/pkgs/linbox/patches/fix-ksh-pkgconfig.patch b/build/pkgs/linbox/patches/fix-ksh-pkgconfig.patch new file mode 100644 index 00000000000..e0cb575b1a1 --- /dev/null +++ b/build/pkgs/linbox/patches/fix-ksh-pkgconfig.patch @@ -0,0 +1,28 @@ +From 52c78df67a08de074991a93b57946b7bd5ea7196 Mon Sep 17 00:00:00 2001 +From: Dima Pasechnik +Date: Fri, 8 May 2020 15:53:25 +0100 +Subject: [PATCH 1/1] remove redundant 1st and last lines + +they remain if the script is run under ksh, leading to broken .pc file +--- + linbox.pc.in | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/linbox.pc.in b/linbox.pc.in +index f54285e..eb6835b 100644 +--- a/linbox.pc.in ++++ b/linbox.pc.in +@@ -1,4 +1,3 @@ +-/------------------ linbox.pc ------------------------ + prefix=@prefix@ + exec_prefix=@prefix@ + libdir=@libdir@ +@@ -11,4 +10,4 @@ Version: @VERSION@ + Requires: fflas-ffpack >= 2.4.0, givaro >= 4.1.0 + Libs: -L${libdir} -llinbox @LINBOXSAGE_LIBS@ @NTL_LIBS@ @MPFR_LIBS@ @FPLLL_LIBS@ @IML_LIBS@ @FLINT_LIBS@ @OCL_LIBS@ + Cflags: @DEFAULT_CFLAGS@ -DDISABLE_COMMENTATOR -I${includedir} @NTL_CFLAGS@ @MPFR_CFLAGS@ @FPLLL_CFLAGS@ @IML_CFLAGS@ @FLINT_CFLAGS@ +-\------------------------------------------------------- ++ +-- +2.26.2 +