<commit_before>dnl ----------------------------------------------------------------
dnl Certain parts of rbOOmit require GLPK, the GNU Linear Programming
dnl Kit.  By default we check for the GLPK installation files in 
dnl --with-glpk-include=xxx and --with-glpk-lib=yyy arguments provided to
dnl configure, or if those don't exist in $GLPK_INC and $GPLK_LIB
dnl directories, or in $GLPK_DIR/include and $GLPK_DIR/lib directories, or
dnl in /usr/local, or in /usr.
dnl ----------------------------------------------------------------

AC_DEFUN([CONFIGURE_GLPK], 
[
  AC_ARG_ENABLE(glpk,
                AC_HELP_STRING([--enable-glpk],
                               [build with GLPK support]),
		[case "${enableval}" in
		  yes)  enableglpk=yes ;;
		   no)  enableglpk=no ;;
 		    *)  AC_MSG_ERROR(bad value ${enableval} for --enable-glpk) ;;
		 esac],
		 [enableglpk=$enableoptional])


  if (test $enableglpk = yes); then
  
    dnl User-specific include path
    AC_ARG_WITH(glpk-include,
                AC_HELP_STRING([--with-glpk-include=PATH],[Specify the path for GLPK header files]),
                withglpkinc=$withval,
                withglpkinc=no)
  	      
    dnl User-specific library path
    AC_ARG_WITH(glpk-lib,
                AC_HELP_STRING([--with-glpk-lib=PATH],[Specify the path for GLPK libs]),
                withglpklib=$withval,
                withglpklib=no)
  
    dnl Fall back on default paths to GLPK's include and lib files
    if (test $withglpkinc != no); then
      GLPK_INC="$withglpkinc"
    elif test "x$GLPK_INC" != x -a -f $GLPK_INC/glpk.h; then
      echo "Environment GLPK_INC=$GLPK_INC"
    elif test "x$GLPK_DIR" != x -a -f $GLPK_DIR/include/glpk.h; then
      GLPK_INC="$GLPK_DIR/include"
    elif test -f /usr/include/glpk/glpk.h; then # RHEL6 puts glpk here
      GLPK_INC="/usr/include/glpk"
    elif test -f /usr/local/include/glpk.h; then
      GLPK_INC="/usr/local/include"
    else
      GLPK_INC="/usr/include"
    fi
  
    if (test $withglpklib != no); then
      GLPK_LIB="$withglpklib"
    elif test "x$GLPK_LIB" != x; then
      echo "Environment GLPK_LIB=$GLPK_INC"
    elif test "x$GLPK_DIR" != x; then
      GLPK_LIB="$GLPK_DIR/lib"
    elif test -f /usr/include/glpk/glpk.h; then # RHEL6 puts glpk here
      if test -f /usr/lib64/libglpk.so -o -f /usr/lib64/libglpk.a; then 
        GLPK_LIB="/usr/lib64"
      elif test -f /usr/lib/libglpk.so -o -f /usr/lib/libglpk.a; then
        GLPK_LIB="/usr/lib"
      fi
    elif test -f /usr/local/include/glpk.h; then
      GLPK_LIB="/usr/local/lib"
    else
      GLPK_LIB="/usr/lib"
    fi
  
    dnl Initialize Makefile/config.h substitution variables
    GLPK_INCLUDE=""
    GLPK_LIBRARY=""
  
    dnl Properly let the substitution variables
    if (test $enableglpk = yes); then
    
       dnl Check for existence of a header file in the specified location
       dnl AC_CHECK_FILE([$GLPK_INC/glpk.h], [glpkincFound="OK"], [glpkincFound="FAIL"])
       glpkincFound=no;
       AC_CHECK_HEADERS($GLPK_INC/glpk.h, glpkincFound=yes)
  
       if (test $glpkincFound = no); then
         AC_MSG_RESULT(GLPK header files not found!)
         enableglpk=no;
       fi
  
       dnl Discover the major and minor version numbers of GLPK by looking in
       dnl glpk.h.  This may eventually be useful for compiling against different
       dnl GLPK APIs...
       if (test $enableglpk = yes); then
         glpkmajor=`grep "define GLP_MAJOR_VERSION" $GLPK_INC/glpk.h | sed -e "s/#define GLP_MAJOR_VERSION[ ]*//g"`
         glpkminor=`grep "define GLP_MINOR_VERSION" $GLPK_INC/glpk.h | sed -e "s/#define GLP_MINOR_VERSION[ ]*//g"`
         glpkversion=$glpkmajor.$glpkminor
         AC_MSG_RESULT(<<< Configuring library with GLPK version $glpkversion support >>>)
       fi
  
       if (test $enableglpk = yes); then
         dnl Also Check for existence of required libraries.  This is not really the
         dnl right way to do it -- it's not portable to Macs, where .so's are called
         dnl .dylib's instead.
         dnl AC_CHECK_FILE($GLPK_LIB/glpk.so, [enableglpk=yes], [enableglpk=no])
         
         dnl AC_HAVE_LIBRARY (library, [action-if-found], [action-if-not-found], [other-libraries])
         dnl Note: Basically tries to compile a function which calls main().  
  
         dnl Save original value of LIBS, then append $GLPK_LIB
         old_LIBS="$LIBS"
         LIBS="$old_LIBS -L$GLPK_LIB"
  
         dnl Try to compile test prog to check for existence of GLPK libraries
         dnl AC_HAVE_LIBRARY uses the LIBS variable.
         AC_HAVE_LIBRARY([glpk], [enableglpk=yes], [enableglpk=no])
         
         dnl Reset $LIBS
         LIBS="$old_LIBS"
       fi
       
       dnl If both the header file and the required libs were found, continue.
       if (test $enableglpk = yes); then
         GLPK_INCLUDE="-I$GLPK_INC"
         GLPK_LIBRARY="-L$GLPK_LIB -lglpk"
	 if (test "x$RPATHFLAG" != "x" -a -d $GLPK_LIB); then # add the GLPK_LIB to the linker run path, if it is a directory
	   GLPK_LIBRARY="${RPATHFLAG}${GLPK_LIB} $GLPK_LIBRARY"
	 fi
         AC_DEFINE(HAVE_GLPK, 1, [Flag indicating whether the library will be compiled with GLPK support])
         AC_MSG_RESULT(<<< Configuring library with GLPK support >>>)
	 libmesh_optional_INCLUDES="$GLPK_INCLUDE $libmesh_optional_INCLUDES"
	 libmesh_optional_LIBS="$GLPK_LIBRARY $libmesh_optional_LIBS"<commit_msg>do not add an RPATH flag for system default libraries - this can wreck havoc when using non-default compilers and, for example, libstdc++ gets foobared.<commit_after>dnl ----------------------------------------------------------------
