Fix crash when auto-sizing a wxDataViewCtrl column.
[wxWidgets.git] / build / aclocal / bakefile.m4
1 dnl
2 dnl  This file is part of Bakefile (http://www.bakefile.org)
3 dnl
4 dnl  Copyright (C) 2003-2007 Vaclav Slavik and others
5 dnl
6 dnl  Permission is hereby granted, free of charge, to any person obtaining a
7 dnl  copy of this software and associated documentation files (the "Software"),
8 dnl  to deal in the Software without restriction, including without limitation
9 dnl  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 dnl  and/or sell copies of the Software, and to permit persons to whom the
11 dnl  Software is furnished to do so, subject to the following conditions:
12 dnl
13 dnl  The above copyright notice and this permission notice shall be included in
14 dnl  all copies or substantial portions of the Software.
15 dnl
16 dnl  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 dnl  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 dnl  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 dnl  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 dnl  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 dnl  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 dnl  DEALINGS IN THE SOFTWARE.
23 dnl
24 dnl  Support macros for makefiles generated by BAKEFILE.
25 dnl
26
27
28 dnl ---------------------------------------------------------------------------
29 dnl Lots of compiler & linker detection code contained here was taken from
30 dnl wxWidgets configure.in script (see http://www.wxwidgets.org)
31 dnl ---------------------------------------------------------------------------
32
33
34
35 dnl ---------------------------------------------------------------------------
36 dnl AC_BAKEFILE_GNUMAKE
37 dnl
38 dnl Detects GNU make
39 dnl ---------------------------------------------------------------------------
40
41 AC_DEFUN([AC_BAKEFILE_GNUMAKE],
42 [
43     dnl does make support "-include" (only GNU make does AFAIK)?
44     AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu,
45     [
46         if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null |
47                 egrep -s GNU > /dev/null); then
48             bakefile_cv_prog_makeisgnu="yes"
49         else
50             bakefile_cv_prog_makeisgnu="no"
51         fi
52     ])
53
54     if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then
55         IF_GNU_MAKE=""
56     else
57         IF_GNU_MAKE="#"
58     fi
59     AC_SUBST(IF_GNU_MAKE)
60 ])
61
62 dnl ---------------------------------------------------------------------------
63 dnl AC_BAKEFILE_PLATFORM
64 dnl
65 dnl Detects platform and sets PLATFORM_XXX variables accordingly
66 dnl ---------------------------------------------------------------------------
67
68 AC_DEFUN([AC_BAKEFILE_PLATFORM],
69 [
70     PLATFORM_UNIX=0
71     PLATFORM_WIN32=0
72     PLATFORM_MSDOS=0
73     PLATFORM_MAC=0
74     PLATFORM_MACOS=0
75     PLATFORM_MACOSX=0
76     PLATFORM_OS2=0
77     PLATFORM_BEOS=0
78
79     if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then
80         case "${BAKEFILE_HOST}" in
81             *-*-mingw32* )
82                 PLATFORM_WIN32=1
83             ;;
84             *-pc-msdosdjgpp )
85                 PLATFORM_MSDOS=1
86             ;;
87             *-pc-os2_emx | *-pc-os2-emx )
88                 PLATFORM_OS2=1
89             ;;
90             *-*-darwin* )
91                 PLATFORM_MAC=1
92                 PLATFORM_MACOSX=1
93             ;;
94             *-*-beos* )
95                 PLATFORM_BEOS=1
96             ;;
97             powerpc-apple-macos* )
98                 PLATFORM_MAC=1
99                 PLATFORM_MACOS=1
100             ;;
101             * )
102                 PLATFORM_UNIX=1
103             ;;
104         esac
105     else
106         case "$BAKEFILE_FORCE_PLATFORM" in
107             win32 )
108                 PLATFORM_WIN32=1
109             ;;
110             msdos )
111                 PLATFORM_MSDOS=1
112             ;;
113             os2 )
114                 PLATFORM_OS2=1
115             ;;
116             darwin )
117                 PLATFORM_MAC=1
118                 PLATFORM_MACOSX=1
119             ;;
120             unix )
121                 PLATFORM_UNIX=1
122             ;;
123             beos )
124                 PLATFORM_BEOS=1
125             ;;
126             * )
127                 AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
128             ;;
129         esac
130     fi
131
132     AC_SUBST(PLATFORM_UNIX)
133     AC_SUBST(PLATFORM_WIN32)
134     AC_SUBST(PLATFORM_MSDOS)
135     AC_SUBST(PLATFORM_MAC)
136     AC_SUBST(PLATFORM_MACOS)
137     AC_SUBST(PLATFORM_MACOSX)
138     AC_SUBST(PLATFORM_OS2)
139     AC_SUBST(PLATFORM_BEOS)
140 ])
141
142
143 dnl ---------------------------------------------------------------------------
144 dnl AC_BAKEFILE_PLATFORM_SPECIFICS
145 dnl
146 dnl Sets misc platform-specific settings
147 dnl ---------------------------------------------------------------------------
148
149 AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS],
150 [
151     AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf],
152                                         [use OMF object format (OS/2)]),
153                   [bk_os2_use_omf="$enableval"])
154
155     case "${BAKEFILE_HOST}" in
156       *-*-darwin* )
157         dnl For Unix to MacOS X porting instructions, see:
158         dnl http://fink.sourceforge.net/doc/porting/porting.html
159         if test "x$GCC" = "xyes"; then
160             CFLAGS="$CFLAGS -fno-common"
161             CXXFLAGS="$CXXFLAGS -fno-common"
162         fi
163         if test "x$XLCC" = "xyes"; then
164             CFLAGS="$CFLAGS -qnocommon"
165             CXXFLAGS="$CXXFLAGS -qnocommon"
166         fi
167         ;;
168
169       *-pc-os2_emx | *-pc-os2-emx )
170         if test "x$bk_os2_use_omf" = "xyes" ; then
171             AR=emxomfar
172             RANLIB=:
173             LDFLAGS="-Zomf $LDFLAGS"
174             CFLAGS="-Zomf $CFLAGS"
175             CXXFLAGS="-Zomf $CXXFLAGS"
176             OS2_LIBEXT="lib"
177         else
178             OS2_LIBEXT="a"
179         fi
180         ;;
181
182       i*86-*-beos* )
183         LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS"
184         ;;
185     esac
186 ])
187
188 dnl ---------------------------------------------------------------------------
189 dnl AC_BAKEFILE_SUFFIXES
190 dnl
191 dnl Detects shared various suffixes for shared libraries, libraries, programs,
192 dnl plugins etc.
193 dnl ---------------------------------------------------------------------------
194
195 AC_DEFUN([AC_BAKEFILE_SUFFIXES],
196 [
197     SO_SUFFIX="so"
198     SO_SUFFIX_MODULE="so"
199     EXEEXT=""
200     LIBPREFIX="lib"
201     LIBEXT=".a"
202     DLLPREFIX="lib"
203     DLLPREFIX_MODULE=""
204     DLLIMP_SUFFIX=""
205     dlldir="$libdir"
206
207     case "${BAKEFILE_HOST}" in
208         dnl PA-RISC HP systems used .sl but IA64 use ELF-64 and so use the
209         dnl standard .so extension
210         ia64-hp-hpux* )
211         ;;
212         *-hp-hpux* )
213             SO_SUFFIX="sl"
214             SO_SUFFIX_MODULE="sl"
215         ;;
216         *-*-aix* )
217             dnl quoting from
218             dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html:
219             dnl     Both archive libraries and shared libraries on AIX have an
220             dnl     .a extension. This will explain why you can't link with an
221             dnl     .so and why it works with the name changed to .a.
222             SO_SUFFIX="a"
223             SO_SUFFIX_MODULE="a"
224         ;;
225         *-*-cygwin* )
226             SO_SUFFIX="dll"
227             SO_SUFFIX_MODULE="dll"
228             DLLIMP_SUFFIX="dll.a"
229             EXEEXT=".exe"
230             DLLPREFIX="cyg"
231             dlldir="$bindir"
232         ;;
233         *-*-mingw32* )
234             SO_SUFFIX="dll"
235             SO_SUFFIX_MODULE="dll"
236             DLLIMP_SUFFIX="dll.a"
237             EXEEXT=".exe"
238             DLLPREFIX=""
239             dlldir="$bindir"
240         ;;
241         *-pc-msdosdjgpp )
242             EXEEXT=".exe"
243             DLLPREFIX=""
244             dlldir="$bindir"
245         ;;
246         *-pc-os2_emx | *-pc-os2-emx )
247             SO_SUFFIX="dll"
248             SO_SUFFIX_MODULE="dll"
249             DLLIMP_SUFFIX=$OS2_LIBEXT
250             EXEEXT=".exe"
251             DLLPREFIX=""
252             LIBPREFIX=""
253             LIBEXT=".$OS2_LIBEXT"
254             dlldir="$bindir"
255         ;;
256         *-*-darwin* )
257             SO_SUFFIX="dylib"
258             SO_SUFFIX_MODULE="bundle"
259         ;;
260     esac
261
262     if test "x$DLLIMP_SUFFIX" = "x" ; then
263         DLLIMP_SUFFIX="$SO_SUFFIX"
264     fi
265
266     AC_SUBST(SO_SUFFIX)
267     AC_SUBST(SO_SUFFIX_MODULE)
268     AC_SUBST(DLLIMP_SUFFIX)
269     AC_SUBST(EXEEXT)
270     AC_SUBST(LIBPREFIX)
271     AC_SUBST(LIBEXT)
272     AC_SUBST(DLLPREFIX)
273     AC_SUBST(DLLPREFIX_MODULE)
274     AC_SUBST(dlldir)
275 ])
276
277
278 dnl ---------------------------------------------------------------------------
279 dnl AC_BAKEFILE_SHARED_LD
280 dnl
281 dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
282 dnl and SHARED_LD_CXX.
283 dnl ---------------------------------------------------------------------------
284
285 AC_DEFUN([AC_BAKEFILE_SHARED_LD],
286 [
287     dnl the extra compiler flags needed for compilation of shared library
288     PIC_FLAG=""
289     if test "x$GCC" = "xyes"; then
290         dnl the switch for gcc is the same under all platforms
291         PIC_FLAG="-fPIC"
292     fi
293
294     dnl Defaults for GCC and ELF .so shared libs:
295     SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o"
296     SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o"
297     WINDOWS_IMPLIB=0
298
299     case "${BAKEFILE_HOST}" in
300       *-hp-hpux* )
301         dnl default settings are good for gcc but not for the native HP-UX
302         if test "x$GCC" != "xyes"; then
303             dnl no idea why it wants it, but it does
304             LDFLAGS="$LDFLAGS -L/usr/lib"
305
306             SHARED_LD_CC="${CC} -b -o"
307             SHARED_LD_CXX="${CXX} -b -o"
308             PIC_FLAG="+Z"
309         fi
310       ;;
311
312       *-*-linux* )
313         dnl newer icc versions use -fPIC just as gcc does and, in fact, the
314         dnl newest (v10+) ones don't even understand -KPIC any longer
315         if test "$INTELCC" = "yes" -a "$INTELCC8" != "yes"; then
316             PIC_FLAG="-KPIC"
317         elif test "x$SUNCXX" = "xyes"; then
318             SHARED_LD_CC="${CC} -G -o"
319             SHARED_LD_CXX="${CXX} -G -o"
320             PIC_FLAG="-KPIC"
321         fi
322       ;;
323
324       *-*-solaris2* )
325         if test "x$SUNCXX" = xyes ; then
326             SHARED_LD_CC="${CC} -G -o"
327             SHARED_LD_CXX="${CXX} -G -o"
328             PIC_FLAG="-KPIC"
329         fi
330       ;;
331
332       *-*-darwin* )
333         AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH
334         chmod +x shared-ld-sh
335
336         SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o"
337         SHARED_LD_MODULE_CXX="CXX=\"\$(CXX)\" $SHARED_LD_MODULE_CC"
338
339         dnl Most apps benefit from being fully binded (its faster and static
340         dnl variables initialized at startup work).
341         dnl This can be done either with the exe linker flag -Wl,-bind_at_load
342         dnl or with a double stage link in order to create a single module
343         dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved
344
345         dnl If using newer dev tools then there is a -single_module flag that
346         dnl we can use to do this for dylibs, otherwise we'll need to use a helper
347         dnl script.  Check the version of gcc to see which way we can go:
348         AC_CACHE_CHECK([for gcc 3.1 or later], bakefile_cv_gcc31, [
349            AC_TRY_COMPILE([],
350                [
351                    #if (__GNUC__ < 3) || \
352                        ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
353                        This is old gcc
354                    #endif
355                ],
356                [
357                    bakefile_cv_gcc31=yes
358                ],
359                [
360                    bakefile_cv_gcc31=no
361                ]
362            )
363         ])
364         if test "$bakefile_cv_gcc31" = "no"; then
365             dnl Use the shared-ld-sh helper script
366             SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
367             SHARED_LD_CXX="$SHARED_LD_CC"
368         else
369             dnl Use the -single_module flag and let the linker do it for us
370             SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o"
371             SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
372         fi
373
374         if test "x$GCC" == "xyes"; then
375             PIC_FLAG="-dynamic -fPIC"
376         fi
377         if test "x$XLCC" = "xyes"; then
378             PIC_FLAG="-dynamic -DPIC"
379         fi
380       ;;
381
382       *-*-aix* )
383         if test "x$GCC" = "xyes"; then
384             dnl at least gcc 2.95 warns that -fPIC is ignored when
385             dnl compiling each and every file under AIX which is annoying,
386             dnl so don't use it there (it's useless as AIX runs on
387             dnl position-independent architectures only anyhow)
388             PIC_FLAG=""
389
390             dnl -bexpfull is needed by AIX linker to export all symbols (by
391             dnl default it doesn't export any and even with -bexpall it
392             dnl doesn't export all C++ support symbols, e.g. vtable
393             dnl pointers) but it's only available starting from 5.1 (with
394             dnl maintenance pack 2, whatever this is), see
395             dnl http://www-128.ibm.com/developerworks/eserver/articles/gnu.html
396             case "${BAKEFILE_HOST}" in
397                 *-*-aix5* )
398                     LD_EXPFULL="-Wl,-bexpfull"
399                     ;;
400             esac
401
402             SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o"
403             SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o"
404         else
405             dnl FIXME: makeC++SharedLib is obsolete, what should we do for
406             dnl        recent AIX versions?
407             AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
408                           makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
409             SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
410             SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
411         fi
412       ;;
413
414       *-*-beos* )
415         dnl can't use gcc under BeOS for shared library creation because it
416         dnl complains about missing 'main'
417         SHARED_LD_CC="${LD} -nostart -o"
418         SHARED_LD_CXX="${LD} -nostart -o"
419       ;;
420
421       *-*-irix* )
422         dnl default settings are ok for gcc
423         if test "x$GCC" != "xyes"; then
424             PIC_FLAG="-KPIC"
425         fi
426       ;;
427
428       *-*-cygwin* | *-*-mingw32* )
429         PIC_FLAG=""
430         SHARED_LD_CC="\$(CC) -shared -o"
431         SHARED_LD_CXX="\$(CXX) -shared -o"
432         WINDOWS_IMPLIB=1
433       ;;
434
435       *-pc-os2_emx | *-pc-os2-emx )
436         SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
437         SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
438         PIC_FLAG=""
439         AC_BAKEFILE_CREATE_FILE_DLLAR_SH
440         chmod +x dllar.sh
441       ;;
442
443       powerpc-apple-macos* | \
444       *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-gnu* | *-*-k*bsd*-gnu | \
445       *-*-mirbsd* | \
446       *-*-sunos4* | \
447       *-*-osf* | \
448       *-*-dgux5* | \
449       *-*-sysv5* | \
450       *-pc-msdosdjgpp )
451         dnl defaults are ok
452       ;;
453
454       *)
455         AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
456     esac
457
458     if test "x$PIC_FLAG" != "x" ; then
459         PIC_FLAG="$PIC_FLAG -DPIC"
460     fi
461
462     if test "x$SHARED_LD_MODULE_CC" = "x" ; then
463         SHARED_LD_MODULE_CC="$SHARED_LD_CC"
464     fi
465     if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
466         SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
467     fi
468
469     AC_SUBST(SHARED_LD_CC)
470     AC_SUBST(SHARED_LD_CXX)
471     AC_SUBST(SHARED_LD_MODULE_CC)
472     AC_SUBST(SHARED_LD_MODULE_CXX)
473     AC_SUBST(PIC_FLAG)
474     AC_SUBST(WINDOWS_IMPLIB)
475 ])
476
477
478 dnl ---------------------------------------------------------------------------
479 dnl AC_BAKEFILE_SHARED_VERSIONS
480 dnl
481 dnl Detects linker options for attaching versions (sonames) to shared  libs.
482 dnl ---------------------------------------------------------------------------
483
484 AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
485 [
486     USE_SOVERSION=0
487     USE_SOVERLINUX=0
488     USE_SOVERSOLARIS=0
489     USE_SOVERCYGWIN=0
490     USE_SOTWOSYMLINKS=0
491     USE_MACVERSION=0
492     SONAME_FLAG=
493
494     case "${BAKEFILE_HOST}" in
495       *-*-linux* | *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
496       *-*-k*bsd*-gnu | *-*-mirbsd* | *-*-gnu* )
497         if test "x$SUNCXX" = "xyes"; then
498             SONAME_FLAG="-h "
499         else
500             SONAME_FLAG="-Wl,-soname,"
501         fi
502         USE_SOVERSION=1
503         USE_SOVERLINUX=1
504         USE_SOTWOSYMLINKS=1
505       ;;
506
507       *-*-solaris2* )
508         SONAME_FLAG="-h "
509         USE_SOVERSION=1
510         USE_SOVERSOLARIS=1
511       ;;
512
513       *-*-darwin* )
514         USE_MACVERSION=1
515         USE_SOVERSION=1
516         USE_SOTWOSYMLINKS=1
517       ;;
518
519       *-*-cygwin* )
520         USE_SOVERSION=1
521         USE_SOVERCYGWIN=1
522       ;;
523     esac
524
525     AC_SUBST(USE_SOVERSION)
526     AC_SUBST(USE_SOVERLINUX)
527     AC_SUBST(USE_SOVERSOLARIS)
528     AC_SUBST(USE_SOVERCYGWIN)
529     AC_SUBST(USE_MACVERSION)
530     AC_SUBST(USE_SOTWOSYMLINKS)
531     AC_SUBST(SONAME_FLAG)
532 ])
533
534
535 dnl ---------------------------------------------------------------------------
536 dnl AC_BAKEFILE_DEPS
537 dnl
538 dnl Detects available C/C++ dependency tracking options
539 dnl ---------------------------------------------------------------------------
540
541 AC_DEFUN([AC_BAKEFILE_DEPS],
542 [
543     AC_ARG_ENABLE([dependency-tracking],
544                   AS_HELP_STRING([--disable-dependency-tracking],
545                                  [don't use dependency tracking even if the compiler can]),
546                   [bk_use_trackdeps="$enableval"])
547
548     AC_MSG_CHECKING([for dependency tracking method])
549
550     BK_DEPS=""
551     if test "x$bk_use_trackdeps" = "xno" ; then
552         DEPS_TRACKING=0
553         AC_MSG_RESULT([disabled])
554     else
555         DEPS_TRACKING=1
556
557         if test "x$GCC" = "xyes"; then
558             DEPSMODE=gcc
559             DEPSFLAG="-MMD"
560             AC_MSG_RESULT([gcc])
561         elif test "x$MWCC" = "xyes"; then
562             DEPSMODE=mwcc
563             DEPSFLAG="-MM"
564             AC_MSG_RESULT([mwcc])
565         elif test "x$SUNCC" = "xyes"; then
566             DEPSMODE=unixcc
567             DEPSFLAG="-xM1"
568             AC_MSG_RESULT([Sun cc])
569         elif test "x$SGICC" = "xyes"; then
570             DEPSMODE=unixcc
571             DEPSFLAG="-M"
572             AC_MSG_RESULT([SGI cc])
573         elif test "x$HPCC" = "xyes"; then
574             DEPSMODE=unixcc
575             DEPSFLAG="+make"
576             AC_MSG_RESULT([HP cc])
577         elif test "x$COMPAQCC" = "xyes"; then
578             DEPSMODE=gcc
579             DEPSFLAG="-MD"
580             AC_MSG_RESULT([Compaq cc])
581         else
582             DEPS_TRACKING=0
583             AC_MSG_RESULT([none])
584         fi
585
586         if test $DEPS_TRACKING = 1 ; then
587             AC_BAKEFILE_CREATE_FILE_BK_DEPS
588             chmod +x bk-deps
589             dnl FIXME: make this $(top_builddir)/bk-deps once autoconf-2.60
590             dnl        is required (and so top_builddir is never empty):
591             BK_DEPS="`pwd`/bk-deps"
592         fi
593     fi
594
595     AC_SUBST(DEPS_TRACKING)
596     AC_SUBST(BK_DEPS)
597 ])
598
599 dnl ---------------------------------------------------------------------------
600 dnl AC_BAKEFILE_CHECK_BASIC_STUFF
601 dnl
602 dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
603 dnl or "install"
604 dnl ---------------------------------------------------------------------------
605
606 AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
607 [
608     AC_PROG_RANLIB
609     AC_PROG_INSTALL
610     AC_PROG_LN_S
611
612     AC_PROG_MAKE_SET
613     AC_SUBST(MAKE_SET)
614
615     if test "x$SUNCXX" = "xyes"; then
616         dnl Sun C++ compiler requires special way of creating static libs;
617         dnl see here for more details:
618         dnl https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1229751&group_id=9863
619         AR=$CXX
620         AROPTIONS="-xar -o"
621         AC_SUBST(AR)
622     elif test "x$SGICC" = "xyes"; then
623         dnl Almost the same as above for SGI mipsPro compiler
624         AR=$CXX
625         AROPTIONS="-ar -o"
626         AC_SUBST(AR)
627     else
628         AC_CHECK_TOOL(AR, ar, ar)
629         AROPTIONS=rcu
630     fi
631     AC_SUBST(AROPTIONS)
632
633     AC_CHECK_TOOL(STRIP, strip, :)
634     AC_CHECK_TOOL(NM, nm, :)
635
636     dnl Don't use `install -d`, see http://trac.wxwidgets.org/ticket/13452
637     INSTALL_DIR="mkdir -p"
638     AC_SUBST(INSTALL_DIR)
639
640     LDFLAGS_GUI=
641     case ${BAKEFILE_HOST} in
642         *-*-cygwin* | *-*-mingw32* )
643         LDFLAGS_GUI="-mwindows"
644     esac
645     AC_SUBST(LDFLAGS_GUI)
646 ])
647
648
649 dnl ---------------------------------------------------------------------------
650 dnl AC_BAKEFILE_RES_COMPILERS
651 dnl
652 dnl Checks for presence of resource compilers for win32 or mac
653 dnl ---------------------------------------------------------------------------
654
655 AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
656 [
657     case ${BAKEFILE_HOST} in
658         *-*-cygwin* | *-*-mingw32* )
659             dnl Check for win32 resources compiler:
660             AC_CHECK_TOOL(WINDRES, windres)
661          ;;
662
663       *-*-darwin* | powerpc-apple-macos* )
664             AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez)
665             AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
666         ;;
667     esac
668
669     AC_SUBST(WINDRES)
670     AC_SUBST(REZ)
671     AC_SUBST(SETFILE)
672 ])
673
674 dnl ---------------------------------------------------------------------------
675 dnl AC_BAKEFILE_PRECOMP_HEADERS
676 dnl
677 dnl Check for precompiled headers support (GCC >= 3.4)
678 dnl ---------------------------------------------------------------------------
679
680 AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
681 [
682
683     AC_ARG_ENABLE([precomp-headers],
684                   AS_HELP_STRING([--disable-precomp-headers],
685                                  [don't use precompiled headers even if compiler can]),
686                   [bk_use_pch="$enableval"])
687
688     GCC_PCH=0
689     ICC_PCH=0
690     USE_PCH=0
691     BK_MAKE_PCH=""
692
693     case ${BAKEFILE_HOST} in
694         *-*-cygwin* )
695             dnl PCH support is broken in cygwin gcc because of unportable
696             dnl assumptions about mmap() in gcc code which make PCH generation
697             dnl fail erratically; disable PCH completely until this is fixed
698             bk_use_pch="no"
699             ;;
700     esac
701
702     if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
703         if test "x$GCC" = "xyes"; then
704             dnl test if we have gcc-3.4:
705             AC_MSG_CHECKING([if the compiler supports precompiled headers])
706             AC_TRY_COMPILE([],
707                 [
708                     #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
709                         There is no PCH support
710                     #endif
711                     #if (__GNUC__ < 3)
712                         There is no PCH support
713                     #endif
714                     #if (__GNUC__ == 3) && \
715                        ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
716                        ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3))) || \
717                        ( defined(__INTEL_COMPILER) )
718                         There is no PCH support
719                     #endif
720                 ],
721                 [
722                     AC_MSG_RESULT([yes])
723                     GCC_PCH=1
724                 ],
725                 [
726                     if test "$INTELCXX8" = "yes"; then
727                         AC_MSG_RESULT([yes])
728                         ICC_PCH=1
729                         if test "$INTELCXX10" = "yes"; then
730                             ICC_PCH_CREATE_SWITCH="-pch-create"
731                             ICC_PCH_USE_SWITCH="-pch-use"
732                         else
733                             ICC_PCH_CREATE_SWITCH="-create-pch"
734                             ICC_PCH_USE_SWITCH="-use-pch"
735                         fi
736                     else
737                         AC_MSG_RESULT([no])
738                     fi
739                 ])
740             if test $GCC_PCH = 1 -o $ICC_PCH = 1 ; then
741                 USE_PCH=1
742                 AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
743                 chmod +x bk-make-pch
744                 dnl FIXME: make this $(top_builddir)/bk-make-pch once
745                 dnl        autoconf-2.60 is required (and so top_builddir is
746                 dnl        never empty):
747                 BK_MAKE_PCH="`pwd`/bk-make-pch"
748             fi
749         fi
750     fi
751
752     AC_SUBST(GCC_PCH)
753     AC_SUBST(ICC_PCH)
754     AC_SUBST(ICC_PCH_CREATE_SWITCH)
755     AC_SUBST(ICC_PCH_USE_SWITCH)
756     AC_SUBST(BK_MAKE_PCH)
757 ])
758
759
760
761 dnl ---------------------------------------------------------------------------
762 dnl AC_BAKEFILE([autoconf_inc.m4 inclusion])
763 dnl
764 dnl To be used in configure.in of any project using Bakefile-generated mks
765 dnl
766 dnl Behaviour can be modified by setting following variables:
767 dnl    BAKEFILE_CHECK_BASICS    set to "no" if you don't want bakefile to
768 dnl                             to perform check for basic tools like ranlib
769 dnl    BAKEFILE_HOST            set this to override host detection, defaults
770 dnl                             to ${host}
771 dnl    BAKEFILE_FORCE_PLATFORM  set to override platform detection
772 dnl
773 dnl Example usage:
774 dnl
775 dnl   AC_BAKEFILE([FOO(autoconf_inc.m4)])
776 dnl
777 dnl (replace FOO with m4_include above, aclocal would die otherwise)
778 dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing
779 dnl we can do...)
780 dnl ---------------------------------------------------------------------------
781
782 AC_DEFUN([AC_BAKEFILE],
783 [
784     AC_PREREQ([2.58])
785
786     dnl We need to always run C/C++ compiler tests, but it's also possible
787     dnl for the user to call these macros manually, hence this instead of
788     dnl simply calling these macros. See http://www.bakefile.org/ticket/64
789     AC_REQUIRE([AC_BAKEFILE_PROG_CC])
790     AC_REQUIRE([AC_BAKEFILE_PROG_CXX])
791
792     if test "x$BAKEFILE_HOST" = "x"; then
793                if test "x${host}" = "x" ; then
794                        AC_MSG_ERROR([You must call the autoconf "CANONICAL_HOST" macro in your configure.ac (or .in) file.])
795                fi
796
797         BAKEFILE_HOST="${host}"
798     fi
799
800     if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
801         AC_BAKEFILE_CHECK_BASIC_STUFF
802     fi
803     AC_BAKEFILE_GNUMAKE
804     AC_BAKEFILE_PLATFORM
805     AC_BAKEFILE_PLATFORM_SPECIFICS
806     AC_BAKEFILE_SUFFIXES
807     AC_BAKEFILE_SHARED_LD
808     AC_BAKEFILE_SHARED_VERSIONS
809     AC_BAKEFILE_DEPS
810     AC_BAKEFILE_RES_COMPILERS
811
812     dnl OBJCFLAGS is set by Autoconf, but OBJCXXFLAGS is not:
813     AC_SUBST(OBJCXXFLAGS)
814
815
816     BAKEFILE_BAKEFILE_M4_VERSION="0.2.9"
817
818     dnl includes autoconf_inc.m4:
819     $1
820
821     if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then
822         AC_MSG_ERROR([No version found in autoconf_inc.m4 - bakefile macro was changed to take additional argument, perhaps configure.in wasn't updated (see the documentation)?])
823     fi
824
825     if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
826         AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
827     fi
828 ])
829
830
831 dnl ---------------------------------------------------------------------------
832 dnl              Embedded copies of helper scripts follow:
833 dnl ---------------------------------------------------------------------------
834
835 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
836 [
837 dnl ===================== bk-deps begins here =====================
838 dnl    (Created by merge-scripts.py from bk-deps
839 dnl     file do not edit here!)
840 D='$'
841 cat <<EOF >bk-deps
842 #!/bin/sh
843
844 # This script is part of Bakefile (http://www.bakefile.org) autoconf
845 # script. It is used to track C/C++ files dependencies in portable way.
846 #
847 # Permission is given to use this file in any way.
848
849 DEPSMODE=${DEPSMODE}
850 DEPSFLAG="${DEPSFLAG}"
851 DEPSDIRBASE=.deps
852
853 if test ${D}DEPSMODE = gcc ; then
854     ${D}* ${D}{DEPSFLAG}
855     status=${D}?
856
857     # determine location of created files:
858     while test ${D}# -gt 0; do
859         case "${D}1" in
860             -o )
861                 shift
862                 objfile=${D}1
863             ;;
864             -* )
865             ;;
866             * )
867                 srcfile=${D}1
868             ;;
869         esac
870         shift
871     done
872     objfilebase=\`basename ${D}objfile\`
873     builddir=\`dirname ${D}objfile\`
874     depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
875     depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
876     depsdir=${D}builddir/${D}DEPSDIRBASE
877     mkdir -p ${D}depsdir
878
879     # if the compiler failed, we're done:
880     if test ${D}{status} != 0 ; then
881         rm -f ${D}depfile
882         exit ${D}{status}
883     fi
884
885     # move created file to the location we want it in:
886     if test -f ${D}depfile ; then
887         sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d
888         rm -f ${D}depfile
889     else
890         # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d
891         depfile=\`echo "${D}objfile" | sed -e 's/\\..*${D}/.d/g'\`
892         if test ! -f ${D}depfile ; then
893             # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++)
894             depfile="${D}objfile.d"
895         fi
896         if test -f ${D}depfile ; then
897             sed -e "\\,^${D}objfile,!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d
898             rm -f ${D}depfile
899         fi
900     fi
901     exit 0
902
903 elif test ${D}DEPSMODE = mwcc ; then
904     ${D}* || exit ${D}?
905     # Run mwcc again with -MM and redirect into the dep file we want
906     # NOTE: We can't use shift here because we need ${D}* to be valid
907     prevarg=
908     for arg in ${D}* ; do
909         if test "${D}prevarg" = "-o"; then
910             objfile=${D}arg
911         else
912             case "${D}arg" in
913                 -* )
914                 ;;
915                 * )
916                     srcfile=${D}arg
917                 ;;
918             esac
919         fi
920         prevarg="${D}arg"
921     done
922
923     objfilebase=\`basename ${D}objfile\`
924     builddir=\`dirname ${D}objfile\`
925     depsdir=${D}builddir/${D}DEPSDIRBASE
926     mkdir -p ${D}depsdir
927
928     ${D}* ${D}DEPSFLAG >${D}{depsdir}/${D}{objfilebase}.d
929     exit 0
930
931 elif test ${D}DEPSMODE = unixcc; then
932     ${D}* || exit ${D}?
933     # Run compiler again with deps flag and redirect into the dep file.
934     # It doesn't work if the '-o FILE' option is used, but without it the
935     # dependency file will contain the wrong name for the object. So it is
936     # removed from the command line, and the dep file is fixed with sed.
937     cmd=""
938     while test ${D}# -gt 0; do
939         case "${D}1" in
940             -o )
941                 shift
942                 objfile=${D}1
943             ;;
944             * )
945                 eval arg${D}#=\\${D}1
946                 cmd="${D}cmd \\${D}arg${D}#"
947             ;;
948         esac
949         shift
950     done
951
952     objfilebase=\`basename ${D}objfile\`
953     builddir=\`dirname ${D}objfile\`
954     depsdir=${D}builddir/${D}DEPSDIRBASE
955     mkdir -p ${D}depsdir
956
957     eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{depsdir}/${D}{objfilebase}.d
958     exit 0
959
960 else
961     ${D}*
962     exit ${D}?
963 fi
964 EOF
965 dnl ===================== bk-deps ends here =====================
966 ])
967
968 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
969 [
970 dnl ===================== shared-ld-sh begins here =====================
971 dnl    (Created by merge-scripts.py from shared-ld-sh
972 dnl     file do not edit here!)
973 D='$'
974 cat <<EOF >shared-ld-sh
975 #!/bin/sh
976 #-----------------------------------------------------------------------------
977 #-- Name:        distrib/mac/shared-ld-sh
978 #-- Purpose:     Link a mach-o dynamic shared library for Darwin / Mac OS X
979 #-- Author:      Gilles Depeyrot
980 #-- Copyright:   (c) 2002 Gilles Depeyrot
981 #-- Licence:     any use permitted
982 #-----------------------------------------------------------------------------
983
984 verbose=0
985 args=""
986 objects=""
987 linking_flag="-dynamiclib"
988 ldargs="-r -keep_private_externs -nostdlib"
989
990 if test "x${D}CXX" = "x"; then
991     CXX="c++"
992 fi
993
994 while test ${D}# -gt 0; do
995     case ${D}1 in
996
997        -v)
998         verbose=1
999         ;;
1000
1001        -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
1002         # collect these options and values
1003         args="${D}{args} ${D}1 ${D}2"
1004         shift
1005         ;;
1006        
1007        -arch|-isysroot)
1008         # collect these options and values
1009         ldargs="${D}{ldargs} ${D}1 ${D}2"
1010         shift
1011         ;;
1012
1013        -s|-Wl,*)
1014         # collect these load args
1015         ldargs="${D}{ldargs} ${D}1"
1016         ;;
1017
1018        -l*|-L*|-flat_namespace|-headerpad_max_install_names)
1019         # collect these options
1020         args="${D}{args} ${D}1"
1021         ;;
1022
1023        -dynamiclib|-bundle)
1024         linking_flag="${D}1"
1025         ;;
1026
1027        -*)
1028         echo "shared-ld: unhandled option '${D}1'"
1029         exit 1
1030         ;;
1031
1032         *.o | *.a | *.dylib)
1033         # collect object files
1034         objects="${D}{objects} ${D}1"
1035         ;;
1036
1037         *)
1038         echo "shared-ld: unhandled argument '${D}1'"
1039         exit 1
1040         ;;
1041
1042     esac
1043     shift
1044 done
1045
1046 status=0
1047
1048 #
1049 # Link one module containing all the others
1050 #
1051 if test ${D}{verbose} = 1; then
1052     echo "${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o"
1053 fi
1054 ${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o
1055 status=${D}?
1056
1057 #
1058 # Link the shared library from the single module created, but only if the
1059 # previous command didn't fail:
1060 #
1061 if test ${D}{status} = 0; then
1062     if test ${D}{verbose} = 1; then
1063         echo "${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
1064     fi
1065     ${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}
1066     status=${D}?
1067 fi
1068
1069 #
1070 # Remove intermediate module
1071 #
1072 rm -f master.${D}${D}.o
1073
1074 exit ${D}status
1075 EOF
1076 dnl ===================== shared-ld-sh ends here =====================
1077 ])
1078
1079 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
1080 [
1081 dnl ===================== bk-make-pch begins here =====================
1082 dnl    (Created by merge-scripts.py from bk-make-pch
1083 dnl     file do not edit here!)
1084 D='$'
1085 cat <<EOF >bk-make-pch
1086 #!/bin/sh
1087
1088 # This script is part of Bakefile (http://www.bakefile.org) autoconf
1089 # script. It is used to generated precompiled headers.
1090 #
1091 # Permission is given to use this file in any way.
1092
1093 outfile="${D}{1}"
1094 header="${D}{2}"
1095 shift
1096 shift
1097
1098 builddir=\`echo ${D}outfile | sed -e 's,/\\.pch/.*${D},,g'\`
1099
1100 compiler=""
1101 headerfile=""
1102
1103 while test ${D}{#} -gt 0; do
1104     add_to_cmdline=1
1105     case "${D}{1}" in
1106         -I* )
1107             incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
1108             if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
1109                 headerfile="${D}{incdir}/${D}{header}"
1110             fi
1111         ;;
1112         -use-pch|-use_pch|-pch-use )
1113             shift
1114             add_to_cmdline=0
1115         ;;
1116     esac
1117     if test ${D}add_to_cmdline = 1 ; then
1118         compiler="${D}{compiler} ${D}{1}"
1119     fi
1120     shift
1121 done
1122
1123 if test "x${D}{headerfile}" = "x" ; then
1124     echo "error: can't find header ${D}{header} in include paths" >&2
1125 else
1126     if test -f ${D}{outfile} ; then
1127         rm -f ${D}{outfile}
1128     else
1129         mkdir -p \`dirname ${D}{outfile}\`
1130     fi
1131     depsfile="${D}{builddir}/.deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
1132     mkdir -p ${D}{builddir}/.deps
1133     if test "x${GCC_PCH}" = "x1" ; then
1134         # can do this because gcc is >= 3.4:
1135         ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
1136     elif test "x${ICC_PCH}" = "x1" ; then
1137         filename=pch_gen-${D}${D}
1138         file=${D}{filename}.c
1139         dfile=${D}{filename}.d
1140         cat > ${D}file <<EOT
1141 #include "${D}header"
1142 EOT
1143         # using -MF icc complains about differing command lines in creation/use
1144         ${D}compiler -c ${ICC_PCH_CREATE_SWITCH} ${D}outfile -MMD ${D}file && \\
1145           sed -e "s,^.*:,${D}outfile:," -e "s, ${D}file,," < ${D}dfile > ${D}depsfile && \\
1146           rm -f ${D}file ${D}dfile ${D}{filename}.o
1147     fi
1148     exit ${D}{?}
1149 fi
1150 EOF
1151 dnl ===================== bk-make-pch ends here =====================
1152 ])