]> git.saurik.com Git - wxWidgets.git/blob - build/aclocal/bakefile.m4
Use lib64 for 64-bit builds on some kinds of linux and lib/64 on solaris
[wxWidgets.git] / build / aclocal / bakefile.m4
1 dnl ---------------------------------------------------------------------------
2 dnl Support macros for makefiles generated by BAKEFILE.
3 dnl ---------------------------------------------------------------------------
4
5 dnl Lots of compiler & linker detection code contained here was taken from
6 dnl wxWindows configure.in script (see http://www.wxwindows.org)
7
8
9
10 dnl ---------------------------------------------------------------------------
11 dnl AC_BAKEFILE_GNUMAKE
12 dnl
13 dnl Detects GNU make
14 dnl ---------------------------------------------------------------------------
15
16 AC_DEFUN([AC_BAKEFILE_GNUMAKE],
17 [
18 dnl does make support "-include" (only GNU make does AFAIK)?
19 AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu,
20 [
21 if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null |
22 egrep -s GNU > /dev/null); then
23 bakefile_cv_prog_makeisgnu="yes"
24 else
25 bakefile_cv_prog_makeisgnu="no"
26 fi
27 ])
28
29 if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then
30 IF_GNU_MAKE=""
31 else
32 IF_GNU_MAKE="#"
33 fi
34 AC_SUBST(IF_GNU_MAKE)
35 ])
36
37 dnl ---------------------------------------------------------------------------
38 dnl AC_BAKEFILE_PLATFORM
39 dnl
40 dnl Detects platform and sets PLATFORM_XXX variables accordingly
41 dnl ---------------------------------------------------------------------------
42
43 AC_DEFUN([AC_BAKEFILE_PLATFORM],
44 [
45 PLATFORM_UNIX=0
46 PLATFORM_WIN32=0
47 PLATFORM_MSDOS=0
48 PLATFORM_MAC=0
49 PLATFORM_MACOS=0
50 PLATFORM_MACOSX=0
51 PLATFORM_OS2=0
52 PLATFORM_BEOS=0
53
54 if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then
55 case "${BAKEFILE_HOST}" in
56 *-*-mingw32* )
57 PLATFORM_WIN32=1
58 ;;
59 *-pc-msdosdjgpp )
60 PLATFORM_MSDOS=1
61 ;;
62 *-pc-os2_emx | *-pc-os2-emx )
63 PLATFORM_OS2=1
64 ;;
65 *-*-darwin* )
66 PLATFORM_MAC=1
67 PLATFORM_MACOSX=1
68 ;;
69 *-*-beos* )
70 PLATFORM_BEOS=1
71 ;;
72 powerpc-apple-macos* )
73 PLATFORM_MAC=1
74 PLATFORM_MACOS=1
75 ;;
76 * )
77 PLATFORM_UNIX=1
78 ;;
79 esac
80 else
81 case "$BAKEFILE_FORCE_PLATFORM" in
82 win32 )
83 PLATFORM_WIN32=1
84 ;;
85 msdos )
86 PLATFORM_MSDOS=1
87 ;;
88 os2 )
89 PLATFORM_OS2=1
90 ;;
91 darwin )
92 PLATFORM_MAC=1
93 PLATFORM_MACOSX=1
94 ;;
95 unix )
96 PLATFORM_UNIX=1
97 ;;
98 beos )
99 PLATFORM_BEOS=1
100 ;;
101 * )
102 AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
103 ;;
104 esac
105 fi
106
107 AC_SUBST(PLATFORM_UNIX)
108 AC_SUBST(PLATFORM_WIN32)
109 AC_SUBST(PLATFORM_MSDOS)
110 AC_SUBST(PLATFORM_MAC)
111 AC_SUBST(PLATFORM_MACOS)
112 AC_SUBST(PLATFORM_MACOSX)
113 AC_SUBST(PLATFORM_OS2)
114 AC_SUBST(PLATFORM_BEOS)
115 ])
116
117
118 dnl ---------------------------------------------------------------------------
119 dnl AC_BAKEFILE_PLATFORM_SPECIFICS
120 dnl
121 dnl Sets misc platform-specific settings
122 dnl ---------------------------------------------------------------------------
123
124 AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS],
125 [
126 AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf],
127 [use OMF object format (OS/2)]),
128 [bk_os2_use_omf="$enableval"])
129
130 case "${BAKEFILE_HOST}" in
131 *-*-darwin* )
132 dnl For Unix to MacOS X porting instructions, see:
133 dnl http://fink.sourceforge.net/doc/porting/porting.html
134 if test "x$GCC" = "xyes"; then
135 CFLAGS="$CFLAGS -fno-common"
136 CXXFLAGS="$CXXFLAGS -fno-common"
137 fi
138 if test "x$XLCC" = "xyes"; then
139 CFLAGS="$CFLAGS -qnocommon"
140 CXXFLAGS="$CXXFLAGS -qnocommon"
141 fi
142 ;;
143
144 *-pc-os2_emx | *-pc-os2-emx )
145 if test "x$bk_os2_use_omf" = "xyes" ; then
146 AR=emxomfar
147 RANLIB=:
148 LDFLAGS="-Zomf $LDFLAGS"
149 CFLAGS="-Zomf $CFLAGS"
150 CXXFLAGS="-Zomf $CXXFLAGS"
151 OS2_LIBEXT="lib"
152 else
153 OS2_LIBEXT="a"
154 fi
155 ;;
156
157 i*86-*-beos* )
158 LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS"
159 ;;
160 esac
161 ])
162
163 dnl ---------------------------------------------------------------------------
164 dnl AC_BAKEFILE_SUFFIXES
165 dnl
166 dnl Detects shared various suffixes for shared libraries, libraries, programs,
167 dnl plugins etc.
168 dnl ---------------------------------------------------------------------------
169
170 AC_DEFUN([AC_BAKEFILE_SUFFIXES],
171 [
172 SO_SUFFIX="so"
173 SO_SUFFIX_MODULE="so"
174 EXEEXT=""
175 LIBPREFIX="lib"
176 LIBEXT=".a"
177 DLLPREFIX="lib"
178 DLLPREFIX_MODULE=""
179 DLLIMP_SUFFIX=""
180 dlldir="$libdir"
181
182 case "${BAKEFILE_HOST}" in
183 *-hp-hpux* )
184 SO_SUFFIX="sl"
185 SO_SUFFIX_MODULE="sl"
186 ;;
187 *-*-aix* )
188 dnl quoting from
189 dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html:
190 dnl Both archive libraries and shared libraries on AIX have an
191 dnl .a extension. This will explain why you can't link with an
192 dnl .so and why it works with the name changed to .a.
193 SO_SUFFIX="a"
194 SO_SUFFIX_MODULE="a"
195 ;;
196 *-*-cygwin* )
197 SO_SUFFIX="dll"
198 SO_SUFFIX_MODULE="dll"
199 DLLIMP_SUFFIX="dll.a"
200 EXEEXT=".exe"
201 DLLPREFIX="cyg"
202 dlldir="$bindir"
203 ;;
204 *-*-mingw32* )
205 SO_SUFFIX="dll"
206 SO_SUFFIX_MODULE="dll"
207 DLLIMP_SUFFIX="dll.a"
208 EXEEXT=".exe"
209 DLLPREFIX=""
210 dlldir="$bindir"
211 ;;
212 *-pc-msdosdjgpp )
213 EXEEXT=".exe"
214 DLLPREFIX=""
215 dlldir="$bindir"
216 ;;
217 *-pc-os2_emx | *-pc-os2-emx )
218 SO_SUFFIX="dll"
219 SO_SUFFIX_MODULE="dll"
220 DLLIMP_SUFFIX=$OS2_LIBEXT
221 EXEEXT=".exe"
222 DLLPREFIX=""
223 LIBPREFIX=""
224 LIBEXT=".$OS2_LIBEXT"
225 dlldir="$bindir"
226 ;;
227 *-*-darwin* )
228 SO_SUFFIX="dylib"
229 SO_SUFFIX_MODULE="bundle"
230 ;;
231 esac
232
233 if test "x$DLLIMP_SUFFIX" = "x" ; then
234 DLLIMP_SUFFIX="$SO_SUFFIX"
235 fi
236
237 AC_SUBST(SO_SUFFIX)
238 AC_SUBST(SO_SUFFIX_MODULE)
239 AC_SUBST(DLLIMP_SUFFIX)
240 AC_SUBST(EXEEXT)
241 AC_SUBST(LIBPREFIX)
242 AC_SUBST(LIBEXT)
243 AC_SUBST(DLLPREFIX)
244 AC_SUBST(DLLPREFIX_MODULE)
245 AC_SUBST(dlldir)
246 ])
247
248
249 dnl ---------------------------------------------------------------------------
250 dnl AC_BAKEFILE_SHARED_LD
251 dnl
252 dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
253 dnl and SHARED_LD_CXX.
254 dnl ---------------------------------------------------------------------------
255
256 AC_DEFUN([AC_BAKEFILE_SHARED_LD],
257 [
258 dnl the extra compiler flags needed for compilation of shared library
259 PIC_FLAG=""
260 if test "x$GCC" = "xyes"; then
261 dnl the switch for gcc is the same under all platforms
262 PIC_FLAG="-fPIC"
263 fi
264
265 dnl Defaults for GCC and ELF .so shared libs:
266 SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o"
267 SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o"
268 WINDOWS_IMPLIB=0
269
270 case "${BAKEFILE_HOST}" in
271 *-hp-hpux* )
272 dnl default settings are good for gcc but not for the native HP-UX
273 if test "x$GCC" != "xyes"; then
274 dnl no idea why it wants it, but it does
275 LDFLAGS="$LDFLAGS -L/usr/lib"
276
277 SHARED_LD_CC="${CC} -b -o"
278 SHARED_LD_CXX="${CXX} -b -o"
279 PIC_FLAG="+Z"
280 fi
281 ;;
282
283 *-*-linux* )
284 if test "x$GCC" != "xyes"; then
285 AC_CACHE_CHECK([for Intel compiler], bakefile_cv_prog_icc,
286 [
287 AC_TRY_COMPILE([],
288 [
289 #ifndef __INTEL_COMPILER
290 #error Not icc
291 #endif
292 ],
293 bakefile_cv_prog_icc=yes,
294 bakefile_cv_prog_icc=no
295 )
296 ])
297 if test "$bakefile_cv_prog_icc" = "yes"; then
298 PIC_FLAG="-KPIC"
299 fi
300 fi
301 ;;
302
303 *-*-solaris2* )
304 if test "x$GCC" != xyes ; then
305 SHARED_LD_CC="${CC} -G -o"
306 SHARED_LD_CXX="${CXX} -G -o"
307 PIC_FLAG="-KPIC"
308 fi
309 ;;
310
311 *-*-darwin* )
312 dnl Most apps benefit from being fully binded (its faster and static
313 dnl variables initialized at startup work).
314 dnl This can be done either with the exe linker flag -Wl,-bind_at_load
315 dnl or with a double stage link in order to create a single module
316 dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved
317
318 dnl If using newer dev tools then there is a -single_module flag that
319 dnl we can use to do this, otherwise we'll need to use a helper
320 dnl script. Check the version of gcc to see which way we can go:
321 AC_CACHE_CHECK([for gcc 3.1 or later], wx_cv_gcc31, [
322 AC_TRY_COMPILE([],
323 [
324 #if (__GNUC__ < 3) || \
325 ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
326 #error old gcc
327 #endif
328 ],
329 [
330 wx_cv_gcc31=yes
331 ],
332 [
333 wx_cv_gcc31=no
334 ]
335 )
336 ])
337 if test "$wx_cv_gcc31" = "no"; then
338 AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH
339 chmod +x shared-ld-sh
340
341 dnl Use the shared-ld-sh helper script
342 SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
343 SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o"
344 SHARED_LD_CXX="$SHARED_LD_CC"
345 SHARED_LD_MODULE_CXX="$SHARED_LD_MODULE_CC"
346 else
347 dnl Use the -single_module flag and let the linker do it for us
348 SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o"
349 SHARED_LD_MODULE_CC="\${CC} -bundle -single_module -headerpad_max_install_names -o"
350 SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
351 SHARED_LD_MODULE_CXX="\${CXX} -bundle -single_module -headerpad_max_install_names -o"
352 fi
353
354 if test "x$GCC" == "xyes"; then
355 PIC_FLAG="-dynamic -fPIC"
356 fi
357 if test "x$XLCC" = "xyes"; then
358 PIC_FLAG="-dynamic -DPIC"
359 fi
360 ;;
361
362 *-*-aix* )
363 if test "x$GCC" = "xyes"; then
364 dnl at least gcc 2.95 warns that -fPIC is ignored when
365 dnl compiling each and every file under AIX which is annoying,
366 dnl so don't use it there (it's useless as AIX runs on
367 dnl position-independent architectures only anyhow)
368 PIC_FLAG=""
369
370 dnl -bexpfull is needed by AIX linker to export all symbols (by
371 dnl default it doesn't export any and even with -bexpall it
372 dnl doesn't export all C++ support symbols, e.g. vtable
373 dnl pointers) but it's only available starting from 5.1 (with
374 dnl maintenance pack 2, whatever this is), see
375 dnl http://www-128.ibm.com/developerworks/eserver/articles/gnu.html
376 case "${BAKEFILE_HOST}" in
377 *-*-aix5* )
378 LD_EXPFULL="-Wl,-bexpfull"
379 ;;
380 esac
381
382 SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o"
383 SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o"
384 else
385 dnl FIXME: makeC++SharedLib is obsolete, what should we do for
386 dnl recent AIX versions?
387 AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
388 makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
389 SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
390 SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
391 fi
392 ;;
393
394 *-*-beos* )
395 dnl can't use gcc under BeOS for shared library creation because it
396 dnl complains about missing 'main'
397 SHARED_LD_CC="${LD} -nostart -o"
398 SHARED_LD_CXX="${LD} -nostart -o"
399 ;;
400
401 *-*-irix* )
402 dnl default settings are ok for gcc
403 if test "x$GCC" != "xyes"; then
404 PIC_FLAG="-KPIC"
405 fi
406 ;;
407
408 *-*-cygwin* | *-*-mingw32* )
409 PIC_FLAG=""
410 SHARED_LD_CC="\$(CC) -shared -o"
411 SHARED_LD_CXX="\$(CXX) -shared -o"
412 WINDOWS_IMPLIB=1
413 ;;
414
415 *-pc-os2_emx | *-pc-os2-emx )
416 SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
417 SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
418 PIC_FLAG=""
419 AC_BAKEFILE_CREATE_FILE_DLLAR_SH
420 chmod +x dllar.sh
421 ;;
422
423 powerpc-apple-macos* | \
424 *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-k*bsd*-gnu | \
425 *-*-sunos4* | \
426 *-*-osf* | \
427 *-*-dgux5* | \
428 *-*-sysv5* | \
429 *-pc-msdosdjgpp )
430 dnl defaults are ok
431 ;;
432
433 *)
434 AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
435 esac
436
437 if test "x$PIC_FLAG" != "x" ; then
438 PIC_FLAG="$PIC_FLAG -DPIC"
439 fi
440
441 if test "x$SHARED_LD_MODULE_CC" = "x" ; then
442 SHARED_LD_MODULE_CC="$SHARED_LD_CC"
443 fi
444 if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
445 SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
446 fi
447
448 AC_SUBST(SHARED_LD_CC)
449 AC_SUBST(SHARED_LD_CXX)
450 AC_SUBST(SHARED_LD_MODULE_CC)
451 AC_SUBST(SHARED_LD_MODULE_CXX)
452 AC_SUBST(PIC_FLAG)
453 AC_SUBST(WINDOWS_IMPLIB)
454 ])
455
456
457 dnl ---------------------------------------------------------------------------
458 dnl AC_BAKEFILE_SHARED_VERSIONS
459 dnl
460 dnl Detects linker options for attaching versions (sonames) to shared libs.
461 dnl ---------------------------------------------------------------------------
462
463 AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
464 [
465 USE_SOVERSION=0
466 USE_SOVERLINUX=0
467 USE_SOVERSOLARIS=0
468 USE_SOVERCYGWIN=0
469 USE_SOSYMLINKS=0
470 USE_MACVERSION=0
471 SONAME_FLAG=
472
473 case "${BAKEFILE_HOST}" in
474 *-*-linux* | *-*-freebsd* | *-*-k*bsd*-gnu )
475 SONAME_FLAG="-Wl,-soname,"
476 USE_SOVERSION=1
477 USE_SOVERLINUX=1
478 USE_SOSYMLINKS=1
479 ;;
480
481 *-*-solaris2* )
482 SONAME_FLAG="-h "
483 USE_SOVERSION=1
484 USE_SOVERSOLARIS=1
485 USE_SOSYMLINKS=1
486 ;;
487
488 *-*-darwin* )
489 USE_MACVERSION=1
490 USE_SOVERSION=1
491 USE_SOSYMLINKS=1
492 ;;
493
494 *-*-cygwin* )
495 USE_SOVERSION=1
496 USE_SOVERCYGWIN=1
497 ;;
498 esac
499
500 AC_SUBST(USE_SOVERSION)
501 AC_SUBST(USE_SOVERLINUX)
502 AC_SUBST(USE_SOVERSOLARIS)
503 AC_SUBST(USE_SOVERCYGWIN)
504 AC_SUBST(USE_MACVERSION)
505 AC_SUBST(USE_SOSYMLINKS)
506 AC_SUBST(SONAME_FLAG)
507 ])
508
509
510 dnl ---------------------------------------------------------------------------
511 dnl AC_BAKEFILE_DEPS
512 dnl
513 dnl Detects available C/C++ dependency tracking options
514 dnl ---------------------------------------------------------------------------
515
516 AC_DEFUN([AC_BAKEFILE_DEPS],
517 [
518 AC_MSG_CHECKING([for dependency tracking method])
519 DEPS_TRACKING=1
520
521 if test "x$GCC" = "xyes"; then
522 DEPSMODE=gcc
523 case "${BAKEFILE_HOST}" in
524 *-*-darwin* )
525 dnl -cpp-precomp (the default) conflicts with -MMD option
526 dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html)
527 DEPSFLAG="-no-cpp-precomp -MMD"
528 ;;
529 * )
530 DEPSFLAG="-MMD"
531 ;;
532 esac
533 AC_MSG_RESULT([gcc])
534 elif test "x$MWCC" = "xyes"; then
535 DEPSMODE=mwcc
536 DEPSFLAG="-MM"
537 AC_MSG_RESULT([mwcc])
538 elif test "x$SUNCC" = "xyes"; then
539 DEPSMODE=unixcc
540 DEPSFLAG="-xM1"
541 AC_MSG_RESULT([Sun cc])
542 elif test "x$SGICC" = "xyes"; then
543 DEPSMODE=unixcc
544 DEPSFLAG="-M"
545 AC_MSG_RESULT([SGI cc])
546 else
547 DEPS_TRACKING=0
548 AC_MSG_RESULT([none])
549 fi
550
551 if test $DEPS_TRACKING = 1 ; then
552 AC_BAKEFILE_CREATE_FILE_BK_DEPS
553 chmod +x bk-deps
554 fi
555
556 AC_SUBST(DEPS_TRACKING)
557 ])
558
559 dnl ---------------------------------------------------------------------------
560 dnl AC_BAKEFILE_CHECK_BASIC_STUFF
561 dnl
562 dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
563 dnl or "install"
564 dnl ---------------------------------------------------------------------------
565
566 AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
567 [
568 AC_PROG_RANLIB
569 AC_PROG_INSTALL
570 AC_PROG_LN_S
571
572 AC_PROG_MAKE_SET
573 AC_SUBST(MAKE_SET)
574
575 AC_CHECK_TOOL(AR, ar, ar)
576 AC_CHECK_TOOL(STRIP, strip, :)
577 AC_CHECK_TOOL(NM, nm, :)
578
579 case ${BAKEFILE_HOST} in
580 *-hp-hpux* )
581 dnl HP-UX install doesn't handle the "-d" switch so don't
582 dnl use it there
583 INSTALL_DIR="mkdir -p"
584 ;;
585 *) INSTALL_DIR="$INSTALL -d"
586 ;;
587 esac
588 AC_SUBST(INSTALL_DIR)
589
590 LDFLAGS_GUI=
591 case ${BAKEFILE_HOST} in
592 *-*-cygwin* | *-*-mingw32* )
593 LDFLAGS_GUI="-mwindows"
594 esac
595 AC_SUBST(LDFLAGS_GUI)
596 ])
597
598
599 dnl ---------------------------------------------------------------------------
600 dnl AC_BAKEFILE_RES_COMPILERS
601 dnl
602 dnl Checks for presence of resource compilers for win32 or mac
603 dnl ---------------------------------------------------------------------------
604
605 AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
606 [
607 RESCOMP=
608 SETFILE=
609
610 case ${BAKEFILE_HOST} in
611 *-*-cygwin* | *-*-mingw32* )
612 dnl Check for win32 resources compiler:
613 if test "$build" != "$host" ; then
614 RESCOMP=$host_alias-windres
615 else
616 AC_CHECK_PROG(RESCOMP, windres, windres, windres)
617 fi
618 ;;
619
620 *-*-darwin* | powerpc-apple-macos* )
621 AC_CHECK_PROG(RESCOMP, Rez, Rez, /Developer/Tools/Rez)
622 AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
623 ;;
624 esac
625
626 AC_SUBST(RESCOMP)
627 AC_SUBST(SETFILE)
628 ])
629
630 dnl ---------------------------------------------------------------------------
631 dnl AC_BAKEFILE_PRECOMP_HEADERS
632 dnl
633 dnl Check for precompiled headers support (GCC >= 3.4)
634 dnl ---------------------------------------------------------------------------
635
636 AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
637 [
638
639 AC_ARG_ENABLE([precomp-headers],
640 AS_HELP_STRING([--disable-precomp-headers],
641 [don't use precompiled headers even if compiler can]),
642 [bk_use_pch="$enableval"])
643
644 GCC_PCH=0
645
646 if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
647 if test "x$GCC" = "xyes"; then
648 dnl test if we have gcc-3.4:
649 AC_MSG_CHECKING([if the compiler supports precompiled headers])
650 AC_TRY_COMPILE([],
651 [
652 #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
653 #error "no pch support"
654 #endif
655 #if (__GNUC__ < 3)
656 #error "no pch support"
657 #endif
658 #if (__GNUC__ == 3) && \
659 ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
660 ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3)))
661 #error "no pch support"
662 #endif
663 ],
664 [
665 AC_MSG_RESULT([yes])
666 GCC_PCH=1
667 ],
668 [
669 AC_MSG_RESULT([no])
670 ])
671 if test $GCC_PCH = 1 ; then
672 AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
673 chmod +x bk-make-pch
674 fi
675 fi
676 fi
677
678 AC_SUBST(GCC_PCH)
679 ])
680
681
682
683 dnl ---------------------------------------------------------------------------
684 dnl AC_BAKEFILE([autoconf_inc.m4 inclusion])
685 dnl
686 dnl To be used in configure.in of any project using Bakefile-generated mks
687 dnl
688 dnl Behaviour can be modified by setting following variables:
689 dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
690 dnl to perform check for basic tools like ranlib
691 dnl BAKEFILE_HOST set this to override host detection, defaults
692 dnl to ${host}
693 dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
694 dnl
695 dnl Example usage:
696 dnl
697 dnl AC_BAKEFILE([FOO(autoconf_inc.m4)])
698 dnl
699 dnl (replace FOO with m4_include above, aclocal would die otherwise)
700 dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing
701 dnl we can do...)
702 dnl ---------------------------------------------------------------------------
703
704 AC_DEFUN([AC_BAKEFILE],
705 [
706 AC_PREREQ(2.58)
707
708 if test "x$BAKEFILE_HOST" = "x"; then
709 BAKEFILE_HOST="${host}"
710 fi
711
712 if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
713 AC_BAKEFILE_CHECK_BASIC_STUFF
714 fi
715 AC_BAKEFILE_GNUMAKE
716 AC_BAKEFILE_PLATFORM
717 AC_BAKEFILE_PLATFORM_SPECIFICS
718 AC_BAKEFILE_SUFFIXES
719 AC_BAKEFILE_SHARED_LD
720 AC_BAKEFILE_SHARED_VERSIONS
721 AC_BAKEFILE_DEPS
722 AC_BAKEFILE_RES_COMPILERS
723
724 BAKEFILE_BAKEFILE_M4_VERSION="0.1.9"
725
726 dnl includes autoconf_inc.m4:
727 $1
728
729 if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then
730 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)?])
731 fi
732
733 if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
734 AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
735 fi
736 ])
737
738
739 dnl ---------------------------------------------------------------------------
740 dnl Embedded copies of helper scripts follow:
741 dnl ---------------------------------------------------------------------------
742
743 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_DLLAR_SH],
744 [
745 dnl ===================== dllar.sh begins here =====================
746 dnl (Created by merge-scripts.py from dllar.sh
747 dnl file do not edit here!)
748 D='$'
749 cat <<EOF >dllar.sh
750 #!/bin/sh
751 #
752 # dllar - a tool to build both a .dll and an .a file
753 # from a set of object (.o) files for EMX/OS2.
754 #
755 # Written by Andrew Zabolotny, bit@freya.etu.ru
756 # Ported to Unix like shell by Stefan Neis, Stefan.Neis@t-online.de
757 #
758 # This script will accept a set of files on the command line.
759 # All the public symbols from the .o files will be exported into
760 # a .DEF file, then linker will be run (through gcc) against them to
761 # build a shared library consisting of all given .o files. All libraries
762 # (.a) will be first decompressed into component .o files then act as
763 # described above. You can optionally give a description (-d "description")
764 # which will be put into .DLL. To see the list of accepted options (as well
765 # as command-line format) simply run this program without options. The .DLL
766 # is built to be imported by name (there is no guarantee that new versions
767 # of the library you build will have same ordinals for same symbols).
768 #
769 # dllar is free software; you can redistribute it and/or modify
770 # it under the terms of the GNU General Public License as published by
771 # the Free Software Foundation; either version 2, or (at your option)
772 # any later version.
773 #
774 # dllar is distributed in the hope that it will be useful,
775 # but WITHOUT ANY WARRANTY; without even the implied warranty of
776 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
777 # GNU General Public License for more details.
778 #
779 # You should have received a copy of the GNU General Public License
780 # along with dllar; see the file COPYING. If not, write to the Free
781 # Software Foundation, 59 Temple Place - Suite 330, Boston, MA
782 # 02111-1307, USA.
783
784 # To successfuly run this program you will need:
785 # - Current drive should have LFN support (HPFS, ext2, network, etc)
786 # (Sometimes dllar generates filenames which won't fit 8.3 scheme)
787 # - gcc
788 # (used to build the .dll)
789 # - emxexp
790 # (used to create .def file from .o files)
791 # - emximp
792 # (used to create .a file from .def file)
793 # - GNU text utilites (cat, sort, uniq)
794 # used to process emxexp output
795 # - GNU file utilities (mv, rm)
796 # - GNU sed
797 # - lxlite (optional, see flag below)
798 # (used for general .dll cleanup)
799 #
800
801 flag_USE_LXLITE=1;
802
803 #
804 # helper functions
805 # basnam, variant of basename, which does _not_ remove the path, _iff_
806 # second argument (suffix to remove) is given
807 basnam(){
808 case ${D}# in
809 1)
810 echo ${D}1 | sed 's/.*\\///' | sed 's/.*\\\\//'
811 ;;
812 2)
813 echo ${D}1 | sed 's/'${D}2'${D}//'
814 ;;
815 *)
816 echo "error in basnam ${D}*"
817 exit 8
818 ;;
819 esac
820 }
821
822 # Cleanup temporary files and output
823 CleanUp() {
824 cd ${D}curDir
825 for i in ${D}inputFiles ; do
826 case ${D}i in
827 *!)
828 rm -rf \`basnam ${D}i !\`
829 ;;
830 *)
831 ;;
832 esac
833 done
834
835 # Kill result in case of failure as there is just to many stupid make/nmake
836 # things out there which doesn't do this.
837 if @<:@ ${D}# -eq 0 @:>@; then
838 rm -f ${D}arcFile ${D}arcFile2 ${D}defFile ${D}dllFile
839 fi
840 }
841
842 # Print usage and exit script with rc=1.
843 PrintHelp() {
844 echo 'Usage: dllar.sh @<:@-o@<:@utput@:>@ output_file@:>@ @<:@-i@<:@mport@:>@ importlib_name@:>@'
845 echo ' @<:@-name-mangler-script script.sh@:>@'
846 echo ' @<:@-d@<:@escription@:>@ "dll descrption"@:>@ @<:@-cc "CC"@:>@ @<:@-f@<:@lags@:>@ "CFLAGS"@:>@'
847 echo ' @<:@-ord@<:@inals@:>@@:>@ -ex@<:@clude@:>@ "symbol(s)"'
848 echo ' @<:@-libf@<:@lags@:>@ "{INIT|TERM}{GLOBAL|INSTANCE}"@:>@ @<:@-nocrt@<:@dll@:>@@:>@ @<:@-nolxl@<:@ite@:>@@:>@'
849 echo ' @<:@*.o@:>@ @<:@*.a@:>@'
850 echo '*> "output_file" should have no extension.'
851 echo ' If it has the .o, .a or .dll extension, it is automatically removed.'
852 echo ' The import library name is derived from this and is set to "name".a,'
853 echo ' unless overridden by -import'
854 echo '*> "importlib_name" should have no extension.'
855 echo ' If it has the .o, or .a extension, it is automatically removed.'
856 echo ' This name is used as the import library name and may be longer and'
857 echo ' more descriptive than the DLL name which has to follow the old '
858 echo ' 8.3 convention of FAT.'
859 echo '*> "script.sh may be given to override the output_file name by a'
860 echo ' different name. It is mainly useful if the regular make process'
861 echo ' of some package does not take into account OS/2 restriction of'
862 echo ' DLL name lengths. It takes the importlib name as input and is'
863 echo ' supposed to procude a shorter name as output. The script should'
864 echo ' expect to get importlib_name without extension and should produce'
865 echo ' a (max.) 8 letter name without extension.'
866 echo '*> "cc" is used to use another GCC executable. (default: gcc.exe)'
867 echo '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)'
868 echo ' These flags will be put at the start of GCC command line.'
869 echo '*> -ord@<:@inals@:>@ tells dllar to export entries by ordinals. Be careful.'
870 echo '*> -ex@<:@clude@:>@ defines symbols which will not be exported. You can define'
871 echo ' multiple symbols, for example -ex "myfunc yourfunc _GLOBAL*".'
872 echo ' If the last character of a symbol is "*", all symbols beginning'
873 echo ' with the prefix before "*" will be exclude, (see _GLOBAL* above).'
874 echo '*> -libf@<:@lags@:>@ can be used to add INITGLOBAL/INITINSTANCE and/or'
875 echo ' TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.'
876 echo '*> -nocrt@<:@dll@:>@ switch will disable linking the library against emx''s'
877 echo ' C runtime DLLs.'
878 echo '*> -nolxl@<:@ite@:>@ switch will disable running lxlite on the resulting DLL.'
879 echo '*> All other switches (for example -L./ or -lmylib) will be passed'
880 echo ' unchanged to GCC at the end of command line.'
881 echo '*> If you create a DLL from a library and you do not specify -o,'
882 echo ' the basename for DLL and import library will be set to library name,'
883 echo ' the initial library will be renamed to 'name'_s.a (_s for static)'
884 echo ' i.e. "dllar gcc.a" will create gcc.dll and gcc.a, and the initial'
885 echo ' library will be renamed into gcc_s.a.'
886 echo '--------'
887 echo 'Example:'
888 echo ' dllar -o gcc290.dll libgcc.a -d "GNU C runtime library" -ord'
889 echo ' -ex "__main __ctordtor*" -libf "INITINSTANCE TERMINSTANCE"'
890 CleanUp
891 exit 1
892 }
893
894 # Execute a command.
895 # If exit code of the commnad <> 0 CleanUp() is called and we'll exit the script.
896 # @Uses Whatever CleanUp() uses.
897 doCommand() {
898 echo "${D}*"
899 eval ${D}*
900 rcCmd=${D}?
901
902 if @<:@ ${D}rcCmd -ne 0 @:>@; then
903 echo "command failed, exit code="${D}rcCmd
904 CleanUp
905 exit ${D}rcCmd
906 fi
907 }
908
909 # main routine
910 # setup globals
911 cmdLine=${D}*
912 outFile=""
913 outimpFile=""
914 inputFiles=""
915 renameScript=""
916 description=""
917 CC=gcc.exe
918 CFLAGS="-s -Zcrtdll"
919 EXTRA_CFLAGS=""
920 EXPORT_BY_ORDINALS=0
921 exclude_symbols=""
922 library_flags=""
923 curDir=\`pwd\`
924 curDirS=curDir
925 case ${D}curDirS in
926 */)
927 ;;
928 *)
929 curDirS=${D}{curDirS}"/"
930 ;;
931 esac
932 # Parse commandline
933 libsToLink=0
934 omfLinking=0
935 while @<:@ ${D}1 @:>@; do
936 case ${D}1 in
937 -ord*)
938 EXPORT_BY_ORDINALS=1;
939 ;;
940 -o*)
941 shift
942 outFile=${D}1
943 ;;
944 -i*)
945 shift
946 outimpFile=${D}1
947 ;;
948 -name-mangler-script)
949 shift
950 renameScript=${D}1
951 ;;
952 -d*)
953 shift
954 description=${D}1
955 ;;
956 -f*)
957 shift
958 CFLAGS=${D}1
959 ;;
960 -c*)
961 shift
962 CC=${D}1
963 ;;
964 -h*)
965 PrintHelp
966 ;;
967 -ex*)
968 shift
969 exclude_symbols=${D}{exclude_symbols}${D}1" "
970 ;;
971 -libf*)
972 shift
973 library_flags=${D}{library_flags}${D}1" "
974 ;;
975 -nocrt*)
976 CFLAGS="-s"
977 ;;
978 -nolxl*)
979 flag_USE_LXLITE=0
980 ;;
981 -* | /*)
982 case ${D}1 in
983 -L* | -l*)
984 libsToLink=1
985 ;;
986 -Zomf)
987 omfLinking=1
988 ;;
989 *)
990 ;;
991 esac
992 EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1
993 ;;
994 *.dll)
995 EXTRA_CFLAGS="${D}{EXTRA_CFLAGS} \`basnam ${D}1 .dll\`"
996 if @<:@ ${D}omfLinking -eq 1 @:>@; then
997 EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.lib"
998 else
999 EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.a"
1000 fi
1001 ;;
1002 *)
1003 found=0;
1004 if @<:@ ${D}libsToLink -ne 0 @:>@; then
1005 EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1
1006 else
1007 for file in ${D}1 ; do
1008 if @<:@ -f ${D}file @:>@; then
1009 inputFiles="${D}{inputFiles} ${D}file"
1010 found=1
1011 fi
1012 done
1013 if @<:@ ${D}found -eq 0 @:>@; then
1014 echo "ERROR: No file(s) found: "${D}1
1015 exit 8
1016 fi
1017 fi
1018 ;;
1019 esac
1020 shift
1021 done # iterate cmdline words
1022
1023 #
1024 if @<:@ -z "${D}inputFiles" @:>@; then
1025 echo "dllar: no input files"
1026 PrintHelp
1027 fi
1028
1029 # Now extract all .o files from .a files
1030 newInputFiles=""
1031 for file in ${D}inputFiles ; do
1032 case ${D}file in
1033 *.a | *.lib)
1034 case ${D}file in
1035 *.a)
1036 suffix=".a"
1037 AR="ar"
1038 ;;
1039 *.lib)
1040 suffix=".lib"
1041 AR="emxomfar"
1042 EXTRA_CFLAGS="${D}EXTRA_CFLAGS -Zomf"
1043 ;;
1044 *)
1045 ;;
1046 esac
1047 dirname=\`basnam ${D}file ${D}suffix\`"_%"
1048 mkdir ${D}dirname
1049 if @<:@ ${D}? -ne 0 @:>@; then
1050 echo "Failed to create subdirectory ./${D}dirname"
1051 CleanUp
1052 exit 8;
1053 fi
1054 # Append '!' to indicate archive
1055 newInputFiles="${D}newInputFiles ${D}{dirname}!"
1056 doCommand "cd ${D}dirname; ${D}AR x ../${D}file"
1057 cd ${D}curDir
1058 found=0;
1059 for subfile in ${D}dirname/*.o* ; do
1060 if @<:@ -f ${D}subfile @:>@; then
1061 found=1
1062 if @<:@ -s ${D}subfile @:>@; then
1063 # FIXME: This should be: is file size > 32 byte, _not_ > 0!
1064 newInputFiles="${D}newInputFiles ${D}subfile"
1065 fi
1066 fi
1067 done
1068 if @<:@ ${D}found -eq 0 @:>@; then
1069 echo "WARNING: there are no files in archive \\'${D}file\\'"
1070 fi
1071 ;;
1072 *)
1073 newInputFiles="${D}{newInputFiles} ${D}file"
1074 ;;
1075 esac
1076 done
1077 inputFiles="${D}newInputFiles"
1078
1079 # Output filename(s).
1080 do_backup=0;
1081 if @<:@ -z ${D}outFile @:>@; then
1082 do_backup=1;
1083 set outFile ${D}inputFiles; outFile=${D}2
1084 fi
1085
1086 # If it is an archive, remove the '!' and the '_%' suffixes
1087 case ${D}outFile in
1088 *_%!)
1089 outFile=\`basnam ${D}outFile _%!\`
1090 ;;
1091 *)
1092 ;;
1093 esac
1094 case ${D}outFile in
1095 *.dll)
1096 outFile=\`basnam ${D}outFile .dll\`
1097 ;;
1098 *.DLL)
1099 outFile=\`basnam ${D}outFile .DLL\`
1100 ;;
1101 *.o)
1102 outFile=\`basnam ${D}outFile .o\`
1103 ;;
1104 *.obj)
1105 outFile=\`basnam ${D}outFile .obj\`
1106 ;;
1107 *.a)
1108 outFile=\`basnam ${D}outFile .a\`
1109 ;;
1110 *.lib)
1111 outFile=\`basnam ${D}outFile .lib\`
1112 ;;
1113 *)
1114 ;;
1115 esac
1116 case ${D}outimpFile in
1117 *.a)
1118 outimpFile=\`basnam ${D}outimpFile .a\`
1119 ;;
1120 *.lib)
1121 outimpFile=\`basnam ${D}outimpFile .lib\`
1122 ;;
1123 *)
1124 ;;
1125 esac
1126 if @<:@ -z ${D}outimpFile @:>@; then
1127 outimpFile=${D}outFile
1128 fi
1129 defFile="${D}{outFile}.def"
1130 arcFile="${D}{outimpFile}.a"
1131 arcFile2="${D}{outimpFile}.lib"
1132
1133 #create ${D}dllFile as something matching 8.3 restrictions,
1134 if @<:@ -z ${D}renameScript @:>@ ; then
1135 dllFile="${D}outFile"
1136 else
1137 dllFile=\`${D}renameScript ${D}outimpFile\`
1138 fi
1139
1140 if @<:@ ${D}do_backup -ne 0 @:>@ ; then
1141 if @<:@ -f ${D}arcFile @:>@ ; then
1142 doCommand "mv ${D}arcFile ${D}{outFile}_s.a"
1143 fi
1144 if @<:@ -f ${D}arcFile2 @:>@ ; then
1145 doCommand "mv ${D}arcFile2 ${D}{outFile}_s.lib"
1146 fi
1147 fi
1148
1149 # Extract public symbols from all the object files.
1150 tmpdefFile=${D}{defFile}_%
1151 rm -f ${D}tmpdefFile
1152 for file in ${D}inputFiles ; do
1153 case ${D}file in
1154 *!)
1155 ;;
1156 *)
1157 doCommand "emxexp -u ${D}file >> ${D}tmpdefFile"
1158 ;;
1159 esac
1160 done
1161
1162 # Create the def file.
1163 rm -f ${D}defFile
1164 echo "LIBRARY \`basnam ${D}dllFile\` ${D}library_flags" >> ${D}defFile
1165 dllFile="${D}{dllFile}.dll"
1166 if @<:@ ! -z ${D}description @:>@; then
1167 echo "DESCRIPTION \\"${D}{description}\\"" >> ${D}defFile
1168 fi
1169 echo "EXPORTS" >> ${D}defFile
1170
1171 doCommand "cat ${D}tmpdefFile | sort.exe | uniq.exe > ${D}{tmpdefFile}%"
1172 grep -v "^ *;" < ${D}{tmpdefFile}% | grep -v "^ *${D}" >${D}tmpdefFile
1173
1174 # Checks if the export is ok or not.
1175 for word in ${D}exclude_symbols; do
1176 grep -v ${D}word < ${D}tmpdefFile >${D}{tmpdefFile}%
1177 mv ${D}{tmpdefFile}% ${D}tmpdefFile
1178 done
1179
1180
1181 if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then
1182 sed "=" < ${D}tmpdefFile | \\
1183 sed '
1184 N
1185 : loop
1186 s/^\\(@<:@0-9@:>@\\+\\)\\(@<:@^;@:>@*\\)\\(;.*\\)\\?/\\2 @\\1 NONAME/
1187 t loop
1188 ' > ${D}{tmpdefFile}%
1189 grep -v "^ *${D}" < ${D}{tmpdefFile}% > ${D}tmpdefFile
1190 else
1191 rm -f ${D}{tmpdefFile}%
1192 fi
1193 cat ${D}tmpdefFile >> ${D}defFile
1194 rm -f ${D}tmpdefFile
1195
1196 # Do linking, create implib, and apply lxlite.
1197 gccCmdl="";
1198 for file in ${D}inputFiles ; do
1199 case ${D}file in
1200 *!)
1201 ;;
1202 *)
1203 gccCmdl="${D}gccCmdl ${D}file"
1204 ;;
1205 esac
1206 done
1207 doCommand "${D}CC ${D}CFLAGS -Zdll -o ${D}dllFile ${D}defFile ${D}gccCmdl ${D}EXTRA_CFLAGS"
1208 touch "${D}{outFile}.dll"
1209
1210 doCommand "emximp -o ${D}arcFile ${D}defFile"
1211 if @<:@ ${D}flag_USE_LXLITE -ne 0 @:>@; then
1212 add_flags="";
1213 if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then
1214 add_flags="-ynd"
1215 fi
1216 doCommand "lxlite -cs -t: -mrn -mln ${D}add_flags ${D}dllFile"
1217 fi
1218 doCommand "emxomf -s -l ${D}arcFile"
1219
1220 # Successful exit.
1221 CleanUp 1
1222 exit 0
1223 EOF
1224 dnl ===================== dllar.sh ends here =====================
1225 ])
1226
1227 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
1228 [
1229 dnl ===================== bk-deps begins here =====================
1230 dnl (Created by merge-scripts.py from bk-deps
1231 dnl file do not edit here!)
1232 D='$'
1233 cat <<EOF >bk-deps
1234 #!/bin/sh
1235
1236 # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1237 # script. It is used to track C/C++ files dependencies in portable way.
1238 #
1239 # Permission is given to use this file in any way.
1240
1241 DEPSMODE=${DEPSMODE}
1242 DEPSDIR=.deps
1243 DEPSFLAG="${DEPSFLAG}"
1244
1245 mkdir -p ${D}DEPSDIR
1246
1247 if test ${D}DEPSMODE = gcc ; then
1248 ${D}* ${D}{DEPSFLAG}
1249 status=${D}?
1250 if test ${D}{status} != 0 ; then
1251 exit ${D}{status}
1252 fi
1253 # move created file to the location we want it in:
1254 while test ${D}# -gt 0; do
1255 case "${D}1" in
1256 -o )
1257 shift
1258 objfile=${D}1
1259 ;;
1260 -* )
1261 ;;
1262 * )
1263 srcfile=${D}1
1264 ;;
1265 esac
1266 shift
1267 done
1268 depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
1269 depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
1270 if test -f ${D}depfile ; then
1271 sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
1272 rm -f ${D}depfile
1273 else
1274 depfile=\`basename ${D}objfile | sed -e 's/\\..*${D}/.d/g'\`
1275 if test -f ${D}depfile ; then
1276 sed -e "/^${D}objfile/!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
1277 rm -f ${D}depfile
1278 fi
1279 fi
1280 exit 0
1281 elif test ${D}DEPSMODE = mwcc ; then
1282 ${D}* || exit ${D}?
1283 # Run mwcc again with -MM and redirect into the dep file we want
1284 # NOTE: We can't use shift here because we need ${D}* to be valid
1285 prevarg=
1286 for arg in ${D}* ; do
1287 if test "${D}prevarg" = "-o"; then
1288 objfile=${D}arg
1289 else
1290 case "${D}arg" in
1291 -* )
1292 ;;
1293 * )
1294 srcfile=${D}arg
1295 ;;
1296 esac
1297 fi
1298 prevarg="${D}arg"
1299 done
1300 ${D}* ${D}DEPSFLAG >${D}{DEPSDIR}/${D}{objfile}.d
1301 exit 0
1302 elif test ${D}DEPSMODE = unixcc; then
1303 ${D}* || exit ${D}?
1304 # Run compiler again with deps flag and redirect into the dep file.
1305 # It doesn't work if the '-o FILE' option is used, but without it the
1306 # dependency file will contain the wrong name for the object. So it is
1307 # removed from the command line, and the dep file is fixed with sed.
1308 cmd=""
1309 while test ${D}# -gt 0; do
1310 case "${D}1" in
1311 -o )
1312 shift
1313 objfile=${D}1
1314 ;;
1315 * )
1316 eval arg${D}#=\\${D}1
1317 cmd="${D}cmd \\${D}arg${D}#"
1318 ;;
1319 esac
1320 shift
1321 done
1322 eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{DEPSDIR}/${D}{objfile}.d
1323 exit 0
1324 else
1325 ${D}*
1326 exit ${D}?
1327 fi
1328 EOF
1329 dnl ===================== bk-deps ends here =====================
1330 ])
1331
1332 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
1333 [
1334 dnl ===================== shared-ld-sh begins here =====================
1335 dnl (Created by merge-scripts.py from shared-ld-sh
1336 dnl file do not edit here!)
1337 D='$'
1338 cat <<EOF >shared-ld-sh
1339 #!/bin/sh
1340 #-----------------------------------------------------------------------------
1341 #-- Name: distrib/mac/shared-ld-sh
1342 #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
1343 #-- Author: Gilles Depeyrot
1344 #-- Copyright: (c) 2002 Gilles Depeyrot
1345 #-- Licence: any use permitted
1346 #-----------------------------------------------------------------------------
1347
1348 verbose=0
1349 args=""
1350 objects=""
1351 linking_flag="-dynamiclib"
1352 ldargs="-r -keep_private_externs -nostdlib"
1353
1354 while test ${D}# -gt 0; do
1355 case ${D}1 in
1356
1357 -v)
1358 verbose=1
1359 ;;
1360
1361 -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
1362 # collect these options and values
1363 args="${D}{args} ${D}1 ${D}2"
1364 shift
1365 ;;
1366
1367 -s|-Wl,*)
1368 # collect these load args
1369 ldargs="${D}{ldargs} ${D}1"
1370 ;;
1371
1372 -l*|-L*|-flat_namespace|-headerpad_max_install_names)
1373 # collect these options
1374 args="${D}{args} ${D}1"
1375 ;;
1376
1377 -dynamiclib|-bundle)
1378 linking_flag="${D}1"
1379 ;;
1380
1381 -*)
1382 echo "shared-ld: unhandled option '${D}1'"
1383 exit 1
1384 ;;
1385
1386 *.o | *.a | *.dylib)
1387 # collect object files
1388 objects="${D}{objects} ${D}1"
1389 ;;
1390
1391 *)
1392 echo "shared-ld: unhandled argument '${D}1'"
1393 exit 1
1394 ;;
1395
1396 esac
1397 shift
1398 done
1399
1400 status=0
1401
1402 #
1403 # Link one module containing all the others
1404 #
1405 if test ${D}{verbose} = 1; then
1406 echo "c++ ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o"
1407 fi
1408 c++ ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o
1409 status=${D}?
1410
1411 #
1412 # Link the shared library from the single module created, but only if the
1413 # previous command didn't fail:
1414 #
1415 if test ${D}{status} = 0; then
1416 if test ${D}{verbose} = 1; then
1417 echo "c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
1418 fi
1419 c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args}
1420 status=${D}?
1421 fi
1422
1423 #
1424 # Remove intermediate module
1425 #
1426 rm -f master.${D}${D}.o
1427
1428 exit ${D}status
1429 EOF
1430 dnl ===================== shared-ld-sh ends here =====================
1431 ])
1432
1433 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
1434 [
1435 dnl ===================== bk-make-pch begins here =====================
1436 dnl (Created by merge-scripts.py from bk-make-pch
1437 dnl file do not edit here!)
1438 D='$'
1439 cat <<EOF >bk-make-pch
1440 #!/bin/sh
1441
1442 # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1443 # script. It is used to generated precompiled headers.
1444 #
1445 # Permission is given to use this file in any way.
1446
1447 outfile="${D}{1}"
1448 header="${D}{2}"
1449 shift
1450 shift
1451
1452 compiler=
1453 headerfile=
1454 while test ${D}{#} -gt 0; do
1455 case "${D}{1}" in
1456 -I* )
1457 incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
1458 if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
1459 headerfile="${D}{incdir}/${D}{header}"
1460 fi
1461 ;;
1462 esac
1463 compiler="${D}{compiler} ${D}{1}"
1464 shift
1465 done
1466
1467 if test "x${D}{headerfile}" = "x" ; then
1468 echo "error: can't find header ${D}{header} in include paths" >2
1469 else
1470 if test -f ${D}{outfile} ; then
1471 rm -f ${D}{outfile}
1472 else
1473 mkdir -p \`dirname ${D}{outfile}\`
1474 fi
1475 depsfile=".deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
1476 mkdir -p .deps
1477 # can do this because gcc is >= 3.4:
1478 ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
1479 exit ${D}{?}
1480 fi
1481 EOF
1482 dnl ===================== bk-make-pch ends here =====================
1483 ])