1From ef72be22ad6d58e230f75553d80b470b80c3303a Mon Sep 17 00:00:00 2001
2From: Samuel Martin <s.martin49@gmail.com>
3Date: Sun, 4 May 2014 00:40:49 +0200
4Subject: [PATCH] auto/feature: add mechanism allowing to force feature run
5 test result
6
7Whenever a feature needs to run a test, the ngx_feature_run_force_result
8variable can be set to the desired test result, and thus skip the test.
9
10Therefore, the generated config.h file will honor these presets.
11
12This mechanism aims to make easier cross-compilation support.
13
14Signed-off-by: Samuel Martin <s.martin49@gmail.com>
15---
16 auto/feature | 80 ++++++++++++++++++++++++++++++++++++++++++++----------------
17 1 file changed, 59 insertions(+), 21 deletions(-)
18
19diff --git a/auto/feature b/auto/feature
20index 1145f28..a194b85 100644
21--- a/auto/feature
22+++ b/auto/feature
23@@ -52,50 +52,88 @@ if [ -x $NGX_AUTOTEST ]; then
24     case "$ngx_feature_run" in
25
26         yes)
27-            # /bin/sh is used to intercept "Killed" or "Abort trap" messages
28-            if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
29-                echo " found"
30+            if test -n "$ngx_feature_run_force_result" ; then
31+                echo " not tested (maybe cross-compiling)"
32+                if test -n "$ngx_feature_name" ; then
33+                    if test "$ngx_feature_run_force_result" = "yes" ; then
34+                        have=$ngx_have_feature . auto/have
35+                    fi
36+                fi
37                 ngx_found=yes
38+            else
39
40-                if test -n "$ngx_feature_name"; then
41-                    have=$ngx_have_feature . auto/have
42+                # /bin/sh is used to intercept "Killed" or "Abort trap" messages
43+                if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
44+                    echo " found"
45+                    ngx_found=yes
46+
47+                    if test -n "$ngx_feature_name"; then
48+                        have=$ngx_have_feature . auto/have
49+                    fi
50+
51+                else
52+                    echo " found but is not working"
53                 fi
54
55-            else
56-                echo " found but is not working"
57             fi
58         ;;
59
60         value)
61-            # /bin/sh is used to intercept "Killed" or "Abort trap" messages
62-            if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
63-                echo " found"
64+            if test -n "$ngx_feature_run_force_result" ; then
65+                echo " not tested (maybe cross-compiling)"
66+                cat << END >> $NGX_AUTO_CONFIG_H
67+
68+#ifndef $ngx_feature_name
69+#define $ngx_feature_name  $ngx_feature_run_force_result
70+#endif
71+
72+END
73                 ngx_found=yes
74+            else
75
76-                cat << END >> $NGX_AUTO_CONFIG_H
77+                # /bin/sh is used to intercept "Killed" or "Abort trap" messages
78+                if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
79+                    echo " found"
80+                    ngx_found=yes
81+
82+                    cat << END >> $NGX_AUTO_CONFIG_H
83
84 #ifndef $ngx_feature_name
85 #define $ngx_feature_name  `$NGX_AUTOTEST`
86 #endif
87
88 END
89-            else
90-                echo " found but is not working"
91+                else
92+                    echo " found but is not working"
93+                fi
94+
95             fi
96         ;;
97
98         bug)
99-            # /bin/sh is used to intercept "Killed" or "Abort trap" messages
100-            if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
101-                echo " not found"
102-
103-            else
104-                echo " found"
105+            if test -n "$ngx_feature_run_force_result" ; then
106+                echo " not tested (maybe cross-compiling)"
107+                if test -n "$ngx_feature_name"; then
108+                    if test "$ngx_feature_run_force_result" = "yes" ; then
109+                        have=$ngx_have_feature . auto/have
110+                    fi
111+                fi
112                 ngx_found=yes
113+            else
114
115-                if test -n "$ngx_feature_name"; then
116-                    have=$ngx_have_feature . auto/have
117+                # /bin/sh is used to intercept "Killed" or "Abort trap" messages
118+                if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
119+                    echo " not found"
120+
121+                else
122+                    echo " found"
123+                    ngx_found=yes
124+
125+                    if test -n "$ngx_feature_name"; then
126+                        have=$ngx_have_feature . auto/have
127+                    fi
128                 fi
129+
130             fi
131         ;;
132
133--
1341.9.2
135
136