1dnl acinclude.m4 -- This file is part of VMIPS. 2dnl It is used to build the configure script. See configure.in for details. 3 4dnl Local macro: VMIPS_CXX_ATTRIBUTE_NORETURN 5dnl Check for availability of __attribute__((noreturn)) syntax for specifying 6dnl that a function will never return. Defines HAVE_ATTRIBUTE_NORETURN if it 7dnl works. We assume that if the attribute-adorned function compiles without 8dnl giving a warning, then it is supported. 9 10AC_DEFUN([VMIPS_CXX_ATTRIBUTE_NORETURN], 11[AC_CACHE_CHECK([whether specifying that a function will never return works], 12[vmips_cv_cxx_attribute_noreturn], 13[if test "x$GXX" = "xyes" 14 then 15 (CXXFLAGS="-Werror $CXXFLAGS" 16 AC_LANG_CPLUSPLUS 17 AC_TRY_COMPILE([#include <cstdlib> 18 __attribute__((noreturn)) void die(void) { abort(); }], 19 [],exit 0,exit 1)) 20 if test $? -eq 0 21 then 22 vmips_cv_cxx_attribute_noreturn=yes 23 else 24 vmips_cv_cxx_attribute_noreturn=no 25 fi 26 else 27 vmips_cv_cxx_attribute_noreturn=no 28 fi]) 29if test "$vmips_cv_cxx_attribute_noreturn" = yes 30then 31 AC_DEFINE(HAVE_ATTRIBUTE_NORETURN, 1, 32 [Define if __attribute__((noreturn)) syntax can be used to specify 33 that a function will never return.]) 34fi]) 35 36dnl Local macro: VMIPS_CXX_ATTRIBUTE_FORMAT 37dnl Check for availability of __attribute__((format (...))) syntax for 38dnl specifying that a function takes printf-style arguments. Defines 39dnl HAVE_ATTRIBUTE_PRINTF if it works. As with VMIPS_CXX_ATTRIBUTE_NORETURN, 40dnl we assume that if the attribute-adorned function compiles without giving 41dnl a warning, then it is supported. 42 43AC_DEFUN([VMIPS_CXX_ATTRIBUTE_FORMAT], 44[AC_CACHE_CHECK([whether specifying that a function takes printf-style arguments works], [vmips_cv_cxx_attribute_format], 45[if test "x$GXX" = "xyes" 46then 47 (CXXFLAGS="-Werror $CXXFLAGS" 48 AC_LANG_CPLUSPLUS 49 AC_TRY_COMPILE([#include <cstdlib> 50 __attribute__((format(printf, 1, 2))) 51 void myprintf(char *fmt, ...) { abort(); }],[],exit 0,exit 1)) 52 if test $? -eq 0 53 then 54 vmips_cv_cxx_attribute_format=yes 55 else 56 vmips_cv_cxx_attribute_format=no 57 fi 58else 59 vmips_cv_cxx_attribute_format=no 60fi]) 61if test "x$vmips_cv_cxx_attribute_format" = "xyes" 62then 63 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT, 1, 64 [True if __attribute__((format (...))) syntax can be used to specify 65 that a function takes printf-style arguments.]) 66fi]) 67 68dnl Local macro: VMIPS_CXX_TEMPLATE_FUNCTIONS 69dnl Check for template function handling bug in, for example, pre-2.95 g++. 70dnl Abort with a configuration-time error if the test program doesn't compile. 71 72AC_DEFUN([VMIPS_CXX_TEMPLATE_FUNCTIONS], 73[AC_CACHE_CHECK([whether you can pass a template function to a function whose return type is the same as the type of its parameter], 74[vmips_cv_cxx_template_functions], 75[(AC_LANG_CPLUSPLUS 76 AC_TRY_COMPILE([ 77 template<class F> F x(F f) { } 78 template<class T> void y(T t) { } 79 void z(void) { x(y<int>); } 80 ],[],exit 0,exit 1)) 81if test $? -eq 0 82then 83 vmips_cv_cxx_template_functions=yes 84else 85 vmips_cv_cxx_template_functions=no 86fi]) 87if test "x$vmips_cv_cxx_template_functions" = "xno" 88then 89 AC_MSG_ERROR([your C++ compiler's template function handling is buggy; see INSTALL]) 90fi]) 91 92dnl Local macro: VMIPS_TYPE_SOCKLEN_T 93dnl #define socklen_t to int if socklen_t is not in sys/socket.h. 94 95AC_DEFUN([VMIPS_TYPE_SOCKLEN_T], 96[AC_CACHE_CHECK([for socklen_t], [vmips_cv_type_socklen_t], 97[AC_TRY_COMPILE( 98[#include <sys/types.h> 99#include <sys/socket.h> 100#include <netdb.h>], 101[socklen_t foo; foo = 1; return 0;], 102vmips_cv_type_socklen_t=yes, vmips_cv_type_socklen_t=no)]) 103if test "x$vmips_cv_type_socklen_t" = "xno" 104then 105 AC_DEFINE(socklen_t, int, 106 [Define to the type pointed to by the third argument to getsockname, 107 if it is not socklen_t.]) 108fi]) 109 110dnl Local macro: VMIPS_LINK_STATIC_GETPWNAM 111dnl Can libtool compile statically linked programs that call getpwnam()? 112dnl On Solaris the answer is no, and we must dynamically link with libdl. 113dnl Based on AC_TRY_LINK from acgeneral.m4. 114 115AC_DEFUN([VMIPS_LINK_STATIC_GETPWNAM], 116[AC_CACHE_CHECK([whether programs calling getpwnam can be statically linked], 117[vmips_cv_link_static_getpwnam],[cat > conftest.$ac_ext <<EOF 118[#]line __oline__ "configure" 119#include "confdefs.h" 120#include <stdio.h> 121#include <pwd.h> 122int main() { 123struct passwd *p; 124p = getpwnam("root"); 125printf("%s\n", p->pw_name); 126return 0; } 127EOF 128vmips_cv_link_static_getpwnam=no 129if AC_TRY_COMMAND(./libtool --mode=compile $CXX $CXXFLAGS -c -o conftest.o conftest.$ac_ext 2>&AC_FD_CC 1>&AC_FD_CC) 130then 131 if AC_TRY_COMMAND(./libtool --mode=link $CXX $CXXFLAGS -all-static -o conftest${ac_exeext} conftest.o 2>&AC_FD_CC 1>&AC_FD_CC) 132 then 133 vmips_cv_link_static_getpwnam=yes 134 fi 135fi 136if test "x$vmips_cv_link_static_getpwnam" = "xyes" 137then 138 true 139else 140 echo "configure: failed program was:" >&AC_FD_CC 141 cat conftest.$ac_ext >&AC_FD_CC 142fi 143rm -rf conftest*]) 144if test "x$vmips_cv_link_static_getpwnam" = "xyes" 145then 146 SOLARIS_DL_HACK="" 147else 148 SOLARIS_DL_HACK="/usr/lib/libdl.so" 149fi 150AC_SUBST(SOLARIS_DL_HACK)]) 151 152