1## ==================================================================== 2## Copyright (c) 1999-2006 Ralf S. Engelschall <rse@engelschall.com> 3## Copyright (c) 1999-2006 The OSSP Project <http://www.ossp.org/> 4## 5## Redistribution and use in source and binary forms, with or without 6## modification, are permitted provided that the following conditions 7## are met: 8## 9## 1. Redistributions of source code must retain the above copyright 10## notice, this list of conditions and the following disclaimer. 11## 12## 2. Redistributions in binary form must reproduce the above copyright 13## notice, this list of conditions and the following disclaimer in 14## the documentation and/or other materials provided with the 15## distribution. 16## 17## 3. All advertising materials mentioning features or use of this 18## software must display the following acknowledgment: 19## "This product includes software developed by 20## Ralf S. Engelschall <rse@engelschall.com>." 21## 22## 4. Redistributions of any form whatsoever must retain the following 23## acknowledgment: 24## "This product includes software developed by 25## Ralf S. Engelschall <rse@engelschall.com>." 26## 27## THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY 28## EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RALF S. ENGELSCHALL OR 31## ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 33## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36## STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 38## OF THE POSSIBILITY OF SUCH DAMAGE. 39## ==================================================================== 40 41dnl ## 42dnl ## Autoconf specification for OSSP mm library 43dnl ## 44 45dnl # 46dnl # standard Autoconf prolog 47dnl # 48 49dnl # autoconf initialization 50AC_PREREQ(2.53)dnl 51AC_INIT(README) 52AC_PREFIX_DEFAULT(/usr/local) 53 54dnl # shtool bootstrap 55SHTOOL="\$(TOP)/shtool" 56AC_SUBST(SHTOOL) 57ac_shtool="./shtool" 58T_MD=`$ac_shtool echo -n -e %B` 59T_ME=`$ac_shtool echo -n -e %b` 60PLATFORM=`${CONFIG_SHELL-/bin/sh} ./config.guess` 61PLATFORM=`${CONFIG_SHELL-/bin/sh} ./config.sub $PLATFORM` 62MM_VERSION_STR="`$ac_shtool version -l c -d long mm_vers.c`" 63AC_SUBST(MM_VERSION_STR) 64 65dnl # friendly header ;-) 66echo "Configuring ${T_MD}OSSP mm${T_ME} (Shared Memory Allocation), Version ${T_MD}${MM_VERSION_STR}${T_ME}" 67echo "Copyright (c) 1999-2006 Ralf S. Engelschall <rse@engelschall.com>" 68echo "Copyright (c) 1999-2006 The OSSP Project <http://www.ossp.org/>" 69echo "Platform: ${T_MD}${PLATFORM}${T_ME}" 70 71dnl # 72dnl # determine build tools and parameters 73dnl # 74 75AC_CONFIGURE_PART(Build Tools) 76AC_PROG_CC 77AC_PROG_CPP 78AC_CHECK_DEBUGGING 79AC_SET_MAKE 80 81sinclude(libtool.m4) 82AC_PROG_LIBTOOL 83 84dnl # support for some special platform/compiler options 85case "$PLATFORM:$CC" in 86 *-hp-hpux*:cc ) CFLAGS="$CFLAGS -Ae +DAportable" ;; 87esac 88 89dnl # 90dnl # determine system parameters 91dnl # 92 93AC_CONFIGURE_PART(Platform Environment) 94 95AC_HAVE_HEADERS(stdio.h stdlib.h string.h dnl 96 errno.h limits.h unistd.h fcntl.h dnl 97 sys/stat.h sys/types.h) 98AC_BEGIN_DECISION([mandatory system headers]) 99AC_IFALLYES(header:stdio.h header:stdlib.h header:string.h dnl 100 header:errno.h header:limits.h header:unistd.h header:fcntl.h dnl 101 header:sys/stat.h header:sys/types.h, 102 AC_DECIDE(fine, [all fine])) 103AC_END_DECISION 104 105AC_HAVE_HEADERS(memory.h) 106AC_CHECK_FUNCS(memcpy memset bcopy) 107AC_CHECK_DEFINE(_POSIX_PATH_MAX, limits.h) 108AC_CHECK_DEFINE(PATH_MAX, limits.h) 109AC_CHECK_DEFINE(_POSIX_CHILD_MAX, limits.h) 110AC_CHECK_DEFINE(CHILD_MAX, limits.h) 111AC_HAVE_HEADERS(sys/param.h) 112AC_CHECK_DEFINE(MAXPATHLEN, sys/param.h) 113 114dnl # some special defines for brain dead platforms 115case $PLATFORM in 116 *-*-sunos* ) AC_DEFINE(MM_OS_SUNOS, 1, [define to 1 for SunOS 4.x support]) ;; 117 BS2000-*-* ) AC_DEFINE(MM_OS_BS2000, 1, [define to 1 for BS2000 support]) ;; 118 *-*-beos* ) AC_DEFINE(MM_OS_BEOS, 1, [define to 1 for BeOS support]) ;; 119esac 120 121dnl # 122dnl # method to determine virtual memory page size 123dnl # 124 125AC_CONFIGURE_PART(Virtual Memory Page Size) 126 127AC_HAVE_HEADERS(unistd.h kernel/OS.h) 128AC_HAVE_FUNCS(getpagesize sysconf) 129AC_CHECK_DEFINE(_SC_PAGESIZE, unistd.h) 130AC_CHECK_DEFINE(B_PAGE_SIZE, kernel/OS.h) 131 132AH_TEMPLATE([MM_VMPS_GETPAGESIZE], [memory page size determination: 4.2BSD getpagesize()]) 133AH_TEMPLATE([MM_VMPS_SYSCONF], [memory page size determination: POSIX.1 sysconf(_SC_PAGESIZE)]) 134AH_TEMPLATE([MM_VMPS_BEOS], [memory page size determination: BeOS B_PAGE_SIZE]) 135AC_BEGIN_DECISION([memory page size determination]) 136AC_IFALLYES(header:unistd.h func:getpagesize, 137 AC_DECIDE(MM_VMPS_GETPAGESIZE, [4.2BSD getpagesize()])) 138AC_IFALLYES(header:unistd.h func:sysconf define:_SC_PAGESIZE, 139 AC_DECIDE(MM_VMPS_SYSCONF, [POSIX.1 sysconf(_SC_PAGESIZE)])) 140AC_IFALLYES(header:kernel/OS.h define:B_PAGE_SIZE, 141 AC_DECIDE(MM_VMPS_BEOS, [BeOS B_PAGE_SIZE])) 142AC_END_DECISION 143AC_DEFINE_UNQUOTED($ac_decision) 144 145dnl # 146dnl # Shared Memory 147dnl # 148 149AC_CONFIGURE_PART(Shared Memory Implementation) 150 151AC_HAVE_HEADERS(sys/mman.h) 152AC_CHECK_DEFINE(MAP_ANON, sys/mman.h) 153AC_HAVE_FUNCS(mmap munmap shm_open shm_unlink) 154AC_TEST_FILE(/dev/zero) 155AC_HAVE_HEADERS(sys/ipc.h sys/shm.h sys/file.h) 156AC_HAVE_FUNCS(shmget shmat shmdt shmctl) 157AC_HAVE_HEADERS(kernel/OS.h) 158AC_HAVE_FUNCS(create_area) 159 160AH_TEMPLATE([MM_SHMT_BEOS], [shared memory allocation method: BeOS areas]) 161AH_TEMPLATE([MM_SHMT_MMFILE], [shared memory allocation method: Classical mmap() on temporary file]) 162AH_TEMPLATE([MM_SHMT_MMPOSX], [shared memory allocation method: mmap() via POSIX.1 shm_open() on temporary file]) 163AH_TEMPLATE([MM_SHMT_MMZERO], [shared memory allocation method: SVR4-style mmap() on /dev/zero]) 164AH_TEMPLATE([MM_SHMT_IPCSHM], [shared memory allocation method: SysV IPC shmget()]) 165AH_TEMPLATE([MM_SHMT_MMANON], [shared memory allocation method: 4.4BSD-style mmap() via MAP_ANON]) 166AC_BEGIN_DECISION([shared memory allocation method]) 167AC_IFALLYES(header:kernel/OS.h func:create_area, 168 AC_DECIDE(MM_SHMT_BEOS, [BeOS areas])) 169AC_IFALLYES(header:sys/mman.h func:mmap func:munmap, 170 AC_DECIDE(MM_SHMT_MMFILE, [Classical mmap() on temporary file])) 171AC_IFALLYES(header:sys/mman.h func:mmap func:munmap func:shm_open func:shm_unlink, 172 AC_DECIDE(MM_SHMT_MMPOSX, [mmap() via POSIX.1 shm_open() on temporary file])) 173AC_IFALLYES(header:sys/mman.h func:mmap func:munmap file:/dev/zero, 174 AC_DECIDE(MM_SHMT_MMZERO, [SVR4-style mmap() on /dev/zero])) 175AC_IFALLYES(header:sys/ipc.h header:sys/shm.h header:sys/file.h dnl 176 func:shmget func:shmat func:shmdt func:shmctl, 177 AC_DECIDE(MM_SHMT_IPCSHM, [SysV IPC shmget()])) 178AC_IFALLYES(header:sys/mman.h func:mmap func:munmap define:MAP_ANON, 179 AC_DECIDE(MM_SHMT_MMANON, [4.4BSD-style mmap() via MAP_ANON])) 180case $PLATFORM in 181 *-*-linux* ) 182 # Unfortunately, Linux has many problems, so we have to do 183 # more granular manual decisions here. The background is: 184 # MM_SHMT_IPCSHM: 185 # Supported under Linux 2.0 and upwards. Works out of the 186 # box on Linux 2.2, but requires an explicitly mounted shm 187 # filesystem under 2.3 only. The requirement for the shm 188 # filesystem should be gone with Linux 2.4. 189 # MM_SHMT_MMANON: 190 # Not allowed up to and included to Linux 2.2. 191 # Should be supported in Linux 2.3, but still hangs there. 192 # Will be supported from Linux 2.4 on the first time really. 193 # MM_SHMT_MMZERO: 194 # Not allowed up to and included to Linux 2.2. 195 # Should be supported in Linux 2.3, but still hangs there. 196 # Will be supported from Linux 2.4 on the first time really. 197 # MM_SHMT_MMFILE: 198 # Works on Linux versions. 199 case $PLATFORM in 200 *-linux1* ) 201 AC_DECISION_FORCE(MM_SHMT_MMFILE) 202 ;; 203 *-*-linux2.0* ) 204 AC_DECISION_FORCE(MM_SHMT_IPCSHM) 205 ;; 206 *-*-linux2.[12]* ) 207 AC_DECISION_FORCE(MM_SHMT_IPCSHM) 208 ;; 209 *-*-linux2.3* ) 210 if test ".`df 2>/dev/null | grep shm`" != .; then 211 AC_DECISION_FORCE(MM_SHMT_IPCSHM) 212 else 213 AC_DECISION_FORCE(MM_SHMT_MMFILE) 214 fi 215 ;; 216 * ) 217 AC_DECISION_OVERRIDE(MM_SHMT_MMFILE MM_SHMT_MMZERO MM_SHMT_MMPOSX MM_SHMT_MMANON MM_SHMT_IPCSHM) 218 esac 219 ;; 220esac 221AC_ARG_WITH(shm,dnl 222[ --with-shm=TYPE force shared memory type: MMFILE MMZERO MMPOSX MMANON IPCSHM BEOS], 223AC_DECISION_FORCE(MM_SHMT_$withval) 224)dnl 225AC_END_DECISION 226AC_DEFINE_UNQUOTED($ac_decision) 227 228AC_CHECK_MAXSEGSIZE($ac_decision) 229 230dnl # 231dnl # Mutex 232dnl # 233 234AC_CONFIGURE_PART(Mutual Exclusion Implementation) 235 236AC_HAVE_HEADERS(sys/ipc.h sys/sem.h sys/file.h) 237AC_HAVE_FUNCS(semget semctl) 238AC_CHECK_DEFINE(LOCK_EX, sys/file.h) 239AC_CHECK_DEFINE(F_SETLK, fcntl.h) 240AC_CHECK_DEFINE(IPC_PRIVATE, sys/ipc.h) 241AC_CHECK_DEFINE(SEM_UNDO, sys/sem.h) 242AC_HAVE_HEADERS(kernel/OS.h) 243AC_CHECK_FUNCS(create_sem) 244 245AC_MSG_CHECKING(whether union semun is defined in sys/sem.h) 246AC_TRY_COMPILE([ 247#include <sys/types.h> 248#include <sys/ipc.h> 249#include <sys/sem.h> 250],[ 251union semun arg; 252semctl(0, 0, 0, arg); 253], 254AC_DEFINE(HAVE_UNION_SEMUN, 1, [define to 1 if you have union semun]) 255msg=yes,dnl 256msg=no) 257AC_MSG_RESULT([$msg]) 258 259AH_TEMPLATE([MM_SEMT_FLOCK], [mutex implementation method: 4.2BSD-style flock() on temporary file]) 260AH_TEMPLATE([MM_SEMT_IPCSEM], [mutex implementation method: SysV IPC semget()]) 261AH_TEMPLATE([MM_SEMT_FCNTL], [mutex implementation method: SVR4-style fcntl() on temporary file]) 262AH_TEMPLATE([MM_SEMT_BEOS], [mutex implementation method: BeOS semaphores]) 263AC_BEGIN_DECISION([mutex implementation method]) 264AC_IFALLYES(header:sys/file.h define:LOCK_EX, 265 AC_DECIDE(MM_SEMT_FLOCK, [4.2BSD-style flock() on temporary file])) 266AC_IFALLYES(header:sys/ipc.h header:sys/sem.h header:sys/file.h dnl 267 func:semget func:semctl, 268 AC_DECIDE(MM_SEMT_IPCSEM, [SysV IPC semget()])) 269AC_IFALLYES(header:fcntl.h define:F_SETLK, 270 AC_DECIDE(MM_SEMT_FCNTL, [SVR4-style fcntl() on temporary file])) 271AC_IFALLYES(header:kernel/OS.h func:create_sem, 272 AC_DECIDE(MM_SEMT_BEOS, [BeOS semaphores])) 273AC_ARG_WITH(sem,dnl 274[ --with-sem=TYPE force semaphore type: FLOCK FCNTL IPCSEM BEOS], 275AC_DECISION_FORCE(MM_SEMT_$withval) 276)dnl 277AC_END_DECISION 278AC_DEFINE_UNQUOTED($ac_decision) 279 280dnl # 281dnl # finally: source file substitution... 282dnl # 283 284AC_CONFIGURE_PART(Output Substitution) 285 286AC_CONFIG_HEADERS(config.h) 287AC_CONFIG_FILES([Makefile mm-config]) 288AC_CONFIG_COMMANDS([adjustment], [chmod a+x mm-config]) 289AC_OUTPUT 290 291