Martin v. Löwis wrote:
What about to start to resolve issues step by step ?
The first step surely should be to get the autoconf issue resolved.
I don't think distutils cross-compilation is going to work, instead,
people wishing to cross-compile should edit Modules/Setup.
Regards,
Martin
Please find attached file "python-2.5.2.patch-CROSS".
Note that this is "proof of concept" unified diff only for configure.in
to show only some changes required for cross-compilation:
- added macro AC_CANONICAL_HOST: this require files config.guess and
config.sub to be copied to top source directiory. The files can be
obtained from GNU automake distribution. In my test I use files from
automake 1.10.1.
- makefile conditional: the idea is to use in makefiles. It seems to me
that build for PGEN (Parser from Makefile.pre.in) has to be suppress in
case of cross-compilation as example (without related changes):
=========
# Parser
@[EMAIL PROTECTED] Parser/pgen$(EXE)
=========
- search for python in build system: usually in the cross environment
we cann't run just build python executable we may use existing
interpreter as example in Makefile.pre.in:
=========
@[EMAIL PROTECTED] [EMAIL PROTECTED]@ @SYSPYTHON@
@[EMAIL PROTECTED] $(RUNSHARED) ./$(BUILDPYTHON)
=========
- $ac_sys_system vs $host: the attached diff show how to detect host
system. The existing detection (variable $ac_sys_system) isn't suitable
for cross-environment.
- ar program : macro AC_CHECK_TOOLS replace AC_CHECK_PROGS. for more
details see autoconf texinfo page.
- detection of files: skip detection in cross-env. and by default assume
that file don't exists. This is minimal change and I think that we
has to use macro AC_CHECK_FILE and in cross-env. to warn user but this
require more changes.
- creation of files from configure script (note this is not related
directly to cross compilation): the script is changed to use macros
AC_CONFIG_COMMANDS{_PRE}, i.e. more autoconf friendly.
I would like to know what is acceptable for above changes ?
(note that changes for mingw are only to show idea how to get host
system and i will exclude from final patch ).
Also how to proceed ?
Must I open new issue and to mark that as example 1597850 depend from
new one ?
What is preferred patch: against trunk, release2.5 or both ?
Roumen
--- ./configure.in.CROSS 2008-02-13 21:17:17.000000000 +0200
+++ ./configure.in 2008-08-19 03:11:48.000000000 +0300
@@ -8,6 +8,7 @@
AC_INIT(python, PYTHON_VERSION, http://www.python.org/python-bugs)
AC_CONFIG_SRCDIR([Include/object.h])
AC_CONFIG_HEADER(pyconfig.h)
+AC_CANONICAL_HOST
dnl This is for stuff that absolutely must end up in pyconfig.h.
dnl Please use pyport.h instead, if possible.
@@ -30,6 +31,36 @@
rm confdefs.h
mv confdefs.h.new confdefs.h
+dnl makefile conditional (for future use)
+if test "x$cross_compiling" = xyes; then
+ CROSS_ON=''
+ CROSS_OFF='#'
+else
+ CROSS_ON='#'
+ CROSS_OFF=''
+fi
+AC_SUBST(CROSS_ON)
+AC_SUBST(CROSS_OFF)
+
+if test "x$cross_compiling" = xyes; then
+ AC_MSG_NOTICE([cross-compilation is incomplete])
+
+ dnl in cross-compilation environment we need python from
+ dnl build system (for future use)
+ AC_PATH_PROG(SYSPYTHON, python, [none],
+ [$PATH:/usr/local/bin]
+ )
+ if test "x$PYTHON" = xnone; then
+ AC_MSG_ERROR([python program is required in cross-compilation environment])
+ fi
+
+ dnl HOST_OS is a variable to be used in makefiles to inform other
+ dnl tools for real host system if differ from build system
+ dnl (reserved for future use)
+ HOST_OS=$host_os
+fi
+AC_SUBST(HOST_OS)
+
AC_SUBST(VERSION)
VERSION=PYTHON_VERSION
@@ -585,6 +616,10 @@
*)
enable_shared="no";;
esac
+ case $host in
+ *-*-mingw*)
+ enable_shared="yes";;
+ esac
fi
AC_MSG_RESULT($enable_shared)
@@ -593,11 +628,11 @@
AC_HELP_STRING(--enable-profiling, enable C-level code
profiling),
[ac_save_cc="$CC"
CC="$CC -pg"
- AC_TRY_RUN([int main() { return 0; }],
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[int main() { return 0; }]])],
ac_enable_profiling="yes",
- ac_enable_profiling="no",
ac_enable_profiling="no")
- CC="$ac_save_cc"])
+ CC="$ac_save_cc"],
+ ac_enable_profiling="no")
AC_MSG_RESULT($ac_enable_profiling)
case "$ac_enable_profiling" in
@@ -675,6 +710,13 @@
RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
;;
esac
+ case $host in
+ *-*-mingw*)
+ LDLIBRARY='libpython$(VERSION).dll.a'
+ DLLLIBRARY='libpython$(VERSION).dll'
+ BLDLIBRARY='-L. -lpython$(VERSION)'
+ ;;
+ esac
else # shared is disabled
case $ac_sys_system in
CYGWIN*)
@@ -682,13 +724,16 @@
LDLIBRARY='libpython$(VERSION).dll.a'
;;
esac
+ case $host in
+ *-*-mingw*)
+ LDLIBRARY='libpython$(VERSION).dll.a';;
+ esac
fi
AC_MSG_RESULT($LDLIBRARY)
AC_PROG_RANLIB
-AC_SUBST(AR)
-AC_CHECK_PROGS(AR, ar aal, ar)
+AC_CHECK_TOOLS(AR, ar aal, ar)
AC_SUBST(SVNVERSION)
AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
@@ -710,6 +755,7 @@
AC_PROG_INSTALL
# Not every filesystem supports hard links
+dnl MAY BE TO FIX: macro AC_PROG_LN_S will do this but require substitution of
LN_S
AC_SUBST(LN)
if test -z "$LN" ; then
case $ac_sys_system in
@@ -807,9 +853,8 @@
AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
ac_save_cc="$CC"
CC="$CC -fno-strict-aliasing"
- AC_TRY_RUN([int main() { return 0; }],
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[int main() { return 0; }]])],
ac_cv_no_strict_aliasing_ok=yes,
- ac_cv_no_strict_aliasing_ok=no,
ac_cv_no_strict_aliasing_ok=no)
CC="$ac_save_cc"
AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
@@ -871,9 +916,8 @@
AC_CACHE_VAL(ac_cv_opt_olimit_ok,
[ac_save_cc="$CC"
CC="$CC -OPT:Olimit=0"
-AC_TRY_RUN([int main() { return 0; }],
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[int main() { return 0; }]])],
ac_cv_opt_olimit_ok=yes,
- ac_cv_opt_olimit_ok=no,
ac_cv_opt_olimit_ok=no)
CC="$ac_save_cc"])
AC_MSG_RESULT($ac_cv_opt_olimit_ok)
@@ -893,9 +937,8 @@
AC_CACHE_VAL(ac_cv_olimit_ok,
[ac_save_cc="$CC"
CC="$CC -Olimit 1500"
- AC_TRY_RUN([int main() { return 0; }],
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[int main() { return 0; }]])],
ac_cv_olimit_ok=yes,
- ac_cv_olimit_ok=no,
ac_cv_olimit_ok=no)
CC="$ac_save_cc"])
AC_MSG_RESULT($ac_cv_olimit_ok)
@@ -1419,6 +1462,9 @@
CYGWIN*) SO=.dll;;
*) SO=.so;;
esac
+ case $host in
+ *-*-mingw*) SO=.dll;;
+ esac
else
# this might also be a termcap variable, see #610332
echo
@@ -1551,6 +1597,11 @@
atheos*) LDSHARED="gcc -shared";;
*) LDSHARED="ld";;
esac
+ case $host in
+ *-*-mingw*)
+ LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base'
+ ;;
+ esac
fi
AC_MSG_RESULT($LDSHARED)
BLDSHARED=${BLDSHARED-$LDSHARED}
@@ -1641,6 +1692,12 @@
LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
fi;;
esac
+ case $host in
+ *-*-mingw*)
+ if test $enable_shared = "no"; then
+ LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
+ fi;;
+ esac
fi
AC_MSG_RESULT($LINKFORSHARED)
@@ -1656,6 +1713,12 @@
*)
CFLAGSFORSHARED='$(CCSHARED)'
esac
+ case $host in
+ *-*-mingw)
+ # TODO mingw needs CCSHARED when building extension DLLs
+ # but not when building the interpreter DLL.
+ CFLAGSFORSHARED='';;
+ esac
fi
AC_MSG_RESULT($CFLAGSFORSHARED)
@@ -2278,7 +2341,7 @@
else
MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
fi
-AC_MSG_RESULT(MACHDEP_OBJS)
+AC_MSG_RESULT($MACHDEP_OBJS)
# checks for library functions
AC_CHECK_FUNCS(alarm bind_textdomain_codeset chown clock confstr ctermid \
@@ -2881,11 +2944,16 @@
# check for --with-libm=...
AC_SUBST(LIBM)
+dnl obsolete style to set libraries for a system
case $ac_sys_system in
Darwin) ;;
BeOS) ;;
*) LIBM=-lm
esac
+dnl new style to set libraries for host system
+case $host in
+ *-*-mingw*) LIBM=;;
+esac
AC_MSG_CHECKING(for --with-libm=STRING)
AC_ARG_WITH(libm,
AC_HELP_STRING(--with-libm=STRING, math library),
@@ -3370,7 +3438,12 @@
)
AC_MSG_CHECKING(for /dev/ptmx)
-
+if test "x$cross_compiling" = xyes; then
+ case $host in
+ *-*-mingw*);;
+ *) AC_MSG_RESULT(cross-compiling, assuming no);;
+ esac
+else
if test -r /dev/ptmx
then
AC_MSG_RESULT(yes)
@@ -3379,9 +3452,15 @@
else
AC_MSG_RESULT(no)
fi
+fi
AC_MSG_CHECKING(for /dev/ptc)
-
+if test "x$cross_compiling" = xyes; then
+ case $host in
+ *-*-mingw*);;
+ *) AC_MSG_RESULT(cross-compiling, assuming no);;
+ esac
+else
if test -r /dev/ptc
then
AC_MSG_RESULT(yes)
@@ -3390,6 +3469,7 @@
else
AC_MSG_RESULT(no)
fi
+fi
case $MACHDEP in
darwin)
@@ -3411,7 +3491,7 @@
AC_MSG_CHECKING(for %zd printf() format support)
-AC_TRY_RUN([#include <stdio.h>
+AC_RUN_IFELSE([#include <stdio.h>
#include <stddef.h>
#include <string.h>
@@ -3447,8 +3527,14 @@
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for
Py_ssize_t])],
- AC_MSG_RESULT(no))
+ AC_MSG_RESULT(no),
+[case $host in
+ *-*-mingw*) AC_MSG_RESULT(no);;
+ *) AC_MSG_RESULT(unknown);;
+esac])
+dnl FIXME: check is incorrect for win host systems, i.e. mingw and etc.,
+dnl but on those systems socklen_t is defined in ws2tcpip.h as int ;)
AC_CHECK_TYPE(socklen_t,,
AC_DEFINE(socklen_t,int,
Define to `int' if <sys/socket.h> does not define.),[
@@ -3477,24 +3563,25 @@
done
AC_MSG_RESULT(done)
-# generate output files
-AC_CONFIG_FILES(Makefile.pre Modules/Setup.config)
-AC_OUTPUT
-
-echo "creating Modules/Setup"
+AC_CONFIG_COMMANDS_PRE([
+AC_MSG_NOTICE([creating Modules/Setup])
if test ! -f Modules/Setup
then
cp $srcdir/Modules/Setup.dist Modules/Setup
fi
-echo "creating Modules/Setup.local"
+AC_MSG_NOTICE([creating Modules/Setup.local])
if test ! -f Modules/Setup.local
then
echo "# Edit this file for local setup changes" >Modules/Setup.local
-fi
+fi])
-echo "creating Makefile"
-$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
+AC_CONFIG_COMMANDS([Makefile],
+[$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
-s Modules Modules/Setup.config \
Modules/Setup.local Modules/Setup
-mv config.c Modules
+mv config.c Modules])
+
+# generate output files
+AC_CONFIG_FILES(Makefile.pre Modules/Setup.config)
+AC_OUTPUT
--
http://mail.python.org/mailman/listinfo/python-list