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