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
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 if test "x$GCC" = "xyes"; then
135 CFLAGS="$CFLAGS -fno-common"
136 CXXFLAGS="$CXXFLAGS -fno-common"
138 if test "x$XLCC" = "xyes"; then
139 CFLAGS="$CFLAGS -qnocommon"
140 CXXFLAGS="$CXXFLAGS -qnocommon"
144 *-pc-os2_emx | *-pc-os2-emx )
145 if test "x$bk_os2_use_omf" = "xyes" ; then
148 LDFLAGS="-Zomf $LDFLAGS"
149 CFLAGS="-Zomf $CFLAGS"
150 CXXFLAGS="-Zomf $CXXFLAGS"
158 LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS"
163 dnl ---------------------------------------------------------------------------
164 dnl AC_BAKEFILE_SUFFIXES
166 dnl Detects shared various suffixes for shared libraries, libraries, programs,
168 dnl ---------------------------------------------------------------------------
170 AC_DEFUN([AC_BAKEFILE_SUFFIXES],
173 SO_SUFFIX_MODULE="so"
182 case "${BAKEFILE_HOST}" in
185 SO_SUFFIX_MODULE="sl"
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.
198 SO_SUFFIX_MODULE="dll"
199 DLLIMP_SUFFIX="dll.a"
206 SO_SUFFIX_MODULE="dll"
207 DLLIMP_SUFFIX="dll.a"
217 *-pc-os2_emx | *-pc-os2-emx )
219 SO_SUFFIX_MODULE="dll"
220 DLLIMP_SUFFIX=$OS2_LIBEXT
224 LIBEXT=".$OS2_LIBEXT"
229 SO_SUFFIX_MODULE="bundle"
233 if test "x$DLLIMP_SUFFIX" = "x" ; then
234 DLLIMP_SUFFIX="$SO_SUFFIX"
238 AC_SUBST(SO_SUFFIX_MODULE)
239 AC_SUBST(DLLIMP_SUFFIX)
244 AC_SUBST(DLLPREFIX_MODULE)
249 dnl ---------------------------------------------------------------------------
250 dnl AC_BAKEFILE_SHARED_LD
252 dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
253 dnl and SHARED_LD_CXX.
254 dnl ---------------------------------------------------------------------------
256 AC_DEFUN([AC_BAKEFILE_SHARED_LD],
258 dnl the extra compiler flags needed for compilation of shared library
260 if test "x$GCC" = "xyes"; then
261 dnl the switch for gcc is the same under all platforms
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"
270 case "${BAKEFILE_HOST}" in
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"
277 SHARED_LD_CC="${CC} -b -o"
278 SHARED_LD_CXX="${CXX} -b -o"
284 if test "x$GCC" != "xyes"; then
285 AC_CACHE_CHECK([for Intel compiler], bakefile_cv_prog_icc,
289 #ifndef __INTEL_COMPILER
293 bakefile_cv_prog_icc=yes,
294 bakefile_cv_prog_icc=no
297 if test "$bakefile_cv_prog_icc" = "yes"; then
304 if test "x$GCC" != xyes ; then
305 SHARED_LD_CC="${CC} -G -o"
306 SHARED_LD_CXX="${CXX} -G -o"
312 dnl Most apps benefit from being fully binded (its faster and static
313 dnl variables initialized at startup work).
314 dnl This can be done either with the exe linker flag -Wl,-bind_at_load
315 dnl or with a double stage link in order to create a single module
316 dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved
318 SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o"
319 SHARED_LD_MODULE_CXX="$SHARED_LD_MODULE_CC"
321 dnl If using newer dev tools then there is a -single_module flag that
322 dnl we can use to do this for dylibs, otherwise we'll need to use a helper
323 dnl script. Check the version of gcc to see which way we can go:
324 AC_CACHE_CHECK([for gcc 3.1 or later], bakefile_cv_gcc31, [
327 #if (__GNUC__ < 3) || \
328 ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
333 bakefile_cv_gcc31=yes
340 if test "$bakefile_cv_gcc31" = "no"; then
341 AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH
342 chmod +x shared-ld-sh
344 dnl Use the shared-ld-sh helper script
345 SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
346 SHARED_LD_CXX="$SHARED_LD_CC"
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"
350 SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
353 if test "x$GCC" == "xyes"; then
354 PIC_FLAG="-dynamic -fPIC"
356 if test "x$XLCC" = "xyes"; then
357 PIC_FLAG="-dynamic -DPIC"
362 if test "x$GCC" = "xyes"; then
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)
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
377 LD_EXPFULL="-Wl,-bexpfull"
381 SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o"
382 SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o"
384 dnl FIXME: makeC++SharedLib is obsolete, what should we do for
385 dnl recent AIX versions?
386 AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
387 makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
388 SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
389 SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
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"
401 dnl default settings are ok for gcc
402 if test "x$GCC" != "xyes"; then
407 *-*-cygwin* | *-*-mingw32* )
409 SHARED_LD_CC="\$(CC) -shared -o"
410 SHARED_LD_CXX="\$(CXX) -shared -o"
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"
418 AC_BAKEFILE_CREATE_FILE_DLLAR_SH
422 powerpc-apple-macos* | \
423 *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-k*bsd*-gnu | \
433 AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
436 if test "x$PIC_FLAG" != "x" ; then
437 PIC_FLAG="$PIC_FLAG -DPIC"
440 if test "x$SHARED_LD_MODULE_CC" = "x" ; then
441 SHARED_LD_MODULE_CC="$SHARED_LD_CC"
443 if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
444 SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
447 AC_SUBST(SHARED_LD_CC)
448 AC_SUBST(SHARED_LD_CXX)
449 AC_SUBST(SHARED_LD_MODULE_CC)
450 AC_SUBST(SHARED_LD_MODULE_CXX)
452 AC_SUBST(WINDOWS_IMPLIB)
456 dnl ---------------------------------------------------------------------------
457 dnl AC_BAKEFILE_SHARED_VERSIONS
459 dnl Detects linker options for attaching versions (sonames) to shared libs.
460 dnl ---------------------------------------------------------------------------
462 AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
472 case "${BAKEFILE_HOST}" in
473 *-*-linux* | *-*-freebsd* | *-*-k*bsd*-gnu )
474 SONAME_FLAG="-Wl,-soname,"
499 AC_SUBST(USE_SOVERSION)
500 AC_SUBST(USE_SOVERLINUX)
501 AC_SUBST(USE_SOVERSOLARIS)
502 AC_SUBST(USE_SOVERCYGWIN)
503 AC_SUBST(USE_MACVERSION)
504 AC_SUBST(USE_SOSYMLINKS)
505 AC_SUBST(SONAME_FLAG)
509 dnl ---------------------------------------------------------------------------
512 dnl Detects available C/C++ dependency tracking options
513 dnl ---------------------------------------------------------------------------
515 AC_DEFUN([AC_BAKEFILE_DEPS],
517 AC_MSG_CHECKING([for dependency tracking method])
520 if test "x$GCC" = "xyes"; then
522 case "${BAKEFILE_HOST}" in
524 dnl -cpp-precomp (the default) conflicts with -MMD option
525 dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html)
526 DEPSFLAG="-no-cpp-precomp -MMD"
533 elif test "x$MWCC" = "xyes"; then
536 AC_MSG_RESULT([mwcc])
537 elif test "x$SUNCC" = "xyes"; then
540 AC_MSG_RESULT([Sun cc])
541 elif test "x$SGICC" = "xyes"; then
544 AC_MSG_RESULT([SGI cc])
545 elif test "x$HPCC" = "xyes"; then
548 AC_MSG_RESULT([HP cc])
549 elif test "x$COMPAQCC" = "xyes"; then
552 AC_MSG_RESULT([Compaq cc])
555 AC_MSG_RESULT([none])
558 if test $DEPS_TRACKING = 1 ; then
559 AC_BAKEFILE_CREATE_FILE_BK_DEPS
563 AC_SUBST(DEPS_TRACKING)
566 dnl ---------------------------------------------------------------------------
567 dnl AC_BAKEFILE_CHECK_BASIC_STUFF
569 dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
571 dnl ---------------------------------------------------------------------------
573 AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
582 AC_CHECK_TOOL(AR, ar, ar)
583 AC_CHECK_TOOL(STRIP, strip, :)
584 AC_CHECK_TOOL(NM, nm, :)
586 case ${BAKEFILE_HOST} in
588 dnl HP-UX install doesn't handle the "-d" switch so don't
590 INSTALL_DIR="mkdir -p"
592 *) INSTALL_DIR="$INSTALL -d"
595 AC_SUBST(INSTALL_DIR)
598 case ${BAKEFILE_HOST} in
599 *-*-cygwin* | *-*-mingw32* )
600 LDFLAGS_GUI="-mwindows"
602 AC_SUBST(LDFLAGS_GUI)
606 dnl ---------------------------------------------------------------------------
607 dnl AC_BAKEFILE_RES_COMPILERS
609 dnl Checks for presence of resource compilers for win32 or mac
610 dnl ---------------------------------------------------------------------------
612 AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
617 case ${BAKEFILE_HOST} in
618 *-*-cygwin* | *-*-mingw32* )
619 dnl Check for win32 resources compiler:
620 if test "$build" != "$host" ; then
621 RESCOMP=$host_alias-windres
623 AC_CHECK_PROG(RESCOMP, windres, windres, windres)
627 *-*-darwin* | powerpc-apple-macos* )
628 AC_CHECK_PROG(RESCOMP, Rez, Rez, /Developer/Tools/Rez)
629 AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
637 dnl ---------------------------------------------------------------------------
638 dnl AC_BAKEFILE_PRECOMP_HEADERS
640 dnl Check for precompiled headers support (GCC >= 3.4)
641 dnl ---------------------------------------------------------------------------
643 AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
646 AC_ARG_ENABLE([precomp-headers],
647 AS_HELP_STRING([--disable-precomp-headers],
648 [don't use precompiled headers even if compiler can]),
649 [bk_use_pch="$enableval"])
653 if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
654 if test "x$GCC" = "xyes"; then
655 dnl test if we have gcc-3.4:
656 AC_MSG_CHECKING([if the compiler supports precompiled headers])
659 #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
660 #error "no pch support"
663 #error "no pch support"
665 #if (__GNUC__ == 3) && \
666 ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
667 ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3)))
668 #error "no pch support"
678 if test $GCC_PCH = 1 ; then
679 AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
690 dnl ---------------------------------------------------------------------------
691 dnl AC_BAKEFILE([autoconf_inc.m4 inclusion])
693 dnl To be used in configure.in of any project using Bakefile-generated mks
695 dnl Behaviour can be modified by setting following variables:
696 dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
697 dnl to perform check for basic tools like ranlib
698 dnl BAKEFILE_HOST set this to override host detection, defaults
700 dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
704 dnl AC_BAKEFILE([FOO(autoconf_inc.m4)])
706 dnl (replace FOO with m4_include above, aclocal would die otherwise)
707 dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing
709 dnl ---------------------------------------------------------------------------
711 AC_DEFUN([AC_BAKEFILE],
715 if test "x$BAKEFILE_HOST" = "x"; then
716 BAKEFILE_HOST="${host}"
719 if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
720 AC_BAKEFILE_CHECK_BASIC_STUFF
724 AC_BAKEFILE_PLATFORM_SPECIFICS
726 AC_BAKEFILE_SHARED_LD
727 AC_BAKEFILE_SHARED_VERSIONS
729 AC_BAKEFILE_RES_COMPILERS
731 BAKEFILE_BAKEFILE_M4_VERSION="0.1.9"
733 dnl includes autoconf_inc.m4:
736 if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then
737 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)?])
740 if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
741 AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
746 dnl ---------------------------------------------------------------------------
747 dnl Embedded copies of helper scripts follow:
748 dnl ---------------------------------------------------------------------------
750 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_DLLAR_SH],
752 dnl ===================== dllar.sh begins here =====================
753 dnl (Created by merge-scripts.py from dllar.sh
754 dnl file do not edit here!)
759 # dllar - a tool to build both a .dll and an .a file
760 # from a set of object (.o) files for EMX/OS2.
762 # Written by Andrew Zabolotny, bit@freya.etu.ru
763 # Ported to Unix like shell by Stefan Neis, Stefan.Neis@t-online.de
765 # This script will accept a set of files on the command line.
766 # All the public symbols from the .o files will be exported into
767 # a .DEF file, then linker will be run (through gcc) against them to
768 # build a shared library consisting of all given .o files. All libraries
769 # (.a) will be first decompressed into component .o files then act as
770 # described above. You can optionally give a description (-d "description")
771 # which will be put into .DLL. To see the list of accepted options (as well
772 # as command-line format) simply run this program without options. The .DLL
773 # is built to be imported by name (there is no guarantee that new versions
774 # of the library you build will have same ordinals for same symbols).
776 # dllar is free software; you can redistribute it and/or modify
777 # it under the terms of the GNU General Public License as published by
778 # the Free Software Foundation; either version 2, or (at your option)
781 # dllar is distributed in the hope that it will be useful,
782 # but WITHOUT ANY WARRANTY; without even the implied warranty of
783 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
784 # GNU General Public License for more details.
786 # You should have received a copy of the GNU General Public License
787 # along with dllar; see the file COPYING. If not, write to the Free
788 # Software Foundation, 59 Temple Place - Suite 330, Boston, MA
791 # To successfuly run this program you will need:
792 # - Current drive should have LFN support (HPFS, ext2, network, etc)
793 # (Sometimes dllar generates filenames which won't fit 8.3 scheme)
795 # (used to build the .dll)
797 # (used to create .def file from .o files)
799 # (used to create .a file from .def file)
800 # - GNU text utilites (cat, sort, uniq)
801 # used to process emxexp output
802 # - GNU file utilities (mv, rm)
804 # - lxlite (optional, see flag below)
805 # (used for general .dll cleanup)
812 # basnam, variant of basename, which does _not_ remove the path, _iff_
813 # second argument (suffix to remove) is given
817 echo ${D}1 | sed 's/.*\\///' | sed 's/.*\\\\//'
820 echo ${D}1 | sed 's/'${D}2'${D}//'
823 echo "error in basnam ${D}*"
829 # Cleanup temporary files and output
832 for i in ${D}inputFiles ; do
835 rm -rf \`basnam ${D}i !\`
842 # Kill result in case of failure as there is just to many stupid make/nmake
843 # things out there which doesn't do this.
844 if @<:@ ${D}# -eq 0 @:>@; then
845 rm -f ${D}arcFile ${D}arcFile2 ${D}defFile ${D}dllFile
849 # Print usage and exit script with rc=1.
851 echo 'Usage: dllar.sh @<:@-o@<:@utput@:>@ output_file@:>@ @<:@-i@<:@mport@:>@ importlib_name@:>@'
852 echo ' @<:@-name-mangler-script script.sh@:>@'
853 echo ' @<:@-d@<:@escription@:>@ "dll descrption"@:>@ @<:@-cc "CC"@:>@ @<:@-f@<:@lags@:>@ "CFLAGS"@:>@'
854 echo ' @<:@-ord@<:@inals@:>@@:>@ -ex@<:@clude@:>@ "symbol(s)"'
855 echo ' @<:@-libf@<:@lags@:>@ "{INIT|TERM}{GLOBAL|INSTANCE}"@:>@ @<:@-nocrt@<:@dll@:>@@:>@ @<:@-nolxl@<:@ite@:>@@:>@'
856 echo ' @<:@*.o@:>@ @<:@*.a@:>@'
857 echo '*> "output_file" should have no extension.'
858 echo ' If it has the .o, .a or .dll extension, it is automatically removed.'
859 echo ' The import library name is derived from this and is set to "name".a,'
860 echo ' unless overridden by -import'
861 echo '*> "importlib_name" should have no extension.'
862 echo ' If it has the .o, or .a extension, it is automatically removed.'
863 echo ' This name is used as the import library name and may be longer and'
864 echo ' more descriptive than the DLL name which has to follow the old '
865 echo ' 8.3 convention of FAT.'
866 echo '*> "script.sh may be given to override the output_file name by a'
867 echo ' different name. It is mainly useful if the regular make process'
868 echo ' of some package does not take into account OS/2 restriction of'
869 echo ' DLL name lengths. It takes the importlib name as input and is'
870 echo ' supposed to procude a shorter name as output. The script should'
871 echo ' expect to get importlib_name without extension and should produce'
872 echo ' a (max.) 8 letter name without extension.'
873 echo '*> "cc" is used to use another GCC executable. (default: gcc.exe)'
874 echo '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)'
875 echo ' These flags will be put at the start of GCC command line.'
876 echo '*> -ord@<:@inals@:>@ tells dllar to export entries by ordinals. Be careful.'
877 echo '*> -ex@<:@clude@:>@ defines symbols which will not be exported. You can define'
878 echo ' multiple symbols, for example -ex "myfunc yourfunc _GLOBAL*".'
879 echo ' If the last character of a symbol is "*", all symbols beginning'
880 echo ' with the prefix before "*" will be exclude, (see _GLOBAL* above).'
881 echo '*> -libf@<:@lags@:>@ can be used to add INITGLOBAL/INITINSTANCE and/or'
882 echo ' TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.'
883 echo '*> -nocrt@<:@dll@:>@ switch will disable linking the library against emx''s'
884 echo ' C runtime DLLs.'
885 echo '*> -nolxl@<:@ite@:>@ switch will disable running lxlite on the resulting DLL.'
886 echo '*> All other switches (for example -L./ or -lmylib) will be passed'
887 echo ' unchanged to GCC at the end of command line.'
888 echo '*> If you create a DLL from a library and you do not specify -o,'
889 echo ' the basename for DLL and import library will be set to library name,'
890 echo ' the initial library will be renamed to 'name'_s.a (_s for static)'
891 echo ' i.e. "dllar gcc.a" will create gcc.dll and gcc.a, and the initial'
892 echo ' library will be renamed into gcc_s.a.'
895 echo ' dllar -o gcc290.dll libgcc.a -d "GNU C runtime library" -ord'
896 echo ' -ex "__main __ctordtor*" -libf "INITINSTANCE TERMINSTANCE"'
902 # If exit code of the commnad <> 0 CleanUp() is called and we'll exit the script.
903 # @Uses Whatever CleanUp() uses.
909 if @<:@ ${D}rcCmd -ne 0 @:>@; then
910 echo "command failed, exit code="${D}rcCmd
936 curDirS=${D}{curDirS}"/"
942 while @<:@ ${D}1 @:>@; do
945 EXPORT_BY_ORDINALS=1;
955 -name-mangler-script)
976 exclude_symbols=${D}{exclude_symbols}${D}1" "
980 library_flags=${D}{library_flags}${D}1" "
999 EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1
1002 EXTRA_CFLAGS="${D}{EXTRA_CFLAGS} \`basnam ${D}1 .dll\`"
1003 if @<:@ ${D}omfLinking -eq 1 @:>@; then
1004 EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.lib"
1006 EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.a"
1011 if @<:@ ${D}libsToLink -ne 0 @:>@; then
1012 EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1
1014 for file in ${D}1 ; do
1015 if @<:@ -f ${D}file @:>@; then
1016 inputFiles="${D}{inputFiles} ${D}file"
1020 if @<:@ ${D}found -eq 0 @:>@; then
1021 echo "ERROR: No file(s) found: "${D}1
1028 done # iterate cmdline words
1031 if @<:@ -z "${D}inputFiles" @:>@; then
1032 echo "dllar: no input files"
1036 # Now extract all .o files from .a files
1038 for file in ${D}inputFiles ; do
1049 EXTRA_CFLAGS="${D}EXTRA_CFLAGS -Zomf"
1054 dirname=\`basnam ${D}file ${D}suffix\`"_%"
1056 if @<:@ ${D}? -ne 0 @:>@; then
1057 echo "Failed to create subdirectory ./${D}dirname"
1061 # Append '!' to indicate archive
1062 newInputFiles="${D}newInputFiles ${D}{dirname}!"
1063 doCommand "cd ${D}dirname; ${D}AR x ../${D}file"
1066 for subfile in ${D}dirname/*.o* ; do
1067 if @<:@ -f ${D}subfile @:>@; then
1069 if @<:@ -s ${D}subfile @:>@; then
1070 # FIXME: This should be: is file size > 32 byte, _not_ > 0!
1071 newInputFiles="${D}newInputFiles ${D}subfile"
1075 if @<:@ ${D}found -eq 0 @:>@; then
1076 echo "WARNING: there are no files in archive \\'${D}file\\'"
1080 newInputFiles="${D}{newInputFiles} ${D}file"
1084 inputFiles="${D}newInputFiles"
1086 # Output filename(s).
1088 if @<:@ -z ${D}outFile @:>@; then
1090 set outFile ${D}inputFiles; outFile=${D}2
1093 # If it is an archive, remove the '!' and the '_%' suffixes
1096 outFile=\`basnam ${D}outFile _%!\`
1103 outFile=\`basnam ${D}outFile .dll\`
1106 outFile=\`basnam ${D}outFile .DLL\`
1109 outFile=\`basnam ${D}outFile .o\`
1112 outFile=\`basnam ${D}outFile .obj\`
1115 outFile=\`basnam ${D}outFile .a\`
1118 outFile=\`basnam ${D}outFile .lib\`
1123 case ${D}outimpFile in
1125 outimpFile=\`basnam ${D}outimpFile .a\`
1128 outimpFile=\`basnam ${D}outimpFile .lib\`
1133 if @<:@ -z ${D}outimpFile @:>@; then
1134 outimpFile=${D}outFile
1136 defFile="${D}{outFile}.def"
1137 arcFile="${D}{outimpFile}.a"
1138 arcFile2="${D}{outimpFile}.lib"
1140 #create ${D}dllFile as something matching 8.3 restrictions,
1141 if @<:@ -z ${D}renameScript @:>@ ; then
1142 dllFile="${D}outFile"
1144 dllFile=\`${D}renameScript ${D}outimpFile\`
1147 if @<:@ ${D}do_backup -ne 0 @:>@ ; then
1148 if @<:@ -f ${D}arcFile @:>@ ; then
1149 doCommand "mv ${D}arcFile ${D}{outFile}_s.a"
1151 if @<:@ -f ${D}arcFile2 @:>@ ; then
1152 doCommand "mv ${D}arcFile2 ${D}{outFile}_s.lib"
1156 # Extract public symbols from all the object files.
1157 tmpdefFile=${D}{defFile}_%
1158 rm -f ${D}tmpdefFile
1159 for file in ${D}inputFiles ; do
1164 doCommand "emxexp -u ${D}file >> ${D}tmpdefFile"
1169 # Create the def file.
1171 echo "LIBRARY \`basnam ${D}dllFile\` ${D}library_flags" >> ${D}defFile
1172 dllFile="${D}{dllFile}.dll"
1173 if @<:@ ! -z ${D}description @:>@; then
1174 echo "DESCRIPTION \\"${D}{description}\\"" >> ${D}defFile
1176 echo "EXPORTS" >> ${D}defFile
1178 doCommand "cat ${D}tmpdefFile | sort.exe | uniq.exe > ${D}{tmpdefFile}%"
1179 grep -v "^ *;" < ${D}{tmpdefFile}% | grep -v "^ *${D}" >${D}tmpdefFile
1181 # Checks if the export is ok or not.
1182 for word in ${D}exclude_symbols; do
1183 grep -v ${D}word < ${D}tmpdefFile >${D}{tmpdefFile}%
1184 mv ${D}{tmpdefFile}% ${D}tmpdefFile
1188 if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then
1189 sed "=" < ${D}tmpdefFile | \\
1193 s/^\\(@<:@0-9@:>@\\+\\)\\(@<:@^;@:>@*\\)\\(;.*\\)\\?/\\2 @\\1 NONAME/
1195 ' > ${D}{tmpdefFile}%
1196 grep -v "^ *${D}" < ${D}{tmpdefFile}% > ${D}tmpdefFile
1198 rm -f ${D}{tmpdefFile}%
1200 cat ${D}tmpdefFile >> ${D}defFile
1201 rm -f ${D}tmpdefFile
1203 # Do linking, create implib, and apply lxlite.
1205 for file in ${D}inputFiles ; do
1210 gccCmdl="${D}gccCmdl ${D}file"
1214 doCommand "${D}CC ${D}CFLAGS -Zdll -o ${D}dllFile ${D}defFile ${D}gccCmdl ${D}EXTRA_CFLAGS"
1215 touch "${D}{outFile}.dll"
1217 doCommand "emximp -o ${D}arcFile ${D}defFile"
1218 if @<:@ ${D}flag_USE_LXLITE -ne 0 @:>@; then
1220 if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then
1223 doCommand "lxlite -cs -t: -mrn -mln ${D}add_flags ${D}dllFile"
1225 doCommand "emxomf -s -l ${D}arcFile"
1231 dnl ===================== dllar.sh ends here =====================
1234 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
1236 dnl ===================== bk-deps begins here =====================
1237 dnl (Created by merge-scripts.py from bk-deps
1238 dnl file do not edit here!)
1243 # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1244 # script. It is used to track C/C++ files dependencies in portable way.
1246 # Permission is given to use this file in any way.
1248 DEPSMODE=${DEPSMODE}
1250 DEPSFLAG="${DEPSFLAG}"
1252 mkdir -p ${D}DEPSDIR
1254 if test ${D}DEPSMODE = gcc ; then
1255 ${D}* ${D}{DEPSFLAG}
1257 if test ${D}{status} != 0 ; then
1260 # move created file to the location we want it in:
1261 while test ${D}# -gt 0; do
1275 depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
1276 depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
1277 if test -f ${D}depfile ; then
1278 sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
1281 # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d
1282 depfile=\`basename ${D}objfile | sed -e 's/\\..*${D}/.d/g'\`
1283 if test ! -f ${D}depfile ; then
1284 # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++)
1285 depfile="${D}objfile.d"
1287 if test -f ${D}depfile ; then
1288 sed -e "/^${D}objfile/!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
1293 elif test ${D}DEPSMODE = mwcc ; then
1295 # Run mwcc again with -MM and redirect into the dep file we want
1296 # NOTE: We can't use shift here because we need ${D}* to be valid
1298 for arg in ${D}* ; do
1299 if test "${D}prevarg" = "-o"; then
1312 ${D}* ${D}DEPSFLAG >${D}{DEPSDIR}/${D}{objfile}.d
1314 elif test ${D}DEPSMODE = unixcc; then
1316 # Run compiler again with deps flag and redirect into the dep file.
1317 # It doesn't work if the '-o FILE' option is used, but without it the
1318 # dependency file will contain the wrong name for the object. So it is
1319 # removed from the command line, and the dep file is fixed with sed.
1321 while test ${D}# -gt 0; do
1328 eval arg${D}#=\\${D}1
1329 cmd="${D}cmd \\${D}arg${D}#"
1334 eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{DEPSDIR}/${D}{objfile}.d
1341 dnl ===================== bk-deps ends here =====================
1344 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
1346 dnl ===================== shared-ld-sh begins here =====================
1347 dnl (Created by merge-scripts.py from shared-ld-sh
1348 dnl file do not edit here!)
1350 cat <<EOF >shared-ld-sh
1352 #-----------------------------------------------------------------------------
1353 #-- Name: distrib/mac/shared-ld-sh
1354 #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
1355 #-- Author: Gilles Depeyrot
1356 #-- Copyright: (c) 2002 Gilles Depeyrot
1357 #-- Licence: any use permitted
1358 #-----------------------------------------------------------------------------
1363 linking_flag="-dynamiclib"
1364 ldargs="-r -keep_private_externs -nostdlib"
1366 while test ${D}# -gt 0; do
1373 -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
1374 # collect these options and values
1375 args="${D}{args} ${D}1 ${D}2"
1380 # collect these load args
1381 ldargs="${D}{ldargs} ${D}1"
1384 -l*|-L*|-flat_namespace|-headerpad_max_install_names)
1385 # collect these options
1386 args="${D}{args} ${D}1"
1389 -dynamiclib|-bundle)
1390 linking_flag="${D}1"
1394 echo "shared-ld: unhandled option '${D}1'"
1398 *.o | *.a | *.dylib)
1399 # collect object files
1400 objects="${D}{objects} ${D}1"
1404 echo "shared-ld: unhandled argument '${D}1'"
1415 # Link one module containing all the others
1417 if test ${D}{verbose} = 1; then
1418 echo "c++ ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o"
1420 c++ ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o
1424 # Link the shared library from the single module created, but only if the
1425 # previous command didn't fail:
1427 if test ${D}{status} = 0; then
1428 if test ${D}{verbose} = 1; then
1429 echo "c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
1431 c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args}
1436 # Remove intermediate module
1438 rm -f master.${D}${D}.o
1442 dnl ===================== shared-ld-sh ends here =====================
1445 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
1447 dnl ===================== bk-make-pch begins here =====================
1448 dnl (Created by merge-scripts.py from bk-make-pch
1449 dnl file do not edit here!)
1451 cat <<EOF >bk-make-pch
1454 # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1455 # script. It is used to generated precompiled headers.
1457 # Permission is given to use this file in any way.
1466 while test ${D}{#} -gt 0; do
1469 incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
1470 if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
1471 headerfile="${D}{incdir}/${D}{header}"
1475 compiler="${D}{compiler} ${D}{1}"
1479 if test "x${D}{headerfile}" = "x" ; then
1480 echo "error: can't find header ${D}{header} in include paths" >2
1482 if test -f ${D}{outfile} ; then
1485 mkdir -p \`dirname ${D}{outfile}\`
1487 depsfile=".deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
1489 # can do this because gcc is >= 3.4:
1490 ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
1494 dnl ===================== bk-make-pch ends here =====================