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