root/lang/objective-cplusplus/i3/trunk/configure.ac @ 37187

Revision 37187, 11.7 kB (checked in by saturday06, 4 years ago)

aaaaa

Line 
1# -*- coding: us-ascii-unix -*-
2
3AC_PREREQ(2.60)
4AC_INIT([i3],[m4_esyscmd(. ./unix/scripts/ac_init_version.sh | tr -d '\r\n')],[dyob@lunaport.net],[],[http://www.lunaport.net/test/])
5
6#
7# macros
8#
9
10AC_DEFUN([I3_HIGHLIGHTED_ECHO], [
11    # some old grep can't use '.*'
12    echo $1 | GREP_COLOR='01' grep --color=auto '.' 2> /dev/null
13    if test $? -ne 0; then
14        echo $1
15    fi
16])
17
18AC_DEFUN([I3_ADD_CXXFLAGS], [
19    AC_MSG_CHECKING([for $1])
20    CXXFLAGS_ORIG="$CXXFLAGS"
21    CXXFLAGS="$1 $CXXFLAGS"
22    AC_COMPILE_IFELSE(
23        [AC_LANG_PROGRAM([[]], [[]])],
24        [AC_MSG_RESULT([yes])],
25        [
26            AC_MSG_RESULT([no])
27            CXXFLAGS="$CXXFLAGS_ORIG"
28            $2
29        ]
30    )
31])
32
33
34#
35# env backup
36#
37
38CFLAGS_before_configure="$CFLAGS"
39CXXFLAGS_before_configure="$CXXFLAGS"
40
41
42#
43# banner
44#
45
46I3_HIGHLIGHTED_ECHO([$0: $PACKAGE_STRING])
47
48
49#
50# basic test
51#
52
53AC_CONFIG_AUX_DIR([unix/build-aux])
54AM_INIT_AUTOMAKE([-Wall gnu no-define filename-length-max=99 std-options])
55#AM_INIT_AUTOMAKE([-Wall gnu no-define filename-length-max=99 std-options check-news])
56AC_CONFIG_SRCDIR([unix/am/i3.am])
57AC_CONFIG_HEADER([config.h])
58AC_USE_SYSTEM_EXTENSIONS
59AC_CANONICAL_HOST
60AC_PROG_CXXCPP # for cygwin
61AC_PROG_CPP
62AC_PROG_CC
63AC_PROG_CXX
64AC_LANG([C++])
65
66AC_DEFINE(MIL_CONFIG_H_INCLUDED, 1, [config.h include guard])
67
68if test ! -d "$srcdir"; then
69    AC_MSG_ERROR([Environment variable "srcdir" not found, please report this to $PACKAGE_BUGREPORT])
70fi
71
72CPPFLAGS="-I${srcdir}/src -I${srcdir}/src/mil/include -Iintl $CPPFLAGS"
73
74#
75# configure options
76#
77
78AC_ARG_ENABLE(
79    debug,
80    AS_HELP_STRING([--enable-debug], [build debug binaries]),
81    enable_debug="$enableval",
82    #enable_debug="no"
83    enable_debug="yes"
84)
85
86AM_CONDITIONAL(ENABLE_DEBUG, test "$enable_debug" = "yes")
87if test "$enable_debug" = "yes"; then
88    if test "$CFLAGS_before_configure" = ""; then
89        CFLAGS="-O0 -g"
90    fi
91    if test "$CXXFLAGS_before_configure" = ""; then
92        CXXFLAGS="-O0 -g"
93    fi
94fi
95
96# ---------------------------------------
97# Runtime envirinment
98
99#
100# OS selection
101#
102
103case "$host_os" in
104    cygwin)
105        with_os=unix
106        #with_gui_default=windows
107        with_gui_default=gnustep
108        LDFLAGS="-Wl,--enable-auto-import $LDFLAGS"
109        ;;
110    darwin*)
111        with_os=unix
112        with_gui_default=cocoa
113        ;;
114    mingw*)
115        with_os=windows
116        with_gui_default=windows
117        ;;
118    *)
119        with_os=unix
120        with_gui_default=gnustep
121        ;;
122esac
123
124if test "$with_os" = "windows"; then
125    CPPFLAGS="-DMIL_OS_WINDOWS $CPPFLAGS"
126    LDFLAGS="-mwindows $LDFLAGS"
127else
128    CPPFLAGS="-DMIL_OS_UNIX $CPPFLAGS"
129fi
130
131#
132# GUI selection
133#
134
135AC_ARG_WITH(gui,
136    AS_HELP_STRING([--with-gui={cocoa|gnustep|windows}], [GUI toolkit]),
137        with_gui="$withval", with_gui=$with_gui_default)
138
139AC_PATH_PROG([PERL], [perl])
140if test "$PERL" = ""; then
141    AC_MSG_WARN([perl not found])
142fi
143
144case "$with_gui" in
145    windows)
146        GCH_LANG="c++-header"
147        I3_ADD_CXXFLAGS([-fno-operator-names])
148        CPPFLAGS="-DMIL_GUI_WINDOWS $CPPFLAGS"
149    ;;
150    cocoa)
151        I3_ADD_CXXFLAGS([-fobjc-exceptions])
152        LDFLAGS="-framework Cocoa $LDFLAGS"
153    ;;
154    gnustep)
155        with_gui=cocoa
156        with_gnustep=yes
157        AC_PATH_PROG([GNUSTEP_CONFIG], [gnustep-config])
158        if test "$GNUSTEP_CONFIG" = ""; then
159            AC_MSG_WARN([gnustep-config not found])
160        else
161            if test "$enable_debug" = "yes"; then
162                debug_arg="--debug"
163            fi
164
165            if test "$PERL" != ""; then
166                GNUSTEP_CONFIG="$PERL $srcdir/unix/scripts/gnustep-config-filter.pl $debug_arg $GNUSTEP_CONFIG"
167            fi
168
169            my_gnustep_cxxflags=`$GNUSTEP_CONFIG --objc-flags`
170            my_gnustep_libs=`$GNUSTEP_CONFIG --gui-libs`
171
172            echo additional GNUstep CXXFLAGS : $my_gnustep_cxxflags
173            echo additional GNUstep LIBS     : $my_gnustep_libs
174
175            CXXFLAGS="$my_gnustep_cxxflags $CXXFLAGS"
176            LIBS="$my_gnustep_libs $LIBS"
177        fi
178    ;;
179    *)
180        AC_MSG_ERROR([--with-gui=$with_gui is invalid])
181    ;;
182esac
183
184if test "$with_os" = "windows" || test "$with_gui" = "windows"; then
185    LIBS="-lgdi32 -luser32 -lpsapi -lshlwapi -lcomctl32 $LIBS"
186fi
187
188if test "$with_gui" = "cocoa"; then
189    GCH_LANG="objective-c++-header"
190    LDFLAGS="-x none $LDFLAGS"
191    CPPFLAGS="-DMIL_GUI_COCOA $CPPFLAGS"
192    CXX_ORIG="$CXX"
193    CXX="$CXX -x objective-c++"
194   
195    AC_MSG_CHECKING([for -x objective-c++])
196    AC_COMPILE_IFELSE(
197        [AC_LANG_PROGRAM([[]], [[]])],
198        [AC_MSG_RESULT([yes])],
199        [
200            AC_MSG_RESULT([no])
201            CXX="$CXX_ORIG"
202            AC_MSG_WARN([compiler option "-x objective-c++" unsupported])
203        ]
204    )
205
206    AC_MSG_CHECKING([for Objective-C++ toolset works])
207    LDFLAGS_ORIG="$LDFLAGS"
208    LDFLAGS="$LDFLAGS -x objective-c++" # override "-x none"
209
210    AC_LINK_IFELSE(
211        [AC_LANG_PROGRAM([[
212#import <Foundation/Foundation.h>
213#import <AppKit/AppKit.h>
214#include <stdlib.h>
215#include <memory>
216class Foo {
217};
218@interface Bar : NSObject {
219}
220@end
221@implementation Bar
222@end
223        ]],
224        [[
225NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
226Bar* bar = [[Bar alloc] init];
227[bar release];
228Foo foo;
229std::auto_ptr<Foo> p(new Foo());
230NSException* e = [NSException exceptionWithName:@"foo"
231                                         reason:@"bar"
232                                       userInfo:nil];
233NSLog([e description]);
234[pool release];
235        ]])],
236        [AC_MSG_RESULT([yes])],
237        [AC_MSG_RESULT([no])
238         echo -----------------------------------------------------
239         echo
240         echo =============
241         echo = ERROR LOG =
242         echo =============
243         echo
244         grep -i -A 100 "for Objective-C++ toolset works" config.log
245         echo
246         echo =================
247         echo = ERROR LOG END =
248         echo =================
249         echo
250         AC_MSG_ERROR([Objective-C++ toolset does not work])])
251
252    LDFLAGS="$LDFLAGS_ORIG"
253fi
254
255AC_SUBST(GCH_LANG)
256
257OS_DIR="os-$with_os"
258GUI_DIR="gui-$with_gui"
259AC_SUBST(OS_DIR)
260AC_SUBST(GUI_DIR)
261
262CPPFLAGS="-I${srcdir}/src/${GUI_DIR} -I${srcdir}/src/${OS_DIR} $CPPFLAGS"
263
264AM_CONDITIONAL(WITH_OS_WINDOWS,  test "$with_os"  = "windows")
265AM_CONDITIONAL(WITH_OS_UNIX,     test "$with_os"  = "unix")
266AM_CONDITIONAL(WITH_GUI_WINDOWS, test "$with_gui" = "windows")
267AM_CONDITIONAL(WITH_GUI_COCOA,   test "$with_gui" = "cocoa")
268
269# ---------------------------------------
270# Libraries
271
272#
273# pthread
274#
275
276if test "$with_os" = "unix"; then
277    AX_PTHREAD
278    CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
279    LIBS="$PTHREAD_LIBS $LIBS"
280fi
281
282#
283# boost
284#
285
286AX_BOOST_BASE([1.33.1], [], [AC_MSG_ERROR([boost c++ libraries required])])
287CPPFLAGS="${BOOST_CPPFLAGS} ${CPPFLAGS}" # Preprocesser
288LDFLAGS="${BOOST_LDFLAGS} ${LDFLAGS}"
289
290AC_CHECK_HEADERS([boost/detail/is_incrementable.hpp boost/ptr_container/detail/static_move_ptr.hpp boost/spirit/include/classic.hpp boost/stopwatches.h])
291
292#
293# gettext
294#
295
296# po/POTFILES.in
297$SHELL $srcdir/unix/scripts/POTFILES.in.sh
298if test $? -ne 0; then
299    AC_MSG_ERROR([can't update po/POTFILES.in])
300fi
301
302# po/LINGUAS
303$SHELL $srcdir/unix/scripts/LINGUAS.sh
304if test $? -ne 0; then
305    AC_MSG_ERROR([can't update po/LINGUAS])
306fi
307
308#AC_LANG_PUSH([C])
309AM_GNU_GETTEXT_VERSION([0.17])
310#AM_GNU_GETTEXT_VERSION([0.16.1])
311#AM_GNU_GETTEXT_VERSION([0.14.5])
312AM_GNU_GETTEXT
313#AC_LANG_POP
314
315LIBS_ORIG=$LIBS
316LIBS="$LIBINTL $LIBS"
317AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [], [LIBS=$LIBS_ORIG])
318
319#
320# wbindtextdomain
321#
322
323AC_CHECK_FUNCS([wbindtextdomain])
324
325
326#
327# popt (may depend on gettext, put it after AM_GNU_GETTEXT)
328#
329
330AC_CHECK_HEADERS([popt.h], [AC_CHECK_LIB([popt], [poptGetContext])])
331
332# ---------------------------------------
333# Checks for header files.
334
335AC_CHECK_HEADERS([malloc.h semaphore.h])
336AC_CHECK_HEADERS([uxtheme.h dwmapi.h], [], [], [
337#include <windows.h>
338])
339
340
341# ---------------------------------------
342# Checks for typedefs, structures, and compiler characteristics.
343
344AC_CHECK_TYPES([HPAINTBUFFER])
345
346#
347# extra compiler options
348#
349
350I3_ADD_CXXFLAGS([-funit-at-a-time])
351I3_ADD_CXXFLAGS([-Wall])
352I3_ADD_CXXFLAGS([-Wno-missing-field-initializers])
353
354if test "$enable_debug" = "yes"; then
355    #I3_ADD_CXXFLAGS([-pg])
356    #I3_ADD_CXXFLAGS([-fprofile-arcs])
357    #I3_ADD_CXXFLAGS([-ftest-coverage])
358    I3_ADD_CXXFLAGS([-Wextra])
359    I3_ADD_CXXFLAGS([-Wcast-align -Wcast-qual -Winit-self -Winvalid-pch -Wpointer-arith -Wwrite-strings -Wfloat-equal -Wformat=2 -Wimplicit -Wmissing-braces -Wdisabled-optimization -Wconversion])
360    #I3_ADD_CXXFLAGS([-Wno-unused-value -Wno-unused-parameter])
361    #I3_ADD_CXXFLAGS([-Weffc++ -Wpadded -Wunsafe-loop-optimizations -Wdisabled-optimization])
362else
363    I3_ADD_CXXFLAGS([-fno-rtti])
364fi
365 
366#
367# Precompiled Headers
368#
369
370use_gch=no
371if test "$GXX" = "yes" && test "$enable_debug" = "yes"; then
372    AC_MSG_CHECKING([for Precompiled Headers])
373    CXXFLAGS_ORIG="$CXXFLAGS"
374    output=foo.cpp.gch
375    rm -f $output
376    if test -e $output; then
377        AC_MSG_ERROR([can't remove file '$output'])
378    fi
379    CXXFLAGS="-x $GCH_LANG -o $output $CXXFLAGS"
380    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [], [])
381    if test -e $output; then
382        AC_MSG_RESULT([yes])
383        use_gch=yes
384    else
385        AC_MSG_RESULT([no])
386    fi
387    rm -f $output
388    CXXFLAGS="$CXXFLAGS_ORIG"
389fi
390AM_CONDITIONAL(USE_GCC_PRECOMPILED_HEADER, test "$use_gch" = "yes")
391
392
393# ---------------------------------------
394# Checks for library functions.
395
396#
397# semaphore
398#
399
400AC_MSG_CHECKING([for unnamed semaphore])
401AC_RUN_IFELSE(
402    [AC_LANG_PROGRAM([[
403#include <stdlib.h>
404#include <semaphore.h>
405    ]],
406    [[
407sem_t sem;
408if (sem_init(&sem, 0, 0) == 0) {
409    sem_destroy(&sem);
410    return EXIT_SUCCESS;
411} else {
412    return EXIT_FAILURE;
413}
414    ]])],
415    [AC_MSG_RESULT([yes])
416     AC_DEFINE(HAVE_UNNAMED_SEMAPHORE, 1, [Unnamed semaphore])],
417    [AC_MSG_RESULT([no])],
418    [AC_MSG_RESULT([treat as no (cross compiling)])])
419
420#
421# atomic operations
422#
423
424AC_MSG_CHECKING([for __sync_bool_compare_and_swap])
425
426AC_DEFUN([I3_GCC_ATOMIC_OPERATIONS_FOUND], [
427    AC_MSG_RESULT([yes])
428    AC_DEFINE(HAVE_GCC_ATOMIC_OPERATIONS,[],[TODO: Description])
429])
430
431body="int data = 0;  __sync_bool_compare_and_swap(&data, 0, 1);"
432
433CXXFLAGS_ORIG="$CXXFLAGS"
434AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[$body]])], [I3_GCC_ATOMIC_OPERATIONS_FOUND], [
435    CXXFLAGS="-march=i486 $CXXFLAGS_ORIG"
436    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[$body]])], [I3_GCC_ATOMIC_OPERATIONS_FOUND], [
437        CXXFLAGS="-march=$host_cpu $CXXFLAGS_ORIG"
438        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[$body]])], [I3_GCC_ATOMIC_OPERATIONS_FOUND], [
439            AC_MSG_RESULT([no]); CXXFLAGS="$CXXFLAGS_ORIG"
440        ])
441    ])
442])
443
444#
445# autotest
446#
447
448AC_CONFIG_TESTDIR([unix/tests])
449AC_CONFIG_FILES([unix/tests/Makefile unix/tests/atlocal])
450
451#
452# my helper variable
453#
454
455CONFIGURE_DATE=`date +%Y%m%d.%H%M%S`
456AC_SUBST(CONFIGURE_DATE)
457
458#
459# internal consistency check
460#
461
462AC_MSG_CHECKING([for simple test program])
463AC_LINK_IFELSE([AC_LANG_PROGRAM([[
464#include <stdlib.h>
465#include <cstdio>
466#include <list>
467#include <exception>
468#include <boost/pool/pool.hpp>
469]],
470[[
471using namespace std;
472try {
473    // instanciation test
474    boost::pool<> p(10);
475    list<int> l;
476} catch (exception&) {
477} catch ( ... ) {
478    return EXIT_FAILURE;
479}
480]])], [AC_MSG_RESULT([yes])],
481     [AC_MSG_RESULT([no]); AC_MSG_ERROR([simple test program does not work])])
482
483AC_MSG_CHECKING([for simple error test program])
484AC_LINK_IFELSE(
485    [AC_LANG_PROGRAM([[ struct {} foo = "bar"; ]],[[]])],
486    [AC_MSG_RESULT([yes]); AC_MSG_ERROR([no error])],
487    [AC_MSG_RESULT([no])])
488
489AC_CHECK_HEADERS([__NON__EXISTANT__HEADER__FILE__], [AC_MSG_ERROR([no error when include file is not found])])
490
491# ---------------------------------------
492AC_CONFIG_FILES([Makefile intl/Makefile po/Makefile.in unix/i3.spec unix/debian/changelog])
493AC_OUTPUT
494
495I3_HIGHLIGHTED_ECHO(["Then type \`make' to make ${PACKAGE_NAME}. Good luck. "])
496
Note: See TracBrowser for help on using the browser.