chiark / gitweb /
Update stressapptest to 1.0.2
[stressapptest] / configure.ac
1 AC_PREREQ(2.61)
2 AC_INIT(stressapptest, 1.0.2_autoconf, opensource@google.com)
3
4 AC_CANONICAL_HOST
5 AC_CANONICAL_BUILD
6 # Checking for target cpu and setting custom configuration
7 # for the different platforms
8 AC_CANONICAL_TARGET
9 case x"$target_cpu" in
10 "xx86_64")
11   AC_DEFINE([STRESSAPPTEST_CPU_X86_64],[],
12             [Defined if the target CPU is x86_64])
13 ;;
14 "xi686")
15   AC_DEFINE([STRESSAPPTEST_CPU_I686],[],
16             [Defined if the target CPU is i686])
17 ;;
18 "xpowerpc")
19   AC_DEFINE([STRESSAPPTEST_CPU_PPC],[],
20             [Defined if the target CPU is PowerPC])
21 ;;
22 esac
23
24 _os=`uname`
25 ## The following allows like systems to share settings. This is not meant to
26 ## imply that these OS are the same thing. From OpenOffice dmake configure.in
27 case "$_os" in
28         "Linux")
29           OS_VERSION=linux
30           AC_DEFINE([STRESSAPPTEST_OS_LINUX],[],
31                     [Defined if the target OS is Linux])
32           ;;
33         "Darwin")
34           OS_VERSION=macosx
35           AC_DEFINE([STRESSAPPTEST_OS_DARWIN],[],
36                     [Defined if the target OS is OSX])
37           ;;
38         "FreeBSD")
39           OS_VERSION=bsd
40           AC_DEFINE([STRESSAPPTEST_OS_BSD],[],
41                     [Defined if the target OS is BSD based])
42           ;;
43         "NetBSD")
44           OS_VERSION=bsd
45           AC_DEFINE([STRESSAPPTEST_OS_BSD],[],
46                     [Defined if the target OS is BSD based])
47           ;;
48    *)
49       AC_MSG_ERROR([$_os operating system is not suitable to build dmake!])
50       ;;
51 esac
52
53 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
54 AC_CONFIG_SRCDIR([src/])
55 AC_CONFIG_HEADER([src/stressapptest_config.h])
56
57 # Checks for programs.
58 #  Don't generate CXXFLAGS defaults: if CXXFLAGS are unset
59 #  AC_PROG_CXX will override them with unwanted defaults.
60 CXXFLAGS="$CXXFLAGS"
61 AC_PROG_CXX
62 AC_PROG_CC
63
64 #Getting user and host info
65 username=$(whoami)
66 AC_MSG_CHECKING([user ID])
67 AC_MSG_RESULT([$username])
68
69 hostname=$(uname -n)
70 AC_MSG_CHECKING([host name])
71 AC_MSG_RESULT([$hostname])
72
73 timestamp=$(date)
74 AC_MSG_CHECKING([current timestamp])
75 AC_MSG_RESULT([$timestamp])
76
77 AC_DEFINE_UNQUOTED([STRESSAPPTEST_TIMESTAMP],
78                    "$username @ $hostname on $timestamp",
79                    [Timestamp when ./configure was executed])
80
81 #Default cxxflags
82 CXXFLAGS="$CXXFLAGS -DCHECKOPTS"
83 CXXFLAGS="$CXXFLAGS -Wreturn-type -Wunused -Wuninitialized -Wall"
84 CXXFLAGS="$CXXFLAGS -O3 -funroll-all-loops  -funroll-loops -DNDEBUG"
85
86 # Checks for header files.
87 AC_HEADER_DIRENT
88 AC_HEADER_STDC
89 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])
90 AC_CHECK_HEADERS([pthread.h libaio.h])
91
92 # Checks for typedefs, structures, and compiler characteristics.
93 AC_HEADER_STDBOOL
94 AC_C_CONST
95 AC_C_INLINE
96 AC_TYPE_PID_T
97 AC_C_RESTRICT
98 AC_TYPE_SSIZE_T
99 AC_HEADER_TIME
100 AC_TYPE_UINT16_T
101 AC_C_VOLATILE
102
103 # Checking for pthreads
104 pthread_arg="not_available"
105 AC_MSG_CHECKING([which argument is required to compile pthreads])
106
107 pthread_header="#include<pthread.h>"
108 pthread_body="pthread_create(0,0,0,0)"
109 # Check if compile with no extra argument
110 AC_LINK_IFELSE([AC_LANG_PROGRAM($pthread_header, $pthread_body)],
111 pthread_arg="")
112
113 if test x"$pthread_arg" = x"not_available"; then
114   # At first, only -pthread was tested, but this is the place
115   # to add extra pthread flags if someone can test them
116   bkp_LDFLAGS="$LDFLAGS"
117   for altheader in -pthread; do
118     LDFLAGS="$bkp_LDFLAGS $altheader"
119     AC_LINK_IFELSE([AC_LANG_PROGRAM($pthread_header, $pthread_body)],
120     pthread_arg="$altheader")
121     LDFLAGS="$bkp_LDFLAGS"
122   done
123 fi
124
125 if test x"$pthread_arg" = x"not_available"; then
126    AC_MSG_FAILURE([Cannot find a proper pthread library])
127 else
128    if test x"$pthread_arg" = x; then
129      AC_MSG_RESULT([none])
130    else
131      AC_MSG_RESULT([$pthread_arg])
132    fi
133    LDFLAGS="$LDFLAGS $pthread_arg"
134 fi
135
136 # Checking for libaio
137 libaio_arg="not_available"
138 AC_MSG_CHECKING([which argument is required to compile libaio])
139
140 libaio_header="#include<libaio.h>"
141 libaio_body="io_submit(0,0,0)"
142 # Check if compile with no extra argument
143 AC_LINK_IFELSE([AC_LANG_PROGRAM($libaio_header, $libaio_body)],
144 libaio_arg="")
145
146 if test x"$libaio_arg" = x"not_available"; then
147   bkp_LDFLAGS="$LDFLAGS"
148   for altheader in -laio; do
149     LDFLAGS="$bkp_LDFLAGS $altheader"
150     AC_LINK_IFELSE([AC_LANG_PROGRAM($libaio_header, $libaio_body)],
151     libaio_arg="$altheader")
152     LDFLAGS="$bkp_LDFLAGS"
153   done
154 fi
155
156 if test x"$libaio_arg" = x"not_available"; then
157    AC_MSG_FAILURE([Cannot find libaio library, please install libaio-dev])
158 else
159    if test x"$libaio_arg" = x; then
160      AC_MSG_RESULT([none])
161    else
162      AC_MSG_RESULT([$libaio_arg])
163    fi
164    LDFLAGS="$LDFLAGS $libaio_arg"
165 fi
166
167 # Checks for library functions.
168 AC_FUNC_CLOSEDIR_VOID
169 AC_PROG_GCC_TRADITIONAL
170 AC_FUNC_SELECT_ARGTYPES
171 AC_TYPE_SIGNAL
172 AC_FUNC_STRERROR_R
173 AC_FUNC_VPRINTF
174 AC_CHECK_FUNCS([gettimeofday memset select socket strtol strtoull])
175
176 AC_CONFIG_FILES([Makefile src/Makefile])
177 AC_OUTPUT