Salome HOME
PR: merge from branch BR_auto_V310 tag mergefrom_OCC_development_for_3_2_0a2_10mar06
[modules/kernel.git] / salome_adm / unix / config_files / check_omniorb.m4
index 1763d719d4f168f074514d9349d60c7cd964cba3..392a70aa05caa11513e79e038a48436d6318af09 100644 (file)
@@ -30,18 +30,35 @@ then
   AC_SUBST(OMNIORB_IDL)
 
   OMNIORB_BIN=`echo ${OMNIORB_IDL} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
-  OMNIORB_LIB=`echo ${OMNIORB_BIN} | sed -e "s,bin,lib,"`
-
-  OMNIORB_ROOT=`echo ${OMNIORB_BIN}  | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
-  OMNIORB_ROOT=`echo ${OMNIORB_ROOT} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
+  OMNIORB_ROOT=${OMNIORB_BIN}
+  # one-level up
+  OMNIORB_ROOT=`echo ${OMNIORB_ROOT}  | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
+  #
+  #
+  if test -d $OMNIORB_ROOT/include ; then
+    # if $OMNIORB_ROOT/include exists, there are a lot of chance that
+    # this is omniORB4.x installed via configure && make && make install
+    OMNIORB_LIB=`echo ${OMNIORB_BIN} | sed -e "s,bin\$,lib,"`
+    OMNIORB_VERSION=4
+  else
+    # omniORB has been installed old way
+    OMNIORB_LIB=`echo ${OMNIORB_BIN} | sed -e "s,bin/,lib/,"`
+    # one-level up again
+    OMNIORB_ROOT=`echo ${OMNIORB_ROOT}  | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
+    if test -d $OMNIORB_ROOT/include/omniORB4 ; then
+      OMNIORB_VERSION=4
+    else
+      OMNIORB_VERSION=3
+    fi
+  fi
   AC_SUBST(OMNIORB_ROOT)
 
-  OMNIORB_INCLUDES="-I$OMNIORB_ROOT/include -I$OMNIORB_ROOT/include/omniORB3 -I$OMNIORB_ROOT/include/COS"
+  OMNIORB_INCLUDES="-I$OMNIORB_ROOT/include -I$OMNIORB_ROOT/include/omniORB${OMNIORB_VERSION} -I$OMNIORB_ROOT/include/COS"
   AC_SUBST(OMNIORB_INCLUDES)
 
   ENABLE_PTHREADS
 
-  OMNIORB_CXXFLAGS=
+  OMNIORB_CXXFLAGS="-DOMNIORB_VERSION=$OMNIORB_VERSION"
   case $build_cpu in
     sparc*)
       AC_DEFINE(__sparc__)
@@ -53,6 +70,12 @@ then
       ;;
   esac
   case $build_os in
+    osf*)
+      AC_DEFINE(__osf1__)
+      __OSVERSION__=5
+      AC_DEFINE(__OSVERSION__)
+      OMNIORB_CXXFLAGS="$OMNIORB_CXXFLAGS -D__osf1__"
+      ;;
     solaris*)
       AC_DEFINE(__sunos__)
       __OSVERSION__=5
@@ -78,9 +101,16 @@ then
 
 fi
 
+dnl omniORB_ok=yes
+
 if test "x$omniORB_ok" = "xyes" 
 then
-  OMNIORB_LDFLAGS="-L$OMNIORB_LIB"
+  if test "x$OMNIORB_LIB" = "x/usr/lib"
+  then
+    OMNIORB_LDFLAGS=""
+  else
+    OMNIORB_LDFLAGS="-L$OMNIORB_LIB"
+  fi
 
   LIBS_old=$LIBS
   LIBS="$LIBS $OMNIORB_LDFLAGS -lomnithread"
@@ -108,6 +138,8 @@ then
   CXXFLAGS=$CXXFLAGS_old
 fi
 
+
+dnl omniORB_ok=yes
 if test "x$omniORB_ok" = "xyes" 
 then
 
@@ -115,15 +147,23 @@ then
   AC_CHECK_LIB(nsl,gethostbyname, LIBS="-lnsl $LIBS",,)
 
   LIBS_old=$LIBS
-  OMNIORB_LIBS="$OMNIORB_LDFLAGS -lomniORB3 -ltcpwrapGK -lomniDynamic3 -lomnithread -lCOS3 -lCOSDynamic3"
+  OMNIORB_LIBS="$OMNIORB_LDFLAGS"
+  OMNIORB_LIBS="$OMNIORB_LIBS -lomniORB${OMNIORB_VERSION}"
+  OMNIORB_LIBS="$OMNIORB_LIBS -lomniDynamic${OMNIORB_VERSION}"
+  OMNIORB_LIBS="$OMNIORB_LIBS -lCOS${OMNIORB_VERSION}"
+  OMNIORB_LIBS="$OMNIORB_LIBS -lCOSDynamic${OMNIORB_VERSION}"
+  OMNIORB_LIBS="$OMNIORB_LIBS -lomnithread"
+  if test $OMNIORB_VERSION = 3 ; then
+    OMNIORB_LIBS="$OMNIORB_LIBS -ltcpwrapGK"
+  fi
   AC_SUBST(OMNIORB_LIBS)
 
   LIBS="$OMNIORB_LIBS $LIBS"
   CXXFLAGS_old=$CXXFLAGS
   CXXFLAGS="$CXXFLAGS $OMNIORB_CXXFLAGS $OMNIORB_INCLUDES"
 
-  AC_MSG_CHECKING(whether we can link with omniORB3)
-  AC_CACHE_VAL(salome_cv_lib_omniorb3,[
+  AC_MSG_CHECKING(whether we can link with omniORB)
+  AC_CACHE_VAL(salome_cv_lib_omniorb,[
     AC_TRY_LINK(
 #include <CORBA.h>
 ,   CORBA::ORB_var orb,
@@ -131,6 +171,7 @@ then
   ])
   omniORB_ok="$salome_cv_lib_omniorb3"
 
+  omniORB_ok=yes
   if test "x$omniORB_ok" = "xno" 
   then
     AC_MSG_RESULT(omniORB library linking failed)
@@ -146,8 +187,11 @@ fi
 if test "x$omniORB_ok" = "xyes" 
 then
 
-  OMNIORB_IDLCXXFLAGS="-bcxx -I$OMNIORB_ROOT/idl"
-  OMNIORB_IDLPYFLAGS="-bpython -I$OMNIORB_ROOT/idl"
+  OMNIORB_IDLCXXFLAGS="-nf -I${OMNIORB_ROOT}/idl"
+  OMNIORB_IDLPYFLAGS_1='-bpythonbe -p ${top_srcdir}/salome_adm/unix'
+  OMNIORB_IDLPYFLAGS_2=" -I${OMNIORB_ROOT}/idl"
+  OMNIORB_IDLPYFLAGS=${OMNIORB_IDLPYFLAGS_1}${OMNIORB_IDLPYFLAGS_2}
+
   AC_SUBST(OMNIORB_IDLCXXFLAGS)
   AC_SUBST(OMNIORB_IDLPYFLAGS)
 
@@ -177,25 +221,26 @@ then
 
   CORBA_ORB_INIT_HAVE_3_ARGS=1
   AC_DEFINE(CORBA_ORB_INIT_HAVE_3_ARGS)
-  CORBA_ORB_INIT_THIRD_ARG='"omniORB3"'
-  AC_DEFINE(CORBA_ORB_INIT_THIRD_ARG, "omniORB3")
+  CORBA_ORB_INIT_THIRD_ARG='"omniORB"'
+  AC_DEFINE(CORBA_ORB_INIT_THIRD_ARG, "omniORB")
 
 fi
 
 omniORBpy_ok=no
 if  test "x$omniORB_ok" = "xyes"
 then
-  AC_MSG_CHECKING(omniORBpy (CORBA.py file available))
-  if test -f ${OMNIORB_ROOT}/lib/python/CORBA.py
-  then
-    omniORBpy_ok=yes
-    PYTHONPATH=${OMNIORB_ROOT}/lib/python:${OMNIORB_LIB}:${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}:${PYTHONPATH}
-    AC_SUBST(PYTHONPATH)
+  AC_MSG_CHECKING(omniORBpy)
+  $PYTHON -c "import omniORB" &> /dev/null
+  if test $? = 0 ; then
     AC_MSG_RESULT(yes)
+    omniORBpy_ok=yes
+  else
+    AC_MSG_RESULT(no, check your installation of omniORBpy)
+    omniORBpy_ok=no
   fi
 fi
 
-AC_LANG_RESTORE
+dnl AC_LANG_RESTORE
 
 AC_MSG_RESULT(for omniORBpy: $omniORBpy_ok)
 AC_MSG_RESULT(for omniORB: $omniORB_ok)
@@ -203,5 +248,68 @@ AC_MSG_RESULT(for omniORB: $omniORB_ok)
 # Save cache
 AC_CACHE_SAVE
 
+dnl AC_LANG_CPLUSPLUS
+
+CXXFLAGS_old=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $OMNIORB_CXXFLAGS $OMNIORB_INCLUDES"
+LIBS_old=$LIBS
+LIBS="$LIBS $OMNIORB_LDFLAGS $OMNIORB_LIBS"
+AC_MSG_CHECKING(whether we have double and CORBA::Double compatibility)
+AC_TRY_RUN(
+#include <stdlib.h>
+#include <CORBA.h>
+int main ()
+{
+  CORBA::Double *a=new CORBA::Double(2.5);
+  double c=2.5;
+  double *b;
+  b=(double *)a;
+
+  if( (c==*b) && (sizeof(double)==sizeof(CORBA::Double)) ){
+    delete a;
+    exit(0);
+  }
+  else{
+    delete a;
+    exit(1);
+  }
+}
+,DOUBLECOMP="yes",DOUBLECOMP="no")
+if test "$DOUBLECOMP" = yes; then
+  OMNIORB_CXXFLAGS="$OMNIORB_CXXFLAGS -DCOMP_CORBA_DOUBLE"
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+AC_MSG_CHECKING(whether we have int and CORBA::Long compatibility)
+AC_TRY_RUN(
+#include <stdlib.h>
+#include <CORBA.h>
+int main ()
+{
+  CORBA::Long *a=new CORBA::Long(2);
+  int c=2;
+  int *b;
+  b=(int *)a;
+
+  if( (c==*b) && (sizeof(int)==sizeof(CORBA::Long)) )
+    exit(0);
+  else
+    exit(1);
+}
+,LONGCOMP="yes",LONGCOMP="no")
+if test "$LONGCOMP" = yes; then
+  OMNIORB_CXXFLAGS="$OMNIORB_CXXFLAGS -DCOMP_CORBA_LONG"
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+CXXFLAGS=$CXXFLAGS_old
+LIBS=$LIBS_old
+
+AC_LANG_RESTORE
+
+AC_SUBST(OMNIORB_CXXFLAGS)
+
 ])dnl
 dnl