1 dnl ---------------------------------------------------------------------------
2 dnl Support macros for makefiles generated by BAKEFILE.
3 dnl ---------------------------------------------------------------------------
5 dnl Lots of compiler & linker detection code contained here was taken from
6 dnl wxWindows configure.in script (see http://www.wxwindows.org)
10 dnl ---------------------------------------------------------------------------
11 dnl AC_BAKEFILE_GNUMAKE
14 dnl ---------------------------------------------------------------------------
16 AC_DEFUN([AC_BAKEFILE_GNUMAKE],
18 dnl does make support "-include" (only GNU make does AFAIK)?
19 AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu,
21 if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null |
22 egrep -s GNU > /dev/null); then
23 bakefile_cv_prog_makeisgnu="yes"
25 bakefile_cv_prog_makeisgnu="no"
29 if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then
37 dnl ---------------------------------------------------------------------------
38 dnl AC_BAKEFILE_PLATFORM
40 dnl Detects platform and sets PLATFORM_XXX variables accordingly
41 dnl ---------------------------------------------------------------------------
43 AC_DEFUN([AC_BAKEFILE_PLATFORM],
54 if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then
55 case "${BAKEFILE_HOST}" in
56 *-*-cygwin* | *-*-mingw32* )
62 *-pc-os2_emx | *-pc-os2-emx )
72 powerpc-apple-macos* )
81 case "$BAKEFILE_FORCE_PLATFORM" in
102 AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
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)
118 dnl ---------------------------------------------------------------------------
119 dnl AC_BAKEFILE_PLATFORM_SPECIFICS
121 dnl Sets misc platform-specific settings
122 dnl ---------------------------------------------------------------------------
124 AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS],
126 AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf],
127 [use OMF object format (OS/2)]),
128 [bk_os2_use_omf="$enableval"])
130 case "${BAKEFILE_HOST}" in
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"
138 *-pc-os2_emx | *-pc-os2-emx )
139 if test "x$bk_os2_use_omf" = "xyes" ; then
142 LDFLAGS="-Zomf $LDFLAGS"
143 CFLAGS="-Zomf $CFLAGS"
144 CXXFLAGS="-Zomf $CXXFLAGS"
152 LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS"
157 dnl ---------------------------------------------------------------------------
158 dnl AC_BAKEFILE_SUFFIXES
160 dnl Detects shared various suffixes for shared libraries, libraries, programs,
162 dnl ---------------------------------------------------------------------------
164 AC_DEFUN([AC_BAKEFILE_SUFFIXES],
167 SO_SUFFIX_MODULE="so"
175 case "${BAKEFILE_HOST}" in
178 SO_SUFFIX_MODULE="sl"
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.
189 *-*-cygwin* | *-*-mingw32* )
191 SO_SUFFIX_MODULE="dll"
192 DLLIMP_SUFFIX="dll.a"
200 *-pc-os2_emx | *-pc-os2-emx )
202 SO_SUFFIX_MODULE="dll"
203 DLLIMP_SUFFIX=$OS2_LIBEXT
207 LIBEXT=".$OS2_LIBEXT"
211 SO_SUFFIX_MODULE="bundle"
215 if test "x$DLLIMP_SUFFIX" = "x" ; then
216 DLLIMP_SUFFIX="$SO_SUFFIX"
220 AC_SUBST(SO_SUFFIX_MODULE)
221 AC_SUBST(DLLIMP_SUFFIX)
226 AC_SUBST(DLLPREFIX_MODULE)
230 dnl ---------------------------------------------------------------------------
231 dnl AC_BAKEFILE_SHARED_LD
233 dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
234 dnl and SHARED_LD_CXX.
235 dnl ---------------------------------------------------------------------------
237 AC_DEFUN([AC_BAKEFILE_SHARED_LD],
239 dnl the extra compiler flags needed for compilation of shared library
241 if test "x$GCC" = "xyes"; then
242 dnl the switch for gcc is the same under all platforms
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"
250 case "${BAKEFILE_HOST}" in
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"
257 SHARED_LD_CC="${CC} -b -o"
258 SHARED_LD_CXX="${CXX} -b -o"
264 if test "x$GCC" != "xyes"; then
265 AC_CACHE_CHECK([for Intel compiler], bakefile_cv_prog_icc,
269 #ifndef __INTEL_COMPILER
273 bakefile_cv_prog_icc=yes,
274 bakefile_cv_prog_icc=no
277 if test "$bakefile_cv_prog_icc" = "yes"; then
284 if test "x$GCC" != xyes ; then
285 SHARED_LD_CC="${CC} -G -o"
286 SHARED_LD_CXX="${CXX} -G -o"
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
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, [
304 #if (__GNUC__ < 3) || \
305 ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
317 if test "$wx_cv_gcc31" = "no"; then
318 AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH
319 chmod +x shared-ld-sh
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"
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"
334 PIC_FLAG="-dynamic -fPIC"
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"
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"
358 dnl default settings are ok for gcc
359 if test "x$GCC" != "xyes"; then
364 *-*-cygwin* | *-*-mingw32* )
366 SHARED_LD_CC="\$(CC) -shared -o"
367 SHARED_LD_CXX="\$(CXX) -shared -o"
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"
374 AC_BAKEFILE_CREATE_FILE_DLLAR_SH
378 powerpc-apple-macos* | \
379 *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
388 AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
391 if test "x$PIC_FLAG" != "x" ; then
392 PIC_FLAG="$PIC_FLAG -DPIC"
395 if test "x$SHARED_LD_MODULE_CC" = "x" ; then
396 SHARED_LD_MODULE_CC="$SHARED_LD_CC"
398 if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
399 SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
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)
410 dnl ---------------------------------------------------------------------------
411 dnl AC_BAKEFILE_SHARED_VERSIONS
413 dnl Detects linker options for attaching versions (sonames) to shared libs.
414 dnl ---------------------------------------------------------------------------
416 AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
425 case "${BAKEFILE_HOST}" in
426 *-*-linux* | *-*-freebsd* )
427 SONAME_FLAG="-Wl,-soname,"
447 AC_SUBST(USE_SOVERSION)
448 AC_SUBST(USE_SOVERLINUX)
449 AC_SUBST(USE_SOVERSOLARIS)
450 AC_SUBST(USE_MACVERSION)
451 AC_SUBST(USE_SOSYMLINKS)
452 AC_SUBST(SONAME_FLAG)
456 dnl ---------------------------------------------------------------------------
459 dnl Detects available C/C++ dependency tracking options
460 dnl ---------------------------------------------------------------------------
462 AC_DEFUN([AC_BAKEFILE_DEPS],
464 AC_MSG_CHECKING([for dependency tracking method])
467 if test "x$GCC" = "xyes"; then
470 case "${BAKEFILE_HOST}" in
472 dnl -cpp-precomp (the default) conflicts with -MMD option
473 dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html)
474 DEPSFLAG_GCC="-no-cpp-precomp -MMD"
482 AC_MSG_RESULT([none])
485 if test $DEPS_TRACKING = 1 ; then
486 AC_BAKEFILE_CREATE_FILE_BK_DEPS
490 AC_SUBST(DEPS_TRACKING)
493 dnl ---------------------------------------------------------------------------
494 dnl AC_BAKEFILE_CHECK_BASIC_STUFF
496 dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
498 dnl ---------------------------------------------------------------------------
500 AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
509 AC_CHECK_TOOL(AR, ar, ar)
510 AC_CHECK_TOOL(STRIP, strip, :)
511 AC_CHECK_TOOL(NM, nm, :)
513 case ${BAKEFILE_HOST} in
515 dnl HP-UX install doesn't handle the "-d" switch so don't
517 INSTALL_DIR="mkdir -p"
519 *) INSTALL_DIR="$INSTALL -d"
522 AC_SUBST(INSTALL_DIR)
525 case ${BAKEFILE_HOST} in
526 *-*-cygwin* | *-*-mingw32* )
527 LDFLAGS_GUI="-mwindows"
529 AC_SUBST(LDFLAGS_GUI)
533 dnl ---------------------------------------------------------------------------
534 dnl AC_BAKEFILE_RES_COMPILERS
536 dnl Checks for presence of resource compilers for win32 or mac
537 dnl ---------------------------------------------------------------------------
539 AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
544 case ${BAKEFILE_HOST} in
545 *-*-cygwin* | *-*-mingw32* )
546 dnl Check for win32 resources compiler:
547 if test "$build" != "$host" ; then
548 RESCOMP=$host_alias-windres
550 AC_CHECK_PROG(RESCOMP, windres, windres, windres)
554 *-*-darwin* | powerpc-apple-macos* )
555 AC_CHECK_PROG(RESCOMP, Rez, Rez, /Developer/Tools/Rez)
556 AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
564 dnl ---------------------------------------------------------------------------
565 dnl AC_BAKEFILE_PRECOMP_HEADERS
567 dnl Check for precompiled headers support (GCC >= 3.4)
568 dnl ---------------------------------------------------------------------------
570 AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
573 AC_ARG_ENABLE([precomp-headers],
574 AS_HELP_STRING([--disable-precomp-headers],
575 [don't use precompiled headers even if compiler can]),
576 [bk_use_pch="$enableval"])
580 if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
581 if test "x$GCC" = "xyes"; then
582 dnl test if we have gcc-3.4:
583 AC_MSG_CHECKING([if the compiler supports precompiled headers])
586 #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
587 #error "no pch support"
590 #error "no pch support"
592 #if (__GNUC__ == 3) && \
593 ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
594 ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3)))
595 #error "no pch support"
605 if test $GCC_PCH = 1 ; then
606 AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
617 dnl ---------------------------------------------------------------------------
620 dnl To be used in configure.in of any project using Bakefile-generated mks
622 dnl Behaviour can be modified by setting following variables:
623 dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
624 dnl to perform check for basic tools like ranlib
625 dnl BAKEFILE_HOST set this to override host detection, defaults
627 dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
628 dnl ---------------------------------------------------------------------------
630 AC_DEFUN([AC_BAKEFILE],
634 if test "x$BAKEFILE_HOST" = "x"; then
635 BAKEFILE_HOST="${host}"
638 if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
639 AC_BAKEFILE_CHECK_BASIC_STUFF
643 AC_BAKEFILE_PLATFORM_SPECIFICS
645 AC_BAKEFILE_SHARED_LD
646 AC_BAKEFILE_SHARED_VERSIONS
648 AC_BAKEFILE_RES_COMPILERS
650 BAKEFILE_BAKEFILE_M4_VERSION="0.1.4"
652 builtin(include, autoconf_inc.m4)
654 if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
655 AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
660 dnl ---------------------------------------------------------------------------
661 dnl Embedded copies of helper scripts follow:
662 dnl ---------------------------------------------------------------------------
664 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_DLLAR_SH],
666 dnl ===================== dllar.sh begins here =====================
671 # dllar - a tool to build both a .dll and an .a file
672 # from a set of object (.o) files for EMX/OS2.
674 # Written by Andrew Zabolotny, bit@freya.etu.ru
675 # Ported to Unix like shell by Stefan Neis, Stefan.Neis@t-online.de
677 # This script will accept a set of files on the command line.
678 # All the public symbols from the .o files will be exported into
679 # a .DEF file, then linker will be run (through gcc) against them to
680 # build a shared library consisting of all given .o files. All libraries
681 # (.a) will be first decompressed into component .o files then act as
682 # described above. You can optionally give a description (-d "description")
683 # which will be put into .DLL. To see the list of accepted options (as well
684 # as command-line format) simply run this program without options. The .DLL
685 # is built to be imported by name (there is no guarantee that new versions
686 # of the library you build will have same ordinals for same symbols).
688 # dllar is free software; you can redistribute it and/or modify
689 # it under the terms of the GNU General Public License as published by
690 # the Free Software Foundation; either version 2, or (at your option)
693 # dllar is distributed in the hope that it will be useful,
694 # but WITHOUT ANY WARRANTY; without even the implied warranty of
695 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
696 # GNU General Public License for more details.
698 # You should have received a copy of the GNU General Public License
699 # along with dllar; see the file COPYING. If not, write to the Free
700 # Software Foundation, 59 Temple Place - Suite 330, Boston, MA
703 # To successfuly run this program you will need:
704 # - Current drive should have LFN support (HPFS, ext2, network, etc)
705 # (Sometimes dllar generates filenames which won't fit 8.3 scheme)
707 # (used to build the .dll)
709 # (used to create .def file from .o files)
711 # (used to create .a file from .def file)
712 # - GNU text utilites (cat, sort, uniq)
713 # used to process emxexp output
714 # - GNU file utilities (mv, rm)
716 # - lxlite (optional, see flag below)
717 # (used for general .dll cleanup)
724 # basnam, variant of basename, which does _not_ remove the path, _iff_
725 # second argument (suffix to remove) is given
729 echo ${D}1 | sed 's/.*\\///' | sed 's/.*\\\\//'
732 echo ${D}1 | sed 's/'${D}2'${D}//'
735 echo "error in basnam ${D}*"
741 # Cleanup temporary files and output
744 for i in ${D}inputFiles ; do
747 rm -rf \`basnam ${D}i !\`
754 # Kill result in case of failure as there is just to many stupid make/nmake
755 # things out there which doesn't do this.
756 if @<:@ ${D}# -eq 0 @:>@; then
757 rm -f ${D}arcFile ${D}arcFile2 ${D}defFile ${D}dllFile
761 # Print usage and exit script with rc=1.
763 echo 'Usage: dllar.sh @<:@-o@<:@utput@:>@ output_file@:>@ @<:@-i@<:@mport@:>@ importlib_name@:>@'
764 echo ' @<:@-name-mangler-script script.sh@:>@'
765 echo ' @<:@-d@<:@escription@:>@ "dll descrption"@:>@ @<:@-cc "CC"@:>@ @<:@-f@<:@lags@:>@ "CFLAGS"@:>@'
766 echo ' @<:@-ord@<:@inals@:>@@:>@ -ex@<:@clude@:>@ "symbol(s)"'
767 echo ' @<:@-libf@<:@lags@:>@ "{INIT|TERM}{GLOBAL|INSTANCE}"@:>@ @<:@-nocrt@<:@dll@:>@@:>@ @<:@-nolxl@<:@ite@:>@@:>@'
768 echo ' @<:@*.o@:>@ @<:@*.a@:>@'
769 echo '*> "output_file" should have no extension.'
770 echo ' If it has the .o, .a or .dll extension, it is automatically removed.'
771 echo ' The import library name is derived from this and is set to "name".a,'
772 echo ' unless overridden by -import'
773 echo '*> "importlib_name" should have no extension.'
774 echo ' If it has the .o, or .a extension, it is automatically removed.'
775 echo ' This name is used as the import library name and may be longer and'
776 echo ' more descriptive than the DLL name which has to follow the old '
777 echo ' 8.3 convention of FAT.'
778 echo '*> "script.sh may be given to override the output_file name by a'
779 echo ' different name. It is mainly useful if the regular make process'
780 echo ' of some package does not take into account OS/2 restriction of'
781 echo ' DLL name lengths. It takes the importlib name as input and is'
782 echo ' supposed to procude a shorter name as output. The script should'
783 echo ' expect to get importlib_name without extension and should produce'
784 echo ' a (max.) 8 letter name without extension.'
785 echo '*> "cc" is used to use another GCC executable. (default: gcc.exe)'
786 echo '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)'
787 echo ' These flags will be put at the start of GCC command line.'
788 echo '*> -ord@<:@inals@:>@ tells dllar to export entries by ordinals. Be careful.'
789 echo '*> -ex@<:@clude@:>@ defines symbols which will not be exported. You can define'
790 echo ' multiple symbols, for example -ex "myfunc yourfunc _GLOBAL*".'
791 echo ' If the last character of a symbol is "*", all symbols beginning'
792 echo ' with the prefix before "*" will be exclude, (see _GLOBAL* above).'
793 echo '*> -libf@<:@lags@:>@ can be used to add INITGLOBAL/INITINSTANCE and/or'
794 echo ' TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.'
795 echo '*> -nocrt@<:@dll@:>@ switch will disable linking the library against emx''s'
796 echo ' C runtime DLLs.'
797 echo '*> -nolxl@<:@ite@:>@ switch will disable running lxlite on the resulting DLL.'
798 echo '*> All other switches (for example -L./ or -lmylib) will be passed'
799 echo ' unchanged to GCC at the end of command line.'
800 echo '*> If you create a DLL from a library and you do not specify -o,'
801 echo ' the basename for DLL and import library will be set to library name,'
802 echo ' the initial library will be renamed to 'name'_s.a (_s for static)'
803 echo ' i.e. "dllar gcc.a" will create gcc.dll and gcc.a, and the initial'
804 echo ' library will be renamed into gcc_s.a.'
807 echo ' dllar -o gcc290.dll libgcc.a -d "GNU C runtime library" -ord'
808 echo ' -ex "__main __ctordtor*" -libf "INITINSTANCE TERMINSTANCE"'
814 # If exit code of the commnad <> 0 CleanUp() is called and we'll exit the script.
815 # @Uses Whatever CleanUp() uses.
821 if @<:@ ${D}rcCmd -ne 0 @:>@; then
822 echo "command failed, exit code="${D}rcCmd
848 curDirS=${D}{curDirS}"/"
854 while @<:@ ${D}1 @:>@; do
857 EXPORT_BY_ORDINALS=1;
867 -name-mangler-script)
888 exclude_symbols=${D}{exclude_symbols}${D}1" "
892 library_flags=${D}{library_flags}${D}1" "
911 EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1
914 EXTRA_CFLAGS="${D}{EXTRA_CFLAGS} \`basnam ${D}1 .dll\`"
915 if @<:@ ${D}omfLinking -eq 1 @:>@; then
916 EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.lib"
918 EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.a"
923 if @<:@ ${D}libsToLink -ne 0 @:>@; then
924 EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1
926 for file in ${D}1 ; do
927 if @<:@ -f ${D}file @:>@; then
928 inputFiles="${D}{inputFiles} ${D}file"
932 if @<:@ ${D}found -eq 0 @:>@; then
933 echo "ERROR: No file(s) found: "${D}1
940 done # iterate cmdline words
943 if @<:@ -z "${D}inputFiles" @:>@; then
944 echo "dllar: no input files"
948 # Now extract all .o files from .a files
950 for file in ${D}inputFiles ; do
961 EXTRA_CFLAGS="${D}EXTRA_CFLAGS -Zomf"
966 dirname=\`basnam ${D}file ${D}suffix\`"_%"
968 if @<:@ ${D}? -ne 0 @:>@; then
969 echo "Failed to create subdirectory ./${D}dirname"
973 # Append '!' to indicate archive
974 newInputFiles="${D}newInputFiles ${D}{dirname}!"
975 doCommand "cd ${D}dirname; ${D}AR x ../${D}file"
978 for subfile in ${D}dirname/*.o* ; do
979 if @<:@ -f ${D}subfile @:>@; then
981 if @<:@ -s ${D}subfile @:>@; then
982 # FIXME: This should be: is file size > 32 byte, _not_ > 0!
983 newInputFiles="${D}newInputFiles ${D}subfile"
987 if @<:@ ${D}found -eq 0 @:>@; then
988 echo "WARNING: there are no files in archive \\'${D}file\\'"
992 newInputFiles="${D}{newInputFiles} ${D}file"
996 inputFiles="${D}newInputFiles"
998 # Output filename(s).
1000 if @<:@ -z ${D}outFile @:>@; then
1002 set outFile ${D}inputFiles; outFile=${D}2
1005 # If it is an archive, remove the '!' and the '_%' suffixes
1008 outFile=\`basnam ${D}outFile _%!\`
1015 outFile=\`basnam ${D}outFile .dll\`
1018 outFile=\`basnam ${D}outFile .DLL\`
1021 outFile=\`basnam ${D}outFile .o\`
1024 outFile=\`basnam ${D}outFile .obj\`
1027 outFile=\`basnam ${D}outFile .a\`
1030 outFile=\`basnam ${D}outFile .lib\`
1035 case ${D}outimpFile in
1037 outimpFile=\`basnam ${D}outimpFile .a\`
1040 outimpFile=\`basnam ${D}outimpFile .lib\`
1045 if @<:@ -z ${D}outimpFile @:>@; then
1046 outimpFile=${D}outFile
1048 defFile="${D}{outFile}.def"
1049 arcFile="${D}{outimpFile}.a"
1050 arcFile2="${D}{outimpFile}.lib"
1052 #create ${D}dllFile as something matching 8.3 restrictions,
1053 if @<:@ -z ${D}renameScript @:>@ ; then
1054 dllFile="${D}outFile"
1056 dllFile=\`${D}renameScript ${D}outimpFile\`
1059 if @<:@ ${D}do_backup -ne 0 @:>@ ; then
1060 if @<:@ -f ${D}arcFile @:>@ ; then
1061 doCommand "mv ${D}arcFile ${D}{outFile}_s.a"
1063 if @<:@ -f ${D}arcFile2 @:>@ ; then
1064 doCommand "mv ${D}arcFile2 ${D}{outFile}_s.lib"
1068 # Extract public symbols from all the object files.
1069 tmpdefFile=${D}{defFile}_%
1070 rm -f ${D}tmpdefFile
1071 for file in ${D}inputFiles ; do
1076 doCommand "emxexp -u ${D}file >> ${D}tmpdefFile"
1081 # Create the def file.
1083 echo "LIBRARY \`basnam ${D}dllFile\` ${D}library_flags" >> ${D}defFile
1084 dllFile="${D}{dllFile}.dll"
1085 if @<:@ ! -z ${D}description @:>@; then
1086 echo "DESCRIPTION \\"${D}{description}\\"" >> ${D}defFile
1088 echo "EXPORTS" >> ${D}defFile
1090 doCommand "cat ${D}tmpdefFile | sort.exe | uniq.exe > ${D}{tmpdefFile}%"
1091 grep -v "^ *;" < ${D}{tmpdefFile}% | grep -v "^ *${D}" >${D}tmpdefFile
1093 # Checks if the export is ok or not.
1094 for word in ${D}exclude_symbols; do
1095 grep -v ${D}word < ${D}tmpdefFile >${D}{tmpdefFile}%
1096 mv ${D}{tmpdefFile}% ${D}tmpdefFile
1100 if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then
1101 sed "=" < ${D}tmpdefFile | \\
1105 s/^\\(@<:@0-9@:>@\\+\\)\\(@<:@^;@:>@*\\)\\(;.*\\)\\?/\\2 @\\1 NONAME/
1107 ' > ${D}{tmpdefFile}%
1108 grep -v "^ *${D}" < ${D}{tmpdefFile}% > ${D}tmpdefFile
1110 rm -f ${D}{tmpdefFile}%
1112 cat ${D}tmpdefFile >> ${D}defFile
1113 rm -f ${D}tmpdefFile
1115 # Do linking, create implib, and apply lxlite.
1117 for file in ${D}inputFiles ; do
1122 gccCmdl="${D}gccCmdl ${D}file"
1126 doCommand "${D}CC ${D}CFLAGS -Zdll -o ${D}dllFile ${D}defFile ${D}gccCmdl ${D}EXTRA_CFLAGS"
1127 touch "${D}{outFile}.dll"
1129 doCommand "emximp -o ${D}arcFile ${D}defFile"
1130 if @<:@ ${D}flag_USE_LXLITE -ne 0 @:>@; then
1132 if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then
1135 doCommand "lxlite -cs -t: -mrn -mln ${D}add_flags ${D}dllFile"
1137 doCommand "emxomf -s -l ${D}arcFile"
1143 dnl ===================== dllar.sh ends here =====================
1146 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
1148 dnl ===================== bk-deps begins here =====================
1153 # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1154 # script. It is used to track C/C++ files dependencies in portable way.
1156 # Permission is given to use this file in any way.
1158 DEPSMODE=${DEPSMODE}
1160 DEPSFLAG_GCC="${DEPSFLAG_GCC}"
1162 mkdir -p ${D}DEPSDIR
1164 if test ${D}DEPSMODE = gcc ; then
1165 ${D}* ${D}{DEPSFLAG_GCC}
1167 if test ${D}{status} != 0 ; then
1170 # move created file to the location we want it in:
1171 while test ${D}# -gt 0; do
1185 depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
1186 depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
1187 if test -f ${D}depfile ; then
1188 sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
1191 depfile=\`basename ${D}objfile | sed -e 's/\\..*${D}/.d/g'\`
1192 if test -f ${D}depfile ; then
1193 sed -e "/^${D}objfile/!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
1203 dnl ===================== bk-deps ends here =====================
1206 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
1208 dnl ===================== shared-ld-sh begins here =====================
1210 cat <<EOF >shared-ld-sh
1212 #-----------------------------------------------------------------------------
1213 #-- Name: distrib/mac/shared-ld-sh
1214 #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
1215 #-- Author: Gilles Depeyrot
1216 #-- Copyright: (c) 2002 Gilles Depeyrot
1217 #-- Licence: any use permitted
1218 #-----------------------------------------------------------------------------
1223 linking_flag="-dynamiclib"
1225 while test ${D}# -gt 0; do
1232 -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
1233 # collect these options and values
1234 args="${D}{args} ${D}1 ${D}2"
1238 -l*|-L*|-flat_namespace|-headerpad_max_install_names)
1239 # collect these options
1240 args="${D}{args} ${D}1"
1243 -dynamiclib|-bundle)
1244 linking_flag="${D}1"
1248 echo "shared-ld: unhandled option '${D}1'"
1252 *.o | *.a | *.dylib)
1253 # collect object files
1254 objects="${D}{objects} ${D}1"
1258 echo "shared-ld: unhandled argument '${D}1'"
1267 # Link one module containing all the others
1269 if test ${D}{verbose} = 1; then
1270 echo "c++ -r -keep_private_externs -nostdlib ${D}{objects} -o master.${D}${D}.o"
1272 c++ -r -keep_private_externs -nostdlib ${D}{objects} -o master.${D}${D}.o
1274 if test ${D}{status} != 0; then
1279 # Link the shared library from the single module created
1281 if test ${D}{verbose} = 1; then
1282 echo "cc ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
1284 c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args}
1286 if test ${D}{status} != 0; then
1291 # Remove intermediate module
1293 rm -f master.${D}${D}.o
1297 dnl ===================== shared-ld-sh ends here =====================
1300 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
1302 dnl ===================== bk-make-pch begins here =====================
1304 cat <<EOF >bk-make-pch
1307 # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1308 # script. It is used to generated precompiled headers.
1310 # Permission is given to use this file in any way.
1319 while test ${D}{#} -gt 0; do
1322 incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
1323 if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
1324 headerfile="${D}{incdir}/${D}{header}"
1328 compiler="${D}{compiler} ${D}{1}"
1332 if test "x${D}{headerfile}" = "x" ; then
1333 echo "error: can't find header ${D}{header} in include paths" >2
1335 if test -f ${D}{outfile} ; then
1338 mkdir -p \`dirname ${D}{outfile}\`
1340 depsfile=".deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
1342 # can do this because gcc is >= 3.4:
1343 ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
1347 dnl ===================== bk-make-pch ends here =====================