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

Revision 37884, 12.5 kB (checked in by saturday06, 4 years ago)

ui ...??

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