]> git.saurik.com Git - wxWidgets.git/blob - build/aclocal/bakefile.m4
compate charset names case-insensitively in GetEncodingFromName()
[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 dnl at least gcc 2.95 warns that -fPIC is ignored when compiling
364 dnl each and every file under AIX which is annoying, so don't use
365 dnl it there (it's useless as AIX runs on position-independent
366 dnl architectures only anyhow)
367 if test "x$GCC" = "xyes"; then
368 PIC_FLAG=""
369 SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o"
370 SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o"
371 else
372 dnl the abs path below used to be hardcoded here so I guess it must
373 dnl be some sort of standard location under AIX?
374 AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
375 makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
376 dnl FIXME - what about makeCSharedLib?
377 SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
378 SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
379 fi
380 ;;
381
382 *-*-beos* )
383 dnl can't use gcc under BeOS for shared library creation because it
384 dnl complains about missing 'main'
385 SHARED_LD_CC="${LD} -nostart -o"
386 SHARED_LD_CXX="${LD} -nostart -o"
387 ;;
388
389 *-*-irix* )
390 dnl default settings are ok for gcc
391 if test "x$GCC" != "xyes"; then
392 PIC_FLAG="-KPIC"
393 fi
394 ;;
395
396 *-*-cygwin* | *-*-mingw32* )
397 PIC_FLAG=""
398 SHARED_LD_CC="\$(CC) -shared -o"
399 SHARED_LD_CXX="\$(CXX) -shared -o"
400 WINDOWS_IMPLIB=1
401 ;;
402
403 *-pc-os2_emx | *-pc-os2-emx )
404 SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
405 SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
406 PIC_FLAG=""
407 AC_BAKEFILE_CREATE_FILE_DLLAR_SH
408 chmod +x dllar.sh
409 ;;
410
411 powerpc-apple-macos* | \
412 *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-k*bsd*-gnu | \
413 *-*-sunos4* | \
414 *-*-osf* | \
415 *-*-dgux5* | \
416 *-*-sysv5* | \
417 *-pc-msdosdjgpp )
418 dnl defaults are ok
419 ;;
420
421 *)
422 AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
423 esac
424
425 if test "x$PIC_FLAG" != "x" ; then
426 PIC_FLAG="$PIC_FLAG -DPIC"
427 fi
428
429 if test "x$SHARED_LD_MODULE_CC" = "x" ; then
430 SHARED_LD_MODULE_CC="$SHARED_LD_CC"
431 fi
432 if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
433 SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
434 fi
435
436 AC_SUBST(SHARED_LD_CC)
437 AC_SUBST(SHARED_LD_CXX)
438 AC_SUBST(SHARED_LD_MODULE_CC)
439 AC_SUBST(SHARED_LD_MODULE_CXX)
440 AC_SUBST(PIC_FLAG)
441 AC_SUBST(WINDOWS_IMPLIB)
442 ])
443
444
445 dnl ---------------------------------------------------------------------------
446 dnl AC_BAKEFILE_SHARED_VERSIONS
447 dnl
448 dnl Detects linker options for attaching versions (sonames) to shared libs.
449 dnl ---------------------------------------------------------------------------
450
451 AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
452 [
453 USE_SOVERSION=0
454 USE_SOVERLINUX=0
455 USE_SOVERSOLARIS=0
456 USE_SOVERCYGWIN=0
457 USE_SOSYMLINKS=0
458 USE_MACVERSION=0
459 SONAME_FLAG=
460
461 case "${BAKEFILE_HOST}" in
462 *-*-linux* | *-*-freebsd* | *-*-k*bsd*-gnu )
463 SONAME_FLAG="-Wl,-soname,"
464 USE_SOVERSION=1
465 USE_SOVERLINUX=1
466 USE_SOSYMLINKS=1
467 ;;
468
469 *-*-solaris2* )
470 SONAME_FLAG="-h "
471 USE_SOVERSION=1
472 USE_SOVERSOLARIS=1
473 USE_SOSYMLINKS=1
474 ;;
475
476 *-*-darwin* )
477 USE_MACVERSION=1
478 USE_SOVERSION=1
479 USE_SOSYMLINKS=1
480 ;;
481
482 *-*-cygwin* )
483 USE_SOVERSION=1
484 USE_SOVERCYGWIN=1
485 ;;
486 esac
487
488 AC_SUBST(USE_SOVERSION)
489 AC_SUBST(USE_SOVERLINUX)
490 AC_SUBST(USE_SOVERSOLARIS)
491 AC_SUBST(USE_SOVERCYGWIN)
492 AC_SUBST(USE_MACVERSION)
493 AC_SUBST(USE_SOSYMLINKS)
494 AC_SUBST(SONAME_FLAG)
495 ])
496
497
498 dnl ---------------------------------------------------------------------------
499 dnl AC_BAKEFILE_DEPS
500 dnl
501 dnl Detects available C/C++ dependency tracking options
502 dnl ---------------------------------------------------------------------------
503
504 AC_DEFUN([AC_BAKEFILE_DEPS],
505 [
506 AC_MSG_CHECKING([for dependency tracking method])
507 DEPS_TRACKING=1
508
509 if test "x$GCC" = "xyes"; then
510 DEPSMODE=gcc
511 case "${BAKEFILE_HOST}" in
512 *-*-darwin* )
513 dnl -cpp-precomp (the default) conflicts with -MMD option
514 dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html)
515 DEPSFLAG="-no-cpp-precomp -MMD"
516 ;;
517 * )
518 DEPSFLAG="-MMD"
519 ;;
520 esac
521 AC_MSG_RESULT([gcc])
522 elif test "x$MWCC" = "xyes"; then
523 DEPSMODE=mwcc
524 DEPSFLAG="-MM"
525 AC_MSG_RESULT([mwcc])
526 elif test "x$SUNCC" = "xyes"; then
527 DEPSMODE=unixcc
528 DEPSFLAG="-xM1"
529 AC_MSG_RESULT([Sun cc])
530 elif test "x$SGICC" = "xyes"; then
531 DEPSMODE=unixcc
532 DEPSFLAG="-M"
533 AC_MSG_RESULT([SGI cc])
534 else
535 DEPS_TRACKING=0
536 AC_MSG_RESULT([none])
537 fi
538
539 if test $DEPS_TRACKING = 1 ; then
540 AC_BAKEFILE_CREATE_FILE_BK_DEPS
541 chmod +x bk-deps
542 fi
543
544 AC_SUBST(DEPS_TRACKING)
545 ])
546
547 dnl ---------------------------------------------------------------------------
548 dnl AC_BAKEFILE_CHECK_BASIC_STUFF
549 dnl
550 dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
551 dnl or "install"
552 dnl ---------------------------------------------------------------------------
553
554 AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
555 [
556 AC_PROG_RANLIB
557 AC_PROG_INSTALL
558 AC_PROG_LN_S
559
560 AC_PROG_MAKE_SET
561 AC_SUBST(MAKE_SET)
562
563 AC_CHECK_TOOL(AR, ar, ar)
564 AC_CHECK_TOOL(STRIP, strip, :)
565 AC_CHECK_TOOL(NM, nm, :)
566
567 case ${BAKEFILE_HOST} in
568 *-hp-hpux* )
569 dnl HP-UX install doesn't handle the "-d" switch so don't
570 dnl use it there
571 INSTALL_DIR="mkdir -p"
572 ;;
573 *) INSTALL_DIR="$INSTALL -d"
574 ;;
575 esac
576 AC_SUBST(INSTALL_DIR)
577
578 LDFLAGS_GUI=
579 case ${BAKEFILE_HOST} in
580 *-*-cygwin* | *-*-mingw32* )
581 LDFLAGS_GUI="-mwindows"
582 esac
583 AC_SUBST(LDFLAGS_GUI)
584 ])
585
586
587 dnl ---------------------------------------------------------------------------
588 dnl AC_BAKEFILE_RES_COMPILERS
589 dnl
590 dnl Checks for presence of resource compilers for win32 or mac
591 dnl ---------------------------------------------------------------------------
592
593 AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
594 [
595 RESCOMP=
596 SETFILE=
597
598 case ${BAKEFILE_HOST} in
599 *-*-cygwin* | *-*-mingw32* )
600 dnl Check for win32 resources compiler:
601 if test "$build" != "$host" ; then
602 RESCOMP=$host_alias-windres
603 else
604 AC_CHECK_PROG(RESCOMP, windres, windres, windres)
605 fi
606 ;;
607
608 *-*-darwin* | powerpc-apple-macos* )
609 AC_CHECK_PROG(RESCOMP, Rez, Rez, /Developer/Tools/Rez)
610 AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
611 ;;
612 esac
613
614 AC_SUBST(RESCOMP)
615 AC_SUBST(SETFILE)
616 ])
617
618 dnl ---------------------------------------------------------------------------
619 dnl AC_BAKEFILE_PRECOMP_HEADERS
620 dnl
621 dnl Check for precompiled headers support (GCC >= 3.4)
622 dnl ---------------------------------------------------------------------------
623
624 AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
625 [
626
627 AC_ARG_ENABLE([precomp-headers],
628 AS_HELP_STRING([--disable-precomp-headers],
629 [don't use precompiled headers even if compiler can]),
630 [bk_use_pch="$enableval"])
631
632 GCC_PCH=0
633
634 if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
635 if test "x$GCC" = "xyes"; then
636 dnl test if we have gcc-3.4:
637 AC_MSG_CHECKING([if the compiler supports precompiled headers])
638 AC_TRY_COMPILE([],
639 [
640 #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
641 #error "no pch support"
642 #endif
643 #if (__GNUC__ < 3)
644 #error "no pch support"
645 #endif
646 #if (__GNUC__ == 3) && \
647 ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
648 ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3)))
649 #error "no pch support"
650 #endif
651 ],
652 [
653 AC_MSG_RESULT([yes])
654 GCC_PCH=1
655 ],
656 [
657 AC_MSG_RESULT([no])
658 ])
659 if test $GCC_PCH = 1 ; then
660 AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
661 chmod +x bk-make-pch
662 fi
663 fi
664 fi
665
666 AC_SUBST(GCC_PCH)
667 ])
668
669
670
671 dnl ---------------------------------------------------------------------------
672 dnl AC_BAKEFILE([autoconf_inc.m4 inclusion])
673 dnl
674 dnl To be used in configure.in of any project using Bakefile-generated mks
675 dnl
676 dnl Behaviour can be modified by setting following variables:
677 dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
678 dnl to perform check for basic tools like ranlib
679 dnl BAKEFILE_HOST set this to override host detection, defaults
680 dnl to ${host}
681 dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
682 dnl
683 dnl Example usage:
684 dnl
685 dnl AC_BAKEFILE([FOO(autoconf_inc.m4)])
686 dnl
687 dnl (replace FOO with m4_include above, aclocal would die otherwise)
688 dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing
689 dnl we can do...)
690 dnl ---------------------------------------------------------------------------
691
692 AC_DEFUN([AC_BAKEFILE],
693 [
694 AC_PREREQ(2.58)
695
696 if test "x$BAKEFILE_HOST" = "x"; then
697 BAKEFILE_HOST="${host}"
698 fi
699
700 if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
701 AC_BAKEFILE_CHECK_BASIC_STUFF
702 fi
703 AC_BAKEFILE_GNUMAKE
704 AC_BAKEFILE_PLATFORM
705 AC_BAKEFILE_PLATFORM_SPECIFICS
706 AC_BAKEFILE_SUFFIXES
707 AC_BAKEFILE_SHARED_LD
708 AC_BAKEFILE_SHARED_VERSIONS
709 AC_BAKEFILE_DEPS
710 AC_BAKEFILE_RES_COMPILERS
711
712 BAKEFILE_BAKEFILE_M4_VERSION="0.1.9"
713
714 dnl includes autoconf_inc.m4:
715 $1
716
717 if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then
718 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)?])
719 fi
720
721 if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
722 AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
723 fi
724 ])
725
726
727 dnl ---------------------------------------------------------------------------
728 dnl Embedded copies of helper scripts follow:
729 dnl ---------------------------------------------------------------------------
730
731 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_DLLAR_SH],
732 [
733 dnl ===================== dllar.sh begins here =====================
734 dnl (Created by merge-scripts.py from dllar.sh
735 dnl file do not edit here!)
736 D='$'
737 cat <<EOF >dllar.sh
738 #!/bin/sh
739 #
740 # dllar - a tool to build both a .dll and an .a file
741 # from a set of object (.o) files for EMX/OS2.
742 #
743 # Written by Andrew Zabolotny, bit@freya.etu.ru
744 # Ported to Unix like shell by Stefan Neis, Stefan.Neis@t-online.de
745 #
746 # This script will accept a set of files on the command line.
747 # All the public symbols from the .o files will be exported into
748 # a .DEF file, then linker will be run (through gcc) against them to
749 # build a shared library consisting of all given .o files. All libraries
750 # (.a) will be first decompressed into component .o files then act as
751 # described above. You can optionally give a description (-d "description")
752 # which will be put into .DLL. To see the list of accepted options (as well
753 # as command-line format) simply run this program without options. The .DLL
754 # is built to be imported by name (there is no guarantee that new versions
755 # of the library you build will have same ordinals for same symbols).
756 #
757 # dllar is free software; you can redistribute it and/or modify
758 # it under the terms of the GNU General Public License as published by
759 # the Free Software Foundation; either version 2, or (at your option)
760 # any later version.
761 #
762 # dllar is distributed in the hope that it will be useful,
763 # but WITHOUT ANY WARRANTY; without even the implied warranty of
764 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
765 # GNU General Public License for more details.
766 #
767 # You should have received a copy of the GNU General Public License
768 # along with dllar; see the file COPYING. If not, write to the Free
769 # Software Foundation, 59 Temple Place - Suite 330, Boston, MA
770 # 02111-1307, USA.
771
772 # To successfuly run this program you will need:
773 # - Current drive should have LFN support (HPFS, ext2, network, etc)
774 # (Sometimes dllar generates filenames which won't fit 8.3 scheme)
775 # - gcc
776 # (used to build the .dll)
777 # - emxexp
778 # (used to create .def file from .o files)
779 # - emximp
780 # (used to create .a file from .def file)
781 # - GNU text utilites (cat, sort, uniq)
782 # used to process emxexp output
783 # - GNU file utilities (mv, rm)
784 # - GNU sed
785 # - lxlite (optional, see flag below)
786 # (used for general .dll cleanup)
787 #
788
789 flag_USE_LXLITE=1;
790
791 #
792 # helper functions
793 # basnam, variant of basename, which does _not_ remove the path, _iff_
794 # second argument (suffix to remove) is given
795 basnam(){
796 case ${D}# in
797 1)
798 echo ${D}1 | sed 's/.*\\///' | sed 's/.*\\\\//'
799 ;;
800 2)
801 echo ${D}1 | sed 's/'${D}2'${D}//'
802 ;;
803 *)
804 echo "error in basnam ${D}*"
805 exit 8
806 ;;
807 esac
808 }
809
810 # Cleanup temporary files and output
811 CleanUp() {
812 cd ${D}curDir
813 for i in ${D}inputFiles ; do
814 case ${D}i in
815 *!)
816 rm -rf \`basnam ${D}i !\`
817 ;;
818 *)
819 ;;
820 esac
821 done
822
823 # Kill result in case of failure as there is just to many stupid make/nmake
824 # things out there which doesn't do this.
825 if @<:@ ${D}# -eq 0 @:>@; then
826 rm -f ${D}arcFile ${D}arcFile2 ${D}defFile ${D}dllFile
827 fi
828 }
829
830 # Print usage and exit script with rc=1.
831 PrintHelp() {
832 echo 'Usage: dllar.sh @<:@-o@<:@utput@:>@ output_file@:>@ @<:@-i@<:@mport@:>@ importlib_name@:>@'
833 echo ' @<:@-name-mangler-script script.sh@:>@'
834 echo ' @<:@-d@<:@escription@:>@ "dll descrption"@:>@ @<:@-cc "CC"@:>@ @<:@-f@<:@lags@:>@ "CFLAGS"@:>@'
835 echo ' @<:@-ord@<:@inals@:>@@:>@ -ex@<:@clude@:>@ "symbol(s)"'
836 echo ' @<:@-libf@<:@lags@:>@ "{INIT|TERM}{GLOBAL|INSTANCE}"@:>@ @<:@-nocrt@<:@dll@:>@@:>@ @<:@-nolxl@<:@ite@:>@@:>@'
837 echo ' @<:@*.o@:>@ @<:@*.a@:>@'
838 echo '*> "output_file" should have no extension.'
839 echo ' If it has the .o, .a or .dll extension, it is automatically removed.'
840 echo ' The import library name is derived from this and is set to "name".a,'
841 echo ' unless overridden by -import'
842 echo '*> "importlib_name" should have no extension.'
843 echo ' If it has the .o, or .a extension, it is automatically removed.'
844 echo ' This name is used as the import library name and may be longer and'
845 echo ' more descriptive than the DLL name which has to follow the old '
846 echo ' 8.3 convention of FAT.'
847 echo '*> "script.sh may be given to override the output_file name by a'
848 echo ' different name. It is mainly useful if the regular make process'
849 echo ' of some package does not take into account OS/2 restriction of'
850 echo ' DLL name lengths. It takes the importlib name as input and is'
851 echo ' supposed to procude a shorter name as output. The script should'
852 echo ' expect to get importlib_name without extension and should produce'
853 echo ' a (max.) 8 letter name without extension.'
854 echo '*> "cc" is used to use another GCC executable. (default: gcc.exe)'
855 echo '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)'
856 echo ' These flags will be put at the start of GCC command line.'
857 echo '*> -ord@<:@inals@:>@ tells dllar to export entries by ordinals. Be careful.'
858 echo '*> -ex@<:@clude@:>@ defines symbols which will not be exported. You can define'
859 echo ' multiple symbols, for example -ex "myfunc yourfunc _GLOBAL*".'
860 echo ' If the last character of a symbol is "*", all symbols beginning'
861 echo ' with the prefix before "*" will be exclude, (see _GLOBAL* above).'
862 echo '*> -libf@<:@lags@:>@ can be used to add INITGLOBAL/INITINSTANCE and/or'
863 echo ' TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.'
864 echo '*> -nocrt@<:@dll@:>@ switch will disable linking the library against emx''s'
865 echo ' C runtime DLLs.'
866 echo '*> -nolxl@<:@ite@:>@ switch will disable running lxlite on the resulting DLL.'
867 echo '*> All other switches (for example -L./ or -lmylib) will be passed'
868 echo ' unchanged to GCC at the end of command line.'
869 echo '*> If you create a DLL from a library and you do not specify -o,'
870 echo ' the basename for DLL and import library will be set to library name,'
871 echo ' the initial library will be renamed to 'name'_s.a (_s for static)'
872 echo ' i.e. "dllar gcc.a" will create gcc.dll and gcc.a, and the initial'
873 echo ' library will be renamed into gcc_s.a.'
874 echo '--------'
875 echo 'Example:'
876 echo ' dllar -o gcc290.dll libgcc.a -d "GNU C runtime library" -ord'
877 echo ' -ex "__main __ctordtor*" -libf "INITINSTANCE TERMINSTANCE"'
878 CleanUp
879 exit 1
880 }
881
882 # Execute a command.
883 # If exit code of the commnad <> 0 CleanUp() is called and we'll exit the script.
884 # @Uses Whatever CleanUp() uses.
885 doCommand() {
886 echo "${D}*"
887 eval ${D}*
888 rcCmd=${D}?
889
890 if @<:@ ${D}rcCmd -ne 0 @:>@; then
891 echo "command failed, exit code="${D}rcCmd
892 CleanUp
893 exit ${D}rcCmd
894 fi
895 }
896
897 # main routine
898 # setup globals
899 cmdLine=${D}*
900 outFile=""
901 outimpFile=""
902 inputFiles=""
903 renameScript=""
904 description=""
905 CC=gcc.exe
906 CFLAGS="-s -Zcrtdll"
907 EXTRA_CFLAGS=""
908 EXPORT_BY_ORDINALS=0
909 exclude_symbols=""
910 library_flags=""
911 curDir=\`pwd\`
912 curDirS=curDir
913 case ${D}curDirS in
914 */)
915 ;;
916 *)
917 curDirS=${D}{curDirS}"/"
918 ;;
919 esac
920 # Parse commandline
921 libsToLink=0
922 omfLinking=0
923 while @<:@ ${D}1 @:>@; do
924 case ${D}1 in
925 -ord*)
926 EXPORT_BY_ORDINALS=1;
927 ;;
928 -o*)
929 shift
930 outFile=${D}1
931 ;;
932 -i*)
933 shift
934 outimpFile=${D}1
935 ;;
936 -name-mangler-script)
937 shift
938 renameScript=${D}1
939 ;;
940 -d*)
941 shift
942 description=${D}1
943 ;;
944 -f*)
945 shift
946 CFLAGS=${D}1
947 ;;
948 -c*)
949 shift
950 CC=${D}1
951 ;;
952 -h*)
953 PrintHelp
954 ;;
955 -ex*)
956 shift
957 exclude_symbols=${D}{exclude_symbols}${D}1" "
958 ;;
959 -libf*)
960 shift
961 library_flags=${D}{library_flags}${D}1" "
962 ;;
963 -nocrt*)
964 CFLAGS="-s"
965 ;;
966 -nolxl*)
967 flag_USE_LXLITE=0
968 ;;
969 -* | /*)
970 case ${D}1 in
971 -L* | -l*)
972 libsToLink=1
973 ;;
974 -Zomf)
975 omfLinking=1
976 ;;
977 *)
978 ;;
979 esac
980 EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1
981 ;;
982 *.dll)
983 EXTRA_CFLAGS="${D}{EXTRA_CFLAGS} \`basnam ${D}1 .dll\`"
984 if @<:@ ${D}omfLinking -eq 1 @:>@; then
985 EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.lib"
986 else
987 EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.a"
988 fi
989 ;;
990 *)
991 found=0;
992 if @<:@ ${D}libsToLink -ne 0 @:>@; then
993 EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1
994 else
995 for file in ${D}1 ; do
996 if @<:@ -f ${D}file @:>@; then
997 inputFiles="${D}{inputFiles} ${D}file"
998 found=1
999 fi
1000 done
1001 if @<:@ ${D}found -eq 0 @:>@; then
1002 echo "ERROR: No file(s) found: "${D}1
1003 exit 8
1004 fi
1005 fi
1006 ;;
1007 esac
1008 shift
1009 done # iterate cmdline words
1010
1011 #
1012 if @<:@ -z "${D}inputFiles" @:>@; then
1013 echo "dllar: no input files"
1014 PrintHelp
1015 fi
1016
1017 # Now extract all .o files from .a files
1018 newInputFiles=""
1019 for file in ${D}inputFiles ; do
1020 case ${D}file in
1021 *.a | *.lib)
1022 case ${D}file in
1023 *.a)
1024 suffix=".a"
1025 AR="ar"
1026 ;;
1027 *.lib)
1028 suffix=".lib"
1029 AR="emxomfar"
1030 EXTRA_CFLAGS="${D}EXTRA_CFLAGS -Zomf"
1031 ;;
1032 *)
1033 ;;
1034 esac
1035 dirname=\`basnam ${D}file ${D}suffix\`"_%"
1036 mkdir ${D}dirname
1037 if @<:@ ${D}? -ne 0 @:>@; then
1038 echo "Failed to create subdirectory ./${D}dirname"
1039 CleanUp
1040 exit 8;
1041 fi
1042 # Append '!' to indicate archive
1043 newInputFiles="${D}newInputFiles ${D}{dirname}!"
1044 doCommand "cd ${D}dirname; ${D}AR x ../${D}file"
1045 cd ${D}curDir
1046 found=0;
1047 for subfile in ${D}dirname/*.o* ; do
1048 if @<:@ -f ${D}subfile @:>@; then
1049 found=1
1050 if @<:@ -s ${D}subfile @:>@; then
1051 # FIXME: This should be: is file size > 32 byte, _not_ > 0!
1052 newInputFiles="${D}newInputFiles ${D}subfile"
1053 fi
1054 fi
1055 done
1056 if @<:@ ${D}found -eq 0 @:>@; then
1057 echo "WARNING: there are no files in archive \\'${D}file\\'"
1058 fi
1059 ;;
1060 *)
1061 newInputFiles="${D}{newInputFiles} ${D}file"
1062 ;;
1063 esac
1064 done
1065 inputFiles="${D}newInputFiles"
1066
1067 # Output filename(s).
1068 do_backup=0;
1069 if @<:@ -z ${D}outFile @:>@; then
1070 do_backup=1;
1071 set outFile ${D}inputFiles; outFile=${D}2
1072 fi
1073
1074 # If it is an archive, remove the '!' and the '_%' suffixes
1075 case ${D}outFile in
1076 *_%!)
1077 outFile=\`basnam ${D}outFile _%!\`
1078 ;;
1079 *)
1080 ;;
1081 esac
1082 case ${D}outFile in
1083 *.dll)
1084 outFile=\`basnam ${D}outFile .dll\`
1085 ;;
1086 *.DLL)
1087 outFile=\`basnam ${D}outFile .DLL\`
1088 ;;
1089 *.o)
1090 outFile=\`basnam ${D}outFile .o\`
1091 ;;
1092 *.obj)
1093 outFile=\`basnam ${D}outFile .obj\`
1094 ;;
1095 *.a)
1096 outFile=\`basnam ${D}outFile .a\`
1097 ;;
1098 *.lib)
1099 outFile=\`basnam ${D}outFile .lib\`
1100 ;;
1101 *)
1102 ;;
1103 esac
1104 case ${D}outimpFile in
1105 *.a)
1106 outimpFile=\`basnam ${D}outimpFile .a\`
1107 ;;
1108 *.lib)
1109 outimpFile=\`basnam ${D}outimpFile .lib\`
1110 ;;
1111 *)
1112 ;;
1113 esac
1114 if @<:@ -z ${D}outimpFile @:>@; then
1115 outimpFile=${D}outFile
1116 fi
1117 defFile="${D}{outFile}.def"
1118 arcFile="${D}{outimpFile}.a"
1119 arcFile2="${D}{outimpFile}.lib"
1120
1121 #create ${D}dllFile as something matching 8.3 restrictions,
1122 if @<:@ -z ${D}renameScript @:>@ ; then
1123 dllFile="${D}outFile"
1124 else
1125 dllFile=\`${D}renameScript ${D}outimpFile\`
1126 fi
1127
1128 if @<:@ ${D}do_backup -ne 0 @:>@ ; then
1129 if @<:@ -f ${D}arcFile @:>@ ; then
1130 doCommand "mv ${D}arcFile ${D}{outFile}_s.a"
1131 fi
1132 if @<:@ -f ${D}arcFile2 @:>@ ; then
1133 doCommand "mv ${D}arcFile2 ${D}{outFile}_s.lib"
1134 fi
1135 fi
1136
1137 # Extract public symbols from all the object files.
1138 tmpdefFile=${D}{defFile}_%
1139 rm -f ${D}tmpdefFile
1140 for file in ${D}inputFiles ; do
1141 case ${D}file in
1142 *!)
1143 ;;
1144 *)
1145 doCommand "emxexp -u ${D}file >> ${D}tmpdefFile"
1146 ;;
1147 esac
1148 done
1149
1150 # Create the def file.
1151 rm -f ${D}defFile
1152 echo "LIBRARY \`basnam ${D}dllFile\` ${D}library_flags" >> ${D}defFile
1153 dllFile="${D}{dllFile}.dll"
1154 if @<:@ ! -z ${D}description @:>@; then
1155 echo "DESCRIPTION \\"${D}{description}\\"" >> ${D}defFile
1156 fi
1157 echo "EXPORTS" >> ${D}defFile
1158
1159 doCommand "cat ${D}tmpdefFile | sort.exe | uniq.exe > ${D}{tmpdefFile}%"
1160 grep -v "^ *;" < ${D}{tmpdefFile}% | grep -v "^ *${D}" >${D}tmpdefFile
1161
1162 # Checks if the export is ok or not.
1163 for word in ${D}exclude_symbols; do
1164 grep -v ${D}word < ${D}tmpdefFile >${D}{tmpdefFile}%
1165 mv ${D}{tmpdefFile}% ${D}tmpdefFile
1166 done
1167
1168
1169 if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then
1170 sed "=" < ${D}tmpdefFile | \\
1171 sed '
1172 N
1173 : loop
1174 s/^\\(@<:@0-9@:>@\\+\\)\\(@<:@^;@:>@*\\)\\(;.*\\)\\?/\\2 @\\1 NONAME/
1175 t loop
1176 ' > ${D}{tmpdefFile}%
1177 grep -v "^ *${D}" < ${D}{tmpdefFile}% > ${D}tmpdefFile
1178 else
1179 rm -f ${D}{tmpdefFile}%
1180 fi
1181 cat ${D}tmpdefFile >> ${D}defFile
1182 rm -f ${D}tmpdefFile
1183
1184 # Do linking, create implib, and apply lxlite.
1185 gccCmdl="";
1186 for file in ${D}inputFiles ; do
1187 case ${D}file in
1188 *!)
1189 ;;
1190 *)
1191 gccCmdl="${D}gccCmdl ${D}file"
1192 ;;
1193 esac
1194 done
1195 doCommand "${D}CC ${D}CFLAGS -Zdll -o ${D}dllFile ${D}defFile ${D}gccCmdl ${D}EXTRA_CFLAGS"
1196 touch "${D}{outFile}.dll"
1197
1198 doCommand "emximp -o ${D}arcFile ${D}defFile"
1199 if @<:@ ${D}flag_USE_LXLITE -ne 0 @:>@; then
1200 add_flags="";
1201 if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then
1202 add_flags="-ynd"
1203 fi
1204 doCommand "lxlite -cs -t: -mrn -mln ${D}add_flags ${D}dllFile"
1205 fi
1206 doCommand "emxomf -s -l ${D}arcFile"
1207
1208 # Successful exit.
1209 CleanUp 1
1210 exit 0
1211 EOF
1212 dnl ===================== dllar.sh ends here =====================
1213 ])
1214
1215 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
1216 [
1217 dnl ===================== bk-deps begins here =====================
1218 dnl (Created by merge-scripts.py from bk-deps
1219 dnl file do not edit here!)
1220 D='$'
1221 cat <<EOF >bk-deps
1222 #!/bin/sh
1223
1224 # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1225 # script. It is used to track C/C++ files dependencies in portable way.
1226 #
1227 # Permission is given to use this file in any way.
1228
1229 DEPSMODE=${DEPSMODE}
1230 DEPSDIR=.deps
1231 DEPSFLAG="${DEPSFLAG}"
1232
1233 mkdir -p ${D}DEPSDIR
1234
1235 if test ${D}DEPSMODE = gcc ; then
1236 ${D}* ${D}{DEPSFLAG}
1237 status=${D}?
1238 if test ${D}{status} != 0 ; then
1239 exit ${D}{status}
1240 fi
1241 # move created file to the location we want it in:
1242 while test ${D}# -gt 0; do
1243 case "${D}1" in
1244 -o )
1245 shift
1246 objfile=${D}1
1247 ;;
1248 -* )
1249 ;;
1250 * )
1251 srcfile=${D}1
1252 ;;
1253 esac
1254 shift
1255 done
1256 depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
1257 depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
1258 if test -f ${D}depfile ; then
1259 sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
1260 rm -f ${D}depfile
1261 else
1262 depfile=\`basename ${D}objfile | sed -e 's/\\..*${D}/.d/g'\`
1263 if test -f ${D}depfile ; then
1264 sed -e "/^${D}objfile/!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
1265 rm -f ${D}depfile
1266 fi
1267 fi
1268 exit 0
1269 elif test ${D}DEPSMODE = mwcc ; then
1270 ${D}*
1271 status=${D}?
1272 if test ${D}{status} != 0 ; then
1273 exit ${D}{status}
1274 fi
1275 # Run mwcc again with -MM and redirect into the dep file we want
1276 # NOTE: We can't use shift here because we need ${D}* to be valid
1277 prevarg=
1278 for arg in ${D}* ; do
1279 if test "${D}prevarg" = "-o"; then
1280 objfile=${D}arg
1281 else
1282 case "${D}arg" in
1283 -* )
1284 ;;
1285 * )
1286 srcfile=${D}arg
1287 ;;
1288 esac
1289 fi
1290 prevarg="${D}arg"
1291 done
1292 ${D}* ${D}DEPSFLAG >${D}{DEPSDIR}/${D}{objfile}.d
1293 exit 0
1294 elif test ${D}DEPSMODE = unixcc; then
1295 ${D}* || exit
1296 # Run compiler again with deps flag and redirect into the dep file.
1297 # It doesn't work if the '-o FILE' option is used, but without it the
1298 # dependency file will contain the wrong name for the object. So it is
1299 # removed from the command line, and the dep file is fixed with sed.
1300 cmd=""
1301 while test ${D}# -gt 0; do
1302 case "${D}1" in
1303 -o )
1304 shift
1305 objfile=${D}1
1306 ;;
1307 * )
1308 eval arg${D}#=\\${D}1
1309 cmd="${D}cmd \\${D}arg${D}#"
1310 ;;
1311 esac
1312 shift
1313 done
1314 eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{DEPSDIR}/${D}{objfile}.d
1315 exit 0
1316 else
1317 ${D}*
1318 exit ${D}?
1319 fi
1320 EOF
1321 dnl ===================== bk-deps ends here =====================
1322 ])
1323
1324 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
1325 [
1326 dnl ===================== shared-ld-sh begins here =====================
1327 dnl (Created by merge-scripts.py from shared-ld-sh
1328 dnl file do not edit here!)
1329 D='$'
1330 cat <<EOF >shared-ld-sh
1331 #!/bin/sh
1332 #-----------------------------------------------------------------------------
1333 #-- Name: distrib/mac/shared-ld-sh
1334 #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
1335 #-- Author: Gilles Depeyrot
1336 #-- Copyright: (c) 2002 Gilles Depeyrot
1337 #-- Licence: any use permitted
1338 #-----------------------------------------------------------------------------
1339
1340 verbose=0
1341 args=""
1342 objects=""
1343 linking_flag="-dynamiclib"
1344 ldargs="-r -keep_private_externs -nostdlib"
1345
1346 while test ${D}# -gt 0; do
1347 case ${D}1 in
1348
1349 -v)
1350 verbose=1
1351 ;;
1352
1353 -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
1354 # collect these options and values
1355 args="${D}{args} ${D}1 ${D}2"
1356 shift
1357 ;;
1358
1359 -s|-Wl,*)
1360 # collect these load args
1361 ldargs="${D}{ldargs} ${D}1"
1362 ;;
1363
1364 -l*|-L*|-flat_namespace|-headerpad_max_install_names)
1365 # collect these options
1366 args="${D}{args} ${D}1"
1367 ;;
1368
1369 -dynamiclib|-bundle)
1370 linking_flag="${D}1"
1371 ;;
1372
1373 -*)
1374 echo "shared-ld: unhandled option '${D}1'"
1375 exit 1
1376 ;;
1377
1378 *.o | *.a | *.dylib)
1379 # collect object files
1380 objects="${D}{objects} ${D}1"
1381 ;;
1382
1383 *)
1384 echo "shared-ld: unhandled argument '${D}1'"
1385 exit 1
1386 ;;
1387
1388 esac
1389 shift
1390 done
1391
1392 status=0
1393
1394 #
1395 # Link one module containing all the others
1396 #
1397 if test ${D}{verbose} = 1; then
1398 echo "c++ ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o"
1399 fi
1400 c++ ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o
1401 status=${D}?
1402
1403 #
1404 # Link the shared library from the single module created, but only if the
1405 # previous command didn't fail:
1406 #
1407 if test ${D}{status} = 0; then
1408 if test ${D}{verbose} = 1; then
1409 echo "c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
1410 fi
1411 c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args}
1412 status=${D}?
1413 fi
1414
1415 #
1416 # Remove intermediate module
1417 #
1418 rm -f master.${D}${D}.o
1419
1420 exit ${D}status
1421 EOF
1422 dnl ===================== shared-ld-sh ends here =====================
1423 ])
1424
1425 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
1426 [
1427 dnl ===================== bk-make-pch begins here =====================
1428 dnl (Created by merge-scripts.py from bk-make-pch
1429 dnl file do not edit here!)
1430 D='$'
1431 cat <<EOF >bk-make-pch
1432 #!/bin/sh
1433
1434 # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1435 # script. It is used to generated precompiled headers.
1436 #
1437 # Permission is given to use this file in any way.
1438
1439 outfile="${D}{1}"
1440 header="${D}{2}"
1441 shift
1442 shift
1443
1444 compiler=
1445 headerfile=
1446 while test ${D}{#} -gt 0; do
1447 case "${D}{1}" in
1448 -I* )
1449 incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
1450 if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
1451 headerfile="${D}{incdir}/${D}{header}"
1452 fi
1453 ;;
1454 esac
1455 compiler="${D}{compiler} ${D}{1}"
1456 shift
1457 done
1458
1459 if test "x${D}{headerfile}" = "x" ; then
1460 echo "error: can't find header ${D}{header} in include paths" >2
1461 else
1462 if test -f ${D}{outfile} ; then
1463 rm -f ${D}{outfile}
1464 else
1465 mkdir -p \`dirname ${D}{outfile}\`
1466 fi
1467 depsfile=".deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
1468 mkdir -p .deps
1469 # can do this because gcc is >= 3.4:
1470 ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
1471 exit ${D}{?}
1472 fi
1473 EOF
1474 dnl ===================== bk-make-pch ends here =====================
1475 ])