| 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]) |
|---|
| 6 | |
|---|
| 7 | CFLAGS_before_configure="$CFLAGS" |
|---|
| 8 | CXXFLAGS_before_configure="$CXXFLAGS" |
|---|
| 9 | OBJCFLAGS_before_configure="$OBJCFLAGS" |
|---|
| 10 | |
|---|
| 11 | AC_CONFIG_AUX_DIR([build-aux]) |
|---|
| 12 | AM_INIT_AUTOMAKE([-Wall gnu no-define std-options filename-length-max=99]) |
|---|
| 13 | #AM_INIT_AUTOMAKE([-Wall gnu no-define check-news std-options filename-length-max=99 color-tests]) |
|---|
| 14 | AC_CONFIG_SRCDIR([src/Main.cpp]) |
|---|
| 15 | AC_CONFIG_HEADER([config.h]) |
|---|
| 16 | |
|---|
| 17 | # --------------------------------------- |
|---|
| 18 | # Programs |
|---|
| 19 | AC_USE_SYSTEM_EXTENSIONS |
|---|
| 20 | AC_CANONICAL_HOST |
|---|
| 21 | AC_PROG_CC |
|---|
| 22 | AC_PROG_CXX |
|---|
| 23 | AC_PROG_OBJC |
|---|
| 24 | AC_LANG([C++]) |
|---|
| 25 | |
|---|
| 26 | AC_ARG_ENABLE(debug, |
|---|
| 27 | AS_HELP_STRING([--enable-debug], [build debug binaries]), |
|---|
| 28 | enable_debug="$enableval", |
|---|
| 29 | # enable_debug="no" |
|---|
| 30 | enable_debug="yes" |
|---|
| 31 | ) |
|---|
| 32 | AM_CONDITIONAL(ENABLE_DEBUG, test "$enable_debug" = "yes") |
|---|
| 33 | if test "$enable_debug" = "yes"; then |
|---|
| 34 | if test "$CFLAGS_before_configure" = ""; then |
|---|
| 35 | CFLAGS="-O0 -g" |
|---|
| 36 | fi |
|---|
| 37 | if test "$CXXFLAGS_before_configure" = ""; then |
|---|
| 38 | CXXFLAGS="-O0 -g" |
|---|
| 39 | fi |
|---|
| 40 | if test "$OBJCFLAGS_before_configure" = ""; then |
|---|
| 41 | OBJCFLAGS="-O0 -g" |
|---|
| 42 | fi |
|---|
| 43 | fi |
|---|
| 44 | |
|---|
| 45 | # --------------------------------------- |
|---|
| 46 | # OS |
|---|
| 47 | |
|---|
| 48 | case "$host_os" in |
|---|
| 49 | mingw*) |
|---|
| 50 | with_os=windows |
|---|
| 51 | with_gui_default=windows |
|---|
| 52 | ;; |
|---|
| 53 | cygwin) |
|---|
| 54 | with_os=unix |
|---|
| 55 | with_gui_default=windows |
|---|
| 56 | with_cygwin=yes |
|---|
| 57 | ;; |
|---|
| 58 | darwin*) |
|---|
| 59 | with_os=unix |
|---|
| 60 | with_gui_default=cocoa |
|---|
| 61 | ;; |
|---|
| 62 | *) |
|---|
| 63 | with_os=unix |
|---|
| 64 | with_gui_default=gnustep |
|---|
| 65 | ;; |
|---|
| 66 | esac |
|---|
| 67 | |
|---|
| 68 | AC_ARG_WITH(gui, |
|---|
| 69 | AS_HELP_STRING([--with-gui={cocoa|gnustep|windows}], [gui]), |
|---|
| 70 | with_gui="$withval", with_gui=$with_gui_default) |
|---|
| 71 | |
|---|
| 72 | case "$with_gui" in |
|---|
| 73 | windows) |
|---|
| 74 | GCH_LANG="c++-header" |
|---|
| 75 | ;; |
|---|
| 76 | cocoa) |
|---|
| 77 | GCH_LANG="objective-c++-header" |
|---|
| 78 | CXXFLAGS="$CXXFLAGS -xobjective-c++" |
|---|
| 79 | LDFLAGS="$LDFLAGS -xnone -framework Cocoa" |
|---|
| 80 | ;; |
|---|
| 81 | gnustep) |
|---|
| 82 | with_gui=cocoa |
|---|
| 83 | GCH_LANG="objective-c++-header" |
|---|
| 84 | CXXFLAGS="$CXXFLAGS -xobjective-c++" |
|---|
| 85 | LDFLAGS="$LDFLAGS -xnone" |
|---|
| 86 | |
|---|
| 87 | #AC_CHECK_PROG(GNUSTEP_CONFIG, gnustep-config) |
|---|
| 88 | which gnustep-config > /dev/null |
|---|
| 89 | if test $? -eq 0; then |
|---|
| 90 | GNUSTEP_CONFIG="gnustep-config" |
|---|
| 91 | if test "$enable_debug" = "yes"; then |
|---|
| 92 | debug_arg="--debug" |
|---|
| 93 | fi |
|---|
| 94 | |
|---|
| 95 | #AC_CHECK_PROG(GNUSTEP_CONFIG, perl) |
|---|
| 96 | which perl > /dev/null |
|---|
| 97 | if test $? -eq 0; then |
|---|
| 98 | GNUSTEP_CONFIG="perl $srcdir/scripts/gnustep-config-filter.pl $debug_arg $GNUSTEP_CONFIG" |
|---|
| 99 | else |
|---|
| 100 | AC_MSG_WARN([perl not found]) |
|---|
| 101 | fi |
|---|
| 102 | |
|---|
| 103 | OBJCFLAGS="$OBJCFLAGS `$GNUSTEP_CONFIG --objc-flags`" |
|---|
| 104 | CXXFLAGS="$CXXFLAGS `$GNUSTEP_CONFIG --objc-flags`" |
|---|
| 105 | LIBS="$LIBS `$GNUSTEP_CONFIG --gui-libs`" |
|---|
| 106 | else |
|---|
| 107 | AC_MSG_WARN([gnustep-config not found]) |
|---|
| 108 | fi |
|---|
| 109 | ;; |
|---|
| 110 | *) |
|---|
| 111 | AC_MSG_ERROR([--with-gui=$with_gui is invalid]) |
|---|
| 112 | ;; |
|---|
| 113 | esac |
|---|
| 114 | |
|---|
| 115 | if test "$with_gui" != "windows"; then |
|---|
| 116 | AC_MSG_CHECKING([objective-c++]) |
|---|
| 117 | prologue="class Foo {}; @interface Bar {} @end @implementation Bar @end" |
|---|
| 118 | body="Foo foo; Bar* bar;" |
|---|
| 119 | LDFLAGS_ORIG="$LDFLAGS" |
|---|
| 120 | LDFLAGS="$LDFLAGS -xobjective-c++" |
|---|
| 121 | AC_LINK_IFELSE( |
|---|
| 122 | [AC_LANG_PROGRAM([[$prologue]], [[$body]])], |
|---|
| 123 | [AC_MSG_RESULT([yes])], |
|---|
| 124 | [AC_MSG_FAILURE([objective-c++ compiler/linker does not work])]) |
|---|
| 125 | AC_CHECK_HEADERS([boost/ptr_container/detail/static_move_ptr.hpp boost/detail/is_incrementable.hpp]) |
|---|
| 126 | LDFLAGS="$LDFLAGS_ORIG" |
|---|
| 127 | fi |
|---|
| 128 | AC_CHECK_HEADERS([__NON..EXISTANT--HEADER__FILE__], |
|---|
| 129 | [AC_MSG_FAILURE([no error when include file is not found])]) |
|---|
| 130 | |
|---|
| 131 | AC_SUBST(GCH_LANG) |
|---|
| 132 | |
|---|
| 133 | OS_DIR="os-$with_os" |
|---|
| 134 | GUI_DIR="gui-$with_gui" |
|---|
| 135 | AC_SUBST(OS_DIR) |
|---|
| 136 | AC_SUBST(GUI_DIR) |
|---|
| 137 | |
|---|
| 138 | AM_CONDITIONAL(WITH_CYGWIN, test "$with_cygwin" = "yes") |
|---|
| 139 | AM_CONDITIONAL(WITH_OS_WINDOWS, test "$with_os" = "windows") |
|---|
| 140 | AM_CONDITIONAL(WITH_OS_UNIX, test "$with_os" = "unix") |
|---|
| 141 | AM_CONDITIONAL(WITH_GUI_WINDOWS, test "$with_gui" = "windows") |
|---|
| 142 | AM_CONDITIONAL(WITH_GUI_COCOA, test "$with_gui" = "cocoa") |
|---|
| 143 | |
|---|
| 144 | # --------------------------------------- |
|---|
| 145 | # Libraries |
|---|
| 146 | |
|---|
| 147 | # |
|---|
| 148 | # boost |
|---|
| 149 | # |
|---|
| 150 | |
|---|
| 151 | AX_BOOST_BASE([1.33.1]) |
|---|
| 152 | |
|---|
| 153 | # |
|---|
| 154 | # pthread |
|---|
| 155 | # |
|---|
| 156 | |
|---|
| 157 | ACX_PTHREAD |
|---|
| 158 | |
|---|
| 159 | # |
|---|
| 160 | # gettext |
|---|
| 161 | # |
|---|
| 162 | |
|---|
| 163 | AC_LANG_PUSH([C]) |
|---|
| 164 | AM_GNU_GETTEXT_VERSION([0.17]) |
|---|
| 165 | #AM_GNU_GETTEXT_VERSION([0.16.1]) |
|---|
| 166 | #AM_GNU_GETTEXT_VERSION([0.14.5]) |
|---|
| 167 | AM_GNU_GETTEXT |
|---|
| 168 | AC_LANG_POP |
|---|
| 169 | |
|---|
| 170 | # --------------------------------------- |
|---|
| 171 | # Checks for header files. |
|---|
| 172 | |
|---|
| 173 | #AC_CHECK_HEADERS([xbyak.h cstdatomic]) |
|---|
| 174 | |
|---|
| 175 | # --------------------------------------- |
|---|
| 176 | # Checks for typedefs, structures, and compiler characteristics. |
|---|
| 177 | |
|---|
| 178 | # --------------------------------------- |
|---|
| 179 | # Checks for library functions. |
|---|
| 180 | |
|---|
| 181 | # |
|---|
| 182 | # popt |
|---|
| 183 | # |
|---|
| 184 | |
|---|
| 185 | #AC_LANG_PUSH([C]) |
|---|
| 186 | AC_CHECK_HEADERS( |
|---|
| 187 | [popt.h], |
|---|
| 188 | [AC_CHECK_LIB( |
|---|
| 189 | [popt], |
|---|
| 190 | [poptGetContext], |
|---|
| 191 | [LIBS="$LIBS -lpopt $LIBINTL"], |
|---|
| 192 | [AC_CHECK_LIB( |
|---|
| 193 | [popt], |
|---|
| 194 | [poptFreeContext])], |
|---|
| 195 | ["$LIBINTL"])]) |
|---|
| 196 | #AC_LANG_POP |
|---|
| 197 | |
|---|
| 198 | # |
|---|
| 199 | # wbindtextdomain |
|---|
| 200 | # |
|---|
| 201 | |
|---|
| 202 | LIBS_ORIG="$LIBS" |
|---|
| 203 | LIBS="$LIBS $LIBINTL" |
|---|
| 204 | AC_CHECK_FUNCS([wbindtextdomain]) |
|---|
| 205 | LIBS="$LIBS_ORIG" |
|---|
| 206 | |
|---|
| 207 | # |
|---|
| 208 | # atomic operations |
|---|
| 209 | # |
|---|
| 210 | |
|---|
| 211 | CXXFLAGS_ORIG="$CXXFLAGS" |
|---|
| 212 | AC_MSG_CHECKING([for __sync_bool_compare_and_swap]) |
|---|
| 213 | prog="int data = 0; __sync_bool_compare_and_swap(&data, 0, 1);" |
|---|
| 214 | |
|---|
| 215 | gcc_atomic_operations_found() { |
|---|
| 216 | AC_MSG_RESULT([yes]); |
|---|
| 217 | AC_DEFINE(HAVE_GCC_ATOMIC_OPERATIONS,[],[TODO: Description]) |
|---|
| 218 | } |
|---|
| 219 | |
|---|
| 220 | AC_LINK_IFELSE( |
|---|
| 221 | [AC_LANG_PROGRAM([[]], [[$prog]])], |
|---|
| 222 | [gcc_atomic_operations_found], |
|---|
| 223 | [ |
|---|
| 224 | CXXFLAGS="$CXXFLAGS -march=$host_cpu" |
|---|
| 225 | AC_LINK_IFELSE( |
|---|
| 226 | [AC_LANG_PROGRAM([[]], [[$prog]])], |
|---|
| 227 | [gcc_atomic_operations_found], |
|---|
| 228 | [AC_MSG_RESULT([no]); CXXFLAGS="$CXXFLAGS_ORIG"])]) |
|---|
| 229 | |
|---|
| 230 | CXXFLAGS_NO_LANG=`echo $CXXFLAGS | sed "s/-xobjective-c++//" -` |
|---|
| 231 | AC_SUBST(CXXFLAGS_NO_LANG) |
|---|
| 232 | |
|---|
| 233 | # -Wno-missing-field-initializers |
|---|
| 234 | AC_MSG_CHECKING([for -Wno-missing-field-initializers]) |
|---|
| 235 | CXXFLAGS_ORIG="$CXXFLAGS" |
|---|
| 236 | CXXFLAGS="$CXXFLAGS -Wno-missing-field-initializers" |
|---|
| 237 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
|---|
| 238 | [AC_MSG_RESULT([yes])], |
|---|
| 239 | [AC_MSG_RESULT([no]); CXXFLAGS="$CXXFLAGS_ORIG"]) |
|---|
| 240 | |
|---|
| 241 | # |
|---|
| 242 | # precompiled headers |
|---|
| 243 | # |
|---|
| 244 | |
|---|
| 245 | use_gch=no |
|---|
| 246 | if test "$GXX" = "yes"; then |
|---|
| 247 | if test "$enable_debug" = "yes"; then |
|---|
| 248 | AC_MSG_CHECKING([for precompiled headers]) |
|---|
| 249 | CXXFLAGS_ORIG="$CXXFLAGS" |
|---|
| 250 | output=foo.cpp.gch |
|---|
| 251 | rm -f $output |
|---|
| 252 | if test -e $output; then |
|---|
| 253 | AC_MSG_ERROR([can't remove file '$output']) |
|---|
| 254 | fi |
|---|
| 255 | CXXFLAGS="$CXXFLAGS_NO_LANG -x$GCH_LANG -o $output" |
|---|
| 256 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [], []) |
|---|
| 257 | if test -e $output; then |
|---|
| 258 | AC_MSG_RESULT([yes]) |
|---|
| 259 | use_gch=yes |
|---|
| 260 | else |
|---|
| 261 | AC_MSG_RESULT([no]) |
|---|
| 262 | fi |
|---|
| 263 | rm -f $output |
|---|
| 264 | CXXFLAGS="$CXXFLAGS_ORIG" |
|---|
| 265 | fi |
|---|
| 266 | fi |
|---|
| 267 | AM_CONDITIONAL(USE_GCC_PRECOMPILED_HEADER, test "$use_gch" = "yes") |
|---|
| 268 | |
|---|
| 269 | # |
|---|
| 270 | # autotest |
|---|
| 271 | # |
|---|
| 272 | |
|---|
| 273 | AC_CONFIG_TESTDIR([tests]) |
|---|
| 274 | AC_CONFIG_FILES([tests/Makefile tests/atlocal]) |
|---|
| 275 | |
|---|
| 276 | # --------------------------------------- |
|---|
| 277 | AC_CONFIG_FILES([Makefile intl/Makefile po/Makefile.in]) |
|---|
| 278 | AC_OUTPUT |
|---|
| 279 | |
|---|
| 280 | echo "Then type \`make' to make ${PACKAGE_NAME}. Good luck. " |
|---|
| 281 | |
|---|
| 282 | |
|---|