Salome HOME
Export in YACS
[modules/adao.git] / adm_local / python.m4
1 dnl  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 dnl
3 dnl  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 dnl  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 dnl
6 dnl  This library is free software; you can redistribute it and/or
7 dnl  modify it under the terms of the GNU Lesser General Public
8 dnl  License as published by the Free Software Foundation; either
9 dnl  version 2.1 of the License.
10 dnl
11 dnl  This library is distributed in the hope that it will be useful,
12 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 dnl  Lesser General Public License for more details.
15 dnl
16 dnl  You should have received a copy of the GNU Lesser General Public
17 dnl  License along with this library; if not, write to the Free Software
18 dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 dnl
20 dnl  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 dnl
22 ## ------------------------
23 ## Python file handling
24 ## From Andrew Dalke
25 ## Modified by Marc Tajchman (06/2001)
26 ## ------------------------
27
28 dnl CHECK_PYTHON([module, classes])
29 dnl
30 dnl Adds support for distributing Python modules or classes.
31 dnl Python library files distributed as a `module' are installed
32 dnl under PYTHON_SITE_PACKAGE (eg, ./python1.5/site-package/package-name)
33 dnl while those distributed as `classes' are installed under PYTHON_SITE
34 dnl (eg, ./python1.5/site-packages).  The default is to install as
35 dnl a `module'.
36
37 AC_DEFUN([CHECK_PYTHON],
38  [
39   python_ok=yes
40  
41   AC_ARG_WITH(python,
42    [AC_HELP_STRING([--with-python=DIR],[root directory path of python installation])],
43    [PYTHON="$withval/bin/python"
44     AC_MSG_RESULT("select python distribution in $withval")
45    ], [
46     AC_PATH_PROG(PYTHON, python)
47     ])
48   
49   AC_CHECKING([local Python configuration])
50
51   AC_REQUIRE([AC_LINKER_OPTIONS])dnl
52
53   PYTHON_PREFIX=`echo $PYTHON | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
54   PYTHON_PREFIX=`echo $PYTHON_PREFIX | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
55   PYTHONHOME=$PYTHON_PREFIX
56
57   AC_SUBST(PYTHON_PREFIX)
58   AC_SUBST(PYTHONHOME)
59
60   changequote(<<, >>)dnl
61   PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"`
62   changequote([, ])dnl
63   AC_SUBST(PYTHON_VERSION)
64
65   PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/Makefile
66   if test ! -f "$PY_MAKEFILE"; then
67      AC_MSG_WARN([*** Couldn't find ${PY_MAKEFILE}.  Maybe you are
68 *** missing the development portion of the python installation])
69      python_ok=no
70   fi
71
72   AC_SUBST(PYTHON_INCLUDES)
73   AC_SUBST(PYTHON_LIBS)
74
75   PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION
76   PYTHON_LIBS="-L${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
77   PYTHON_LIB=$PYTHON_LIBS
78   PYTHON_LIBA=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
79
80   dnl At times (like when building shared libraries) you may want
81   dnl to know which OS Python thinks this is.
82
83   AC_SUBST(PYTHON_PLATFORM)
84   PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
85
86   AC_SUBST(PYTHON_SITE)
87   AC_ARG_WITH(python-site,
88     [AC_HELP_STRING([--with-python-site=DIR],
89        [Use DIR for installing platform independent Python site-packages])],
90
91 dnl modification : by default, we install python script in salome root tree
92
93 dnl [PYTHON_SITE="$withval"
94 dnl python_site_given=yes],
95 dnl [PYTHON_SITE=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
96 dnl python_site_given=no]
97
98    [PYTHON_SITE="$withval"
99     python_site_given=yes],
100    [PYTHON_SITE=${prefix}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
101     python_site_given=no])
102
103   AC_SUBST(PYTHON_SITE_PACKAGE)
104   PYTHON_SITE_PACKAGE=$PYTHON_SITE/$PACKAGE
105
106
107   dnl Get PYTHON_SITE from --with-python-site-exec or from
108   dnl --with-python-site or from running Python
109
110   AC_SUBST(PYTHON_SITE_EXEC)
111   AC_ARG_WITH(python-site-exec,
112     [AC_HELP_STRING([--with-python-site-exec=DIR],
113                     [Use DIR for installing platform dependent Python site-packages])],
114     [PYTHON_SITE_EXEC="$withval"],
115     [if test "$python_site_given" = yes; then
116        PYTHON_SITE_EXEC=$PYTHON_SITE
117      else
118        PYTHON_SITE_EXEC=${PYTHON_EXEC_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
119      fi])
120
121   dnl Set up the install directory
122   ifelse($1, classes,
123 [PYTHON_SITE_INSTALL=$PYTHON_SITE],
124 [PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE])
125   AC_SUBST(PYTHON_SITE_INSTALL)
126
127   dnl Also lets automake think PYTHON means something.
128
129   pythondir=${PYTHON_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/
130   AC_SUBST(pythondir)
131
132  AC_MSG_CHECKING([if we need libdb])
133  PY_NEEDOPENDB=`nm $PYTHON_LIBA | grep dbopen | grep U`
134   if test "x$PY_NEEDOPENDB" != "x"; then
135      AC_MSG_RESULT(yes)
136      AC_CHECK_LIB(db,dbopen,PYTHON_LIBS="$PYTHON_LIBS -ldb",db_ok=no)
137   else
138      AC_MSG_RESULT(no)
139   fi
140
141  AC_MSG_CHECKING([if we need libdl])
142   PY_NEEDOPENDL=`nm $PYTHON_LIBA | grep dlopen | grep U`
143   if test "x$PY_NEEDOPENDL" != "x"; then
144      AC_MSG_RESULT(yes)
145      AC_CHECK_LIB(dl,dlopen,PYTHON_LIBS="$PYTHON_LIBS -ldl",dl_ok=no)
146   else
147      AC_MSG_RESULT(no)
148   fi
149
150  AC_MSG_CHECKING([if we need libutil])
151   PY_NEEDOPENPTY=`nm $PYTHON_LIBA | grep openpty | grep U`
152   if test "x$PY_NEEDOPENPTY" != "x"; then
153      AC_MSG_RESULT(yes)
154      AC_CHECK_LIB(util,openpty,PYTHON_LIBS="$PYTHON_LIBS -lutil",openpty_ok=no)
155   else
156      AC_MSG_RESULT(no)
157   fi
158
159  AC_MSG_CHECKING([if we need tcltk])
160   PY_NEEDTCLTK=`nm $PYTHON_LIBA | grep Tcl_Init | grep U`
161   if test "x$PY_NEEDTCLTK" != "x"; then
162      AC_MSG_RESULT(yes)
163      AC_CHECK_LIB(tcl,Tcl_Init,PYTHON_LIBS="$PYTHON_LIBS -ltcl -ltk",tclinit_ok=no)
164   else
165      AC_MSG_RESULT(no)
166   fi
167
168   if test "$python_ok" == "yes"; then
169       AC_MSG_RESULT(looks good)
170   fi
171 ])