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 $2)
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=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 AC_MSG_CHECKING(system definitions for $2)
87 cat >confrun.c <<_______EOF
90 int main (int c, char **v) {
91 FILE *f = fopen ("$glib_sysdefso", "a");
94 for glib_sysdef in $2 ; do
95 echo "#ifdef $glib_sysdef" >>confrun.c
96 echo " fprintf (f, \"#define GLIB_SYSDEF_%s %s%d\\n\", \"$glib_sysdef\", \"$4\", $glib_sysdef);" >>confrun.c
97 echo "#else" >>confrun.c
98 echo " fprintf (f, \"#define GLIB_SYSDEF_%s\\n\", \"$glib_sysdef\");" >>confrun.c
99 echo "#endif" >>confrun.c
101 echo "return 0; }" >>confrun.c
102 AC_TRY_RUN(`cat confrun.c`, AC_MSG_RESULT(done),
103 for glib_sysdef in $2 ; do
104 echo "#define GLIB_SYSDEF_$glib_sysdef" >>$glib_sysdefso
106 AC_MSG_RESULT(failed),)