chiark / gitweb /
026fa076a6c4261c38a45a7d7f91f2f2f06a70ed
[stressapptest] / configure.ac
1 AC_PREREQ(2.61)
2 AC_INIT(stressapptest, 1.0.0_autoconf, opensource@gmail.com)
3
4 # Checking for target cpu and setting custom configuration
5 # for the different platforms
6 AC_CANONICAL_TARGET
7 case x"$target_cpu" in
8 "xx86_64")
9   AC_DEFINE([STRESSAPPTEST_CPU_X86_64],[],
10             [Defined if the target CPU is x86_64])
11 ;;
12 "xi686")
13   AC_DEFINE([STRESSAPPTEST_CPU_I686],[],
14             [Defined if the target CPU is i686])
15 ;;
16 "xpowerpc")
17   AC_DEFINE([STRESSAPPTEST_CPU_PPC],[],
18             [Defined if the target CPU is PowerPC])
19 ;;
20 esac
21
22 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
23 AC_CONFIG_SRCDIR([src/])
24 AC_CONFIG_HEADER([src/stressapptest_config.h])
25
26 # Checks for programs.
27 AC_PROG_CXX
28 AC_PROG_CC
29
30 #Getting user and host info
31 username=$(whoami)
32 AC_MSG_CHECKING([user ID])
33 AC_MSG_RESULT([$username])
34
35 hostname=$(uname -n)
36 AC_MSG_CHECKING([host name])
37 AC_MSG_RESULT([$hostname])
38
39 timestamp=$(date)
40 AC_MSG_CHECKING([current timestamp])
41 AC_MSG_RESULT([$timestamp])
42
43 AC_DEFINE_UNQUOTED([STRESSAPPTEST_TIMESTAMP],
44                    "$username @ $hostname on $timestamp", 
45                    [Timestamp when ./configure was executed])
46
47 #Default cxxflags
48 CXXFLAGS="$CXXFLAGS -DCHECKOPTS"
49 CXXFLAGS="$CXXFLAGS -Wreturn-type -Wunused -Wuninitialized -Wall"
50 CXXFLAGS="$CXXFLAGS -O3 -funroll-all-loops  -funroll-loops -DNDEBUG"
51
52 # Checks for header files.
53 AC_HEADER_DIRENT
54 AC_HEADER_STDC
55 AC_CHECK_HEADERS([arpa/inet.h fcntl.h malloc.h netdb.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h unistd.h])
56
57 # Checks for typedefs, structures, and compiler characteristics.
58 AC_HEADER_STDBOOL
59 AC_C_CONST
60 AC_C_INLINE
61 AC_TYPE_PID_T
62 AC_C_RESTRICT
63 AC_TYPE_SSIZE_T
64 AC_HEADER_TIME
65 AC_TYPE_UINT16_T
66 AC_C_VOLATILE
67
68 # Checking for pthreads
69 pthread_arg="not_available"
70 AC_MSG_CHECKING([which argument is required to compile pthreads])
71
72 pthread_header="#include<pthread.h>"
73 pthread_body="pthread_create(0,0,0,0)"
74 # Check if compile with no extra argument
75 AC_LINK_IFELSE([AC_LANG_PROGRAM($pthread_header, $pthread_body)], 
76 pthread_arg="")
77
78 if test x"$pthread_arg" = x"not_available"; then
79   # At first, only -pthread was tested, but this is the place
80   # to add extra pthread flags if someone can test them
81   bkp_LDFLAGS="$LDFLAGS"
82   for altheader in -pthread; do
83     LDFLAGS="$bkp_LDFLAGS $altheader"
84     AC_LINK_IFELSE([AC_LANG_PROGRAM($pthread_header, $pthread_body)], 
85     pthread_arg="$altheader")
86     LDFLAGS="$bkp_LDFLAGS"
87   done
88 fi
89
90 if test x"$pthread_arg" = x"not_available"; then
91    AC_MSG_FAILURE([Cannot find a proper pthread library])
92 else
93    if test x"$pthread_arg" = x; then
94      AC_MSG_RESULT([none])
95    else
96      AC_MSG_RESULT([$pthread_arg])
97    fi
98    LDFLAGS="$LDFLAGS $pthread_arg"
99 fi
100
101 # Checks for library functions.
102 AC_FUNC_CLOSEDIR_VOID
103 AC_PROG_GCC_TRADITIONAL
104 AC_FUNC_SELECT_ARGTYPES
105 AC_TYPE_SIGNAL
106 AC_FUNC_STRERROR_R
107 AC_FUNC_VPRINTF
108 AC_CHECK_FUNCS([gettimeofday memset select socket strtol strtoull])
109
110 AC_CONFIG_FILES([Makefile src/Makefile])
111 AC_OUTPUT