| 1 | # -*- Autoconf -*- |
|---|
| 2 | # Process this file with autoconf to produce a configure script. |
|---|
| 3 | |
|---|
| 4 | AC_PREREQ(2.60) |
|---|
| 5 | AC_INIT([i3],[0.1alpha],[dyob@lunaport.net]) |
|---|
| 6 | AC_CONFIG_AUX_DIR([build-aux]) |
|---|
| 7 | #AM_INIT_AUTOMAKE([gnu no-define check-news std-options tar-pax filename-length-max=99]) |
|---|
| 8 | AM_INIT_AUTOMAKE([gnu no-define check-news std-options]) |
|---|
| 9 | AC_CONFIG_SRCDIR([src/Main.cpp]) |
|---|
| 10 | AC_CONFIG_HEADER([config.h]) |
|---|
| 11 | |
|---|
| 12 | # --------------------------------------- |
|---|
| 13 | # this should be set before AC_PROG_CC, AC_USE_SYSTEM_EXTENSIONS |
|---|
| 14 | AC_ARG_ENABLE(debug, |
|---|
| 15 | AS_HELP_STRING([--enable-debug], [build debug binaries]), |
|---|
| 16 | enable_debug="$enableval", enable_debug="no") |
|---|
| 17 | AM_CONDITIONAL(ENABLE_DEBUG, test "$enable_debug" = "yes") |
|---|
| 18 | if test "$enable_debug" = "yes"; then |
|---|
| 19 | if test "$CFLAGS" = ""; then |
|---|
| 20 | CFLAGS="-O0 -g" |
|---|
| 21 | fi |
|---|
| 22 | if test "$CXXFLAGS" = ""; then |
|---|
| 23 | CXXFLAGS="-O0 -g" |
|---|
| 24 | fi |
|---|
| 25 | fi |
|---|
| 26 | |
|---|
| 27 | # --------------------------------------- |
|---|
| 28 | # Programs |
|---|
| 29 | AC_USE_SYSTEM_EXTENSIONS |
|---|
| 30 | AC_CANONICAL_HOST |
|---|
| 31 | AC_PROG_CC |
|---|
| 32 | AC_PROG_CXX |
|---|
| 33 | AC_LANG([C++]) |
|---|
| 34 | |
|---|
| 35 | AM_CONDITIONAL(USE_GCH, test "$GXX" = "yes") |
|---|
| 36 | |
|---|
| 37 | # --------------------------------------- |
|---|
| 38 | # OS |
|---|
| 39 | |
|---|
| 40 | case "$host_os" in |
|---|
| 41 | mingw*) |
|---|
| 42 | with_os=windows |
|---|
| 43 | with_gui_default=gnustep |
|---|
| 44 | ;; |
|---|
| 45 | cygwin*) |
|---|
| 46 | with_os=unix |
|---|
| 47 | with_gui_default=windows |
|---|
| 48 | with_cygwin=yes |
|---|
| 49 | ;; |
|---|
| 50 | darwin*) |
|---|
| 51 | with_os=unix |
|---|
| 52 | with_gui_default=cocoa |
|---|
| 53 | ;; |
|---|
| 54 | *) |
|---|
| 55 | with_os=unix |
|---|
| 56 | with_gui_default=gnustep |
|---|
| 57 | ;; |
|---|
| 58 | esac |
|---|
| 59 | |
|---|
| 60 | AC_ARG_WITH(gui, |
|---|
| 61 | AS_HELP_STRING([--with-gui={cocoa|gnustep|windows}], [gui]), |
|---|
| 62 | with_gui="$withval", with_gui=$with_gui_default) |
|---|
| 63 | |
|---|
| 64 | case "$with_gui" in |
|---|
| 65 | windows) |
|---|
| 66 | ;; |
|---|
| 67 | cocoa) |
|---|
| 68 | CXXFLAGS="$CXXFLAGS -x objective-c++" |
|---|
| 69 | LDFLAGS="$LDFLAGS -x none -framework Cocoa" |
|---|
| 70 | ;; |
|---|
| 71 | gnustep) |
|---|
| 72 | which gnustep-config > /dev/null |
|---|
| 73 | if test $? -ne 0; then |
|---|
| 74 | AC_MSG_WARN([gnustep-config not found]) |
|---|
| 75 | fi |
|---|
| 76 | |
|---|
| 77 | if test "$enable_debug" = "yes"; then |
|---|
| 78 | debug_arg="--debug" |
|---|
| 79 | fi |
|---|
| 80 | |
|---|
| 81 | CXXFLAGS="$CXXFLAGS -x objective-c++ `perl $srcdir/scripts/gnustep-config-filter.pl $debug_arg gnustep-config --objc-flags`" |
|---|
| 82 | LDFLAGS="$LDFLAGS -x none" |
|---|
| 83 | LIBS="$LIBS `perl $srcdir/scripts/gnustep-config-filter.pl $debug_arg gnustep-config --gui-libs`" |
|---|
| 84 | with_gui=cocoa |
|---|
| 85 | ;; |
|---|
| 86 | *) |
|---|
| 87 | AC_MSG_ERROR([--with-gui=$with_gui is invalid]) |
|---|
| 88 | ;; |
|---|
| 89 | esac |
|---|
| 90 | |
|---|
| 91 | OS_DIR="os-$with_os" |
|---|
| 92 | GUI_DIR="gui-$with_gui" |
|---|
| 93 | AC_SUBST(OS_DIR) |
|---|
| 94 | AC_SUBST(GUI_DIR) |
|---|
| 95 | |
|---|
| 96 | AM_CONDITIONAL(WITH_CYGWIN, test "$with_cygwin" = "yes") |
|---|
| 97 | AM_CONDITIONAL(WITH_OS_WINDOWS, test "$with_os" = "windows") |
|---|
| 98 | AM_CONDITIONAL(WITH_OS_UNIX, test "$with_os" = "unix") |
|---|
| 99 | AM_CONDITIONAL(WITH_GUI_WINDOWS, test "$with_gui" = "windows") |
|---|
| 100 | AM_CONDITIONAL(WITH_GUI_COCOA, test "$with_gui" = "cocoa") |
|---|
| 101 | |
|---|
| 102 | if test "$with_gui" != "windows"; then |
|---|
| 103 | AC_MSG_CHECKING([objective-c++]) |
|---|
| 104 | prologue="class Foo {}; @interface Bar {} @end @implementation Bar @end" |
|---|
| 105 | body="Foo foo; Bar* bar;" |
|---|
| 106 | AC_COMPILE_IFELSE( |
|---|
| 107 | [AC_LANG_PROGRAM([[$prologue]], [[$body]])], |
|---|
| 108 | [], |
|---|
| 109 | [AC_MSG_FAILURE([objective-c++ compiler not found])]) |
|---|
| 110 | LDFLAGS_ORIG="$LDFLAGS" |
|---|
| 111 | LDFLAGS="$LDFLAGS -x objective-c++" |
|---|
| 112 | AC_LINK_IFELSE( |
|---|
| 113 | [AC_LANG_PROGRAM([[$prologue]], [[$body]])], |
|---|
| 114 | [AC_MSG_RESULT([yes])], |
|---|
| 115 | [AC_MSG_FAILURE([objective-c++ linker does not work])]) |
|---|
| 116 | LDFLAGS="$LDFLAGS_ORIG" |
|---|
| 117 | fi |
|---|
| 118 | |
|---|
| 119 | # --------------------------------------- |
|---|
| 120 | # Libraries |
|---|
| 121 | |
|---|
| 122 | # |
|---|
| 123 | # boost |
|---|
| 124 | # |
|---|
| 125 | |
|---|
| 126 | AX_BOOST_BASE([1.38.0]) |
|---|
| 127 | #AX_BOOST_PROGRAM_OPTIONS |
|---|
| 128 | #AX_BOOST_UNIT_TEST_FRAMEWORK |
|---|
| 129 | |
|---|
| 130 | # |
|---|
| 131 | # pthread |
|---|
| 132 | # |
|---|
| 133 | |
|---|
| 134 | ACX_PTHREAD |
|---|
| 135 | |
|---|
| 136 | # |
|---|
| 137 | # gettext |
|---|
| 138 | # |
|---|
| 139 | |
|---|
| 140 | AC_LANG_PUSH([C]) |
|---|
| 141 | AM_GNU_GETTEXT_VERSION([0.16.1]) |
|---|
| 142 | AM_GNU_GETTEXT |
|---|
| 143 | AC_LANG_POP |
|---|
| 144 | |
|---|
| 145 | # --------------------------------------- |
|---|
| 146 | # Checks for header files. |
|---|
| 147 | AC_CHECK_HEADERS([popt.h xbyak.h cstdatomic]) |
|---|
| 148 | |
|---|
| 149 | # --------------------------------------- |
|---|
| 150 | # Checks for typedefs, structures, and compiler characteristics. |
|---|
| 151 | |
|---|
| 152 | # --------------------------------------- |
|---|
| 153 | # Checks for library functions. |
|---|
| 154 | |
|---|
| 155 | #AC_CHECK_LIB([argtable2],[arg_parse], [], [echo "argtable2 not found"]) |
|---|
| 156 | |
|---|
| 157 | # |
|---|
| 158 | # popt |
|---|
| 159 | # |
|---|
| 160 | |
|---|
| 161 | AC_CHECK_LIB([popt],[poptGetContext], |
|---|
| 162 | [ |
|---|
| 163 | LIBS="$LIBS -lpopt $LIBINTL" |
|---|
| 164 | ], |
|---|
| 165 | [ |
|---|
| 166 | AC_CHECK_LIB([popt],[poptFreeContext], [], [echo "popt not found"]) |
|---|
| 167 | ], |
|---|
| 168 | ["$LIBINTL"]) |
|---|
| 169 | |
|---|
| 170 | # |
|---|
| 171 | # wbindtextdomain |
|---|
| 172 | # |
|---|
| 173 | |
|---|
| 174 | LIBS_ORIG="$LIBS" |
|---|
| 175 | LIBS="$LIBS $LIBINTL" |
|---|
| 176 | AC_CHECK_FUNCS([wbindtextdomain]) |
|---|
| 177 | LIBS="$LIBS_ORIG" |
|---|
| 178 | |
|---|
| 179 | # |
|---|
| 180 | # atomic operations |
|---|
| 181 | # |
|---|
| 182 | AC_MSG_CHECKING([for __sync_bool_compare_and_swap]) |
|---|
| 183 | prog="int data = 0; __sync_bool_compare_and_swap(&data, 0, 1);" |
|---|
| 184 | AC_LINK_IFELSE( |
|---|
| 185 | [AC_LANG_PROGRAM([[]], [[$prog]])], |
|---|
| 186 | [AC_MSG_RESULT([yes])], |
|---|
| 187 | [ |
|---|
| 188 | CXXFLAGS="$CXXFLAGS -march=$host_cpu" |
|---|
| 189 | AC_LINK_IFELSE( |
|---|
| 190 | [AC_LANG_PROGRAM([[]], [[$prog]])], |
|---|
| 191 | [AC_MSG_RESULT([yes])], |
|---|
| 192 | [AC_MSG_FAILURE([__sync_bool_compare_and_swap not found])])]) |
|---|
| 193 | |
|---|
| 194 | # |
|---|
| 195 | # autotest |
|---|
| 196 | # |
|---|
| 197 | |
|---|
| 198 | AC_CONFIG_TESTDIR([tests]) |
|---|
| 199 | AC_CONFIG_FILES([tests/Makefile tests/atlocal]) |
|---|
| 200 | |
|---|
| 201 | # --------------------------------------- |
|---|
| 202 | AC_CONFIG_FILES([Makefile intl/Makefile po/Makefile.in]) |
|---|
| 203 | AC_OUTPUT |
|---|
| 204 | |
|---|
| 205 | echo "Then type 'make' to make ${PACKAGE_NAME}. Good luck. " |
|---|
| 206 | |
|---|