$ svn cat svn://svn.psellos.com/trunk/ocamlxarm/3.1/xarm-build
通过修改“chain”配置,可以生成文件。
Ocamls配置脚本假设可以在同一运行中编译和执行结果,但在交叉编译环境中可能是不可能的。
因此,必须修改配置过程,以便编译结果(包括可执行文件)被存储并可在目标机器上的第二次运行中使用。这是显示修改的差异文件(约200行)。
diff -r -U 1 ocaml-4.00.0-orig/config/auto-aux/hasgot ocaml-4.00.0-cross/config/auto-aux/hasgot
--- ocaml-4.00.0-orig/config/auto-aux/hasgot
+++ ocaml-4.00.0-cross/config/auto-aux/hasgot
@@ -15,2 +15,4 @@
+. ./keyval.sh
+
opts=""
@@ -36,7 +38,13 @@
+key="$cc $args"
+getValueExit "$key"
+
if test "$verbose" = yes; then
echo "hasgot $args: $cc $opts -o tst hasgot.c $libs" >&2
- exec $cc $opts -o tst hasgot.c $libs > /dev/null
+ `exec $cc $opts -o tst hasgot.c $libs > /dev/null`
else
- exec $cc $opts -o tst hasgot.c $libs > /dev/null 2>/dev/null
+ `exec $cc $opts -o tst hasgot.c $libs > /dev/null 2>/dev/null`
fi
+res=$?
+setValue "$key" "$res"
+exit "$res"
diff -r -U 1 ocaml-4.00.0-orig/config/auto-aux/hasgot2 ocaml-4.00.0-cross/config/auto-aux/hasgot2
--- ocaml-4.00.0-orig/config/auto-aux/hasgot2
+++ ocaml-4.00.0-cross/config/auto-aux/hasgot2
@@ -15,2 +15,4 @@
+. ./keyval.sh
+
opts=""
@@ -36,7 +38,13 @@
+key="$cc $args"
+getValueExit "$key"
+
if test "$verbose" = yes; then
echo "hasgot2 $args: $cc $opts -o tst hasgot.c $libs" >&2
- exec $cc $opts -o tst hasgot.c $libs > /dev/null
+ `exec $cc $opts -o tst hasgot.c $libs > /dev/null`
else
- exec $cc $opts -o tst hasgot.c $libs > /dev/null 2>/dev/null
+ `exec $cc $opts -o tst hasgot.c $libs > /dev/null 2>/dev/null`
fi
+res=$?
+setValue "$key" "$res"
+exit "$res"
Only in ocaml-4.00.0-cross/config/auto-aux: keyval.sh
diff -r -U 1 ocaml-4.00.0-orig/config/auto-aux/runtest ocaml-4.00.0-cross/config/auto-aux/runtest
--- ocaml-4.00.0-orig/config/auto-aux/runtest
+++ ocaml-4.00.0-cross/config/auto-aux/runtest
@@ -17,6 +17,30 @@
echo "runtest: $cc -o tst $* $cclibs" >&2
-$cc -o tst $* $cclibs || exit 100
+stream=/dev/stderr
else
-$cc -o tst $* $cclibs 2> /dev/null || exit 100
+stream=/dev/null
+#$cc -o tst $* $cclibs 2> /dev/null || exit 100
fi
+
+key="$* $cclibs"
+
+if test "$crossmode" = cross-cc; then
+ i=`cat ./counter`
+ $cc -o tst"$i" $* $cclibs 2> "$stream" || exit 100
+ echo "$key"'%%#%%'tst"$i" >> ./map_runtest
+ i=`expr $i + 1`
+ echo "$i" > ./counter
+ if test "$*" = sizes.c; then
+ echo "4 4 4 2"
+ fi
+ if test `expr "$*" : '.*tclversion.c'` -ne 0; then
+ echo "8.5"
+ fi
+ exit 0
+fi
+if test "$crossmode" = cross-run; then
+ tst=`awk -v ccargs="$key" 'BEGIN {FS="%%#%%"} $1 == ccargs {print $2}' ./map_runtest`
+ exec ./"$tst"
+fi
+
+$cc -o tst $* $cclibs 2> "$stream" || exit 100
exec ./tst
diff -r -U 1 ocaml-4.00.0-orig/config/auto-aux/tryassemble ocaml-4.00.0-cross/config/auto-aux/tryassemble
--- ocaml-4.00.0-orig/config/auto-aux/tryassemble
+++ ocaml-4.00.0-cross/config/auto-aux/tryassemble
@@ -1,8 +1,16 @@
#!/bin/sh
+
+. ./keyval.sh
+
+key="$aspp $*"
+getValueExit "$key"
+
if test "$verbose" = yes; then
echo "tryassemble: $aspp -o tst $*" >&2
-$aspp -o tst $* || exit 100
+`$aspp -o tst $* || exit 100`
else
-$aspp -o tst $* 2> /dev/null || exit 100
+`$aspp -o tst $* 2> /dev/null || exit 100`
fi
+res=$?
+setValue "$key" "$res"
@@ -11,7 +19,14 @@
if test "$verbose" = yes; then
+key="$as $*"
+getValueExit "$key"
echo "tryassemble: $as -o tst $*" >&2
-$as -o tst $* || exit 100
+`$as -o tst $* || exit 100`
else
-$as -o tst $* 2> /dev/null || exit 100
+`$as -o tst $* 2> /dev/null || exit 100`
fi
+res=$?
+setValue "$key" "$res"
+exit $res
+else
+exit $res
fi
diff -r -U 1 ocaml-4.00.0-orig/config/auto-aux/trycompile ocaml-4.00.0-cross/config/auto-aux/trycompile
--- ocaml-4.00.0-orig/config/auto-aux/trycompile
+++ ocaml-4.00.0-cross/config/auto-aux/trycompile
@@ -15,7 +15,15 @@
+. ./keyval.sh
+
+key="$cc $* $cclibs"
+getValueExit "$key"
+
if test "$verbose" = yes; then
echo "trycompile: $cc -o tst $* $cclibs" >&2
-$cc -o tst $* $cclibs || exit 100
+`$cc -o tst $* $cclibs || exit 100`
else
-$cc -o tst $* $cclibs 2> /dev/null || exit 100
+`$cc -o tst $* $cclibs 2> /dev/null || exit 100`
fi
+res=$?
+setValue "$key" "$res"
+exit $res
diff -r -U 1 ocaml-4.00.0-orig/configure ocaml-4.00.0-cross/configure
--- ocaml-4.00.0-orig/configure
+++ ocaml-4.00.0-cross/configure
@@ -47,2 +47,3 @@
withcamlp4=camlp4
+crossmode=''
@@ -119,2 +120,4 @@
withcamlp4="";;
+ -cross|--cross)
+ crossmode="$2"; shift;;
*) echo "Unknown option \"$1\"." 1>&2; exit 2;;
@@ -158,2 +161,21 @@
+case "$crossmode" in
+ cc)
+ crossmode=cross-cc
+ echo 0 > ./counter
+ rm -f ./map_runtest ./map_hasgot
+ touch ./map_runtest ./map_hasgot;;
+ run)
+ crossmode=cross-run
+ if test ! -e ./map_runtest -o ! -e ./map_hasgot; then
+ echo 'Run with -cross cc first'
+ exit 2
+ fi
+ rm -f ./counter;;
+ none) crossmode=none;;
+ "") crossmode=none ;;
+ *)
+ echo 'Unknown crossmode'>&2
+ exit 2;;
+esac
# Write options to Makefile
@@ -350,3 +372,3 @@
cc="$bytecc -O $bytecclinkopts"
-export cc cclibs verbose
+export cc cclibs verbose crossmode
@@ -1647,2 +1669,5 @@
+if test "$crossmode" = cross-run; then
+ rm -f tst* ./map_runtest ./map_hasgot
+fi
# Print a summary
getValueExit()
{
if test "$crossmode" = cross-run; then
res=`awk -v ccargs="$1" 'BEGIN {FS="%%#%%"} $1 == ccargs {print $2; exit}' ./map_hasgot`
exit "$res"
fi
}
setValue()
{
if test "$crossmode" = cross-cc; then
echo "$1"'%%#%%'"$2" >> ./map_hasgot
fi
}
tk
,则必须修改config/auto-aux/runtest并将0.0
替换为其版本号。此外,如果solaris用作目标或主机机器,则可能需要修改文件config/auto-aux/solaris-ld。
-prefix $XARMTARGET/v7
来节省4行代码。此外,我有些不知所措。build1
中的ocamlopt
是什么?它将OCaml编译成ARM,但没有正确的工具链环境吗?而这个问题在build2
中得到解决了吗?你是否隐含地认为ARM环境与i386环境差别不大? - Percival Ulysses