Improved handing of 'lib64' vs. 'lib' for glpk-cut-log and antlr-3.4 (#6091)
authorAndrew V. Jones <andrewvaughanj@gmail.com>
Wed, 10 Mar 2021 22:10:12 +0000 (22:10 +0000)
committerGitHub <noreply@github.com>
Wed, 10 Mar 2021 22:10:12 +0000 (22:10 +0000)
Signed-off-by: Andrew V. Jones <andrewvaughanj@gmail.com>
contrib/get-antlr-3.4
contrib/get-glpk-cut-log
contrib/get-script-header.sh

index dcb48325bab955dffe4e5beef3b77a065a17671c..0b717266f6afd40681bbd40343bed42188e091ed 100755 (executable)
@@ -80,12 +80,10 @@ sed 's,^\(CFLAGS = .*\),\1 -fexceptions,' Makefile.orig > Makefile
 make CFLAGS="${MAKE_CFLAGS}" CXXFLAGS="${MAKE_CXXFLAGS}" LDFLAGS="${MAKE_LDFLAGS}"
 make install
 
-# Build shared ANTLR library
-
-# On some systems the library may be installed to lib64/ instead of lib/
-LIB_DIR="$(dirname "$(find "$INSTALL_DIR" -name libantlr3c.a)")"
+# Find and move the static build
+rename_installed_lib "libantlr3c.a" "libantlr3c-static.a"
 
-mv "$LIB_DIR/libantlr3c.a" "$LIB_DIR/libantlr3c-static.a"
+# Build shared ANTLR library
 make clean
 
 ./configure --with-pic --disable-antlrdebug --prefix="$INSTALL_DIR" $ANTLR_CONFIGURE_ARGS $BUILD_TYPE
@@ -94,8 +92,9 @@ cp Makefile Makefile.orig
 sed 's,^\(CFLAGS = .*\),\1 -fexceptions,' Makefile.orig > Makefile
 make CFLAGS="${MAKE_CFLAGS}" CXXFLAGS="${MAKE_CXXFLAGS}" LDFLAGS="${MAKE_LDFLAGS}"
 make install
-mv "$LIB_DIR/libantlr3c.la" "$LIB_DIR/libantlr3c.la.orig"
+rename_installed_lib "libantlr3c.la" "libantlr3c.la.orig"
 
+LIB_DIR=$(guess_lib_dir "libantlr3c.la.orig")
 awk '/^old_library=/ {print "old_library='\''libantlr3c-static.a'\''"} /^library_names=/ {print "library_names='\''libantlr3c.a'\''"} !/^old_library=/ && !/^library_names=/ {print}' < "$LIB_DIR/libantlr3c.la.orig" > "$LIB_DIR/libantlr3c.la"
 rm "$LIB_DIR/libantlr3c.la.orig"
 
index f8eff85bb8a290d77b9d0f92fe488c64e3ff5716..cf523dc5a01df0c88dcc459bcbf2343dabeec91a 100755 (executable)
@@ -32,7 +32,9 @@ automake --add-missing
 ./configure --without-pic --prefix="$INSTALL_DIR" --disable-shared --enable-static --disable-dependency-tracking
 make install -j$(nproc)
 make distclean
-mv "$INSTALL_LIB_DIR/libglpk.a" "$INSTALL_LIB_DIR/libglpk-static.a"
+
+# Find and move the static build
+rename_installed_lib "libglpk.a" "libglpk-static.a"
 
 ./configure --with-pic --prefix="$INSTALL_DIR" --disable-shared --enable-static --disable-dependency-tracking
 make install -j$(nproc)
index 64ef5440131d5937722348e79008787b0a74a6c6..394669c681846e4b188bb4cfc0f54e09ba947dd4 100644 (file)
@@ -85,3 +85,29 @@ function install_bin
   [ ! -d "$INSTALL_BIN_DIR" ] && mkdir -p "$INSTALL_BIN_DIR"
   cp "$1" "$INSTALL_BIN_DIR"
 }
+
+function guess_lib_dir
+{
+   #
+   # On some systems the library may be installed to lib64/
+   # instead of lib/
+   #
+   # This function guesses the install lib directory
+   #
+   lib_name="$1"
+   lib_dir="$(dirname "$(find "$INSTALL_DIR" -name "${lib_name}")")"
+   echo ${lib_dir}
+}
+
+function rename_installed_lib
+{
+   #
+   # This function uses the calculated library directory and
+   # then relocates the first argument to the second.
+   #
+   src="$1"
+   dest="$2"
+   lib_dir="$(guess_lib_dir "$src")"
+   mv "$lib_dir/$src" "$lib_dir/$dest"
+}
+