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