acoracle.m4

来自「一个很好用的Linux/Unix下Oracle OCI开发接口封装库」· M4 代码 · 共 458 行 · 第 1/2 页

M4
458
字号
dnl $Id: acoracle.m4,v 1.1 2005/01/13 02:56:43 cvsroot Exp $
dnl
dnl acoracle.m4
dnl
dnl Author: Kai Poitschke <kai.poitschke@computer.org>
dnl
dnl Defines the macros:
dnl  ACX_LD_RUNPATH_SWITCH 
dnl  AM_PATH_ORACLE
dnl
dnl  ACKP_ORACLE for backward compatibility (calls AM_PATH_ORACLE)

dnl -------------------------------------------------------------------------
dnl ACX_LD_RUNPATH_SWITCH([ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
dnl Sets the variable LD_RUNPATH_SWITCH
dnl We try:
dnl -Wl,-R 
dnl -Wl,-rpath 
dnl -Wl,+s,+b
dnl If nothing works, the LD_RUNPATH_SWITCH is set to "".
dnl
AC_DEFUN(ACX_LD_RUNPATH_SWITCH, [

  if test "x$LD_RUNPATH_SWITCH" = "x"; then
    AC_CACHE_CHECK([if compiler supports -Wl,-R], ackp_cv_cc_dashr,[
    ackp_save_libs="${LIBS}"
    LIBS="-R/usr/lib ${LIBS}"
    AC_TRY_LINK([], [], ackp_cv_cc_dashr=yes, ackp_cv_cc_dashr=no)
    LIBS="${ackp_save_libs}"])
  

    if test $ackp_cv_cc_dashr = "yes"; then
        LD_RUNPATH_SWITCH="-Wl,-R"
    else
        AC_CACHE_CHECK([if compiler supports -Wl,-rpath,], ackp_cv_cc_rpath,[
                ackp_save_libs="${LIBS}"
                LIBS="-Wl,-rpath,/usr/lib ${LIBS}"
                AC_TRY_LINK([], [], ackp_cv_cc_rpath=yes, ackp_cv_cc_rpath=no)
                LIBS="${ackp_save_libs}"])
        if test $ackp_cv_cc_rpath = "yes"; then
            LD_RUNPATH_SWITCH="-Wl,-rpath,"
        else
            AC_CACHE_CHECK([if compiler supports -Wl,+s,+b,], ackp_cv_cc_plusb,[
                ackp_save_libs="${LIBS}"
                LIBS="-Wl,+s,+b,/usr/lib ${LIBS}"
                AC_TRY_LINK([], [], ackp_cv_cc_plusb=yes, ackp_cv_cc_plusb=no)
                LIBS="${ackp_save_libs}"])

            if test $ackp_cv_cc_plusb = "yes" ; then
                LD_RUNPATH_SWITCH="-Wl,+s,+b,"
            else
                LD_RUNPATH_SWITCH=""
            fi
        fi
    fi
  fi
  if test "x$LD_RUNPATH_SWITCH" != "x"; then
      # action-if-found
      ifelse([$1], , :, [$1])
  else
      # action-if-not-found
      ifelse([$2], , :, [$2])
  fi
])


dnl -------------------------------------------------------------------------
dnl ACX_ORACLE_VERSION([MINIMUM-VERSION [,ORACLE_HOME] [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
dnl Tries to find out which oracle version is installed
dnl Returns the version in $ORACLE_VERSION
dnl Substitutes ORACLE_VERSION
dnl
AC_DEFUN(ACX_ORACLE_VERSION, [

AC_ARG_ENABLE(oraversion, 
  AC_HELP_STRING([--disable-oraversion], [Do not check for the minimum oracle version]),
  [], [enable_oraversion=yes])

  ora_min_version=$1

  AC_CACHE_CHECK([Oracle version >= $ora_min_version], ackp_cv_oracle_version, [

  acx_orahome=ifelse([$2], , $ORACLE_HOME, $2)

  export acx_orahome
  ackp_cv_oracle_version=""

  if test -f "$acx_orahome/bin/svrmgrl" ; then
    ackp_cv_oracle_version=`$acx_orahome/bin/svrmgrl command=exit |\
                egrep '(PL/SQL|JServer) (Release|Version)' |\
                sed 's/  */:/g' | cut -d: -f3 | cut -c 1-7`
  else
    if test -f "$acx_orahome/bin/sqlplus" ; then
       # Oracle 8i knows sqlplus -?
       # and Oracle 9i knows only sqlplus -v 
       # Cannot use the return code, have to parse the output
       n=`$acx_orahome/bin/sqlplus -? | grep -i -c Usage`
       if test $n -eq 0 ; then
         sqlplus_opt="-?"
       else
         sqlplus_opt="-v"
       fi
       ackp_cv_oracle_version=`$acx_orahome/bin/sqlplus $sqlplus_opt |\
                      egrep '(Release|Version)' |\
                      sed 's/  */:/g' | cut -d: -f4 | cut -c 1-7`
    fi
  fi

  unset acx_orahome
  unset sqlplus_opt
  ])
  ORACLE_VERSION=$ackp_cv_oracle_version
  AC_SUBST(ORACLE_VERSION)

  if test "x$ORACLE_VERSION" != "x"; then
      if test "x$enable_oraversion" = "xyes" ; then
          # split the minumum
          ora_min_major=`echo $ora_min_version. | cut -d. -f1`
          test -z "$ora_min_major" && ora_min_major=0
          ora_min_minor=`echo $ora_min_version. | cut -d. -f2`
          test -z "$ora_min_minor" && ora_min_minor=0
          ora_min_micro=`echo $ora_min_version. | cut -d. -f3`
          test -z "$ora_min_micro" && ora_min_micro=0
          ora_min_patchl=`echo $ora_min_version. | cut -d. -f4`
          test -z "$ora_min_patchl" && ora_min_patchl=0

          #split the detected version
          ora_major=`echo $ORACLE_VERSION | cut -d. -f1`
          test -z "$ora_major" && ora_major=0
          ora_minor=`echo $ORACLE_VERSION | cut -d. -f2`
          test -z "$ora_minor" && ora_minor=0
          ora_micro=`echo $ORACLE_VERSION | cut -d. -f3`
          test -z "$ora_micro" && ora_micro=0
          ora_patchl=`echo $ORACLE_VERSION | cut -d. -f4`
          test -z "$ora_patchl" && ora_patchl=0

          if test \( \( $ora_major -gt $ora_min_major \) -o \
                \( \( $ora_major -eq $ora_min_major \) -a \( $ora_minor -gt $ora_min_minor \) \) -o \
                \( \( $ora_major -eq $ora_min_major \) -a \( $ora_minor -eq $ora_min_minor \) -a \( $ora_micro -gt $ora_min_micro \) \) -o \
                \( \( $ora_major -eq $ora_min_major \) -a \( $ora_minor -eq $ora_min_minor \) -a \( $ora_micro -eq $ora_min_micro \) -a \( $ora_patchl -ge $ora_min_patchl \) \) \) ; then
              # this is the minumum required version
              # action-if-found
              ifelse([$3], , :, [$3]) 
          else
              echo "*** Sorry your Oracle version is not sufficient"
              # action-if-not-found
              ifelse([$4], , :, [$4])
          fi
      else
         # ignore version check. Do action-if-found
         ifelse([$3],,:,[$3])
      fi  
  else
      echo "*** Could not detect your oracle version"
      # action-if-not-found
      ifelse([$4], , :, [$4])
  fi

])

dnl-------------------------------------------------------------------------
dnl AM_PATH_ORACLE([MINIMUM-VERSION [, ORACLE_HOME [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
dnl Sets all variables to support oracle
dnl Sets $ORACLE_SHLIBS, $ORACLE_STLIBS, $ORACLE_LDFLAGS
dnl $ORACLE_CPPFLAGS, $ORACLE_HOME, $ORACLE_VERSION (vial ACKP_ORACLE_VERSION)
dnl and $ORACLE_LIBDIR
dnl
dnl Requires macro ACX_LD_RUNPATH_SWITH
dnl
AC_DEFUN(AM_PATH_ORACLE, [
AC_ARG_WITH(oracle,
  AC_HELP_STRING([--with-oraclehome[=DIR]], [DIR is Oracle's home directory, defaults to \$ORACLE_HOME.]),
[ORACLEINST_TOP=$withval], 
[ORACLEINST_TOP=ifelse([$2], , $ORACLE_HOME, [$2], yes, $ORACLE_HOME, [$1])])

  NLS_LANG="American_America.WE8ISO8859P1"
  export NLS_LANG

  if test "$ORACLEINST_TOP" != ""
  then

    ACX_ORACLE_VERSION([$1], $ORACLEINST_TOP, [

    # Oracle include files
    if test -f "$ORACLEINST_TOP/rdbms/public/ocidfn.h"
    then
      # V8.0.5
      ORACLE_CPPFLAGS="-I$ORACLEINST_TOP/rdbms/public"
    elif test -f "$ORACLEINST_TOP/rdbms/demo/ocidfn.h" ; then
      # V7.[0123]
      ORACLE_CPPFLAGS="-I$ORACLEINST_TOP/rdbms/demo"
    fi

    if test -d "$ORACLEINST_TOP/network/public"
    then
      # V8
      ORACLE_CPPFLAGS="$ORACLE_CPPFLAGS -I$ORACLEINST_TOP/network/public"
    fi

    if test -d "$ORACLEINST_TOP/plsql/public"
    then
      # V8
      ORACLE_CPPFLAGS="$ORACLE_CPPFLAGS -I$ORACLEINST_TOP/plsql/public"
    fi

    if test -d "$ORACLEINST_TOP/rdbms/public"
    then
      # V8
      ORACLE_CPPFLAGS="$ORACLE_CPPFLAGS -I$ORACLEINST_TOP/rdbms/public"
    fi

    # Oracle libs - nightmare :-)
    if test -r $ORACLEINST_TOP/lib32
    then
       # for Solaris9
       ORACLE_LIBDIR=$ORACLEINST_TOP/lib32
    else
       ORACLE_LIBDIR=$ORACLEINST_TOP/lib
    fi

    ACX_LD_RUNPATH_SWITCH([
      ORACLE_LDFLAGS="-L$ORACLE_LIBDIR ${LD_RUNPATH_SWITCH}$ORACLE_LIBDIR"
    ], [ ORACLE_LDFLAGS="-L$ORACLE_LIBDIR" ])


    if test -f "$ORACLE_LIBDIR/sysliblist"
    then
      ORA_SYSLIB="`cat $ORACLE_LIBDIR/sysliblist`"
    else

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?