The following adds support for cross compiling nginx. You need SSH access to your system to run the tests. It's not a complete patch because it still looks locally for headers and such.
diff --git a/auto/endianness b/auto/endianness
--- a/auto/endianness
+++ b/auto/endianness
@@ -27,7 +27,7 @@
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then
- if $NGX_AUTOTEST >/dev/null 2>&1; then
+ if auto/run $NGX_AUTOTEST >/dev/null 2>&1; then
echo " little endian"
have=NGX_HAVE_LITTLE_ENDIAN . auto/have
else
diff --git a/auto/feature b/auto/feature
--- a/auto/feature
+++ b/auto/feature
@@ -53,7 +53,8 @@
yes)
# /bin/sh is used to intercept "Killed" or "Abort trap" messages
- if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
+# if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
+ if auto/run $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
echo " found"
ngx_found=yes
@@ -68,14 +69,15 @@
value)
# /bin/sh is used to intercept "Killed" or "Abort trap" messages
- if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
+# if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
+ if auto/run $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
echo " found"
ngx_found=yes
cat << END >> $NGX_AUTO_CONFIG_H
#ifndef $ngx_feature_name
-#define $ngx_feature_name `$NGX_AUTOTEST`
+#define $ngx_feature_name `auto/run $NGX_AUTOTEST`
#endif
END
@@ -86,7 +88,8 @@
bug)
# /bin/sh is used to intercept "Killed" or "Abort trap" messages
- if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
+# if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
+ if auto/run $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
echo " not found"
else
diff --git a/auto/os/linux b/auto/os/linux
--- a/auto/os/linux
+++ b/auto/os/linux
@@ -18,7 +18,7 @@
# Linux kernel version
-version=$((`uname -r \
+version=$((`auto/run uname -r \
| sed -n -e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/ \
\1*256*256+\2*256+\3/p' \
-e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1*256*256+\2*256/p'`))
diff --git a/auto/types/sizeof b/auto/types/sizeof
--- a/auto/types/sizeof
+++ b/auto/types/sizeof
@@ -40,7 +40,7 @@
if [ -x $NGX_AUTOTEST ]; then
- ngx_size=`$NGX_AUTOTEST`
+ ngx_size=`auto/run $NGX_AUTOTEST`
echo " $ngx_size bytes"
fi
You'll need to create a auto/run script that's used for running scripts remotely. I used:
diff --git a/auto/run b/auto/run
new file mode 100755
--- /dev/null
+++ b/auto/run
@@ -0,0 +1,53 @@
+#!/bin/bash
+basedir=$(dirname $(readlink -f $0))
+keyfile=${basedir}/remote-ssh-key
+logfile=${basedir}/run.txt
+remote="root@testhost"
+verbose=
+
+if [ "$1" = "-v" ] ; then
+ verbose=1
+ shift
+fi
+
+if [ -z "$1" ] ; then
+ echo "Usage: $0 COMMAND ARG..."
+ exit 1
+fi
+
+set -e -u
+
+if [ ! -f $keyfile ] ; then
+ echo "Generating key file $keyfile" >> ${logfile}
+ ssh-keygen -f ${keyfile} -N ""
+ echo "Transferring key to remote system (type in password please)" >> ${logfile}
+ scp -q ${keyfile}.pub ${remote}:/tmp
+ echo "Adding file to authorized_keys (type in password please)" >> ${logfile}
+ ssh -q ${remote} "mkdir ~/.ssh; chmod 700 ~ ~/.ssh; cat /tmp/remote-ssh-key.pub >> ~/.ssh/authorized_keys;"
+fi
+
+if [ -x "$1" ] ; then
+ if [ -n "$verbose" ] ; then
+ echo "Copying $1 to $remote" >&2
+ else
+ echo "$(date) Copying $1 to $remote" >> ${logfile}
+ fi
+ scp -q -i ${keyfile} "$1" ${remote}:/tmp
+ remotename="/tmp/$(basename $1)"
+ shift
+ if [ -n "$verbose" ] ; then
+ echo "Running remotely: ${remotename} $@" >&2
+ else
+ else
+ echo "$(date) Running remotely: ${remotename} $@" >> ${logfile}
+ fi
+ ssh -q -i ${keyfile} ${remote} "${remotename} $@"
+else
+ if [ -n "$verbose" ] ; then
+ echo "Running remotely: $@" >&2
+ else
+ echo "$(date) Running remotely: $@" >> ${logfile}
+ fi
+ ssh -q -i ${keyfile} ${remote} "$@"
+fi
1 comments:
Hi Ali,
Your blog help me a lot. Thanks! BTW, there is a redundant 'else' in the second diff.
+ if [ -n "$verbose" ] ; then
+ echo "Running remotely: ${remotename} $@" >&2
+ else
+ else # HERE
Post a Comment