xref: /unit/auto/feature (revision 396:3ed1efa34ac2)
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) NGINX, Inc.
4
5
6$echo -n "checking for $nxt_feature ..."
7
8cat << END >> $NXT_AUTOCONF_ERR
9----------------------------------------
10checking for $nxt_feature
11END
12
13
14nxt_found=no
15nxt_feature_value=
16nxt_feature_inc_path=
17
18if test -n "$nxt_feature_incs"; then
19    case "$nxt_feature_incs" in
20        -*)
21            nxt_feature_inc_path="$nxt_feature_incs"
22        ;;
23
24        *)
25            for nxt_temp in $nxt_feature_incs; do
26                nxt_feature_inc_path="$nxt_feature_inc_path -I $nxt_temp"
27            done
28        ;;
29    esac
30fi
31
32
33cat << END > $NXT_AUTOTEST.c
34$nxt_feature_test
35END
36
37
38nxt_test="$CC $CFLAGS $NXT_CFLAGS $NXT_CC_OPT $NXT_TEST_CFLAGS \
39          $nxt_feature_inc_path -o $NXT_AUTOTEST $NXT_AUTOTEST.c \
40          $NXT_LD_OPT $NXT_TEST_LIBS $nxt_feature_libs"
41
42# /bin/sh -c "(...)" is to intercept "Killed", "Abort trap",
43# "Segmentation fault", or other shell messages.
44# "|| true" is to bypass "set -e" setting.
45
46/bin/sh -c "($nxt_test || true)" >> $NXT_AUTOCONF_ERR 2>&1
47
48
49if [ -x $NXT_AUTOTEST ]; then
50
51    case "$nxt_feature_run" in
52
53        value)
54            if /bin/sh -c "($NXT_AUTOTEST)" >> $NXT_AUTOCONF_ERR 2>&1; then
55                $echo >> $NXT_AUTOCONF_ERR
56                nxt_found=yes
57                nxt_feature_value=`$NXT_AUTOTEST`
58                $echo " $nxt_feature_value"
59                if [ -n "$nxt_feature_name" ]; then
60                    cat << END >> $NXT_AUTO_CONFIG_H
61
62#ifndef $nxt_feature_name
63#define $nxt_feature_name  $nxt_feature_value
64#endif
65
66END
67                fi
68            else
69                $echo " not found"
70            fi
71        ;;
72
73        yes)
74            if /bin/sh -c "($NXT_AUTOTEST)" >> $NXT_AUTOCONF_ERR 2>&1; then
75                $echo " found"
76                nxt_found=yes
77                if [ -n "$nxt_feature_name" ]; then
78                    cat << END >> $NXT_AUTO_CONFIG_H
79
80#ifndef $nxt_feature_name
81#define $nxt_feature_name  1
82#endif
83
84END
85                fi
86            else
87                $echo " found but is not working"
88            fi
89        ;;
90
91        *)
92            $echo " found"
93            nxt_found=yes
94            if [ -n "$nxt_feature_name" ]; then
95                cat << END >> $NXT_AUTO_CONFIG_H
96
97#ifndef $nxt_feature_name
98#define $nxt_feature_name  1
99#endif
100
101END
102            fi
103        ;;
104    esac
105
106else
107    $echo " not found"
108
109    $echo "----------"    >> $NXT_AUTOCONF_ERR
110    cat $NXT_AUTOTEST.c   >> $NXT_AUTOCONF_ERR
111    $echo "----------"    >> $NXT_AUTOCONF_ERR
112    $echo $nxt_test       >> $NXT_AUTOCONF_ERR
113    $echo "----------"    >> $NXT_AUTOCONF_ERR
114fi
115
116rm -rf $NXT_AUTOTEST*
117