1 ## Portability defines that help interoperate with classic and modern autoconfs
3 define([GLIB_TR_SH],[AC_TR_SH([$1])])
4 define([GLIB_TR_CPP],[AC_TR_CPP([$1])])
7 [patsubst(translit([[$1]], [*+], [pp]), [[^a-zA-Z0-9_]], [_])])
9 [patsubst(translit([[$1]],
10 [*abcdefghijklmnopqrstuvwxyz],
11 [PABCDEFGHIJKLMNOPQRSTUVWXYZ]),
15 # GLIB_AC_DIVERT_BEFORE_HELP(STUFF)
16 # ---------------------------------
17 # Put STUFF early enough so that they are available for $ac_help expansion.
18 # Handle both classic (<= v2.13) and modern autoconf
19 AC_DEFUN([GLIB_AC_DIVERT_BEFORE_HELP],
20 [ifdef([m4_divert_text], [m4_divert_text([NOTICE],[$1])],
21 [ifdef([AC_DIVERT], [AC_DIVERT([NOTICE],[$1])],
22 [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
26 dnl GLIB_IF_VAR_EQ (ENV_VAR, VALUE [, EQUALS_ACTION] [, ELSE_ACTION])
27 AC_DEFUN(GLIB_IF_VAR_EQ,[
37 dnl GLIB_STR_CONTAINS (SRC_STRING, SUB_STRING [, CONTAINS_ACTION] [, ELSE_ACTION])
38 AC_DEFUN(GLIB_STR_CONTAINS,[
48 dnl GLIB_ADD_TO_VAR (ENV_VARIABLE, CHECK_STRING, ADD_STRING)
49 AC_DEFUN(GLIB_ADD_TO_VAR,[
50 GLIB_STR_CONTAINS($[$1], [$2], [$1]="$[$1]", [$1]="$[$1] [$3]")
53 dnl GLIB_SIZEOF (INCLUDES, TYPE, ALIAS [, CROSS-SIZE])
55 [pushdef([glib_Sizeof], GLIB_TR_SH([glib_cv_sizeof_$3]))dnl
56 AC_CACHE_CHECK([size of $2], glib_Sizeof,
57 [AC_TRY_RUN([#include <stdio.h>
65 FILE *f=fopen("conftestval", "w");
67 fprintf(f, "%d\n", sizeof($2));
70 [glib_Sizeof=`cat conftestval` dnl''
73 ifelse([$4], [], [], [glib_Sizeof=$4]))])
74 AC_DEFINE_UNQUOTED(GLIB_TR_CPP(glib_sizeof_$3), [$[]glib_Sizeof], [Size of $3])
75 popdef([glib_Sizeof])dnl
78 dnl GLIB_BYTE_CONTENTS (INCLUDES, TYPE, ALIAS, N_BYTES, INITIALIZER)
79 AC_DEFUN(GLIB_BYTE_CONTENTS,
80 [pushdef([glib_ByteContents], GLIB_TR_SH([glib_cv_byte_contents_$3]))dnl
81 AC_CACHE_CHECK([byte contents of $5], glib_ByteContents,
82 [AC_TRY_RUN([#include <stdio.h>
87 char *p = (char*) &tv;
89 FILE *f=fopen("conftestval", "w");
91 for (i = 0; i < $4; i++)
92 fprintf(f, "%s%d", i?",":"", *(p++));
96 [glib_ByteContents=`cat conftestval` dnl''
98 [glib_ByteContents=no],
99 [glib_ByteContents=no])])
100 AC_DEFINE_UNQUOTED(GLIB_TR_CPP(glib_byte_contents_$3), [$[]glib_ByteContents],
101 [Byte contents of $3])
102 popdef([glib_ByteContents])dnl
105 dnl GLIB_SYSDEFS (INCLUDES, DEFS_LIST, OFILE [, PREFIX])
106 AC_DEFUN(GLIB_SYSDEFS,
107 [glib_sysdefso="translit($3, [-_a-zA-Z0-9 *], [-_a-zA-Z0-9])"
108 glib_sysdef_msg=`echo $2 | sed 's/:[[^ ]]*//g'`
109 if test "x`(echo '\n') 2>/dev/null`" != 'x\n'; then
114 AC_MSG_CHECKING(system definitions for $glib_sysdef_msg)
115 cat >confrun.c <<_______EOF
118 int main (int c, char **v) {
119 FILE *f = fopen ("$glib_sysdefso", "a");
122 for glib_sysdef_input in $2 ; do
123 glib_sysdef=`echo $glib_sysdef_input | sed 's/^\([[^:]]*\):.*$/\1/'`
124 glib_default=`echo $glib_sysdef_input | sed 's/^[[^:]]*:\(.*\)$/\1/'`
125 echo "#ifdef $glib_sysdef" >>confrun.c
126 echo " fprintf (f, \"#define GLIB_SYSDEF_%s %s%d${glib_nl}\", \"$glib_sysdef\", \"$4\", $glib_sysdef);" >>confrun.c
127 echo "#else" >>confrun.c
128 if test $glib_sysdef != $glib_default; then
129 echo " fprintf (f, \"#define GLIB_SYSDEF_%s %s%d${glib_nl}\", \"$glib_sysdef\", \"$4\", $glib_default);" >>confrun.c
131 echo " fprintf (f, \"#define GLIB_SYSDEF_%s${glib_nl}\", \"$glib_sysdef\");" >>confrun.c
133 echo "#endif" >>confrun.c
135 echo "return 0; }" >>confrun.c
136 AC_TRY_RUN(`cat confrun.c`, AC_MSG_RESULT(done),
137 [ for glib_sysdef_input in $2 ; do
138 glib_sysdef=`echo $glib_sysdef_input | sed 's/^\([[^:]]*\):.*$/\1/'`
139 glib_default=`echo $glib_sysdef_input | sed 's/^[[^:]]*:\(.*\)$/\1/'`
140 if test $glib_sysdef != $glib_default; then
141 glib_default=" $4$glib_default"
145 echo "#define GLIB_SYSDEF_$glib_sysdef$glib_default" >>$glib_sysdefso
147 AC_MSG_RESULT(failed)])