| 1 | # -*- Autoconf -*- |
|---|
| 2 | # Process this file with autoconf to produce a configure script. |
|---|
| 3 | |
|---|
| 4 | AC_PREREQ(2.60) |
|---|
| 5 | AC_INIT([i3],[m4_esyscmd(./scripts/ac_init_version.sh | tr -d '\r\n')],[dyob@lunaport.net],[],[http://www.lunaport.net/test/]) |
|---|
| 6 | |
|---|
| 7 | echo_highlighted() { |
|---|
| 8 | if test "$2" != ""; then |
|---|
| 9 | regexp=$2 |
|---|
| 10 | else |
|---|
| 11 | regexp='.*' |
|---|
| 12 | fi |
|---|
| 13 | |
|---|
| 14 | echo $1 | GREP_COLOR='01' grep --color=auto "$regexp" 2> /dev/null |
|---|
| 15 | if test $? -ne 0; then |
|---|
| 16 | echo $1 |
|---|
| 17 | fi |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | echo_highlighted "$0: $PACKAGE_STRING" |
|---|
| 21 | |
|---|
| 22 | CFLAGS_before_configure="$CFLAGS" |
|---|
| 23 | CXXFLAGS_before_configure="$CXXFLAGS" |
|---|
| 24 | OBJCFLAGS_before_configure="$OBJCFLAGS" |
|---|
| 25 | |
|---|
| 26 | AC_CONFIG_AUX_DIR([autotools/build-aux]) |
|---|
| 27 | AM_INIT_AUTOMAKE([-Wall gnu no-define std-options filename-length-max=99 readme-alpha]) |
|---|
| 28 | #AM_INIT_AUTOMAKE([-Wall gnu no-define check-news std-options filename-length-max=99 color-tests]) |
|---|
| 29 | AC_CONFIG_SRCDIR([src/Main.cpp]) |
|---|
| 30 | AC_CONFIG_HEADER([config.h]) |
|---|
| 31 | |
|---|
| 32 | #echo "builddir: [${builddir}]" |
|---|
| 33 | #echo "top_builddir: [${top_builddir}]" |
|---|
| 34 | #echo "abs_top_builddir: [${abs_top_builddir}]" |
|---|
| 35 | #echo "srcdir: [${srcdir}]" |
|---|
| 36 | #echo "top_srcdir: [${top_srcdir}]" |
|---|
| 37 | #echo "abs_top_srcdir: [${abs_top_srcdir}]" |
|---|
| 38 | |
|---|
| 39 | # --------------------------------------- |
|---|
| 40 | # Programs |
|---|
| 41 | AC_USE_SYSTEM_EXTENSIONS |
|---|
| 42 | AC_CANONICAL_HOST |
|---|
| 43 | AC_PROG_CC |
|---|
| 44 | AC_PROG_CXXCPP # for cygwin |
|---|
| 45 | AC_PROG_CXX |
|---|
| 46 | AC_PROG_CPP_WERROR |
|---|
| 47 | #AC_PROG_OBJC |
|---|
| 48 | AC_LANG([C++]) |
|---|
| 49 | |
|---|
| 50 | AC_ARG_ENABLE( |
|---|
| 51 | debug, |
|---|
| 52 | AS_HELP_STRING([--enable-debug], [build debug binaries]), |
|---|
| 53 | enable_debug="$enableval", |
|---|
| 54 | #enable_debug="no" |
|---|
| 55 | enable_debug="yes" |
|---|
| 56 | ) |
|---|
| 57 | |
|---|
| 58 | AM_CONDITIONAL(ENABLE_DEBUG, test "$enable_debug" = "yes") |
|---|
| 59 | if test "$enable_debug" = "yes"; then |
|---|
| 60 | if test "$CFLAGS_before_configure" = ""; then |
|---|
| 61 | CFLAGS="-O0 -g" |
|---|
| 62 | fi |
|---|
| 63 | if test "$CXXFLAGS_before_configure" = ""; then |
|---|
| 64 | CXXFLAGS="-O0 -g" |
|---|
| 65 | fi |
|---|
| 66 | if test "$OBJCFLAGS_before_configure" = ""; then |
|---|
| 67 | OBJCFLAGS="-O0 -g" |
|---|
| 68 | fi |
|---|
| 69 | fi |
|---|
| 70 | |
|---|
| 71 | AC_ARG_ENABLE( |
|---|
| 72 | windows-unicode, |
|---|
| 73 | AS_HELP_STRING([--enable-windows-unicode],[windows unicode]) |
|---|
| 74 | ) |
|---|
| 75 | |
|---|
| 76 | # --------------------------------------- |
|---|
| 77 | # OS |
|---|
| 78 | |
|---|
| 79 | case "$host_os" in |
|---|
| 80 | cygwin) |
|---|
| 81 | with_os=unix |
|---|
| 82 | #with_gui_default=windows |
|---|
| 83 | with_gui_default=gnustep |
|---|
| 84 | LDFLAGS="$LDFLAGS -Wl,--enable-auto-import" |
|---|
| 85 | ;; |
|---|
| 86 | darwin*) |
|---|
| 87 | with_os=unix |
|---|
| 88 | with_gui_default=cocoa |
|---|
| 89 | ;; |
|---|
| 90 | mingw*) |
|---|
| 91 | with_os=windows |
|---|
| 92 | with_gui_default=windows |
|---|
| 93 | if test "$enable_windows_unicode" = "yes"; then |
|---|
| 94 | CFLAGS=" ${CFLAGS} -DUNICODE -D_UNICODE" |
|---|
| 95 | CXXFLAGS=" ${CXXFLAGS} -DUNICODE -D_UNICODE" |
|---|
| 96 | OBJCFLAGS=" ${OBJCFLAGS} -DUNICODE -D_UNICODE" |
|---|
| 97 | fi |
|---|
| 98 | ;; |
|---|
| 99 | *) |
|---|
| 100 | with_os=unix |
|---|
| 101 | with_gui_default=gnustep |
|---|
| 102 | ;; |
|---|
| 103 | esac |
|---|
| 104 | |
|---|
| 105 | AC_ARG_WITH(gui, |
|---|
| 106 | AS_HELP_STRING([--with-gui={cocoa|gnustep|windows}], [gui]), |
|---|
| 107 | with_gui="$withval", with_gui=$with_gui_default) |
|---|
| 108 | |
|---|
| 109 | case "$with_gui" in |
|---|
| 110 | windows) |
|---|
| 111 | GCH_LANG="c++-header" |
|---|
| 112 | ;; |
|---|
| 113 | cocoa) |
|---|
| 114 | GCH_LANG="objective-c++-header" |
|---|
| 115 | CXXFLAGS="$CXXFLAGS -xobjective-c++" |
|---|
| 116 | #CXXFLAGS="$CXXFLAGS $OBJCFLAGS -xobjective-c++" |
|---|
| 117 | LDFLAGS="$LDFLAGS -xnone -framework Cocoa" |
|---|
| 118 | ;; |
|---|
| 119 | gnustep) |
|---|
| 120 | with_gui=cocoa |
|---|
| 121 | GCH_LANG="objective-c++-header" |
|---|
| 122 | CXXFLAGS="$CXXFLAGS -xobjective-c++" |
|---|
| 123 | #CXXFLAGS="$CXXFLAGS $OBJCFLAGS -xobjective-c++" |
|---|
| 124 | LDFLAGS="$LDFLAGS -xnone" |
|---|
| 125 | |
|---|
| 126 | #AC_CHECK_PROG(GNUSTEP_CONFIG, gnustep-config) |
|---|
| 127 | |
|---|
| 128 | for command in \ |
|---|
| 129 | "$GNUSTEP_CONFIG" \ |
|---|
| 130 | gnustep-config \ |
|---|
| 131 | ~/GNUstep/System/Tools/gnustep-config \ |
|---|
| 132 | /usr/local/GNUstep/System/Tools/gnustep-config \ |
|---|
| 133 | /usr/GNUstep/System/Tools/gnustep-config \ |
|---|
| 134 | ; do |
|---|
| 135 | which $command > /dev/null 2> /dev/null |
|---|
| 136 | if test $? -eq 0; then |
|---|
| 137 | GNUSTEP_CONFIG=$command |
|---|
| 138 | break |
|---|
| 139 | fi |
|---|
| 140 | done |
|---|
| 141 | |
|---|
| 142 | if test "$GNUSTEP_CONFIG" != ""; then |
|---|
| 143 | if test "$enable_debug" = "yes"; then |
|---|
| 144 | debug_arg="--debug" |
|---|
| 145 | fi |
|---|
| 146 | |
|---|
| 147 | #AC_CHECK_PROG(GNUSTEP_CONFIG, perl) |
|---|
| 148 | which perl > /dev/null |
|---|
| 149 | if test $? -eq 0; then |
|---|
| 150 | GNUSTEP_CONFIG="perl $srcdir/scripts/gnustep-config-filter.pl $debug_arg $GNUSTEP_CONFIG" |
|---|
| 151 | else |
|---|
| 152 | AC_MSG_WARN([perl not found]) |
|---|
| 153 | fi |
|---|
| 154 | |
|---|
| 155 | OBJCFLAGS="$OBJCFLAGS `$GNUSTEP_CONFIG --objc-flags`" |
|---|
| 156 | CXXFLAGS="$CXXFLAGS `$GNUSTEP_CONFIG --objc-flags`" |
|---|
| 157 | LIBS="$LIBS `$GNUSTEP_CONFIG --gui-libs`" |
|---|
| 158 | else |
|---|
| 159 | AC_MSG_WARN([gnustep-config not found]) |
|---|
| 160 | fi |
|---|
| 161 | ;; |
|---|
| 162 | *) |
|---|
| 163 | AC_MSG_ERROR([--with-gui=$with_gui is invalid]) |
|---|
| 164 | ;; |
|---|
| 165 | esac |
|---|
| 166 | |
|---|
| 167 | if test "$with_gui" != "windows"; then |
|---|
| 168 | AC_MSG_CHECKING([for Objective C++]) |
|---|
| 169 | LDFLAGS_ORIG="$LDFLAGS" |
|---|
| 170 | LDFLAGS="$LDFLAGS -xobjective-c++" |
|---|
| 171 | AC_RUN_IFELSE( |
|---|
| 172 | [AC_LANG_PROGRAM( |
|---|
| 173 | [[ |
|---|
| 174 | #import <Cocoa/Cocoa.h> |
|---|
| 175 | class Foo { |
|---|
| 176 | }; |
|---|
| 177 | @interface Bar : NSObject |
|---|
| 178 | { |
|---|
| 179 | } |
|---|
| 180 | @end |
|---|
| 181 | @implementation Bar |
|---|
| 182 | @end |
|---|
| 183 | ]], |
|---|
| 184 | [[ |
|---|
| 185 | Foo foo; |
|---|
| 186 | Bar* bar = [[Bar alloc] init]; |
|---|
| 187 | [bar release]; |
|---|
| 188 | ]])], |
|---|
| 189 | [], |
|---|
| 190 | [AC_MSG_FAILURE([Objective program does not work])], |
|---|
| 191 | []) |
|---|
| 192 | |
|---|
| 193 | AC_MSG_RESULT([yes]) |
|---|
| 194 | LDFLAGS="$LDFLAGS_ORIG" |
|---|
| 195 | fi |
|---|
| 196 | |
|---|
| 197 | AC_SUBST(GCH_LANG) |
|---|
| 198 | |
|---|
| 199 | OS_DIR="os-$with_os" |
|---|
| 200 | GUI_DIR="gui-$with_gui" |
|---|
| 201 | AC_SUBST(OS_DIR) |
|---|
| 202 | AC_SUBST(GUI_DIR) |
|---|
| 203 | |
|---|
| 204 | AM_CONDITIONAL(WITH_OS_WINDOWS, test "$with_os" = "windows") |
|---|
| 205 | AM_CONDITIONAL(WITH_OS_UNIX, test "$with_os" = "unix") |
|---|
| 206 | AM_CONDITIONAL(WITH_GUI_WINDOWS, test "$with_gui" = "windows") |
|---|
| 207 | AM_CONDITIONAL(WITH_GUI_COCOA, test "$with_gui" = "cocoa") |
|---|
| 208 | |
|---|
| 209 | # --------------------------------------- |
|---|
| 210 | # Libraries |
|---|
| 211 | |
|---|
| 212 | # |
|---|
| 213 | # boost |
|---|
| 214 | # |
|---|
| 215 | |
|---|
| 216 | AX_BOOST_BASE([1.33.1]) |
|---|
| 217 | AC_CHECK_HEADERS([boost/ptr_container/detail/static_move_ptr.hpp boost/detail/is_incrementable.hpp]) |
|---|
| 218 | |
|---|
| 219 | # |
|---|
| 220 | # pthread |
|---|
| 221 | # |
|---|
| 222 | |
|---|
| 223 | ACX_PTHREAD |
|---|
| 224 | |
|---|
| 225 | # |
|---|
| 226 | # gettext |
|---|
| 227 | # |
|---|
| 228 | |
|---|
| 229 | if test -d po; then |
|---|
| 230 | LINGUAS=`cd po/ && find . -name '*.po' -type f -print | sort | sed 's/^\.\///' | sed 's/\.po$//' | tr '\r\n' ' '` |
|---|
| 231 | if test "$LINGUAS" != "`cat po/LINGUAS 2> /dev/null`"; then |
|---|
| 232 | echo $LINGUAS > po/LINGUAS |
|---|
| 233 | fi |
|---|
| 234 | fi |
|---|
| 235 | |
|---|
| 236 | AC_LANG_PUSH([C]) |
|---|
| 237 | AM_GNU_GETTEXT_VERSION([0.17]) |
|---|
| 238 | #AM_GNU_GETTEXT_VERSION([0.16.1]) |
|---|
| 239 | #AM_GNU_GETTEXT_VERSION([0.14.5]) |
|---|
| 240 | AM_GNU_GETTEXT |
|---|
| 241 | AC_LANG_POP |
|---|
| 242 | |
|---|
| 243 | # --------------------------------------- |
|---|
| 244 | # Checks for header files. |
|---|
| 245 | |
|---|
| 246 | AC_CHECK_HEADERS([malloc.h xbyak.h cstdatomic semaphore.h]) |
|---|
| 247 | |
|---|
| 248 | # --------------------------------------- |
|---|
| 249 | # Checks for typedefs, structures, and compiler characteristics. |
|---|
| 250 | |
|---|
| 251 | # --------------------------------------- |
|---|
| 252 | # Checks for library functions. |
|---|
| 253 | |
|---|
| 254 | # |
|---|
| 255 | # popt |
|---|
| 256 | # |
|---|
| 257 | |
|---|
| 258 | AC_CHECK_HEADERS( |
|---|
| 259 | [popt.h], |
|---|
| 260 | [AC_CHECK_LIB( |
|---|
| 261 | [popt], |
|---|
| 262 | [poptGetContext], |
|---|
| 263 | [LIBS="$LIBS -lpopt $LIBINTL"], |
|---|
| 264 | [AC_CHECK_LIB( |
|---|
| 265 | [popt], |
|---|
| 266 | [poptFreeContext])], |
|---|
| 267 | ["$LIBINTL"])]) |
|---|
| 268 | |
|---|
| 269 | # |
|---|
| 270 | # semaphore |
|---|
| 271 | # |
|---|
| 272 | |
|---|
| 273 | AC_MSG_CHECKING([for unnamed semaphore]) |
|---|
| 274 | AC_RUN_IFELSE( |
|---|
| 275 | [AC_LANG_PROGRAM([[ |
|---|
| 276 | #include <stdlib.h> |
|---|
| 277 | #include <semaphore.h> |
|---|
| 278 | ]], |
|---|
| 279 | [[ |
|---|
| 280 | sem_t sem; |
|---|
| 281 | if (sem_init(&sem, 0, 0) == 0) { |
|---|
| 282 | return EXIT_SUCCESS; |
|---|
| 283 | } else { |
|---|
| 284 | return EXIT_FAILURE; |
|---|
| 285 | } |
|---|
| 286 | ]])], |
|---|
| 287 | [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UNNAMED_SEMAPHORE, 1, [Unnamed semaphore])], |
|---|
| 288 | [AC_MSG_RESULT([no])], |
|---|
| 289 | [AC_MSG_RESULT([treat as no (cross compiling)])]) |
|---|
| 290 | |
|---|
| 291 | # |
|---|
| 292 | # wbindtextdomain |
|---|
| 293 | # |
|---|
| 294 | |
|---|
| 295 | LIBS_ORIG="$LIBS" |
|---|
| 296 | LIBS="$LIBS $LIBINTL" |
|---|
| 297 | AC_CHECK_FUNCS([wbindtextdomain]) |
|---|
| 298 | LIBS="$LIBS_ORIG" |
|---|
| 299 | |
|---|
| 300 | # |
|---|
| 301 | # atomic operations |
|---|
| 302 | # |
|---|
| 303 | |
|---|
| 304 | CXXFLAGS_ORIG="$CXXFLAGS" |
|---|
| 305 | AC_MSG_CHECKING([for __sync_bool_compare_and_swap]) |
|---|
| 306 | |
|---|
| 307 | gcc_atomic_operations_found() { |
|---|
| 308 | AC_MSG_RESULT([yes]); |
|---|
| 309 | AC_DEFINE(HAVE_GCC_ATOMIC_OPERATIONS,[],[TODO: Description]) |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | body="int data = 0; __sync_bool_compare_and_swap(&data, 0, 1);" |
|---|
| 313 | |
|---|
| 314 | AC_LINK_IFELSE( |
|---|
| 315 | [AC_LANG_PROGRAM([[]], [[$body]])], |
|---|
| 316 | [gcc_atomic_operations_found], |
|---|
| 317 | [ |
|---|
| 318 | CXXFLAGS="$CXXFLAGS -march=$host_cpu" |
|---|
| 319 | AC_LINK_IFELSE( |
|---|
| 320 | [AC_LANG_PROGRAM([[]], [[$body]])], |
|---|
| 321 | [gcc_atomic_operations_found], |
|---|
| 322 | [AC_MSG_RESULT([no]); CXXFLAGS="$CXXFLAGS_ORIG"])]) |
|---|
| 323 | |
|---|
| 324 | CXXFLAGS_NO_LANG=`echo $CXXFLAGS | sed "s/-xobjective-c++//" -` |
|---|
| 325 | AC_SUBST(CXXFLAGS_NO_LANG) |
|---|
| 326 | |
|---|
| 327 | # -Wno-missing-field-initializers |
|---|
| 328 | AC_MSG_CHECKING([for -Wno-missing-field-initializers]) |
|---|
| 329 | CXXFLAGS_ORIG="$CXXFLAGS" |
|---|
| 330 | CXXFLAGS="$CXXFLAGS -Wno-missing-field-initializers" |
|---|
| 331 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
|---|
| 332 | [AC_MSG_RESULT([yes])], |
|---|
| 333 | [AC_MSG_RESULT([no]); CXXFLAGS="$CXXFLAGS_ORIG"]) |
|---|
| 334 | |
|---|
| 335 | # |
|---|
| 336 | # precompiled headers |
|---|
| 337 | # |
|---|
| 338 | |
|---|
| 339 | use_gch=no |
|---|
| 340 | if test "$GXX" = "yes"; then |
|---|
| 341 | if test "$enable_debug" = "yes"; then |
|---|
| 342 | AC_MSG_CHECKING([for precompiled headers]) |
|---|
| 343 | CXXFLAGS_ORIG="$CXXFLAGS" |
|---|
| 344 | output=foo.cpp.gch |
|---|
| 345 | rm -f $output |
|---|
| 346 | if test -e $output; then |
|---|
| 347 | AC_MSG_ERROR([can't remove file '$output']) |
|---|
| 348 | fi |
|---|
| 349 | CXXFLAGS="$CXXFLAGS_NO_LANG -x$GCH_LANG -o $output" |
|---|
| 350 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [], []) |
|---|
| 351 | if test -e $output; then |
|---|
| 352 | AC_MSG_RESULT([yes]) |
|---|
| 353 | use_gch=yes |
|---|
| 354 | else |
|---|
| 355 | AC_MSG_RESULT([no]) |
|---|
| 356 | fi |
|---|
| 357 | rm -f $output |
|---|
| 358 | CXXFLAGS="$CXXFLAGS_ORIG" |
|---|
| 359 | fi |
|---|
| 360 | fi |
|---|
| 361 | AM_CONDITIONAL(USE_GCC_PRECOMPILED_HEADER, test "$use_gch" = "yes") |
|---|
| 362 | |
|---|
| 363 | # |
|---|
| 364 | # autotest |
|---|
| 365 | # |
|---|
| 366 | |
|---|
| 367 | AC_CONFIG_TESTDIR([autotools/tests]) |
|---|
| 368 | AC_CONFIG_FILES([autotools/tests/Makefile autotools/tests/atlocal]) |
|---|
| 369 | |
|---|
| 370 | if test -f scripts/potfiles.sh; then |
|---|
| 371 | $SHELL scripts/potfiles.sh |
|---|
| 372 | fi |
|---|
| 373 | |
|---|
| 374 | CONFIGURE_DATE=`date +%Y%m%d.%H%M%S` |
|---|
| 375 | AC_SUBST(CONFIGURE_DATE) |
|---|
| 376 | |
|---|
| 377 | AC_DEFINE(I3_CONFIG_H_INCLUDE_GUARD, 1, [Include guard]) |
|---|
| 378 | |
|---|
| 379 | AC_CHECK_HEADERS([__NON__EXISTANT__HEADER__FILE__], |
|---|
| 380 | [AC_MSG_FAILURE([no error when include file is not found])]) |
|---|
| 381 | |
|---|
| 382 | # --------------------------------------- |
|---|
| 383 | AC_CONFIG_FILES([Makefile intl/Makefile po/Makefile.in]) |
|---|
| 384 | AC_OUTPUT |
|---|
| 385 | |
|---|
| 386 | echo_highlighted "Then type \`make' to make ${PACKAGE_NAME}. Good luck. " |
|---|
| 387 | |
|---|