Salome HOME
To see which hdf5 we're using in configure log
[modules/kernel.git] / salome_adm / unix / config_files / pyembed.m4
1 dnl  Copyright (C) 2007-2008  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.
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 dnl This macro defines the PYTHON_EMBED_{CFLAGS,LDFLAGS,LIBS} substitutions
23 dnl that should be used when embedding the python interpreter into a program.
24 dnl AM_INIT_PYTHON_EMBED
25 dnl
26 AC_DEFUN([AM_INIT_PYTHON_EMBED],
27 [AC_REQUIRE([AM_PATH_PYTHON])
28 AC_REQUIRE([AM_INIT_PYEXEC_MOD])
29
30 AC_MSG_CHECKING(for flags used to embed python interpreter)
31 changequote(,)dnl
32 py_makefile="`$PYTHON -c '
33 import sys
34 print \"%s/lib/python%s/config/Makefile\"%(sys.exec_prefix, sys.version[:3])'`"
35 changequote([,])dnl
36 if test ! -f "$py_makefile"; then
37    AC_MSG_ERROR([*** Couldn't find the python config makefile.  Maybe you are
38 *** missing the development portion of the python installation])
39 fi
40
41 changequote(,)dnl
42 py_lib="`$PYTHON -c '
43 import sys
44 ver = sys.version[:3]
45 pre = sys.exec_prefix
46 print \"-L%s/lib/python%s/config\" % (pre, ver),
47 if ver == \"1.4\":
48         print \"-lPython -lObjects -lParser\"
49 else:
50         print \"-lpython\" + ver
51
52 changequote([,])dnl
53
54 py_ldflags=`sed -n -e 's/^LDFLAGS=\(.*\)/\1/p' $py_makefile`
55 py_linkforshared=`sed -n -e 's/^LINKFORSHARED=\(.*\)/\1/p' $py_makefile`
56
57 PYTHON_EMBED_LDFLAGS="$py_ldflags $py_linkforshared"
58
59 py_localmodlibs=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $py_makefile`
60 py_basemodlibs=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $py_makefile`
61 py_other_libs=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $py_makefile`
62
63 PYTHON_EMBED_LIBS="$py_lib $py_localmodlibs $py_basemodlibs $py_other_libs"
64
65 PYTHON_EMBED_CFLAGS="$PYTHON_INCLUDES"
66
67 AC_MSG_RESULT(done)
68
69 AC_SUBST(PYTHON_EMBED_CFLAGS)
70 AC_SUBST(PYTHON_EMBED_LDFLAGS)
71 AC_SUBST(PYTHON_EMBED_LIBS)
72 ])
73
74 dnl creates a config.c file, which holds the builtin module initialisation
75 dnl table for python.  The first argument should be the output filename.
76 dnl The second argument gives the names of all the modules you want to build
77 dnl into the executable.
78 dnl AM_PYTHON_CREATE_CONFIG_C(CONFIG_C, MODULE ...)
79 AC_DEFUN([AM_PYTHON_CREATE_CONFIG_C],
80 [AC_REQUIRE([AM_INIT_PYTHON_EMBED])
81 AC_MSG_CHECKING(for config.c.in)
82 changequote(,)dnl
83 py_config_in="`$PYTHON -c '
84 import sys
85 print \"%s/lib/python%s/config/config.c.in\"%(sys.exec_prefix, sys.version[:3])'`"
86 changequote([,])dnl
87 if test ! -f "$py_config_in"; then
88    AC_MSG_ERROR([*** Couldn't find the config.c.in file.  Maybe you are
89 *** missing the development portion of the python installation])
90 fi
91
92 py_cnf_decls=""
93 py_cnf_inits=""
94 py_nl='\
95 '
96 for mod in . $2; do
97   if test "$mod" != .; then
98     py_cnf_decls="${py_cnf_decls}extern void init$mod();$py_nl"
99     py_cnf_inits="${py_cnf_inits}  {\"$mod\", init$mod},$py_nl"
100   fi
101 done
102 sed -e "
103   /MARKER 1/i$py_nl$py_cnf_decls
104   /MARKER 2/i$py_nl$py_cnf_inits
105 " $py_config_in > $1
106 AC_MSG_RESULT(created $1)
107 ])
108
109 s page was automatically generated Contact Matt Wilson with any comments
110 the LXR engine written by Arne     or questions about LXR on gnome.org.
111 rg Gleditsch and Per Kristian      Do not contact Matt Wilson concerning
112 rmshus.                            any software on this site.