<?xml version="1.0" ?>
<!-- $Id$ -->


<!-- Master bakefile for wxWidgets -->

<makefile>

    <!-- make sure setup.h is created as soon as possible: -->
    <phony id="setup_h" cond="FORMAT!='autoconf'">
        <dependency-of>all</dependency-of>
    </phony>

    <set var="BUILDING_LIB">1</set>

    <!-- common rules, names etc. for wx: -->
    <include file="common.bkl"/>

    <!-- list of files sorted into categories: -->
    <include file="files.bkl"/>

    <!-- wxWidgets variant where everything is in one library: -->
    <include file="monolithic.bkl"/>
    <!-- ...and when there are multiple libraries: -->
    <include file="multilib.bkl"/>

    <if cond="FORMAT in ['msvc6prj','msevc4prj','msvs2003prj','msvs2005prj']">
        <set var="MSVC6PRJ_MERGED_TARGETS">
            <if cond="MONOLITHIC=='0'">$(MSVC6PRJ_MERGED_TARGETS_MULTILIB)</if>
            <if cond="MONOLITHIC=='1'">$(MSVC6PRJ_MERGED_TARGETS_MONOLIB)</if>
        </set>
    </if>

    <!-- OpenGL canvas is built as separate library in both cases: -->
    <include file="opengl.bkl"/>
    <!-- Dynamically loadable plugins: -->
    <include file="plugins.bkl"/>

    <!-- Samples target (not dependency of 'all'): -->
    <subproject id="samples">
        <installable>no</installable>
        <dir cond="FORMAT=='autoconf'">samples</dir>
        <dir cond="FORMAT!='autoconf' and TOOLKIT in ['PM','MSW','MGL','MOTIF']">../../samples</dir>
    </subproject>

    <if cond="FORMAT=='autoconf'">

        <!-- WXRC compiler is built by default: -->
        <!-- FIXME: this is dirty hack, better bakefile support for
             conditional and optional subprojects is needed -->
        <action id="wxrc" cond="USE_XRC=='1'">
            <dependency-of>all</dependency-of>

            <!-- some of these are not built in all configurations, <depends>
                 takes care of ignoring the disabled ones: -->
            <depends>monodll</depends>
            <depends>monolib</depends>
            <depends>basedll</depends>
            <depends>baselib</depends>
            <depends>xmldll</depends>
            <depends>xmllib</depends>

            <command>
                (if test -d utils/wxrc ; then cd utils/wxrc &amp;&amp; $(DOLLAR)(MAKE) all ; fi)
            </command>
        </action>
        <action id="clean-wxrc" cond="USE_XRC=='1'">
            <dependency-of>clean</dependency-of>
            <command>
                (if test -d utils/wxrc ; then cd utils/wxrc &amp;&amp; $(DOLLAR)(MAKE) clean ; fi)
            </command>
        </action>
        <action id="install-wxrc" cond="USE_XRC=='1'">
            <dependency-of>install</dependency-of>
            <depends>wxrc</depends>
            <command>
                (if test -d utils/wxrc ; then cd utils/wxrc &amp;&amp; $(DOLLAR)(MAKE) install ; fi)
            </command>
        </action>

        <!-- "make install": -->

        <data-files>
            <files>wxwin.m4</files>
            <install-to>$(DATADIR)/aclocal</install-to>
        </data-files>

        <data-files>
            <srcdir>$(SRCDIR)/build/bakefiles/wxpresets/presets</srcdir>
            <files>wx.bkl wx_unix.bkl wx_win32.bkl</files>
            <install-to>$(DATADIR)/bakefile/presets</install-to>
        </data-files>

        <action id="install-wxconfig">
            <dependency-of>install</dependency-of>
            <command>
                $(INSTALL_DIR) $(DESTDIR)$(BINDIR)
                $(INSTALL_DIR) $(DESTDIR)$(LIBDIR)/wx/config
                $(INSTALL_PROGRAM) lib/wx/config/$(TOOLCHAIN_FULLNAME) $(DESTDIR)$(LIBDIR)/wx/config
                (cd $(DESTDIR)$(BINDIR) &amp;&amp; rm -f wx-config &amp;&amp; $(LN_S) $(LIBDIR)/wx/config/$(TOOLCHAIN_FULLNAME) wx-config)
            </command>
        </action>

        <set var="RCDEFS_H">
            <if cond="TOOLKIT=='MSW'">msw/rcdefs.h</if>
        </set>


        <data-files-tree>
            <srcdir>
                $(BUILDDIR)/lib/wx/include/$(TOOLCHAIN_FULLNAME)/wx
            </srcdir>
            <files>
                setup.h $(RCDEFS_H)
            </files>
            <install-to>
                $(LIBDIR)/wx/include/$(TOOLCHAIN_FULLNAME)/wx
            </install-to>
        </data-files-tree>

        <!-- FIXME: make this use <headers> once it supports prefix removal -->
        <if cond="BAKEFILE_VERSION!='0.2.3'">
            <warning>is it time to use per-target &lt;headers&gt; now?</warning>
        </if>
        <data-files-tree>
            <srcdir>$(SRCDIR)/include</srcdir>
            <files>$(ALL_HEADERS)</files>
            <install-to>
                $(INCLUDEDIR)/wx-$(WX_RELEASE)$(WX_FLAVOUR)
            </install-to>
        </data-files-tree>

        <!-- Locales: -->
        <using module="gettext"/>
        <gettext-catalogs id="locale">
            <srcdir>$(SRCDIR)/locale</srcdir>
            <catalog-name>wxstd</catalog-name>
            <linguas>
                ca cs da de el es fi fr hu id it ja nl pl ru sl sv tr uk
                zh zh_CN zh_TW
            </linguas>
            <install-to>$(LOCALEDIR)</install-to>
        </gettext-catalogs>
        <gettext-catalogs id="locale_msw">
            <srcdir>$(SRCDIR)/locale/msw</srcdir>
            <catalog-name>wxmsw</catalog-name>
            <linguas>it</linguas>
            <install-to>$(LOCALEDIR)</install-to>
        </gettext-catalogs>
                

        <!-- Mac OS X resources: -->
        <set var="MACOS_R">lib/libwx_$(TOOLCHAIN_NAME).$(WXSOVERSION[0]).r</set>
        <set var="MACOS_RSRC">lib/libwx_$(TOOLCHAIN_NAME).$(WXSOVERSION[0]).rsrc</set>
        <action id="cocoa-res" cond="TOOLKIT=='COCOA'">
            <dependency-of>all</dependency-of>
            <set var="__targetname">$(MACOS_R)</set>
            <command>
                $(REZ) -d __UNIX__ -useDF $(top_srcdir)/src/cocoa/dummy.r -o $(MACOS_RSRC)
                $(DEREZ) $(MACOS_RSRC) -useDF >$(MACOS_R)
            </command>
            <clean-files>$(MACOS_RSRC) $(MACOS_R)</clean-files>
        </action>
        <action id="cocoa-res-install" cond="TOOLKIT=='COCOA'">
            <dependency-of>install</dependency-of>
            <depends>cocoa-res</depends>
            <command>
                $(INSTALL_DATA) $(MACOS_R) $(LIBDIR)
                $(INSTALL_DATA) $(MACOS_RSRC) $(LIBDIR)
            </command>
        </action>

    </if>


    <!-- copy setup.h on DOS/OS2/Windows: -->
    <if cond="FORMAT!='autoconf' and TOOLKIT in ['PM','MSW','MGL','MOTIF']">
        <mkdir id="libdir">
            <dir>$(LIBDIRNAME)</dir>
        </mkdir>
        <mkdir id="libdir_setup">
            <depends>libdir</depends>
            <dir>$(SETUPHDIR)</dir>
        </mkdir>
        <mkdir id="libdir_setup_wx">
            <depends>libdir_setup</depends>
            <dependency-of>setup_h</dependency-of>
            <dir>$(SETUPHDIR)/wx</dir>
        </mkdir>

        <set var="SETUP_H_SUBDIR">
            <if cond="WXUNIV=='1'">univ</if>
            <if cond="WXUNIV=='0' and TOOLKIT!='PM'">$(TOOLKIT_LOWERCASE)</if>
            <if cond="WXUNIV=='0' and TOOLKIT=='PM'">os2</if>
        </set>

        <copy-file-to-file-if-not-exist id="master_setup.h">
            <src>$(SRCDIR)/include/wx/$(SETUP_H_SUBDIR)/setup0.h</src>
            <dst>$(SRCDIR)/include/wx/$(SETUP_H_SUBDIR)/setup.h</dst>
            <dependency-of>setup_h</dependency-of>
        </copy-file-to-file-if-not-exist>
        <copy-file-to-file-if-not-exist id="setup.h">
            <dependency-of>setup_h</dependency-of>
            <src>$(SRCDIR)/include/wx/$(SETUP_H_SUBDIR)/setup.h</src>
            <dst>$(SETUPHDIR)/wx/setup.h</dst>
        </copy-file-to-file-if-not-exist>

    </if>


    <!-- create rcdefs.h on Windows: -->
    <if cond="FORMAT in ['borland','mingw','msvc','watcom'] and TOOLKIT == 'MSW'">

        <mkdir id="libdir_setup_wx_msw">
            <depends>libdir_setup_wx</depends>
            <dir>$(SETUPHDIR)/wx/msw</dir>
        </mkdir>

        <action id="rcdefs.h">

            <!-- Can't seem to set id to a name with a dollar sign
                 so use __targetname as a temporary work around -->
            <set var="__targetname">$(SETUPHDIR)\wx\msw\rcdefs.h</set>

            <dependency-of>setup_h</dependency-of>
            <depends>libdir_setup_wx_msw</depends>
            <depends-on-file>$(SRCDIR)/include/wx/msw/genrcdefs.h</depends-on-file>

            <command>
                $(DOLLAR)(CPP) "$(nativePaths(SRCDIR))\include\wx\msw\genrcdefs.h" > "$(SETUPHDIR)\wx\msw\rcdefs.h"
            </command>

        </action>

    </if>


    <if cond="FORMAT=='autoconf'">

        <!-- Show this banner after installation: -->
        <modify-target target="install">
            <command>
@echo " "
@echo " ------------------------------------------------------"
@echo " "
@echo " The installation of wxWidgets is finished.  On certain"
@echo " platforms (e.g. Linux) you'll now have to run ldconfig"
@echo " if you installed a shared library and also modify the"
@echo " LD_LIBRARY_PATH (or equivalent) environment variable."
@echo " "
@echo " wxWidgets comes with no guarantees and doesn't claim"
@echo " to be suitable for any purpose."
@echo " "
@echo " Read the wxWidgets Licence on licencing conditions."
@echo " "
@echo " ------------------------------------------------------"
@echo " "
            </command>
        </modify-target>

        <!-- add "make dist" target to autoconf: -->
        <set var="VARS_DONT_ELIMINATE" append="1">
            ALL_PORTS_BASE_HEADERS ALL_BASE_SOURCES WX_VERSION
        </set>
        <fragment format="autoconf" file="make_dist.mk"/>

    </if>

    <include file="build_cfg.bkl"/>

</makefile>