1AC_PREREQ(2.61)
2AC_INIT([stressapptest], [1.0.4_autoconf], [opensource@google.com])
3
4AC_ARG_WITH(static, [  --with-static            enable static linking])
5
6if test "$with_static" == "yes"
7then
8	AC_MSG_NOTICE([Compiling with staticaly linked libraries.])
9	LIBS="$LIBS -static"
10else
11	AC_MSG_NOTICE([Compiling with dynamically linked libraries.])
12fi
13
14AC_CANONICAL_HOST
15AC_CANONICAL_BUILD
16# Checking for target cpu and setting custom configuration
17# for the different platforms
18AC_CANONICAL_TARGET
19case x"$target_cpu" in
20  "xx86_64")
21    AC_DEFINE([STRESSAPPTEST_CPU_X86_64],[],
22              [Defined if the target CPU is x86_64])
23    ;;
24  "xi686")
25    AC_DEFINE([STRESSAPPTEST_CPU_I686],[],
26              [Defined if the target CPU is i686])
27    ;;
28  "xpowerpc")
29    AC_DEFINE([STRESSAPPTEST_CPU_PPC],[],
30              [Defined if the target CPU is PowerPC])
31    ;;
32  "xarmv7a")
33    AC_DEFINE([STRESSAPPTEST_CPU_ARMV7A],[],
34              [Defined if the target CPU is armv7a])
35    ;;
36  *)
37    AC_MSG_ERROR([$target_cpu is not supported! Try x86_64, i686, powerpc, or armv7a])
38    ;;
39esac
40
41_os=`uname`
42## The following allows like systems to share settings. This is not meant to
43## imply that these OS are the same thing. From OpenOffice dmake configure.in
44case "$_os" in
45  "Linux")
46    OS_VERSION=linux
47    AC_DEFINE([STRESSAPPTEST_OS_LINUX],[],
48              [Defined if the target OS is Linux])
49    ;;
50  "Darwin")
51    OS_VERSION=macosx
52    AC_DEFINE([STRESSAPPTEST_OS_DARWIN],[],
53              [Defined if the target OS is OSX])
54    ;;
55  "FreeBSD")
56    OS_VERSION=bsd
57    AC_DEFINE([STRESSAPPTEST_OS_BSD],[],
58              [Defined if the target OS is BSD based])
59    ;;
60  "NetBSD")
61    OS_VERSION=bsd
62    AC_DEFINE([STRESSAPPTEST_OS_BSD],[],
63              [Defined if the target OS is BSD based])
64    ;;
65  *)
66    AC_MSG_ERROR([$_os operating system is not suitable to build dmake!])
67    ;;
68esac
69
70AM_INIT_AUTOMAKE([-Wall -Werror foreign])
71AC_CONFIG_SRCDIR([src/])
72AC_CONFIG_HEADER([src/stressapptest_config.h])
73
74# Checks for programs.
75#  Don't generate CXXFLAGS defaults: if CXXFLAGS are unset
76#  AC_PROG_CXX will override them with unwanted defaults.
77CXXFLAGS="$CXXFLAGS"
78AC_PROG_CXX
79AC_PROG_CC
80
81#Getting user and host info
82username=$(whoami)
83AC_MSG_CHECKING([user ID])
84AC_MSG_RESULT([$username])
85
86hostname=$(uname -n)
87AC_MSG_CHECKING([host name])
88AC_MSG_RESULT([$hostname])
89
90timestamp=$(date)
91AC_MSG_CHECKING([current timestamp])
92AC_MSG_RESULT([$timestamp])
93
94AC_DEFINE_UNQUOTED([STRESSAPPTEST_TIMESTAMP],
95                   "$username @ $hostname on $timestamp",
96                   [Timestamp when ./configure was executed])
97
98#Default cxxflags
99CXXFLAGS="$CXXFLAGS -DCHECKOPTS"
100CXXFLAGS="$CXXFLAGS -Wreturn-type -Wunused -Wuninitialized -Wall -Wno-psabi"
101CXXFLAGS="$CXXFLAGS -O3 -funroll-all-loops  -funroll-loops -DNDEBUG"
102
103# Checks for header files.
104AC_HEADER_DIRENT
105AC_HEADER_STDC
106# Skip malloc.h to prevent redefinition of HAVE_MALLOC_H on some platforms
107AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h unistd.h], [], [AC_MSG_FAILURE([Missing some header files.])])
108AC_CHECK_HEADERS([pthread.h])
109AC_SEARCH_LIBS([pthread_create], [pthread])
110AC_CHECK_HEADERS([libaio.h])
111AC_SEARCH_LIBS([io_setup], [aio])
112AC_CHECK_HEADERS([sys/shm.h])
113AC_SEARCH_LIBS([shm_open], [rt])
114
115# Checks for typedefs, structures, and compiler characteristics.
116AC_HEADER_STDBOOL
117AC_C_CONST
118AC_C_INLINE
119AC_TYPE_PID_T
120AC_C_RESTRICT
121AC_TYPE_SIZE_T
122AC_TYPE_SSIZE_T
123AC_HEADER_TIME
124AC_TYPE_UINT16_T
125AC_C_VOLATILE
126
127
128# Checks for library functions.
129AC_FUNC_CLOSEDIR_VOID
130AC_PROG_GCC_TRADITIONAL
131AC_FUNC_SELECT_ARGTYPES
132AC_TYPE_SIGNAL
133AC_FUNC_STRERROR_R
134AC_FUNC_VPRINTF
135AC_CHECK_FUNCS([ftruncate gettimeofday memset munmap select socket strtol strtoull])
136AC_CHECK_FUNCS([mmap64 posix_memalign rand_r sched_getaffinity])
137
138AC_CONFIG_FILES([Makefile src/Makefile])
139AC_OUTPUT
140