Salome HOME
rename SALOME_* options as MEDTOOL_*
[modules/med.git] / adm_local_without_kernel / unix / config_files / python.m4
1 dnl Copyright (C) 2007-2015  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, or (at your option) any later version.
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 ## ------------------------
24 ## Python file handling
25 ## From Andrew Dalke
26 ## Modified by Marc Tajchman (06/2001)
27 ## ------------------------
28
29 dnl CHECK_PYTHON([module, classes])
30 dnl
31 dnl Adds support for distributing Python modules or classes.
32 dnl Python library files distributed as a `module' are installed
33 dnl under PYTHON_SITE_PACKAGE (eg, ./python1.5/site-package/package-name)
34 dnl while those distributed as `classes' are installed under PYTHON_SITE
35 dnl (eg, ./python1.5/site-packages).  The default is to install as
36 dnl a `module'.
37
38 AC_DEFUN([CHECK_PYTHON],
39  [
40   python_ok=yes
41  
42   AC_ARG_WITH(python,
43    [AC_HELP_STRING([--with-python=DIR],[root directory path of python installation])],
44    [PYTHON="$withval/bin/python"
45     AC_MSG_RESULT("select python distribution in $withval")
46    ], [
47     AC_PATH_PROG(PYTHON, python)
48     ])
49   
50   AC_CHECKING([local Python configuration])
51
52   AC_REQUIRE([AC_LINKER_OPTIONS])dnl
53
54   PYTHON_PREFIX=`echo $PYTHON | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
55   PYTHON_PREFIX=`echo $PYTHON_PREFIX | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
56   PYTHONHOME=$PYTHON_PREFIX
57
58   AC_SUBST(PYTHON_PREFIX)
59   AC_SUBST(PYTHONHOME)
60
61   changequote(<<, >>)dnl
62   PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"`
63   changequote([, ])dnl
64   AC_SUBST(PYTHON_VERSION)
65
66   PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/Makefile
67   if test ! -f "$PY_MAKEFILE"; then
68      AC_MSG_WARN([*** Couldn't find ${PY_MAKEFILE}.  Maybe you are
69 *** missing the development portion of the python installation])
70      python_ok=no
71   fi
72
73   AC_SUBST(PYTHON_INCLUDES)
74   AC_SUBST(PYTHON_LIBS)
75
76   PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION
77   PYTHON_LIBS="-L${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
78   PYTHON_LIB=$PYTHON_LIBS
79   PYTHON_LIBA=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
80
81   dnl At times (like when building shared libraries) you may want
82   dnl to know which OS Python thinks this is.
83
84   AC_SUBST(PYTHON_PLATFORM)
85   PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
86
87   AC_SUBST(PYTHON_SITE)
88   AC_ARG_WITH(python-site,
89     [AC_HELP_STRING([--with-python-site=DIR],
90        [Use DIR for installing platform independent Python site-packages])],
91
92 dnl modification : by default, we install python script in salome root tree
93
94 dnl [PYTHON_SITE="$withval"
95 dnl python_site_given=yes],
96 dnl [PYTHON_SITE=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
97 dnl python_site_given=no]
98
99    [PYTHON_SITE="$withval"
100     python_site_given=yes],
101    [PYTHON_SITE=${prefix}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
102     python_site_given=no])
103
104   AC_SUBST(PYTHON_SITE_PACKAGE)
105   PYTHON_SITE_PACKAGE=$PYTHON_SITE/$PACKAGE
106
107
108   dnl Get PYTHON_SITE from --with-python-site-exec or from
109   dnl --with-python-site or from running Python
110
111   AC_SUBST(PYTHON_SITE_EXEC)
112   AC_ARG_WITH(python-site-exec,
113     [AC_HELP_STRING([--with-python-site-exec=DIR],
114                     [Use DIR for installing platform dependent Python site-packages])],
115     [PYTHON_SITE_EXEC="$withval"],
116     [if test "$python_site_given" = yes; then
117        PYTHON_SITE_EXEC=$PYTHON_SITE
118      else
119        PYTHON_SITE_EXEC=${PYTHON_EXEC_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
120      fi])
121
122   dnl Set up the install directory
123   ifelse($1, classes,
124 [PYTHON_SITE_INSTALL=$PYTHON_SITE],
125 [PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE])
126   AC_SUBST(PYTHON_SITE_INSTALL)
127
128   dnl Also lets automake think PYTHON means something.
129
130   pythondir=${PYTHON_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/
131   AC_SUBST(pythondir)
132
133  AC_MSG_CHECKING([if we need libdb])
134  PY_NEEDOPENDB=`nm $PYTHON_LIBA | grep dbopen | grep U`
135   if test "x$PY_NEEDOPENDB" != "x"; then
136      AC_MSG_RESULT(yes)
137      AC_CHECK_LIB(db,dbopen,PYTHON_LIBS="$PYTHON_LIBS -ldb",db_ok=no)
138   else
139      AC_MSG_RESULT(no)
140   fi
141
142  AC_MSG_CHECKING([if we need libdl])
143   PY_NEEDOPENDL=`nm $PYTHON_LIBA | grep dlopen | grep U`
144   if test "x$PY_NEEDOPENDL" != "x"; then
145      AC_MSG_RESULT(yes)
146      AC_CHECK_LIB(dl,dlopen,PYTHON_LIBS="$PYTHON_LIBS -ldl",dl_ok=no)
147   else
148      AC_MSG_RESULT(no)
149   fi
150
151  AC_MSG_CHECKING([if we need libutil])
152   PY_NEEDOPENPTY=`nm $PYTHON_LIBA | grep openpty | grep U`
153   if test "x$PY_NEEDOPENPTY" != "x"; then
154      AC_MSG_RESULT(yes)
155      AC_CHECK_LIB(util,openpty,PYTHON_LIBS="$PYTHON_LIBS -lutil",openpty_ok=no)
156   else
157      AC_MSG_RESULT(no)
158   fi
159
160  AC_MSG_CHECKING([if we need tcltk])
161   PY_NEEDTCLTK=`nm $PYTHON_LIBA | grep Tcl_Init | grep U`
162   if test "x$PY_NEEDTCLTK" != "x"; then
163      AC_MSG_RESULT(yes)
164      AC_CHECK_LIB(tcl,Tcl_Init,PYTHON_LIBS="$PYTHON_LIBS -ltcl -ltk",tclinit_ok=no)
165   else
166      AC_MSG_RESULT(no)
167   fi
168
169   if test "$python_ok" == "yes"; then
170       AC_MSG_RESULT(looks good)
171   fi
172 ])