Home | History | Annotate | Download | only in m4
      1 dnl AX_CHECK_TYPEDEF(typedef_name, type, action-if-true, action-if-false)
      2 dnl exec action-if-true if typedef_name is a typedef to type else exec 
      3 dnl action-if-false
      4 dnl currently work only with type typedef'ed in stddef.h
      5 AC_DEFUN([AX_CHECK_TYPEDEF], [
      6 dnl AC_LANG_PUSH(C) not in autoconf 2.13
      7 AC_LANG_SAVE
      8 AC_LANG_C
      9 SAVE_CFLAGS=$CFLAGS
     10 CFLAGS="-Werror $CFLAGS"
     11 
     12 AC_TRY_COMPILE(
     13   [
     14   #include <stddef.h>
     15   ],
     16   [
     17   typedef void (*fct1)($1);
     18   typedef void (*fct2)($2);
     19   fct1 f1 = 0;
     20   fct2 f2 = 0;
     21   if (f1 == f2) {}
     22   ],
     23 [$3],[$4])
     24 
     25 CFLAGS=$SAVE_CFLAGS
     26 AC_LANG_RESTORE
     27 ])
     28 
     29 
     30 dnl AX_TYPEDEFED_NAME(typedef_name, candidate_list, var_name)
     31 dnl set var_name to the typedef name of $1 which must be in canditate_list
     32 dnl else produce a fatal error
     33 AC_DEFUN([AX_TYPEDEFED_NAME], [
     34 	AC_MSG_CHECKING([type of $1])
     35 	for f in $2; do
     36 		AX_CHECK_TYPEDEF($1, $f, $3="$f", $3="")
     37 		if test -n "${$3}"; then
     38 			break
     39 		fi
     40 	done
     41 	if test -n "${$3}"; then
     42 		AC_MSG_RESULT([${$3}])
     43 	else
     44 		AC_MSG_ERROR([not found])
     45 	fi
     46 ])
     47