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