From 868a4561fedf2756df9f2683a0bd68cedddf8dae Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Sat, 24 May 2008 16:13:40 +0530 Subject: Restructured automake macros --- m4macros/argenable.m4 | 19 ++++++++++ m4macros/typecheck.m4 | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 m4macros/argenable.m4 create mode 100644 m4macros/typecheck.m4 (limited to 'm4macros') diff --git a/m4macros/argenable.m4 b/m4macros/argenable.m4 new file mode 100644 index 0000000..ed5d7f0 --- /dev/null +++ b/m4macros/argenable.m4 @@ -0,0 +1,19 @@ +dnl $Id: argenable.m4,v 1.1 2004-08-24 18:40:21 rjkaes Exp $ +dnl +dnl Define a new AC_ARG_ENABLE like macro which handles invalid inputs +dnl correctly. The macro takes three arguments: +dnl 1) the option name (used like --enable-option) +dnl 2) the help string +dnl 3) the default value (either yes or no) +dnl +dnl This macro also defines on variable in the form "option_enabled" +dnl set to either "yes" or "no". +dnl +AC_DEFUN(TP_ARG_ENABLE, +[AC_ARG_ENABLE([$1], + AS_HELP_STRING([--enable-$1], [$2]), + [case "${enableval}" in + yes) $1_enabled=yes ;; + no) $1_enabled=no ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-$1]) ;; + esac],[$1_enabled=$3])]) diff --git a/m4macros/typecheck.m4 b/m4macros/typecheck.m4 new file mode 100644 index 0000000..a8a88b4 --- /dev/null +++ b/m4macros/typecheck.m4 @@ -0,0 +1,103 @@ +dnl Taken from Unix Network Programming, W. Richard Stevens + +dnl ################################################################## +dnl We cannot use the AC_CHECK_TYPE macros becasue AC_CHECK_TYPE +dnl #includes only , , and . +dnl Unfortunately, many implementations today hide typedefs in wierd +dnl locations: Solaris 2.5.1 has uint8_t and uint32_t in . +dnl SunOS 4.1.x has int8_t in . +dnl So we define our own macro AC_UNP_CHECK_TYPE that does the same +dnl #includes as "unp.h", and then looks for the typedef. +dnl +dnl This macro should be invoked after all the header checks have been +dnl performed, since we #include "confdefs.h" below, and then use the +dnl HAVE_foo_H values that is can #define. +dnl +AC_DEFUN([AC_UNP_CHECK_TYPE], + [AC_MSG_CHECKING(if $1 defined) + AC_CACHE_VAL(ac_cv_type_$1, + [AC_TRY_COMPILE( +[ +#include "confdefs.h" /* the header built by configure so far */ +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_SOCKET_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif +#ifdef HAVE_ERRNO_H +# include +#endif +#ifdef HAVE_FCNTL_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_SIGNAL_H +# include +#endif +#ifdef HAVE_STDIO_H +# include +#endif +#ifdef HAVE_STDLIB_H +# include +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef HAVE_SYS_UIO_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef HAVE_SYS_WAIT_H +# include +#endif +#ifdef HAVE_SYS_UN_H +# include +#endif +#ifdef HAVE_SYS_SELECT_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_SYS_IOCTL_H +# include +#endif +#ifdef HAVE_SYS_FILIO_H +# include +#endif +#ifdef HAVE_SYS_SOCKIO_H +# include +#endif +#ifdef HAVE_PTHREAD_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +], + [ $1 foo ], + [ac_cv_type_$1=yes], + [ac_cv_type_$1=no])]) + AC_MSG_RESULT([$ac_cv_type_$1]) + if test $ac_cv_type_$1 = no ; then + AH_TEMPLATE([$1], [Defined with the proper type.]) + AC_DEFINE($1, $2) + fi +]) \ No newline at end of file -- cgit v1.2.3