| 1 | # -*- Autoconf -*- |
|---|
| 2 | # Process this file with autoconf to produce a configure script. |
|---|
| 3 | |
|---|
| 4 | CFLAGS_before_configure="$CFLAGS" |
|---|
| 5 | CXXFLAGS_before_configure="$CXXFLAGS" |
|---|
| 6 | |
|---|
| 7 | AC_PREREQ(2.60) |
|---|
| 8 | AC_INIT([i3],[0.1alpha],[dyob@lunaport.net]) |
|---|
| 9 | AC_CONFIG_AUX_DIR([build-aux]) |
|---|
| 10 | #AM_INIT_AUTOMAKE([gnu no-define check-news std-options tar-pax filename-length-max=99]) |
|---|
| 11 | AM_INIT_AUTOMAKE([gnu no-define check-news std-options]) |
|---|
| 12 | AC_CONFIG_SRCDIR([src/Main.cpp]) |
|---|
| 13 | AC_CONFIG_HEADER([config.h]) |
|---|
| 14 | |
|---|
| 15 | # --------------------------------------- |
|---|
| 16 | # Programs |
|---|
| 17 | |
|---|
| 18 | AC_USE_SYSTEM_EXTENSIONS |
|---|
| 19 | AC_CANONICAL_HOST |
|---|
| 20 | AC_PROG_CC |
|---|
| 21 | AC_PROG_CXX |
|---|
| 22 | AC_LANG([C++]) |
|---|
| 23 | |
|---|
| 24 | AC_ARG_ENABLE(debug, |
|---|
| 25 | AS_HELP_STRING([--enable-debug], [build debug binaries]), |
|---|
| 26 | enable_debug="$enableval", enable_debug="no") |
|---|
| 27 | AM_CONDITIONAL(ENABLE_DEBUG, test "$enable_debug" = "yes") |
|---|
| 28 | if test "$enable_debug" = "yes"; then |
|---|
| 29 | if test "$CFLAGS_before_configure" = ""; then |
|---|
| 30 | CFLAGS="-O0 -g" |
|---|
| 31 | fi |
|---|
| 32 | if test "$CXXFLAGS_before_configure" = ""; then |
|---|
| 33 | CXXFLAGS="-O0 -g" |
|---|
| 34 | fi |
|---|
| 35 | fi |
|---|
| 36 | |
|---|
| 37 | AC_ARG_ENABLE(windows-release, |
|---|
| 38 | AS_HELP_STRING([--enable-windows-release], [build windows release binaries]), |
|---|
| 39 | enable_windows_release="$enableval", enable_windows_release="no") |
|---|
| 40 | if test "$enable_windows_release" = "yes"; then |
|---|
| 41 | CFLAGS="-O3 -DNDEBUG -march=i486" |
|---|
| 42 | CXXFLAGS="$CFLAGS" |
|---|
| 43 | LDFLAGS="-s" |
|---|
| 44 | fi |
|---|
| 45 | AM_CONDITIONAL(ENABLE_WINDOWS_RELEASE, test "$enable_windows_release" = "yes") |
|---|
| 46 | |
|---|
| 47 | use_gch=no |
|---|
| 48 | if test "$enable_debug" = "yes"; then |
|---|
| 49 | if test "$GXX" = "yes"; then |
|---|
| 50 | # AC_MSG_CHECKING([precompiled headers]) |
|---|
| 51 | # CXXFLAGS_ORIG="$CXXFLAGS" |
|---|
| 52 | # CXXFLAGS="$CXXFLAGS -x c++-header" |
|---|
| 53 | # AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
|---|
| 54 | # [AC_MSG_RESULT([yes]); use_gch=yes], |
|---|
| 55 | # [AC_MSG_RESULT([no])]) |
|---|
| 56 | # CXXFLAGS="$CXXFLAGS_ORIG" |
|---|
| 57 | use_gch=yes |
|---|
| 58 | fi |
|---|
| 59 | fi |
|---|
| 60 | AM_CONDITIONAL(USE_GCC_PRECOMPILED_HEADER, test "$use_gch" = "yes") |
|---|
| 61 | |
|---|
| 62 | # --------------------------------------- |
|---|
| 63 | # OS |
|---|
| 64 | |
|---|
| 65 | case "$host_os" in |
|---|
| 66 | mingw*) |
|---|
| 67 | with_os=windows |
|---|
| 68 | with_gui_default=windows |
|---|
| 69 | ;; |
|---|
| 70 | cygwin*) |
|---|
| 71 | with_os=unix |
|---|
| 72 | with_gui_default=gnustep |
|---|
| 73 | with_cygwin=yes |
|---|
| 74 | ;; |
|---|
| 75 | darwin*) |
|---|
| 76 | with_os=unix |
|---|
| 77 | with_gui_default=cocoa |
|---|
| 78 | ;; |
|---|
| 79 | *) |
|---|
| 80 | with_os=unix |
|---|
| 81 | with_gui_default=gnustep |
|---|
| 82 | ;; |
|---|
| 83 | esac |
|---|
| 84 | |
|---|
| 85 | AC_ARG_WITH(gui, |
|---|
| 86 | AS_HELP_STRING([--with-gui={cocoa|gnustep|windows}], [gui]), |
|---|
| 87 | with_gui="$withval", with_gui=$with_gui_default) |
|---|
| 88 | |
|---|
| 89 | case "$with_gui" in |
|---|
| 90 | windows) |
|---|
| 91 | GCH_LANG="c++-header" |
|---|
| 92 | ;; |
|---|
| 93 | cocoa) |
|---|
| 94 | GCH_LANG="objective-c++-header" |
|---|
| 95 | CXXFLAGS="$CXXFLAGS -x objective-c++" |
|---|
| 96 | LDFLAGS="$LDFLAGS -x none -framework Cocoa" |
|---|
| 97 | ;; |
|---|
| 98 | gnustep) |
|---|
| 99 | #AC_CHECK_PROG(GNUSTEP_CONFIG, gnustep-config) |
|---|
| 100 | which gnustep-config > /dev/null |
|---|
| 101 | if test $? -eq 0; then |
|---|
| 102 | GNUSTEP_CONFIG="gnustep-config" |
|---|
| 103 | if test "$enable_debug" = "yes"; then |
|---|
| 104 | debug_arg="--debug" |
|---|
| 105 | fi |
|---|
| 106 | |
|---|
| 107 | #AC_CHECK_PROG(GNUSTEP_CONFIG, perl) |
|---|
| 108 | which perl > /dev/null |
|---|
| 109 | if test $? -eq 0; then |
|---|
| 110 | GNUSTEP_CONFIG="perl $srcdir/scripts/gnustep-config-filter.pl $debug_arg $GNUSTEP_CONFIG" |
|---|
| 111 | else |
|---|
| 112 | AC_MSG_WARN([perl not found]) |
|---|
| 113 | fi |
|---|
| 114 | |
|---|
| 115 | CXXFLAGS="$CXXFLAGS `$GNUSTEP_CONFIG --objc-flags`" |
|---|
| 116 | LIBS="$LIBS `$GNUSTEP_CONFIG --gui-libs`" |
|---|
| 117 | |
|---|
| 118 | else |
|---|
| 119 | AC_MSG_WARN([gnustep-config not found]) |
|---|
| 120 | fi |
|---|
| 121 | |
|---|
| 122 | GCH_LANG="objective-c++-header" |
|---|
| 123 | CXXFLAGS="$CXXFLAGS -x objective-c++" |
|---|
| 124 | LDFLAGS="$LDFLAGS -x none" |
|---|
| 125 | with_gui=cocoa |
|---|
| 126 | ;; |
|---|
| 127 | *) |
|---|
| 128 | AC_MSG_ERROR([--with-gui=$with_gui is invalid]) |
|---|
| 129 | ;; |
|---|
| 130 | esac |
|---|
| 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 | if test "$with_gui" != "windows"; then |
|---|
| 145 | AC_MSG_CHECKING([objective-c++]) |
|---|
| 146 | prologue="class Foo {}; @interface Bar {} @end @implementation Bar @end" |
|---|
| 147 | body="Foo foo; Bar* bar;" |
|---|
| 148 | LDFLAGS_ORIG="$LDFLAGS" |
|---|
| 149 | LDFLAGS="$LDFLAGS -x objective-c++" |
|---|
| 150 | AC_RUN_IFELSE( |
|---|
| 151 | [AC_LANG_PROGRAM([[$prologue]], [[$body]])], |
|---|
| 152 | [AC_MSG_RESULT([yes])], |
|---|
| 153 | [AC_MSG_FAILURE([objective-c++ compiler/linker does not work])]) |
|---|
| 154 | LDFLAGS="$LDFLAGS_ORIG" |
|---|
| 155 | fi |
|---|
| 156 | AC_CHECK_HEADERS([__NON..EXISTANT--HEADER__FILE__], |
|---|
| 157 | [AC_MSG_FAILURE([no error unless include file is not found])]) |
|---|
| 158 | |
|---|
| 159 | # --------------------------------------- |
|---|
| 160 | # Libraries |
|---|
| 161 | |
|---|
| 162 | # |
|---|
| 163 | # boost |
|---|
| 164 | # |
|---|
| 165 | |
|---|
| 166 | AX_BOOST_BASE([1.38.0]) |
|---|
| 167 | #AX_BOOST_PROGRAM_OPTIONS |
|---|
| 168 | #AX_BOOST_UNIT_TEST_FRAMEWORK |
|---|
| 169 | |
|---|
| 170 | # |
|---|
| 171 | # pthread |
|---|
| 172 | # |
|---|
| 173 | |
|---|
| 174 | ACX_PTHREAD |
|---|
| 175 | |
|---|
| 176 | # |
|---|
| 177 | # gettext |
|---|
| 178 | # |
|---|
| 179 | |
|---|
| 180 | AC_LANG_PUSH([C]) |
|---|
| 181 | AM_GNU_GETTEXT_VERSION([0.17]) |
|---|
| 182 | #AM_GNU_GETTEXT_VERSION([0.16.1]) |
|---|
| 183 | AM_GNU_GETTEXT |
|---|
| 184 | AC_LANG_POP |
|---|
| 185 | |
|---|
| 186 | # --------------------------------------- |
|---|
| 187 | # Checks for header files. |
|---|
| 188 | AC_CHECK_HEADERS([xbyak.h cstdatomic]) |
|---|
| 189 | |
|---|
| 190 | # --------------------------------------- |
|---|
| 191 | # Checks for typedefs, structures, and compiler characteristics. |
|---|
| 192 | |
|---|
| 193 | # --------------------------------------- |
|---|
| 194 | # Checks for library functions. |
|---|
| 195 | |
|---|
| 196 | # |
|---|
| 197 | # popt |
|---|
| 198 | # |
|---|
| 199 | |
|---|
| 200 | AC_CHECK_HEADERS( |
|---|
| 201 | [popt.h], |
|---|
| 202 | [AC_CHECK_LIB( |
|---|
| 203 | [popt], |
|---|
| 204 | [poptGetContext], |
|---|
| 205 | [LIBS="$LIBS -lpopt $LIBINTL"], |
|---|
| 206 | [AC_CHECK_LIB( |
|---|
| 207 | [popt], |
|---|
| 208 | [poptFreeContext])], |
|---|
| 209 | ["$LIBINTL"])]) |
|---|
| 210 | |
|---|
| 211 | # |
|---|
| 212 | # wbindtextdomain |
|---|
| 213 | # |
|---|
| 214 | |
|---|
| 215 | LIBS_ORIG="$LIBS" |
|---|
| 216 | LIBS="$LIBS $LIBINTL" |
|---|
| 217 | AC_CHECK_FUNCS([wbindtextdomain]) |
|---|
| 218 | LIBS="$LIBS_ORIG" |
|---|
| 219 | |
|---|
| 220 | # |
|---|
| 221 | # atomic operations |
|---|
| 222 | # |
|---|
| 223 | |
|---|
| 224 | AC_MSG_CHECKING([for __sync_bool_compare_and_swap]) |
|---|
| 225 | prog="int data = 0; __sync_bool_compare_and_swap(&data, 0, 1);" |
|---|
| 226 | AC_LINK_IFELSE( |
|---|
| 227 | [AC_LANG_PROGRAM([[]], [[$prog]])], |
|---|
| 228 | [AC_MSG_RESULT([yes])], |
|---|
| 229 | [ |
|---|
| 230 | CXXFLAGS="$CXXFLAGS -march=$host_cpu" |
|---|
| 231 | AC_LINK_IFELSE( |
|---|
| 232 | [AC_LANG_PROGRAM([[]], [[$prog]])], |
|---|
| 233 | [AC_MSG_RESULT([yes])], |
|---|
| 234 | [AC_MSG_FAILURE([__sync_bool_compare_and_swap not found])])]) |
|---|
| 235 | |
|---|
| 236 | # |
|---|
| 237 | # autotest |
|---|
| 238 | # |
|---|
| 239 | |
|---|
| 240 | AC_CONFIG_TESTDIR([tests]) |
|---|
| 241 | AC_CONFIG_FILES([tests/Makefile tests/atlocal]) |
|---|
| 242 | |
|---|
| 243 | CXXFLAGS_NO_LANG=`echo $CXXFLAGS | sed "s/-x objective-c++//" -` |
|---|
| 244 | AC_SUBST(CXXFLAGS_NO_LANG) |
|---|
| 245 | |
|---|
| 246 | # --------------------------------------- |
|---|
| 247 | AC_CONFIG_FILES([Makefile intl/Makefile po/Makefile.in]) |
|---|
| 248 | AC_OUTPUT |
|---|
| 249 | |
|---|
| 250 | echo "Then type 'make' to make ${PACKAGE_NAME}. Good luck. " |
|---|
| 251 | |
|---|