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