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