]> SALOME platform Git repositories - tools/configuration.git/blob - autotools/m4/python.m4
Salome HOME
Merge branch 'V9_9_BR'
[tools/configuration.git] / autotools / m4 / python.m4
1 dnl Copyright (C) 2007-2022  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   AC_BEFORE([$0],[AM_PATH_PYTHON])
41   AC_REQUIRE([AC_LINKER_OPTIONS])dnl
42
43   python_ok=yes
44  
45   AM_PATH_PYTHON([3])
46   
47   AC_MSG_NOTICE([local Python configuration])
48
49   AC_SUBST([python_bin],
50            [`basename ${PYTHON}`] )
51            
52   AC_SUBST([PYTHON_ABIFLAGS],
53            [`${PYTHON} -c "import sys; print (sys.abiflags)"`] )
54            
55   AC_SUBST([PYTHON_PREFIX],
56            [`${PYTHON} -c "import sys; print (sys.prefix)"`] )
57            
58   AC_SUBST([PYTHONHOME],
59            [`${PYTHON} -c "import sys; print (sys.prefix)"`] )
60
61   PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/Makefile
62   if test ! -f "$PY_MAKEFILE"; then
63     PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config-${PYTHON_VERSION}${PYTHON_ABIFLAGS}-${build_cpu}-${build_os}/Makefile
64   fi
65   if test ! -f "$PY_MAKEFILE"; then
66     # For Ubuntu >= 13.04
67     PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config-${build_cpu}-${build_os}/Makefile
68   fi
69   if test ! -f "$PY_MAKEFILE"; then
70     if test "${build_cpu::6}" = "x86_64" ; then
71       PY_MAKEFILE=${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/Makefile
72     fi
73   fi
74   if test ! -f "$PY_MAKEFILE"; then
75      AC_MSG_WARN([*** Couldn't find ${PY_MAKEFILE}.  Maybe you are
76 *** missing the development portion of the python installation])
77      python_ok=no
78   fi
79
80   AC_SUBST(PYTHON_INCLUDES)
81   AC_SUBST(PYTHON_LIBS)
82
83   PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION
84   PYTHON_LIBS="-L${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
85   PYTHON_LIB=$PYTHON_LIBS
86   PYTHON_LIBA=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
87   if test "${build_cpu::6}" = "x86_64" ; then
88     if test "$PY_MAKEFILE" = "${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/Makefile" ; then
89       PYTHON_LIBS="-L${PYTHON_PREFIX}/lib64/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
90       PYTHON_LIB=$PYTHON_LIBS
91       PYTHON_LIBA=${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
92     fi
93     if test "$PY_MAKEFILE" = "${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config-${PYTHON_VERSION}${PYTHON_ABIFLAGS}-${build_cpu}-${build_os}/Makefile" ; then
94       PYTHON_LIBS="-L${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/config-${PYTHON_VERSION}${PYTHON_ABIFLAGS}-${build_cpu}-${build_os} -lpython${PYTHON_VERSION}${PYTHON_ABIFLAGS}"
95       PYTHON_LIB=$PYTHON_LIBS
96       PYTHON_LIBA=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config-${PYTHON_VERSION}${PYTHON_ABIFLAGS}-${build_cpu}-${build_os}/libpython${PYTHON_VERSION}${PYTHON_ABIFLAGS}.a
97     fi
98   fi
99
100   dnl At times (like when building shared libraries) you may want
101   dnl to know which OS Python thinks this is.
102
103   AC_SUBST(PYTHON_PLATFORM)
104   PYTHON_PLATFORM=`$PYTHON -c "import sys; print(sys.platform)"`
105
106   AC_SUBST(PYTHON_SITE)
107   AC_ARG_WITH(python-site,
108     [AC_HELP_STRING([--with-python-site=DIR],
109        [Use DIR for installing platform independent Python site-packages])],
110
111 dnl modification : by default, we install python script in salome root tree
112
113 dnl [PYTHON_SITE="$withval"
114 dnl python_site_given=yes],
115 dnl [PYTHON_SITE=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
116 dnl python_site_given=no]
117
118    [PYTHON_SITE="$withval"
119     python_site_given=yes],
120    [PYTHON_SITE=${prefix}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
121     python_site_given=no])
122
123   AC_SUBST(PYTHON_SITE_PACKAGE)
124   PYTHON_SITE_PACKAGE=$PYTHON_SITE/$PACKAGE
125
126
127   dnl Get PYTHON_SITE from --with-python-site-exec or from
128   dnl --with-python-site or from running Python
129
130   AC_SUBST(PYTHON_SITE_EXEC)
131   AC_ARG_WITH(python-site-exec,
132     [AC_HELP_STRING([--with-python-site-exec=DIR],
133                     [Use DIR for installing platform dependent Python site-packages])],
134     [PYTHON_SITE_EXEC="$withval"],
135     [if test "$python_site_given" = yes; then
136        PYTHON_SITE_EXEC=$PYTHON_SITE
137      else
138        PYTHON_SITE_EXEC=${PYTHON_EXEC_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
139      fi])
140
141   dnl Set up the install directory
142   ifelse($1, classes,
143 [PYTHON_SITE_INSTALL=$PYTHON_SITE],
144 [PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE])
145   AC_SUBST(PYTHON_SITE_INSTALL)
146
147   dnl Also lets automake think PYTHON means something.
148
149   pythondir=${PYTHON_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/
150   AC_SUBST(pythondir)
151
152  AC_MSG_CHECKING([if we need libdb])
153  PY_NEEDOPENDB=`nm $PYTHON_LIBA | grep dbopen | grep U`
154   if test "x$PY_NEEDOPENDB" != "x"; then
155      AC_MSG_RESULT(yes)
156      AC_CHECK_LIB(db,dbopen,PYTHON_LIBS="$PYTHON_LIBS -ldb",db_ok=no)
157   else
158      AC_MSG_RESULT(no)
159   fi
160
161  AC_MSG_CHECKING([if we need libdl])
162   PY_NEEDOPENDL=`nm $PYTHON_LIBA | grep dlopen | grep U`
163   if test "x$PY_NEEDOPENDL" != "x"; then
164      AC_MSG_RESULT(yes)
165      AC_CHECK_LIB(dl,dlopen,PYTHON_LIBS="$PYTHON_LIBS -ldl",dl_ok=no)
166   else
167      AC_MSG_RESULT(no)
168   fi
169
170  AC_MSG_CHECKING([if we need libutil])
171   PY_NEEDOPENPTY=`nm $PYTHON_LIBA | grep openpty | grep U`
172   if test "x$PY_NEEDOPENPTY" != "x"; then
173      AC_MSG_RESULT(yes)
174      AC_CHECK_LIB(util,openpty,PYTHON_LIBS="$PYTHON_LIBS -lutil",openpty_ok=no)
175   else
176      AC_MSG_RESULT(no)
177   fi
178
179  AC_MSG_CHECKING([if we need tcltk])
180   PY_NEEDTCLTK=`nm $PYTHON_LIBA | grep Tcl_Init | grep U`
181   if test "x$PY_NEEDTCLTK" != "x"; then
182      AC_MSG_RESULT(yes)
183      AC_CHECK_LIB(tcl,Tcl_Init,PYTHON_LIBS="$PYTHON_LIBS -ltcl -ltk",tclinit_ok=no)
184   else
185      AC_MSG_RESULT(no)
186   fi
187
188   if test "$python_ok" == "yes"; then
189       AC_MSG_RESULT(looks good)
190   fi
191 ])