dnl Certain parts of rbOOmit require GLPK, the GNU Linear Programming
dnl Kit.  By default we check for the GLPK installation files in 
dnl --with-glpk-include=xxx and --with-glpk-lib=yyy arguments provided to
dnl configure, or if those don't exist in $GLPK_INC and $GPLK_LIB
dnl directories, or in $GLPK_DIR/include and $GLPK_DIR/lib directories, or
dnl in /usr/local, or in /usr.
dnl ----------------------------------------------------------------

AC_DEFUN([CONFIGURE_GLPK], 
[
  AC_ARG_ENABLE(glpk,
                AC_HELP_STRING([--enable-glpk],
                               [build with GLPK support]),
		[case "${enableval}" in
		  yes)  enableglpk=yes ;;
		   no)  enableglpk=no ;;
 		    *)  AC_MSG_ERROR(bad value ${enableval} for --enable-glpk) ;;
		 esac],
		 [enableglpk=$enableoptional])


  if (test $enableglpk = yes); then
  
    dnl User-specific include path
    AC_ARG_WITH(glpk-include,
                AC_HELP_STRING([--with-glpk-include=PATH],[Specify the path for GLPK header files]),
                withglpkinc=$withval,
                withglpkinc=no)
  	      
    dnl User-specific library path
    AC_ARG_WITH(glpk-lib,
                AC_HELP_STRING([--with-glpk-lib=PATH],[Specify the path for GLPK libs]),
                withglpklib=$withval,
                withglpklib=no)
  
    dnl Fall back on default paths to GLPK's include and lib files
    if (test $withglpkinc != no); then
      GLPK_INC="$withglpkinc"
    elif test "x$GLPK_INC" != x -a -f $GLPK_INC/glpk.h; then
      echo "Environment GLPK_INC=$GLPK_INC"
    elif test "x$GLPK_DIR" != x -a -f $GLPK_DIR/include/glpk.h; then
      GLPK_INC="$GLPK_DIR/include"
    elif test -f /usr/include/glpk/glpk.h; then # RHEL6 puts glpk here
      GLPK_INC="/usr/include/glpk"
    elif test -f /usr/local/include/glpk.h; then
      GLPK_INC="/usr/local/include"
    else
      GLPK_INC="/usr/include"
    fi
  
    if (test $withglpklib != no); then
      GLPK_LIB="$withglpklib"
    elif test "x$GLPK_LIB" != x; then
      echo "Environment GLPK_LIB=$GLPK_INC"
    elif test "x$GLPK_DIR" != x; then
      GLPK_LIB="$GLPK_DIR/lib"
    elif test -f /usr/include/glpk/glpk.h; then # RHEL6 puts glpk here
      if test -f /usr/lib64/libglpk.so -o -f /usr/lib64/libglpk.a; then 
        GLPK_LIB="/usr/lib64"
      elif test -f /usr/lib/libglpk.so -o -f /usr/lib/libglpk.a; then
        GLPK_LIB="/usr/lib"
      fi
    elif test -f /usr/local/include/glpk.h; then
      GLPK_LIB="/usr/local/lib"
    else
      GLPK_LIB="/usr/lib"
    fi
  
    dnl Initialize Makefile/config.h substitution variables
    GLPK_INCLUDE=""
    GLPK_LIBRARY=""
  
    dnl Properly let the substitution variables
    if (test $enableglpk = yes); then
    
       dnl Check for existence of a header file in the specified location
       dnl AC_CHECK_FILE([$GLPK_INC/glpk.h], [glpkincFound="OK"], [glpkincFound="FAIL"])
       glpkincFound=no;
       AC_CHECK_HEADERS($GLPK_INC/glpk.h, glpkincFound=yes)
  
       if (test $glpkincFound = no); then
         AC_MSG_RESULT(GLPK header files not found!)
         enableglpk=no;
       fi
  
       dnl Discover the major and minor version numbers of GLPK by looking in
       dnl glpk.h.  This may eventually be useful for compiling against different
       dnl GLPK APIs...
       if (test $enableglpk = yes); then
         glpkmajor=`grep "define GLP_MAJOR_VERSION" $GLPK_INC/glpk.h | sed -e "s/#define GLP_MAJOR_VERSION[ ]*//g"`
         glpkminor=`grep "define GLP_MINOR_VERSION" $GLPK_INC/glpk.h | sed -e "s/#define GLP_MINOR_VERSION[ ]*//g"`
         glpkversion=$glpkmajor.$glpkminor
         AC_MSG_RESULT(<<< Configuring library with GLPK version $glpkversion support >>>)
       fi
  
       if (test $enableglpk = yes); then
         dnl Also Check for existence of required libraries.  This is not really the
         dnl right way to do it -- it's not portable to Macs, where .so's are called
         dnl .dylib's instead.
         dnl AC_CHECK_FILE($GLPK_LIB/glpk.so, [enableglpk=yes], [enableglpk=no])
         
         dnl AC_HAVE_LIBRARY (library, [action-if-found], [action-if-not-found], [other-libraries])
         dnl Note: Basically tries to compile a function which calls main().  
  
         dnl Save original value of LIBS, then append $GLPK_LIB
         old_LIBS="$LIBS"
         LIBS="$old_LIBS -L$GLPK_LIB"
  
         dnl Try to compile test prog to check for existence of GLPK libraries
         dnl AC_HAVE_LIBRARY uses the LIBS variable.
         AC_HAVE_LIBRARY([glpk], [enableglpk=yes], [enableglpk=no])
         
         dnl Reset $LIBS
         LIBS="$old_LIBS"
       fi
       
       dnl If both the header file and the required libs were found, continue.
       if (test $enableglpk = yes); then
         GLPK_INCLUDE="-I$GLPK_INC"
         GLPK_LIBRARY="-L$GLPK_LIB -lglpk"
	 if (test "x$RPATHFLAG" != "x" -a -d $GLPK_LIB); then # add the GLPK_LIB to the linker run path, if it is a directory
	   if (test "$GLPK_LIB" != "/usr/lib" -a "$GLPK_LIB" != "/usr/lib64"); then
	      GLPK_LIBRARY="${RPATHFLAG}${GLPK_LIB} $GLPK_LIBRARY"
	   fi				    
	 fi
         AC_DEFINE(HAVE_GLPK, 1, [Flag indicating whether the library will be compiled with GLPK support])
         AC_MSG_RESULT(<<< Configuring library with GLPK support >>>)
	 libmesh_optional_INCLUDES="$GLPK_INCLUDE $libmesh_optional_INCLUDES"
	 libmesh_optional_LIBS="$GLPK_LIBRARY $libmesh_optional_LIBS"
{'fraction_non_alphanumeric': 0.125858330321648, 'fraction_numerical': 0.0018070112034694614, 'mean_word_length': 2.404798523531221, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2215262', 'n_tokens_mistral': 3893, 'n_tokens_neox': 3688, 'n_words': 1027}