Salome HOME
updated copyright message
[modules/yacs.git] / src / wrappergen / bin / Cpp_Template__SRC / adm / 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   AC_ARG_WITH(python,
38    [  --with-python=DIR root directory path of python installation ],
39    [PYTHON="$withval/bin/python"
40     AC_MSG_RESULT("select python distribution in $withval")
41    ], [
42     AC_PATH_PROG(PYTHON, python)
43     ])
44   
45   AC_CHECKING([local Python configuration])
46   PYTHON_PREFIX=`echo $PYTHON | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
47   PYTHON_PREFIX=`echo $PYTHON_PREFIX | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
48   PYTHONHOME=$PYTHON_PREFIX
49
50   AC_SUBST(PYTHON_PREFIX)
51   AC_SUBST(PYTHONHOME)
52
53   changequote(<<, >>)dnl
54   PYTHON_VERSION=`$PYTHON -c "import sys; print(sys.version[:3])"`
55   changequote([, ])dnl
56   AC_SUBST(PYTHON_VERSION)
57
58   PY_MAKEFILE=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/config/Makefile
59   if test ! -f "$PY_MAKEFILE"; then
60      AC_MSG_ERROR([*** Couldn't find ${PY_MAKEFILE}.  Maybe you are
61 *** missing the development portion of the python installation])
62   fi
63
64   AC_SUBST(PYTHON_INCLUDES)
65   AC_SUBST(PYTHON_LIBS)
66
67   PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION
68   PYTHON_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
69   PYTHON_LIB=$PYTHON_LIBS
70   PYTHON_LIBA=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
71
72   dnl At times (like when building shared libraries) you may want
73   dnl to know which OS Python thinks this is.
74
75   AC_SUBST(PYTHON_PLATFORM)
76   PYTHON_PLATFORM=`$PYTHON -c "import sys; print(sys.platform)"`
77
78   AC_SUBST(PYTHON_SITE)
79   AC_ARG_WITH(python-site,
80 [  --with-python-site=DIR          Use DIR for installing platform independent
81                                   Python site-packages],
82
83 dnl modification : by default, we install python script in salome root tree
84
85 dnl [PYTHON_SITE="$withval"
86 dnl python_site_given=yes],
87 dnl [PYTHON_SITE=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
88 dnl python_site_given=no])
89
90 [PYTHON_SITE="$withval"
91 python_site_given=yes],
92 [PYTHON_SITE=$prefix"/lib/python"$PYTHON_VERSION/site-packages
93 python_site_given=no])
94
95   AC_SUBST(PYTHON_SITE_PACKAGE)
96   PYTHON_SITE_PACKAGE=$PYTHON_SITE/$PACKAGE
97
98
99   dnl Get PYTHON_SITE from --with-python-site-exec or from
100   dnl --with-python-site or from running Python
101
102   AC_SUBST(PYTHON_SITE_EXEC)
103   AC_ARG_WITH(python-site-exec,
104 [  --with-python-site-exec=DIR     Use DIR for installing platform dependent
105                                   Python site-packages],
106 [PYTHON_SITE_EXEC="$withval"],
107 [if test "$python_site_given" = yes; then
108   PYTHON_SITE_EXEC=$PYTHON_SITE
109 else
110   PYTHON_SITE_EXEC=$PYTHON_EXEC_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
111 fi])
112
113   dnl Set up the install directory
114   ifelse($1, classes,
115 [PYTHON_SITE_INSTALL=$PYTHON_SITE],
116 [PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE])
117   AC_SUBST(PYTHON_SITE_INSTALL)
118
119   dnl Also lets automake think PYTHON means something.
120
121   pythondir=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/
122   AC_SUBST(pythondir)
123
124  AC_MSG_CHECKING([if we need libdb])
125  PY_NEEDOPENDB=`nm $PYTHON_LIBA | grep dbopen | grep U`
126   if test "x$PY_NEEDOPENDB" != "x"; then
127      PYTHON_LIBS="$PYTHON_LIBS -ldb"
128      AC_MSG_RESULT(yes)
129   else
130      AC_MSG_RESULT(no)
131   fi
132
133  AC_MSG_CHECKING([if we need libdl])
134   PY_NEEDOPENDL=`nm $PYTHON_LIBA | grep dlopen | grep U`
135   if test "x$PY_NEEDOPENDL" != "x"; then
136      PYTHON_LIBS="$PYTHON_LIBS -ldl"
137      AC_MSG_RESULT(yes)
138   else
139      AC_MSG_RESULT(no)
140   fi
141
142  AC_MSG_CHECKING([if we need libutil])
143   PY_NEEDOPENPTY=`nm $PYTHON_LIBA | grep openpty | grep U`
144   if test "x$PY_NEEDOPENPTY" != "x"; then
145      PYTHON_LIBS="$PYTHON_LIBS -lutil"
146      AC_MSG_RESULT(yes)
147   else
148      AC_MSG_RESULT(no)
149   fi
150
151  AC_MSG_CHECKING([if we need tcltk])
152   PY_NEEDTCLTK=`nm $PYTHON_LIBA | grep Tcl_Init | grep U`
153   if test "x$PY_NEEDTCLTK" != "x"; then
154      PYTHON_LIBS="$PYTHON_LIBS -ltcl -ltk"
155      AC_MSG_RESULT(yes)
156   else
157      AC_MSG_RESULT(no)
158   fi
159
160   python_ok=yes
161   AC_MSG_RESULT(looks good)])