1 dnl GLIB_IF_VAR_EQ (ENV_VAR, VALUE [, EQUALS_ACTION] [, ELSE_ACTION])
2 AC_DEFUN(GLIB_IF_VAR_EQ,[
12 dnl GLIB_STR_CONTAINS (SRC_STRING, SUB_STRING [, CONTAINS_ACTION] [, ELSE_ACTION])
13 AC_DEFUN(GLIB_STR_CONTAINS,[
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])
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
36 AC_MSG_CHECKING(size of $2)
37 AC_CACHE_VAL(AC_CV_NAME,
38 [AC_TRY_RUN([#include <stdio.h>
42 FILE *f=fopen("conftestval", "w");
44 fprintf(f, "%d\n", sizeof($2));
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
61 AC_MSG_CHECKING(byte contents of $5)
62 AC_CACHE_VAL(AC_CV_NAME,
63 [AC_TRY_RUN([#include <stdio.h>
68 char *p = (char*) &tv;
70 FILE *f=fopen("conftestval", "w");
72 for (i = 0; i < $4; i++)
73 fprintf(f, "%s%d", i?",":"", *(p++));
76 }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=no, AC_CV_NAME=no)])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
92 AC_MSG_CHECKING(system definitions for $glib_sysdef_msg)
93 cat >confrun.c <<_______EOF
96 int main (int c, char **v) {
97 FILE *f = fopen ("$glib_sysdefso", "a");
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
109 echo " fprintf (f, \"#define GLIB_SYSDEF_%s${glib_nl}\", \"$glib_sysdef\");" >>confrun.c
111 echo "#endif" >>confrun.c
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"
123 echo "#define GLIB_SYSDEF_$glib_sysdef$glib_default" >>$glib_sysdefso
125 AC_MSG_RESULT(failed)])