summaryrefslogtreecommitdiff
path: root/ext/oci8/config.m4
blob: b1b4d2f1723a5dd419e115b0b175298b028311d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
dnl $Id$

AC_DEFUN(AC_ORACLE_VERSION,[
  AC_MSG_CHECKING([Oracle version])
  if test -f "$ORACLEINST_TOP/orainst/unix.rgs"
  then
	changequote({,})
	ORACLE_VERSION=`grep '"ocommon"' $ORACLEINST_TOP/orainst/unix.rgs | sed 's/[ ][ ]*/:/g' | cut -d: -f 6 | cut -c 2-4`
	changequote([,])
    test -z "$ORACLE_VERSION" && ORACLE_VERSION=7.3
  else
    if test -f "$ORACLEINST_TOP/lib/libclntsh.so.8.0"
    then
	ORACLE_VERSION=8.1
    else
	ORACLE_VERSION=8.0
    fi
  fi
  AC_MSG_RESULT($ORACLE_VERSION)
])

AC_MSG_CHECKING(for Oracle-OCI8 support)
AC_ARG_WITH(oci8,
[  --with-oci8[=DIR]       Include Oracle database support.  DIR is Oracle's
                          home directory, defaults to \$ORACLE_HOME.],
[
 case "$withval" in
    yes)
      ORACLEINST_TOP=$ORACLE_HOME
      AC_MSG_RESULT(yes)
      PHP_EXTENSION(oci8)
      ;;
    no)
      ORACLEINST_TOP=
      AC_MSG_RESULT(no)
      ;;
    *)
      ORACLEINST_TOP=$withval
      AC_MSG_RESULT(yes)
      PHP_EXTENSION(oci8)
      ;;
  esac

  if test "$ORACLEINST_TOP" != ""
  then

    # Oracle include files

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

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

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

    # Need to know the version, otherwhise we will mixup nlsrtl
    AC_ORACLE_VERSION($ORACLEINST_TOP)

    # Oracle libs - nightmare :-)

    ORACLE_LIBDIR=lib
    ORACLE_LFLAGS="-L$ORACLEINST_TOP/$ORACLE_LIBDIR ${ld_runpath_switch}$ORACLEINST_TOP/$ORACLE_LIBDIR"
    if test -f "$ORACLEINST_TOP/rdbms/lib/sysliblist"
    then
      ORA_SYSLIB="`cat $ORACLEINST_TOP/rdbms/lib/sysliblist`"
    else
      ORA_SYSLIB="-lm"
    fi

    # Oracle Static libs
    case $ORACLE_VERSION in
      7.0|7.1)
  	ORACLE_STLIBS="-locic $ORACLEINST_TOP/$ORACLE_LIBDIR/osntab.o \
            -lsqlnet -lora -lsqlnet -lnlsrtl -lcv6 -lcore -lnlsrtl -lcv6 \
            -lcore $ORA_SYSLIB -lcore $ORA_SYSLIB"
    if test "`uname -s 2>/dev/null`" = "AIX"; then
      ORACLE_STLIBS="$ORACLE_STLIBS -bI:$ORACLE_HOME/lib/mili.exp"
    fi
  	;;
      7.2)
  	ORACLE_STLIBS="-locic $ORACLEINST_TOP/$ORACLE_LIBDIR/osntab.o \
            -lsqlnet -lora -lsqlnet -lora -lnlsrtl3 -lc3v6 -lcore3 -lnlsrtl3 \
            -lcore3 $ORA_SYSLIB -lcore3 $ORA_SYSLIB"
  	;;
      7.3)
  	ORACLE_STLIBS="-lclient -lsqlnet -lncr -lsqlnet -lclient -lcommon \
  	    -lgeneric -lsqlnet -lncr -lsqlnet -lclient -lcommon -lgeneric \
            -lepc -lnlsrtl3 -lc3v6 -lcore3 -lnlsrtl3 -lcore3 -lnlsrtl3 \
            $ORA_SYSLIB -lcore3 $ORA_SYSLIB"
  	;;
      8.0)
  	ORACLE_STLIBS="-lclient -lsqlnet -lncr -lsqlnet -lclient -lcommon \
  	    -lgeneric -lsqlnet -lncr -lsqlnet -lclient -lcommon -lgeneric \
            -lepc -lnlsrtl3 -lc3v6 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 \
            $ORA_SYSLIB -lcore3 $ORA_SYSLIB"
	;;
      *)
  	ORACLE_STLIBS=
  	;;
    esac
  
    # Oracle shared libs
    case $ORACLE_VERSION in
      7.0)
  	# shared libs not supported
  	ORACLE_SHLIBS="$ORACLE_STLIBS"
  	;;
      7.1)
  	if test -f $ORACLEINST_TOP/$ORACLE_LIBDIR/liboracle.s?
  	then
  	  ORACLE_SHLIBS="-loracle $ORA_SYSLIB"
  	else
  	  ORACLE_SHLIBS="$ORACLE_STLIBS"
  	fi
  	;;
      7.2|7.3)
    	if test -f $ORACLEINST_TOP/$ORACLE_LIBDIR/libclntsh.s?
    	then
    	  ORACLE_SHLIBS="-lclntsh $ORA_SYSLIB"
    	else
    	  ORACLE_SHLIBS="$ORACLE_STLIBS"
    	fi
    	;;
      8.0)
	if test -f $ORACLEINST_TOP/$ORACLE_LIBDIR/libclntsh.s? -o \
	        -f $ORACLEINST_TOP/$ORACLE_LIBDIR/libclntsh.a # AIX
    	then
	  if test "$CC" = "gcc" -a "`uname -sv`" = "AIX 4"; then
	    # for Oracle 8 on AIX 4
	    ORA_SYSLIB="$ORA_SYSLIB -nostdlib /lib/crt0_r.o /usr/lib/libpthreads.a /usr/lib/libc_r.a -lgcc"
	  fi
    	  ORACLE_SHLIBS="-lclntsh -lpsa -lcore4 -lnlsrtl3 -lclntsh $ORA_SYSLIB"
    	else
    	  ORACLE_SHLIBS="$ORACLE_STLIBS"
    	fi
        AC_DEFINE(HAVE_OCI8)
    	;;
      8.1)
	ORACLE_SHLIBS="-lclntsh $ORA_SYSLIB"
	AC_DEFINE(HAVE_OCI8)
	;;
      *)
  	ORACLE_SHLIBS=
  	;;
    esac
  
    # only using shared libs right now
    ORACLE_LIBS=$ORACLE_SHLIBS

    AC_DEFINE(HAVE_ORACLE)

  fi

],[AC_MSG_RESULT(no)])
#EXTRA_LIBS="$EXTRA_LIBS $ORACLE_SHLIBS $ORACLE_STLIBS $ORACLE_LIBS $ORACLE_LFLAGS"
EXTRA_LIBS="$EXTRA_LIBS $ORACLE_LFLAGS $ORACLE_LIBS"
INCLUDES="$INCLUDES $ORACLE_INCLUDE"
AC_SUBST(ORACLE_HOME)
AC_SUBST(ORACLE_VERSION)