From fb26974ef31a8cfe409af5fbeee7c79483335ac4 Mon Sep 17 00:00:00 2001
From: Mayo Roettger <mayo.roettger@uni-duesseldorf.de>
Date: Mon, 21 Sep 2020 13:57:25 +0200
Subject: [PATCH] Version 4.1.1; Adaptation of configure scripts to guess
 default installation directory on Mac OS

---
 DESCRIPTION  |  8 +++----
 configure    | 65 ++++++++++++++++++++++++++++++++++++++++++++--------
 configure.ac |  9 ++++++--
 inst/INSTALL |  4 +++-
 inst/NEWS.Rd | 11 +++++++++
 5 files changed, 80 insertions(+), 17 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index b963920..883f6f2 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
 Package: cplexAPI
 Type: Package
 Title: R Interface to C API of IBM ILOG CPLEX
-Version: 1.4.0
-Date: 2020-09-17
+Version: 1.4.1
+Date: 2020-09-21
 Authors@R: c(person("Mayo", "Roettger", role = "cre", email = "mayo.roettger@hhu.de"),
              person("Gabriel", "Gelius-Dietrich", role = "aut", email = "geliudie@uni-duesseldorf.de"),
              person(c("C.", "Jonathan"), "Fritzemeier", role = c("ctb"), email = "clausjonathan.fritzemeier@uni-duesseldorf.de"))
@@ -14,7 +14,7 @@ License: GPL-3 | file LICENSE
 LazyLoad: yes
 Collate: generics.R cplexConst.R cplexErrorClass.R cplexPtrClass.R
         cplex.R cplexAPI.R cplex_checkAPI.R cplex_longparamAPI.R zzz.R
-Packaged: 2020-09-17 12:58:00 UTC; mayo
+Packaged: 2020-09-21 11:49:00 UTC; mayo
 NeedsCompilation: yes
 Repository: CRAN
-Date/Publication: 2020-09-17 14:58:00
+Date/Publication: 2020-09-21 13:49:00
diff --git a/configure b/configure
index d127ebe..96c9942 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for cplexAPI 1.4.0.
+# Generated by GNU Autoconf 2.69 for cplexAPI 1.4.1.
 #
 # Report bugs to <mayo.roettger@hhu.de>.
 #
@@ -580,8 +580,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='cplexAPI'
 PACKAGE_TARNAME='cplexapi'
-PACKAGE_VERSION='1.4.0'
-PACKAGE_STRING='cplexAPI 1.4.0'
+PACKAGE_VERSION='1.4.1'
+PACKAGE_STRING='cplexAPI 1.4.1'
 PACKAGE_BUGREPORT='mayo.roettger@hhu.de'
 PACKAGE_URL=''
 
@@ -1246,7 +1246,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures cplexAPI 1.4.0 to adapt to many kinds of systems.
+\`configure' configures cplexAPI 1.4.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1308,7 +1308,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of cplexAPI 1.4.0:";;
+     short | recursive ) echo "Configuration of cplexAPI 1.4.1:";;
    esac
   cat <<\_ACEOF
 
@@ -1399,7 +1399,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-cplexAPI configure 1.4.0
+cplexAPI configure 1.4.1
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1701,7 +1701,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by cplexAPI $as_me 1.4.0, which was
+It was created by cplexAPI $as_me 1.4.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3156,7 +3156,52 @@ fi
     { $as_echo "$as_me:${as_lineno-$LINENO}: NOTICE $CPLEX_BIN ermittelt" >&5
 $as_echo "$as_me: NOTICE $CPLEX_BIN ermittelt" >&6;}
     if test  "$CPLEX_BIN" = "NONE"  ; then
-        as_fn_error $? "CPLEX interactive optimizer not found" "$LINENO" 5
+                for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AWK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+        CPLEX_DIR=`ls -ld /Applications/CPLEX_Studio* |${AWK} '($1 ~ /^d/) { print $NF }' | head -n 1`
+        if test  -z "$CPLEX_DIR" -o ! -d "$CPLEX_DIR"  ; then
+            as_fn_error $? "CPLEX interactive optimizer not found" "$LINENO" 5
+        fi
     else
         CPLEX_DIR=`$as_dirname -- "$CPLEX_BIN" ||
 $as_expr X"$CPLEX_BIN" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
@@ -4234,7 +4279,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by cplexAPI $as_me 1.4.0, which was
+This file was extended by cplexAPI $as_me 1.4.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -4296,7 +4341,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-cplexAPI config.status 1.4.0
+cplexAPI config.status 1.4.1
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index bc2aeb3..5082b92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([cplexAPI], [1.4.0], [mayo.roettger@hhu.de])
+AC_INIT([cplexAPI], [1.4.1], [mayo.roettger@hhu.de])
 
 ## adopted from configure.ac in Rcplex_0.3-0
 
@@ -154,7 +154,12 @@ if test [ "$ARGS_OK" = "FALSE" -a -z "$CPLEX_DIR" ] ; then
     AC_PATH_PROG(CPLEX_BIN, cplex, "NONE")
     AC_MSG_NOTICE([NOTICE $CPLEX_BIN ermittelt])
     if test [ "$CPLEX_BIN" = "NONE" ] ; then
-        AC_MSG_ERROR([CPLEX interactive optimizer not found])
+        dnl # Try Mac OS default folder guess
+        AC_PROG_AWK
+        CPLEX_DIR=`ls -ld /Applications/CPLEX_Studio* |${AWK} '($1 ~ /^d/) { print $NF }' | head -n 1`
+        if test [ -z "$CPLEX_DIR" -o ! -d "$CPLEX_DIR" ] ; then
+            AC_MSG_ERROR([CPLEX interactive optimizer not found])
+        fi
     else
         CPLEX_DIR=`AS_DIRNAME(["$CPLEX_BIN"])`
         dnl # get name of last folder in the path. This is the MACHINE.
diff --git a/inst/INSTALL b/inst/INSTALL
index edbc2b6..1021999 100644
--- a/inst/INSTALL
+++ b/inst/INSTALL
@@ -86,7 +86,9 @@ There are several ways of installing the cplexAPI package:
    This procedure will try to find the CPLEX interactive optimizer, or the
    CPLEX_BIN environment variable pointing to the CPLEX interactive optimizer
    will be used. The directory two levels above is used as CPLEX directory, all
-   other information is taken from the CPLEX example Makefile as in #3 above.
+   other information is taken from the CPLEX example Makefile as in #3 above. 
+   In case, the directory could not be determined on Mac OS, the default 
+   installation directory will be used.
 
 
 # ---------------------------------------------------------------------------- #
diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd
index e12d914..3d7a3d3 100644
--- a/inst/NEWS.Rd
+++ b/inst/NEWS.Rd
@@ -3,6 +3,17 @@
 \name{NEWS}
 \title{cplexAPI News}
 \encoding{UTF-8}
+% ---------------------------------------------------------------------------- %
+\section{Changes in version 1.4.1 2020-09-21}{
+  \itemize{
+    \item Adaptation of configure script to guess CPLEX installation directory on Mac OS, if neither environment variables 
+    PKG_CPPFLAGS and PKG_LIBS, nor configure arguments --with-cplex-include and --with-cplex-lib are given, and option 
+    --with-cplex-dir was not given and respective directory could not be extracted from the path variable.
+    \item Small change in INSTALL file according to Mac OS installation information.
+  }
+}
+
+
 % ---------------------------------------------------------------------------- %
 \section{Changes in version 1.4.0 2020-09-17}{
   \itemize{
-- 
GitLab