1# Source of configuration for Kyoto Cabinet 2 3 4 5#================================================================ 6# Generic Settings 7#================================================================ 8 9# Package name 10AC_INIT(kyotocabinet, 1.2.79) 11 12# Package information 13MYLIBVER=16 14MYLIBREV=14 15MYFORMATVER=6 16 17# Targets 18MYHEADERFILES="kccommon.h kcutil.h kcthread.h kcfile.h" 19MYHEADERFILES="$MYHEADERFILES kccompress.h kccompare.h kcmap.h kcregex.h" 20MYHEADERFILES="$MYHEADERFILES kcdb.h kcplantdb.h kcprotodb.h kcstashdb.h kccachedb.h" 21MYHEADERFILES="$MYHEADERFILES kchashdb.h kcdirdb.h kctextdb.h kcpolydb.h kcdbext.h kclangc.h" 22MYLIBRARYFILES="libkyotocabinet.a" 23MYLIBOBJFILES="kcutil.o kcthread.o kcfile.o kccompress.o kccompare.o kcmap.o kcregex.o" 24MYLIBOBJFILES="$MYLIBOBJFILES kcdb.o kcplantdb.o kcprotodb.o kcstashdb.o kccachedb.o" 25MYLIBOBJFILES="$MYLIBOBJFILES kchashdb.o kcdirdb.o kctextdb.o kcpolydb.o kcdbext.o kclangc.o" 26MYCOMMANDFILES="kcutiltest kcutilmgr kcprototest kcstashtest kccachetest kcgrasstest" 27MYCOMMANDFILES="$MYCOMMANDFILES kchashtest kchashmgr kctreetest kctreemgr" 28MYCOMMANDFILES="$MYCOMMANDFILES kcdirtest kcdirmgr kcforesttest kcforestmgr" 29MYCOMMANDFILES="$MYCOMMANDFILES kcpolytest kcpolymgr kclangctest" 30MYMAN1FILES="kcutiltest.1 kcutilmgr.1 kcprototest.1 kcstashtest.1 kccachetest.1 kcgrasstest.1" 31MYMAN1FILES="$MYMAN1FILES kchashtest.1 kchashmgr.1 kctreetest.1 kctreemgr.1" 32MYMAN1FILES="$MYMAN1FILES kcdirtest.1 kcdirmgr.1 kcforesttest.1 kcforestmgr.1" 33MYMAN1FILES="$MYMAN1FILES kcpolytest.1 kcpolymgr.1 kclangctest.1" 34MYDOCUMENTFILES="COPYING FOSSEXCEPTION ChangeLog doc kyotocabinet.idl" 35MYPCFILES="kyotocabinet.pc" 36 37# Building flags 38MYCFLAGS="-Wall -ansi -pedantic -fPIC -fsigned-char -g0 -O2" 39MYCXXFLAGS="-Wall -fPIC -fsigned-char -g0 -O2" 40MYCPPFLAGS="-I. -I\$(INCLUDEDIR) -I/usr/local/include" 41MYCPPFLAGS="$MYCPPFLAGS -DNDEBUG -D_GNU_SOURCE=1" 42MYCPPFLAGS="$MYCPPFLAGS -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D__EXTENSIONS__" 43MYLDFLAGS="-L. -L\$(LIBDIR) -L/usr/local/lib" 44MYCMDLDFLAGS="" 45MYCMDLIBS="" 46MYLDLIBPATH="" 47MYLDLIBPATHENV="LD_LIBRARY_PATH" 48MYPOSTCMD="true" 49 50# Building paths 51PATH=".:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:$PATH" 52CPATH=".:/usr/local/include:$CPATH" 53LIBRARY_PATH=".:/usr/local/lib:$LIBRARY_PATH" 54LD_LIBRARY_PATH=".:/usr/local/lib:$LD_LIBRARY_PATH" 55PKG_CONFIG_PATH=".:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" 56export PATH CPATH LIBRARY_PATH LD_LIBRARY_PATH PKG_CONFIG_PATH 57 58 59 60#================================================================ 61# Options 62#================================================================ 63 64# Internal variables 65enables="" 66is_static="" 67 68# Debug mode 69AC_ARG_ENABLE(debug, 70 AC_HELP_STRING([--enable-debug], [build for debugging])) 71if test "$enable_debug" = "yes" 72then 73 MYCFLAGS="-Wall -ansi -pedantic -fPIC -fsigned-char -g -O0" 74 MYCXXFLAGS="-Wall -fPIC -fsigned-char -g -O0" 75 MYCPPFLAGS="$MYCPPFLAGS -UNDEBUG -D_KCDEBUG" 76 is_static="yes" 77 enables="$enables (debug)" 78fi 79 80# Developping mode 81AC_ARG_ENABLE(devel, 82 AC_HELP_STRING([--enable-devel], [build for development])) 83if test "$enable_devel" = "yes" 84then 85 MYCFLAGS="-Wall -Wextra -Wno-unused-parameter" 86 MYCFLAGS="$MYCFLAGS -ansi -pedantic -fPIC -fsigned-char -O2 -fno-inline -pipe" 87 MYCXXFLAGS="-Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor" 88 MYCXXFLAGS="$MYCXXFLAGS -fPIC -fsigned-char -g -O2 -fno-inline -pipe" 89 MYCPPFLAGS="$MYCPPFLAGS -UNDEBUG -D_KCDEBUG" 90 enables="$enables (devel)" 91fi 92 93# Disable optimization 94AC_ARG_ENABLE(opt, 95 AC_HELP_STRING([--disable-opt], [build without optimization])) 96if test "$enable_opt" = "no" 97then 98 MYCFLAGS="$MYCFLAGS -O0" 99 MYCXXFLAGS="$MYCXXFLAGS -O0" 100 enables="$enables (no-opt)" 101fi 102 103# Profiling mode 104AC_ARG_ENABLE(profile, 105 AC_HELP_STRING([--enable-profile], [build for profiling])) 106if test "$enable_profile" = "yes" 107then 108 MYCXXFLAGS="-Wall -fPIC -fsigned-char -g -pg -O2 -fno-inline -pipe" 109 enables="$enables (profile)" 110fi 111 112# Micro yield mode 113AC_ARG_ENABLE(uyield, 114 AC_HELP_STRING([--enable-uyield], [build for detecting race conditions])) 115if test "$enable_uyield" = "yes" 116then 117 MYCPPFLAGS="$MYCPPFLAGS -UNDEBUG -D_KCUYIELD" 118 enables="$enables (uyield)" 119fi 120 121# Static mode 122AC_ARG_ENABLE(static, 123 AC_HELP_STRING([--enable-static], [build by static linking])) 124if test "$enable_static" = "yes" 125then 126 is_static="yes" 127 enables="$enables (static)" 128fi 129 130# Disable shared object 131AC_ARG_ENABLE(shared, 132 AC_HELP_STRING([--disable-shared], [avoid to build shared libraries])) 133if test "$enable_shared" = "no" 134then 135 enables="$enables (no-shared)" 136fi 137 138# Disable atomic operations 139AC_ARG_ENABLE(atomic, 140 AC_HELP_STRING([--disable-atomic], [build without atomic operations])) 141if test "$enable_atomic" = "no" 142then 143 enables="$enables (no-atomic)" 144fi 145 146# Disable ZLIB compression 147AC_ARG_ENABLE(zlib, 148 AC_HELP_STRING([--disable-zlib], [build without ZLIB compression])) 149if test "$enable_zlib" = "no" 150then 151 enables="$enables (no-zlib)" 152else 153 MYCPPFLAGS="$MYCPPFLAGS -D_MYZLIB" 154fi 155 156# Enable LZO compression 157AC_ARG_ENABLE(lzo, 158 AC_HELP_STRING([--enable-lzo], [build with LZO compression])) 159if test "$enable_lzo" = "yes" 160then 161 MYCPPFLAGS="$MYCPPFLAGS -D_MYLZO" 162 enables="$enables (lzo)" 163fi 164 165# Enable LZMA compression 166AC_ARG_ENABLE(lzma, 167 AC_HELP_STRING([--enable-lzma], [build with LZMA compression])) 168if test "$enable_lzma" = "yes" 169then 170 MYCPPFLAGS="$MYCPPFLAGS -D_MYLZMA" 171 enables="$enables (lzma)" 172fi 173 174# Messages 175printf '#================================================================\n' 176printf '# Configuring Kyoto Cabinet version %s%s.\n' "$PACKAGE_VERSION" "$enables" 177printf '#================================================================\n' 178 179 180 181#================================================================ 182# Checking Commands and Libraries 183#================================================================ 184 185# C and C++ compilers 186AC_PROG_CC 187AC_PROG_CXX 188AC_LANG(C++) 189 190# Reset variables 191if test "$GCC" != "yes" 192then 193 AC_MSG_WARN([another compiler except for GCC was detected]) 194 MYCFLAGS="" 195 MYCXXFLAGS="" 196fi 197test -n "$CFLAGS" && MYCFLAGS="$CFLAGS $MYCFLAGS" 198test -n "$CXXFLAGS" && MYCXXFLAGS="$CXXFLAGS $MYCXXFLAGS" 199test -n "$CPPFLAGS" && MYCPPFLAGS="$CPPFLAGS $MYCPPFLAGS" 200test -n "$LDFLAGS" && MYLDFLAGS="$LDFLAGS $MYLDFLAGS" 201 202# Byte order 203AC_C_BIGENDIAN(MYCPPFLAGS="$MYCPPFLAGS -D_MYBIGEND") 204 205# System-depending optimization 206printf 'checking for 64-bit availability... ' 207if printf 'main() {}' | $CC -xc -m64 -o config.tmp - >config.tmp 2>&1 208then 209 MYCFLAGS="-m64 $MYCFLAGS" 210 MYCXXFLAGS="-m64 $MYCXXFLAGS" 211 printf 'yes\n' 212else 213 printf 'no\n' 214fi 215if test "$enable_opt" != "no" 216then 217 printf 'checking for CPU optimization availability... ' 218 if printf 'main() {}' | $CC -xc -march=native -o config.tmp - >config.tmp 2>&1 219 then 220 MYCFLAGS="-march=native $MYCFLAGS" 221 MYCXXFLAGS="-march=native $MYCXXFLAGS" 222 printf 'yes\n' 223 else 224 printf 'no\n' 225 fi 226fi 227printf 'checking for useless warnings... ' 228if printf 'main() {}' | $CC -xc \ 229 -Wno-unused-but-set-variable -Wno-unused-but-set-parameter -o config.tmp - >config.tmp 2>&1 230then 231 MYCFLAGS="$MYCFLAGS -Wno-unused-but-set-variable -Wno-unused-but-set-parameter" 232 MYCXXFLAGS="$MYCXXFLAGS -Wno-unused-but-set-variable -Wno-unused-but-set-parameter" 233 printf 'yes\n' 234else 235 printf 'no\n' 236fi 237 238# Atomic operations 239if test "$enable_atomic" != "no" 240then 241 printf 'checking for atomic operations... ' 242 AC_TRY_COMPILE([], [__sync_fetch_and_add], [MYGCCATOMIC=yes], [MYGCCATOMIC=no]) 243 if test "$MYGCCATOMIC" = "yes" 244 then 245 MYCPPFLAGS="$MYCPPFLAGS -D_MYGCCATOMIC" 246 printf 'yes\n' 247 else 248 printf 'no\n' 249 fi 250fi 251 252# Underlying libraries 253AC_CHECK_LIB(c, main) 254AC_CHECK_LIB(m, main) 255AC_CHECK_LIB(pthread, main) 256AC_CHECK_LIB(rt, main) 257AC_CHECK_LIB(stdc++, main) 258AC_CHECK_LIB(regex, main) 259if test "$enable_zlib" != "no" 260then 261 AC_CHECK_LIB(z, main) 262fi 263if test "$enable_lzo" = "yes" 264then 265 AC_CHECK_LIB(lzo2, main) 266fi 267if test "$enable_lzma" = "yes" 268then 269 AC_CHECK_LIB(lzma, main) 270fi 271AC_CHECK_LIB(kyotocabinet, main, AC_MSG_WARN([old version of Kyoto Cabinet was detected])) 272MYLDLIBPATH="$LD_LIBRARY_PATH" 273 274# Necessary headers 275AC_CHECK_HEADER(stdlib.h, true, AC_MSG_ERROR([stdlib.h is required])) 276AC_CHECK_HEADER(stdint.h, true, AC_MSG_ERROR([stdint.h is required])) 277AC_CHECK_HEADER(unistd.h, true, AC_MSG_ERROR([unistd.h is required])) 278AC_CHECK_HEADER(fcntl.h, true, AC_MSG_ERROR([fcntl.h is required])) 279AC_CHECK_HEADER(dirent.h, true, AC_MSG_ERROR([dirent.h is required])) 280AC_CHECK_HEADER(pthread.h, true, AC_MSG_ERROR([pthread.h is required])) 281AC_CHECK_HEADER(regex.h, true, AC_MSG_ERROR([regex.h is required])) 282if test "$enable_zlib" != "no" 283then 284 AC_CHECK_HEADER(zlib.h, true, AC_MSG_ERROR([zlib.h is required])) 285fi 286if test "$enable_lzo" = "yes" 287then 288 AC_CHECK_HEADER(lzo/lzo1x.h, true, AC_MSG_ERROR([lzo/lzo1x.h is required])) 289fi 290if test "$enable_lzma" = "yes" 291then 292 AC_CHECK_HEADER(lzma.h, true, AC_MSG_ERROR([lzma.h is required])) 293fi 294 295# Static linking 296if test "$is_static" = "yes" 297then 298 MYCMDLDFLAGS="$MYCMDLDFLAGS -static" 299 MYCMDLIBS="$MYCMDLIBS $LIBS" 300fi 301 302# As-needed linking 303if uname | grep Linux >config.tmp 304then 305 MYLDFLAGS="$MYLDFLAGS -Wl,-rpath-link,.:/usr/local/lib:$MYLDLIBPATH" 306 MYLDFLAGS="$MYLDFLAGS -Wl,--as-needed" 307else 308 MYCMDLIBS="$MYCMDLIBS $LIBS" 309fi 310 311# Shared libraries 312if test "$enable_shared" != "no" && test "$enable_profile" != "yes" 313then 314 if uname | grep Darwin >config.tmp 315 then 316 MYLIBRARYFILES="$MYLIBRARYFILES libkyotocabinet.$MYLIBVER.$MYLIBREV.0.dylib" 317 MYLIBRARYFILES="$MYLIBRARYFILES libkyotocabinet.$MYLIBVER.dylib" 318 MYLIBRARYFILES="$MYLIBRARYFILES libkyotocabinet.dylib" 319 MYLDLIBPATHENV="DYLD_LIBRARY_PATH" 320 else 321 MYLIBRARYFILES="$MYLIBRARYFILES libkyotocabinet.so.$MYLIBVER.$MYLIBREV.0" 322 MYLIBRARYFILES="$MYLIBRARYFILES libkyotocabinet.so.$MYLIBVER" 323 MYLIBRARYFILES="$MYLIBRARYFILES libkyotocabinet.so" 324 fi 325fi 326 327# Work around of bugs of some environments 328if uname | grep Darwin >config.tmp 329then 330 MYCFLAGS="$MYCFLAGS -Os" 331 MYCXXFLAGS="$MYCXXFLAGS -Os" 332fi 333 334 335 336#================================================================ 337# Generic Settings 338#================================================================ 339 340# Export variables 341AC_SUBST(MYLIBVER) 342AC_SUBST(MYLIBREV) 343AC_SUBST(MYFORMATVER) 344AC_SUBST(MYHEADERFILES) 345AC_SUBST(MYLIBRARYFILES) 346AC_SUBST(MYLIBOBJFILES) 347AC_SUBST(MYCOMMANDFILES) 348AC_SUBST(MYMAN1FILES) 349AC_SUBST(MYDOCUMENTFILES) 350AC_SUBST(MYPCFILES) 351AC_SUBST(MYCFLAGS) 352AC_SUBST(MYCXXFLAGS) 353AC_SUBST(MYCPPFLAGS) 354AC_SUBST(MYLDFLAGS) 355AC_SUBST(MYCMDLDFLAGS) 356AC_SUBST(MYCMDLIBS) 357AC_SUBST(MYLDLIBPATH) 358AC_SUBST(MYLDLIBPATHENV) 359AC_SUBST(MYPOSTCMD) 360 361# Targets 362AC_OUTPUT(Makefile kyotocabinet.pc) 363 364# Messages 365printf '#================================================================\n' 366printf '# Ready to make.\n' 367printf '#================================================================\n' 368 369 370 371# END OF FILE 372