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