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

Revision 38897, 14.4 kB (checked in by saturday06, 4 years ago)

aisdjfka

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