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