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