1dnl Prefered emacs editing mode: -*- Autoconf -*- 2dnl 3dnl Process this file with autoconf to produce a configure script. 4dnl 5dnl Copyright (c) 2003, 2004, 2005, 2006, 2007 6dnl Stephane Thiell <mbuna@bugged.org>. All rights reserved. 7dnl 8dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 9dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 10dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 11dnl PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 12dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 13dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 14dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 15dnl OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 16dnl WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 17dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 18dnl ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 19dnl 20dnl $Id: configure.ac,v 1.14 2007/05/24 13:26:43 mbuna Exp $ 21 22AC_INIT([PEAK Library], 0.1.2, [mbuna@bugged.org], [libpeak]) 23AC_CONFIG_SRCDIR([peak/peak.h]) 24AC_CANONICAL_HOST 25AM_INIT_AUTOMAKE 26AM_CONFIG_HEADER([config.h]) 27AM_MAINTAINER_MODE 28 29dnl Assume GCC compatibility. 30cflags='-O2 -g -Wall' 31default_includes=' -I. -I$(srcdir) -I$(top_builddir)' 32includes='-I- -I$(top_builddir)' 33 34case "$host" in 35 *-*-aix*) 36 if test -z "$CC"; then 37 AC_CHECK_PROGS(CC, [cc_r xlc_r gcc cc]) 38 fi 39 if test "$CC" = "cc_r" -o "$CC" = "xlc_r"; then 40 cflags='-O3 -qthreaded -qwarn64' 41 default_includes='-I$(top_builddir)' 42 includes= 43 elif test "$CC" = gcc; then 44 AC_MSG_WARN([GCC not recommended on AIX]) 45 else 46 AC_MSG_WARN([cc_r on AIX not found; threads wont work!]) 47 default_includes='-I$(top_builddir)' 48 includes= 49 fi 50 ;; 51 52 *-*-netbsd*) 53 includes='-I- -I/usr/pkg/include -I$(top_builddir)' 54 PTHREAD_CFLAGS='-I/usr/pkg/include' 55 PTHREAD_LIBS='-L/usr/pkg/lib -lpthread' 56 ;; 57 58 powerpc-*-darwin*) 59 dnl We support the PowerPC IBM compiler on Darwin. 60 if test -z "$CC"; then 61 AC_CHECK_PROGS(CC, [gcc cc_r cc]) 62 fi 63 if test "$CC" = "cc_r" -o "$CC" = "xlc_r"; then 64 cflags='-O3 -qthreaded -qtune=auto' 65 default_includes='-I$(top_builddir)' 66 includes='-I$(ARCH_INCLUDES)' 67 fi 68 ;; 69 70 *) 71 ;; 72esac 73CFLAGS=$cflags 74AC_SUBST(default_includes) 75AC_SUBST(includes) 76 77dnl Check for asm includes 78AC_PROG_LN_S 79AC_MSG_CHECKING(for architecture-dependent code) 80arch=unknown 81case "$host" in 82 powerpc-*) 83 arch=powerpc 84 ;; 85 86 i*86-* | x86-* | x86_64-*) 87 arch=x86 88 ;; 89 90 m68k-*) 91 arch=m68k 92 ;; 93 94 sparc-*) 95 arch=sparc 96 ;; 97 98 ia64-*) 99 arch=ia64 100 ;; 101 102 *) 103 AC_MSG_RESULT([failed!]) 104 AC_MSG_ERROR([libpeak is not available for your architecture yet, 105 please submit a feature request for: 106 ${host}]) 107 ;; 108esac 109AC_CONFIG_LINKS([peak/atomic.h:peak/arch/${arch}/atomic.h 110 peak/spinlock.h:peak/arch/${arch}/spinlock.h]) 111AC_MSG_RESULT([peak/arch/${arch} will be used.]) 112 113AC_SUBST_FILE([atomic_header]) 114atomic_header="peak/atomic.h" 115 116dnl Initialize libtool 117AM_PROG_LIBTOOL 118 119dnl Checks for programs. 120AC_PROG_CC 121AC_PROG_MAKE_SET 122ACX_PTHREAD 123LIBS="$PTHREAD_CFLAGS $PTHREAD_LIBS $LIBS" 124CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 125CC="$PTHREAD_CC" 126 127dnl Checks for header files. 128AC_HEADER_STDC 129AC_CHECK_HEADERS([pthread.h sched.h mach/mach_init.h mach/mach.h]) 130AC_CHECK_HEADERS([mach/semaphore.h mach/task.h signal.h sys/signal.h]) 131AC_CHECK_HEADERS([machine/hal_sysinfo.h sys/atomic_op.h]) 132AC_CHECK_HEADERS([poll.h sys/poll.h sys/devpoll.h sys/epoll.h sys/event.h]) 133AC_CHECK_HEADERS([sys/mpctl.h sys/sysctl.h sys/sysinfo.h]) 134AC_CREATE_STDINT_H([peak/stdint.h]) 135 136dnl Checks for typedefs, structures, and compiler characteristics. 137AC_C_INLINE 138AC_TYPE_SIZE_T 139AC_HEADER_TIME 140AC_STRUCT_TM 141ACX_STRUCT_TZHEAD 142ACX_FD_SETSIZE 143 144dnl Checks for library functions. 145AC_PROG_GCC_TRADITIONAL 146AC_FUNC_ALLOCA 147AC_FUNC_SELECT_ARGTYPES 148 149dnl Do all the checks necessary to figure out -lnsl / -lsocket stuff 150AC_LIBRARY_NET 151 152AC_CHECK_FUNCS([gettimeofday memset strerror]) 153AC_CHECK_FUNCS([getpagesize getsysinfo mpctl sysconf sysctl]) 154AC_CHECK_FUNCS([epoll_create poll kqueue getrlimit getrusage setrlimit]) 155AC_CHECK_FUNCS([semaphore_create semaphore_signal]) 156AC_CHECK_FUNCS([_spin_lock _spin_lock_try _spin_unlock]) 157AC_SEARCH_LIBS([sched_yield], [rt posix4]) 158 159dnl Now choose the engine 160AC_MSG_CHECKING([for event engine module type]) 161AC_ARG_WITH([engine], 162 [ --with-engine=ENGINE Force event engine module type [[automatic]]], 163 [peak_engine=$with_engine]) 164if test -z "$peak_engine" -o x"$peak_engine" = xno; then 165 if test x"$ac_cv_header_sys_event_h" = xyes -a x"$ac_cv_func_kqueue" = xyes; then 166 peak_engine=kqueue 167 elif test x"$ac_cv_header_sys_epoll_h" = xyes; then 168 peak_engine=epoll 169 elif test x"$ac_cv_header_sys_devpoll_h" = xyes; then 170 case "$host" in 171 *-*-linux*) dnl Do not use devpoll on Linux. 172 peak_engine=poll 173 ;; 174 *) 175 peak_engine=devpoll 176 ;; 177 esac 178 elif test x"$ac_cv_header_poll_h" = xyes; then 179 peak_engine=poll 180 else 181 peak_engine=select 182 fi 183fi 184case "$peak_engine" in 185 devpoll) 186 AC_LIBOBJ([engine_mod_devpoll]) 187 AC_DEFINE_UNQUOTED(PEAK_ENGINE_DEVPOLL, 1, [Use engine devpoll.]) 188 ;; 189 epoll) 190 AC_LIBOBJ([engine_mod_epoll]) 191 AC_DEFINE_UNQUOTED(PEAK_ENGINE_EPOLL, 1, [Use engine epoll.]) 192 ;; 193 kqueue) 194 AC_LIBOBJ([engine_mod_kqueue]) 195 AC_DEFINE_UNQUOTED(PEAK_ENGINE_KQUEUE, 1, [Use engine kqueue.]) 196 ;; 197 poll) 198 AC_LIBOBJ([engine_mod_poll]) 199 AC_DEFINE_UNQUOTED(PEAK_ENGINE_POLL, 1, [Use engine poll.]) 200 ;; 201 select) 202 AC_DEFINE_UNQUOTED(PEAK_ENGINE_SELECT, 1, [Use engine select.]) 203 AC_LIBOBJ([engine_mod_select]) 204 ;; 205 *) 206 AC_MSG_ERROR([Unable to find requested engine module type]) 207 ;; 208esac 209AC_MSG_RESULT([$peak_engine]) 210 211 212dnl Now check for --enable-profile 213AC_MSG_CHECKING([whether to enable profiling support (gprof)]) 214AC_ARG_ENABLE([profile], 215[ --enable-profile Enable profiling support (add -pg to CFLAGS)], 216[peak_cv_enable_profile=$enable_profile], 217[AC_CACHE_VAL(peak_cv_enable_profile, 218[peak_cv_enable_profile=no])]) 219AC_MSG_RESULT([$peak_cv_enable_profile]) 220 221if test x"$peak_cv_enable_profile" = xyes; then 222 CFLAGS="-pg $CFLAGS" 223fi 224 225 226dnl Now check for --enable-pedantic 227AC_MSG_CHECKING([whether to enable pedantic compiler warnings]) 228AC_ARG_ENABLE([pedantic], 229[ --enable-pedantic Enable pedantic warnings (add -pedantic to CFLAGS)], 230[peak_cv_enable_pedantic=$enable_pedantic], 231[AC_CACHE_VAL(peak_cv_enable_pedantic, 232[peak_cv_enable_pedantic=no])]) 233AC_MSG_RESULT([$peak_cv_enable_pedantic]) 234 235if test x"$peak_cv_enable_pedantic" = xyes; then 236 CFLAGS="-pedantic $CFLAGS" 237fi 238 239dnl Now check for --enable-uniprocessor-only 240AC_MSG_CHECKING([whether to enable uniprocessor-only code]) 241AC_ARG_ENABLE([uniprocessor-only], 242[ --enable-uniprocessor-only Enable uniprocessor-only code optimization 243 Warning: library binary no more SMP safe 244 [[default=no]]], 245[peak_cv_enable_uniprocessor_only=$enable_uniprocessor_only], 246[AC_CACHE_VAL(peak_cv_enable_uniprocessor_only, 247[peak_cv_enable_uniprocessor_only=no])]) 248AC_MSG_RESULT([$peak_cv_enable_uniprocessor_only]) 249 250if test x"$peak_cv_enable_uniprocessor_only" = xyes; then 251 AC_DEFINE_UNQUOTED(PEAK_CONFIG_UNIPROCESSOR, 1, [Enable uniprocessor-only code.]) 252fi 253 254 255dnl --with-default-maxfds 256peak_default_maxfds=256 257AC_MSG_CHECKING([for default maxfds flavor]) 258AC_ARG_WITH([default-maxfds], 259[ --with-default-maxfds=MAXFDS Default MAXFDS flavor number [[default=256]]], 260[peak_cv_with_default_maxfds=$with_default_maxfds], 261[AC_CACHE_VAL(peak_cv_with_default_maxfds, 262[peak_cv_with_default_maxfds=$peak_default_maxfds])]) 263 264if test x"$peak_cv_with_default_maxfds" = xyes -o x"$peak_cv_with_default_maxfds" = xno; then 265 peak_cv_with_default_maxfds=$peak_default_maxfds 266fi 267AC_MSG_RESULT([$peak_cv_with_default_maxfds]) 268AC_DEFINE_UNQUOTED(PEAK_DEFAULT_FLAVOR_MAXFDS, $peak_cv_with_default_maxfds, 269[Default maxfds flavor number]) 270 271 272if test $peak_engine = "select"; then 273 274dnl --with-select-maxfds allows us to set the number of fds for systems that support 275dnl it and with the select engine only 276AC_MSG_CHECKING([for max fds for select]) 277AC_ARG_WITH([select-maxfds], 278 [ --with-select-maxfds=MAXFDS Maximum number of fds the library can handle 279 (make sense for select engine only) 280 [[default=FD_SETSIZE]]], 281 [select_maxfds=$with_select_maxfds]) 282 283if test -n "$select_maxfds"; then 284 AC_MSG_RESULT([$select_maxfds]) 285 AC_DEFINE_UNQUOTED(PEAK_FD_SETSIZE, $peak_cv_with_select_maxfds, 286 [Maximum number of fds the library can handle with select]) 287else 288 AC_MSG_RESULT([n/a]) 289fi 290 291fi 292 293 294dnl We need another host scan for atomic.h configuration 295ATOMIC_HEADERS= 296case "$host" in 297 *-*-aix*) 298 if test x"$ac_cv_header_atomic_op_h" = xyes; then 299 ATOMIC_HEADERS=[#include <sys/atomic_op.h> /* AIX */] 300 fi 301 ;; 302 i*86-* | x86-*) 303 if test x"$peak_cv_enable_uniprocessor_only" = xyes; then 304 ATOMIC_HEADERS=[#define PEAK_CONFIG_UNIPROCESSOR] 305 fi 306 ;; 307 *) 308 ;; 309esac 310AC_SUBST(ATOMIC_HEADERS) 311 312 313PEAK_CFLAGS= 314PEAK_LIBS=-lpeak 315PEAK_LIBDEPS=$LIBS 316PEAK_VERSION=$PACKAGE_VERSION 317 318AC_CONFIG_LIBCONFIG_IN([peak]) 319 320AC_CONFIG_FILES([Makefile peak-config peak/Makefile tests/Makefile 321 peak/arch/ia64/atomic.h 322 peak/arch/ia64/spinlock.h 323 peak/arch/m68k/atomic.h 324 peak/arch/m68k/spinlock.h 325 peak/arch/powerpc/atomic.h 326 peak/arch/powerpc/spinlock.h 327 peak/arch/sparc/atomic.h 328 peak/arch/sparc/spinlock.h 329 peak/arch/x86/atomic.h 330 peak/arch/x86/spinlock.h]) 331 332AC_OUTPUT 333 334eval e_bindir=${bindir}; eval e_bindir=${e_bindir} 335eval e_includedir=${includedir}; eval e_includedir=${e_includedir} 336eval e_libdir=${libdir}; eval e_libdir=${e_libdir} 337AC_MSG_RESULT([ 338PEAK library compile-time configuration done. 339 340Installation base directory: ${prefix} 341Installation binary directory: ${e_bindir} 342Installation include directory: ${e_includedir} 343Installation library directory: ${e_libdir} 344Architecture: ${arch} 345Engine module: ${peak_engine} 346 347Type 'make' to compile the library 348then 'make check' to compile and run the test suite (optional) 349then 'make install' to install libpeak.]) 350 351