1# -*- Autoconf -*- 2# Process this file with autoconf to produce a configure script. 3 4AC_PREREQ(2.62) 5AC_INIT(mosh, 0.2.7, higepon@users.sourceforge.jp) 6AC_CANONICAL_SYSTEM 7 8AM_INIT_AUTOMAKE([foreign]) 9AC_CONFIG_SRCDIR([src/VM.h]) 10AC_CONFIG_HEADER([src/config.h]) 11 12# we don't like default CFLAGS(-O2 -g). 13AC_SUBST(CFLAGS) 14if test "" = "$CFLAGS"; then 15 CFLAGS=" " 16fi 17 18AC_SUBST(CXXFLAGS) 19if test "" = "$CXXFLAGS"; then 20 CXXFLAGS=" " 21fi 22 23AC_SUBST(MOSH_LIB_PATH, "${datadir}/mosh-$PACKAGE_VERSION") 24 25# Checks for programs. 26dnl AC_PROG_LIBTOOL # use LTLIBRARIES 27dnl AC_LIBTOOL_DLOPEN # use dlopen 28AM_PROG_AS 29AC_PROG_CXX 30AC_PROG_CC 31AC_PROG_MAKE_SET 32AC_PROG_RANLIB 33 34AC_CHECK_PROGS(NATURALDOCS, 35 [naturaldocs NaturalDocs], 36 [perl ~/NaturalDocs-1.4/NaturalDocs]) 37 38AC_ARG_WITH([r6rs-doc], 39 AC_HELP_STRING([--with-r6rs-doc=PATH], 40 [build R6RS docs from TeX source at PATH]), 41 AC_SUBST([R6RS_DOC_PATH], "$withval"), 42 AC_SUBST([R6RS_DOC_PATH], "$HOME/Desktop/r6rs")) 43 44# Prerequisites 45 46LOCAL_CONFIGURE_ARGS="--host=$host --build=$build" 47 48### GMP or MPIR(gmp API) 49 50AC_CHECK_LIB(gmp, __gmpz_init, , 51 [AC_MSG_ERROR([GNU MP not found, see http://gmplib.org/.])]) 52 53### OpenSSL (optional) 54have_openssl=no 55AC_TRY_LINK([#include <openssl/opensslv.h>], 56 [ return OPENSSL_VERSION_NUMBER; ], 57 [ 58 have_openssl=1 59 LIBS="-lssl -lcrypto $LIBS" 60 ], 61 [ 62 AC_MSG_WARN("libssl not found. OpenSSL Disabled...") 63 have_openssl=0 64 ]) 65 66HAVE_OPENSSL=$have_openssl 67AC_DEFINE_UNQUOTED([HAVE_OPENSSL], $have_openssl, [Do we have openssl?]) 68AC_SUBST([HAVE_OPENSSL]) 69 70### Oniguruma 5 71## we need oniguruma 5.x for unicode support 72 73have_onig=no 74local_onig_build=no 75LOCAL_ONIG="" 76 77# option0: use onig-config in PATH 78if test $have_onig = no; then 79 ONIGCONFIG="" 80 AC_PATH_PROG(ONIGCONFIG,onig-config) 81 if test "" = "$ONIGCONFIG"; then 82 # put some warning here.. 83 ONIG_CFLAGS="" 84 ONIG_LIBS="" 85 else 86 ONIG_CFLAGS=`$ONIGCONFIG --cflags` 87 ONIG_LIBS=`$ONIGCONFIG --libs` 88 saved_cflags=$CFLAGS 89 saved_libs=$LIBS 90 CFLAGS="$CFLAGS $ONIG_CFLAGS" 91 LIBS="$LIBS $ONIG_LIBS" 92 AC_CHECK_LIB([onig],[regexec],have_onig=yes,have_onig=no) 93 CFLAGS=$saved_cflags 94 LIBS=$saved_libs 95 fi 96fi 97 98# option1 was disabled (not reliable in some Linux variants) 99dnl # option1: try to link with current configuration 100dnl if test $have_onig = "no" ; then 101dnl AC_CHECK_LIB([onig],[regexec],[LIBS="$LIBS -lonig" have_onig="yes"]) 102dnl fi 103 104if test $have_onig = "no" ; then 105 AC_MSG_ERROR([oniguruma not found, mosh requires oniguruma 5.x]) 106fi 107 108AM_CONDITIONAL(BUILD_LOCAL_ONIG,test $local_onig_build = "yes") 109 110AC_SUBST(ONIG_CFLAGS) 111AC_SUBST(ONIG_LIBS) 112 113# gtest requires POSIX regexp and this will conflict oniguruma 114# We will define -D ONIG_ESCAPE_REGEX_T_COLLISION for this 115 116AC_SUBST(LOCAL_CONFIGURE_ARGS) 117 118## ~prereq. 119 120AC_ARG_ENABLE(profiler, [ --enable-profiler Build with profiler feature [default=yes]], ,[enable_profiler=yes]) 121AC_MSG_CHECKING(whether to enable profiler) 122if test "$enable_profiler" = "yes"; then 123 case $host in 124 *mingw*) 125 AC_MSG_ERROR([Profiling is not supported on MinGW hosts]) 126 ;; 127 *) 128 AC_DEFINE(ENABLE_PROFILER, 1, enable -p option for profiling) 129 ;; 130 esac 131fi 132AC_MSG_RESULT([$enable_profiler]) 133 134dnl AC_MSG_RESULT([$host_os]) 135dnl AC_MSG_RESULT([$host]) 136dnl AC_MSG_RESULT([$target]) 137 138case $host in 139 *darwin*) 140 SHLIB_SO_LDFLAGS="-dynamiclib" 141 ;; 142 *) 143 SHLIB_SO_LDFLAGS="-shared" 144 ;; 145esac 146AC_SUBST(SHLIB_SO_LDFLAGS) 147 148# Checks for libraries. 149have_tr1_hashes=0 150have_ext_hashes=0 151AC_LANG([C++]) 152AC_MSG_CHECKING([for hashed associative containers]) 153AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 154#include <tr1/unordered_map> 155int main(int, char **) 156{ 157 std::tr1::unordered_map<int, int> m; 158 m.insert(std::make_pair(1, 2)); 159} 160]])], 161[have_tr1_hashes=1], 162[have_tr1_hashes=0]) 163 164AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 165#include <ext/hash_map> 166int main(int, char **) 167{ 168 __gnu_cxx::hash_map<int, int> m; 169 m.insert(std::make_pair(1, 2)); 170} 171]])], 172[have_ext_hashes=1], 173[have_ext_hashes=0]) 174AC_MSG_RESULT([$have_ext_hashes]) 175 176HAVE_TR1_HASHES=$have_tr1_hashes 177AC_DEFINE_UNQUOTED([HAVE_TR1_HASHES], $have_tr1_hashes, [Do we have std::tr1:: hashes?]) 178AC_SUBST([HAVE_TR1_HASHES]) 179HAVE_EXT_HASHES=$have_ext_hashes 180AC_DEFINE_UNQUOTED([HAVE_EXT_HASHES], $have_ext_hashes, [Do we have __gnu_cxx:: hashes?]) 181AC_SUBST([HAVE_EXT_HASHES]) 182 183# Checks for OS 184case "$target_os" in 185 *linux*) 186 AC_DEFINE([MOSH_HOST_OS], ["linux"], [define operating-system]) 187 ;; 188 *bsd*) 189 AC_DEFINE([MOSH_HOST_OS], ["bsd"], [define operating-system]) 190 ;; 191 *darwin*) 192 AC_DEFINE([MOSH_HOST_OS], ["darwin"], [define operating-system]) 193 ;; 194 *mingw*) 195 AC_DEFINE([MOSH_HOST_OS], ["win32"], [define operating-system]) 196 ;; 197 *cygwin*) 198 AC_DEFINE([MOSH_HOST_OS], ["cygwin"], [define operating-system]) 199 ;; 200 *) 201 AC_DEFINE([MOSH_HOST_OS], ["unknown"], [define operating-system]) 202 ;; 203esac 204 205MOSH_GENERIC_OPTS="-O3" 206MOSH_INTEL_OPTS="$MOSH_GENERIC_OPTS -momit-leaf-frame-pointer -fomit-frame-pointer" 207 208# Checks for O/S specific features 209 210has_gc_pthread=false 211has_gc_darwin=false 212has_gc_win32=false 213AC_MSG_CHECKING([check threads]) 214case "$target_os" in 215*darwin*) 216 AC_DEFINE(GC_DARWIN_THREADS,1,[Define to use Darwin threads]) 217 has_gc_pthread=true 218 has_gc_darwin=true 219 ;; 220*linux*) 221 AC_DEFINE(GC_LINUX_THREADS,1,[Define to use Linux threads]) 222 AC_DEFINE(_REENTRANT,1,[Define to use reentrant libc]) 223 has_gc_pthread=true 224 ;; 225freebsd*) 226 AC_DEFINE(GC_FREEBSD_THREADS,1,[Define to use FreeBSD threads]) 227 has_gc_pthread=true 228 ;; 229netbsd*) 230 AC_DEFINE(GC_NETBSD_THREADS,1,[Define to use NetBSD threads]) 231 has_gc_pthread=true 232 ;; 233cygwin) 234 AC_DEFINE(GC_THREADS,1,[Define to use generic thread support]) 235 AC_DEFINE(_REENTRANT,1,[Define to use reentrant libc]) 236 has_gc_pthread=true 237 has_gc_win32=true 238 ;; 239 240mingw*) 241 AC_DEFINE(GC_THREADS,1,[Define to use generic thread support]) # FIXME 242 AC_DEFINE(_REENTRANT,1,[Define to use reentrant libc]) # FIXME 243 has_gc_win32=true 244 ;; 245*) 246 AC_MSG_ERROR([Please modify configure.ac for $target_os]) 247 ;; 248esac 249 250AM_CONDITIONAL(GC_PTHREAD, $has_gc_pthread) 251AM_CONDITIONAL(GC_DARWIN, $has_gc_darwin) 252AM_CONDITIONAL(GC_WIN32, $has_gc_win32) 253# Checks for cpu 254AC_MSG_CHECKING([for supported architecture]) 255MOSH_LDADD_ARCH="-ldl -lpthread" 256case "$host_cpu" in 257i[[3456]]86|pentium) 258 arch=i386 259 case "$target_os" in 260 *darwin*) 261 if test -n "`system_profiler |grep 'Intel Core 2'`" ; then 262 MOSH_OPTS="$MOSH_INTEL_OPTS -march=pentium-m -msse2 -mfpmath=sse" 263 else 264 MOSH_OPTS="$MOSH_INTEL_OPTS -march=$host_cpu" 265 fi 266 ;; 267 *linux*) 268 if test -n "`grep 'Core(TM)2 CPU' /proc/cpuinfo`" ; then 269 MOSH_OPTS="$MOSH_INTEL_OPTS -march=pentium-m -msse3 -mfpmath=sse" 270 else 271 if test -n "`grep 'ssse3' /proc/cpuinfo`" ; then 272 MOSH_OPTS="$MOSH_INTEL_OPTS -march=$host_cpu -msse3 -mfpmath=sse" 273 else 274 if test -n "`grep 'sse2' /proc/cpuinfo`" ; then 275 MOSH_OPTS="$MOSH_INTEL_OPTS -march=$host_cpu -msse2 -mfpmath=sse" 276 else 277 if test -n "`grep 'sse' /proc/cpuinfo`" ; then 278 MOSH_OPTS="$MOSH_INTEL_OPTS -march=$host_cpu -msse -mfpmath=sse" 279 else 280 MOSH_OPTS="$MOSH_INTEL_OPTS -march=$host_cpu" 281 fi 282 fi 283 fi 284 fi 285 ;; 286 *freebsd*) 287 MOSH_OPTS="$MOSH_INTEL_OPTS" 288 MOSH_LDADD_ARCH="-lpthread" 289 ;; 290 *netbsd*) 291 MOSH_OPTS="$MOSH_INTEL_OPTS" 292 MOSH_LDADD_ARCH="-lpthread" 293 ;; 294 *mingw*) #FIXME: now broken 295 MOSH_OPTS="$MOSH_GENERIC_OPTS -mtune=generic -DMOSH_MINGW32 -D_UNICODE -DUNICODE -DWINVER=0x501 -D_WIN32_WINNT=0x501 -static-libgcc -static-libstdc++ -fwide-exec-charset=ucs-4le" #forcing WinXP & Gcc >= 4.5 296 MOSH_LDADD_ARCH="-lshlwapi -lshell32 -lws2_32" 297 ;; 298 *cygwin*) 299 MOSH_OPTS="$MOSH_INTEL_OPTS -mtune=generic -fwide-exec-charset=ucs-4le" 300 MOSH_LDADD_ARCH="-ldl -lpthread" 301 ;; 302 303 *) 304 MOSH_OPTS="-O3 -momit-leaf-frame-pointer -fomit-frame-pointer" # -mfpmath=sse -msse3 -march=$host_cpu 305 ;; 306 esac 307 308 AC_MSG_RESULT([$host_cpu]) 309 AC_DEFINE([ARCH_IA32], 1, [Define for the IA32 architecture.]) 310 AM_CONDITIONAL(FFI_I386, true) 311 AM_CONDITIONAL(FFI_X86_64, false) 312 ;; 313 x86?64*|amd64) 314 arch=x86_64 315 AC_DEFINE([ARCH_X86_64], 1, [Define for the AMD x86-64 architecture.]) 316 AM_CONDITIONAL(FFI_I386, false) 317 AM_CONDITIONAL(FFI_X86_64, true) 318 case "$target_os" in 319 *darwin*) 320 AC_MSG_RESULT([x86_64]) 321 MOSH_OPTS="-O3" 322 ;; 323 *freebsd*) 324 AC_MSG_RESULT([x86_64(FreeBSD amd64)]) 325 MOSH_OPTS="$MOSH_INTEL_OPTS" 326 MOSH_LDADD_ARCH="-lpthread" 327 ;; 328 *netbsd*) 329 AC_MSG_RESULT([x86_64(NetBSD amd64)]) 330 MOSH_OPTS="$MOSH_INTEL_OPTS" 331 MOSH_LDADD_ARCH="-lpthread" 332 ;; 333 *) 334 MOSH_OPTS="-O3 -momit-leaf-frame-pointer -fomit-frame-pointer" 335 AC_MSG_RESULT([x86_64]) 336 ;; 337 esac 338 ;; 339 *) 340 AC_MSG_RESULT([$host_cpu]) 341 MOSH_OPTS="-O3" 342 AC_MSG_WARN([architecture $host_cpu is not supported, but may work other than FFI]) 343 AC_DEFINE([ARCH_UNKNOWN], 1, [Define for the unknown architecture.]) 344 AM_CONDITIONAL(FFI_I386, false) 345 AM_CONDITIONAL(FFI_X86_64, false) 346 ;; 347 esac 348 349AC_MSG_CHECKING([whether to enable MinGW support]) 350case "$host_os" in 351*mingw*) #FIXME: now broken 352 mingw32=true 353 AC_MSG_RESULT([yes]) 354 AC_MSG_WARN([MinGW support with this configure is now broken. Use CMake instead]) 355 AC_CHECK_TOOL(WINDRES, windres) 356 ac_configure_args="$ac_configure_args --disable-shared --enable-threads=win32 CFLAGS=\"$CFLAGS -DGC_THREADS\" win32_threads=true" 357 358 ;; 359*) 360 mingw32=false 361 AC_MSG_RESULT([no]) 362 ;; 363esac 364AM_CONDITIONAL(MINGW32, test x$mingw32 = xtrue) 365 366AC_MSG_CHECKING([whether to enable kqueue support]) 367case "$host_os" in 368freebsd*) 369 kqueuestub=true 370 AC_MSG_RESULT([yes]) 371 AC_DEFINE([HAVE_KQUEUE], 1, [BSD Kqueue support.]) 372 373 ;; 374*) 375 kqueuestub=false 376 AC_MSG_RESULT([no]) 377 ;; 378esac 379AM_CONDITIONAL(KQUEUE, test x$kqueuestub = xtrue) 380 381AC_MSG_CHECKING([whether to enable ptrace support]) 382case "$host_os" in 383freebsd*) 384 ptracestub_common=true 385 AC_MSG_RESULT([yes(common)]) 386 AC_DEFINE([HAVE_PTRACE_COMMON], 1, [Common ptrace support.]) 387 388 ;; 389*) 390 ptracestub_common=false 391 AC_MSG_RESULT([no]) 392 ;; 393esac 394AM_CONDITIONAL(PTRACE_COMMON, test x$ptracestub_common = xtrue) 395 396AC_SUBST(MOSH_OPTS) 397AC_SUBST(MOSH_LDADD_ARCH) 398 399 400AC_ARG_WITH(mysql, 401 AC_HELP_STRING([--with-mysql=FULL_PATH_TO_libmysqlclient]), 402 [ 403 AC_SUBST(PATH_TO_MYSQLCLIENT, "$withval") 404 ], 405 [ 406 AC_SUBST(PATH_TO_MYSQLCLIENT, "libmysqlclient.so.16") 407 ] 408) 409 410AC_ARG_ENABLE(developer, AS_HELP_STRING([--enable-developer], 411 [Flags are enabled for Mosh Developer]) , 412 [enable_developer=true], [enable_developer=false]) 413AM_CONDITIONAL(DEVELOPER, test x$enable_developer = xtrue) 414 415# Checks for header files. 416AC_HEADER_STDC 417AC_CHECK_HEADERS([fcntl.h stdint.h stdlib.h string.h sys/time.h utmp.h tr1/unordered_map ext/hash_map unistd.h]) 418AC_CHECK_HEADERS([sys/types.h sys/wait.h sys/stat.h]) 419 420# Checks for typedefs, structures, and compiler characteristics. 421AC_HEADER_STDBOOL 422AC_C_CONST 423AC_C_INLINE 424AC_C_BIGENDIAN 425AC_TYPE_INT8_T 426AC_TYPE_SIZE_T 427AC_HEADER_TIME 428AC_TYPE_UINT32_T 429AC_TYPE_UINT8_T 430AC_C_VOLATILE 431 432# Checks for library functions. 433AC_FUNC_ALLOCA 434AC_CHECK_FUNCS([gettimeofday memmove memset strtol]) 435 436# Check system type 437# todo: added another system type 438case "$target_in" in 439 *cygwin* | *mingw* | amigados* | msdos* | rdos*) 440 AC_DEFINE(LINE_FEED_CODE_CRLF, 1, system line feed code is CRLF) 441 ;; 442 mac*) 443 AC_DEFINE(LINE_FEED_CODE_CR, 1, system line feed code is CR) 444 ;; 445 *) 446 AC_DEFINE(LINE_FEED_CODE_LF, 1, system line feed code is LF) 447 ;; 448esac 449 450AC_CONFIG_FILES([Makefile]) 451AC_OUTPUT(src/mosh_config lib/mosh/mysql.ss lib/mosh/config.ss doc/text/Download.txt) 452