Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / glib / acglib.m4
blob5d3cd93dec01287c430eaeea3f17264eb2983156
1 dnl GLIB_IF_VAR_EQ (ENV_VAR, VALUE [, EQUALS_ACTION] [, ELSE_ACTION])
2 AC_DEFUN(GLIB_IF_VAR_EQ,[
3         case "$[$1]" in
4         "[$2]"[)]
5                 [$3]
6                 ;;
7         *[)]
8                 [$4]
9                 ;;
10         esac
12 dnl GLIB_STR_CONTAINS (SRC_STRING, SUB_STRING [, CONTAINS_ACTION] [, ELSE_ACTION])
13 AC_DEFUN(GLIB_STR_CONTAINS,[
14         case "[$1]" in
15         *"[$2]"*[)]
16                 [$3]
17                 ;;
18         *[)]
19                 [$4]
20                 ;;
21         esac
23 dnl GLIB_ADD_TO_VAR (ENV_VARIABLE, CHECK_STRING, ADD_STRING)
24 AC_DEFUN(GLIB_ADD_TO_VAR,[
25         GLIB_STR_CONTAINS($[$1], [$2], [$1]="$[$1]", [$1]="$[$1] [$3]")
28 dnl GLIB_SIZEOF (INCLUDES, TYPE, ALIAS [, CROSS-SIZE])
29 AC_DEFUN(GLIB_SIZEOF,
30 [changequote(<<, >>)dnl
31 dnl The name to #define.
32 define(<<AC_TYPE_NAME>>, translit(glib_sizeof_$3, [a-z *], [A-Z_P]))dnl
33 dnl The cache variable name.
34 define(<<AC_CV_NAME>>, translit(glib_cv_sizeof_$3, [ *], [_p]))dnl
35 changequote([, ])dnl
36 AC_MSG_CHECKING(size of $2)
37 AC_CACHE_VAL(AC_CV_NAME,
38 [AC_TRY_RUN([#include <stdio.h>
40 main()
42   FILE *f=fopen("conftestval", "w");
43   if (!f) exit(1);
44   fprintf(f, "%d\n", sizeof($2));
45   exit(0);
46 }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$4], , , AC_CV_NAME=$4))])dnl
47 AC_MSG_RESULT($AC_CV_NAME)
48 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
49 undefine([AC_TYPE_NAME])dnl
50 undefine([AC_CV_NAME])dnl
53 dnl GLIB_BYTE_CONTENTS (INCLUDES, TYPE, ALIAS, N_BYTES, INITIALIZER)
54 AC_DEFUN(GLIB_BYTE_CONTENTS,
55 [changequote(<<, >>)dnl
56 dnl The name to #define.
57 define(<<AC_TYPE_NAME>>, translit(glib_byte_contents_$3, [a-z *], [A-Z_P]))dnl
58 dnl The cache variable name.
59 define(<<AC_CV_NAME>>, translit(glib_cv_byte_contents_$3, [ *], [_p]))dnl
60 changequote([, ])dnl
61 AC_MSG_CHECKING(byte contents of $2)
62 AC_CACHE_VAL(AC_CV_NAME,
63 [AC_TRY_RUN([#include <stdio.h>
65 main()
67   static $2 tv = $5;
68   char *p = (char*) &tv;
69   int i;
70   FILE *f=fopen("conftestval", "w");
71   if (!f) exit(1);
72   for (i = 0; i < $4; i++)
73     fprintf(f, "%s%d", i?",":"", *(p++));
74   fprintf(f, "\n");
75   exit(0);
76 }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, AC_CV_NAME=0)])dnl
77 AC_MSG_RESULT($AC_CV_NAME)
78 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
79 undefine([AC_TYPE_NAME])dnl
80 undefine([AC_CV_NAME])dnl
83 dnl GLIB_SYSDEFS (INCLUDES, DEFS_LIST, OFILE [, PREFIX])
84 AC_DEFUN(GLIB_SYSDEFS,
85 [glib_sysdefso="translit($3, [-_a-zA-Z0-9 *], [-_a-zA-Z0-9])"
86 glib_sysdef_msg=`echo $2 | sed 's/:[[^  ]]*//g'`
87 if test "x`(echo '\n') 2>/dev/null`" != 'x\n'; then
88   glib_nl='\\n'
89 else
90   glib_nl='\n'
92 AC_MSG_CHECKING(system definitions for $glib_sysdef_msg)
93 cat >confrun.c <<_______EOF
94 #include <stdio.h>
96 int main (int c, char **v) {
97   FILE *f = fopen ("$glib_sysdefso", "a");
98   if (!f) return 1;
99 _______EOF
100 for glib_sysdef_input in $2 ; do
101         glib_sysdef=`echo $glib_sysdef_input | sed 's/^\([[^:]]*\):.*$/\1/'`
102         glib_default=`echo $glib_sysdef_input | sed 's/^[[^:]]*:\(.*\)$/\1/'`
103         echo "#ifdef $glib_sysdef" >>confrun.c
104         echo "  fprintf (f, \"#define GLIB_SYSDEF_%s %s%d${glib_nl}\", \"$glib_sysdef\", \"$4\", $glib_sysdef);" >>confrun.c
105         echo "#else" >>confrun.c
106         if test $glib_sysdef != $glib_default; then
107                 echo "  fprintf (f, \"#define GLIB_SYSDEF_%s %s%d${glib_nl}\", \"$glib_sysdef\", \"$4\", $glib_default);" >>confrun.c
108         else
109                 echo "  fprintf (f, \"#define GLIB_SYSDEF_%s${glib_nl}\", \"$glib_sysdef\");" >>confrun.c
110         fi
111         echo "#endif" >>confrun.c
112 done
113 echo "return 0; }" >>confrun.c
114 AC_TRY_RUN(`cat confrun.c`, AC_MSG_RESULT(done),
115 [       for glib_sysdef_input in $2 ; do
116                 glib_sysdef=`echo $glib_sysdef_input | sed 's/^\([[^:]]*\):.*$/\1/'`
117                 glib_default=`echo $glib_sysdef_input | sed 's/^[[^:]]*:\(.*\)$/\1/'`
118                 if test $glib_sysdef != $glib_default; then
119                         glib_default=" $4$glib_default"
120                 else
121                         glib_default=
122                 fi
123                 echo "#define GLIB_SYSDEF_$glib_sysdef$glib_default" >>$glib_sysdefso
124         done
125         AC_MSG_RESULT(failed)])
126 rm -f confrun.c