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