<?xml version="1.0" ?>
<!-- $Id: wx_win32.bkl 49352 2007-10-23 13:40:27Z VZ $ -->

<!-- Original source: http://wiki.wxwidgets.org/wiki.pl?Bakefile    -->
<!-- Modified by: Francesco Montorsi <frm@users.sourceforge.net>    -->
<!--              Vaclav Slavik <vslavik@fastmail.fm> to better fit
                  into Bakefile's presets                           -->
<!-- Creation date: 6/9/2004                                        -->
<!-- Last revision: 22/1/2005 off-CVS                               -->
<!--                $Id: wx_win32.bkl 49352 2007-10-23 13:40:27Z VZ $ -->


<makefile>


    <!--                        OPTIONS                             -->
    <!--                                                            -->
    <!--    These are essentially the configurations you            -->
    <!--    want in bakefile.                                       -->
    <!--                                                            -->
    <!--    In MSVC these are the different build                   -->
    <!--    configurations you can have (in the build menu),        -->
    <!--    and in autoconf is enabled with enable-xxx=xx.          -->
    <!--    For other compilers a separate configuration            -->
    <!--    file is created (such as config.gcc on gcc)             -->
    <!--    which has several options a user can modify.            -->
    <!--                                                            -->
    <!--    Note that the above only happens if an option           -->
    <!--    is not constant, i.e. if it cannot be determined        -->
    <!--    by bakefile itself.                                     -->
    <!--    Also note that for 'autoconf' format these options      -->
    <!--    are only useful when used together with wxpresets.m4    -->
    <!--    macro file which contains macros for detecting the      -->
    <!--    option values for wx-based projects. See wxpresets.m4   -->
    <!--    comments for more info.    -->



    <!--                     HELPER VARIABLES                       -->
    <!--                                                            -->


    <!--    The unicode define we want.  By default bakefile        -->
    <!--    makes variables an empty string, so if unicode          -->
    <!--    is not defined $(UNICODE_DEFINE) would expand           -->
    <!--    to nothing (literally).                                 -->
    <set var="WXUNICODE_DEFINE">
        <if cond="WX_UNICODE=='1'">_UNICODE</if>
    </set>

    <!--    The debug define we need with win32 compilers           -->
    <!--    (on Linux, the wx-config program is used).              -->
    <set var="WXDEBUG_DEFINE">
        <if cond="WX_DEBUG=='1'">__WXDEBUG__</if>
    </set>

    <!--    These are handy ways of dealing with the                -->
    <!--    extensions in the library names of the                  -->
    <!--    wxWindows library.                                      -->
    <set var="WX3RDPARTYLIBPOSTFIX">
        <if cond="WX_DEBUG=='1'">d</if>
    </set>

    <set var="WXCPU">
        <if cond="FORMAT=='msevc4prj'">_$(CPU)</if>
    </set>

    <set var="WXLIBPATH">
        <if cond="WX_SHARED=='0'">$(DIRSEP)lib$(DIRSEP)$(COMPILER)$(WXCPU)_lib</if>
        <if cond="WX_SHARED=='1'">$(DIRSEP)lib$(DIRSEP)$(COMPILER)$(WXCPU)_dll</if>
    </set>

    <!-- under Unix this is an option (detected at configure-time);
         under Windows this is not an user option! -->
    <set var="WX_PORT">
        <if cond="FORMAT=='msevc4prj'">wince</if>
        <if cond="FORMAT!='msevc4prj'">msw</if>
    </set>

    <set var="WXLIBINCLUDE">$(WXLIBPATH)$(DIRSEP)$(WX_PORT)$(WXLIBPOSTFIX)</set>


    <!--    All the possible mixes for the wx library names          -->
    <set var="WXLIB_BASE_NAME">
        <if cond="WX_MONOLITHIC=='0' and WX_UNICODE=='0' and WX_DEBUG=='0'">wxbase$(WX_VERSION)</if>
        <if cond="WX_MONOLITHIC=='0' and WX_UNICODE=='0' and WX_DEBUG=='1'">wxbase$(WX_VERSION)d</if>
        <if cond="WX_MONOLITHIC=='0' and WX_UNICODE=='1' and WX_DEBUG=='0'">wxbase$(WX_VERSION)u</if>
        <if cond="WX_MONOLITHIC=='0' and WX_UNICODE=='1' and WX_DEBUG=='1'">wxbase$(WX_VERSION)ud</if>

        <!--
            the trick used to support monolithic builds is here: when the
            <wx-lib>base</wx-lib> tag is found, and user selected
            WX_MONOLITHIC=1, then the base library is translated to the
            monolithic library
        -->
        <if cond="WX_MONOLITHIC=='1' and WX_UNICODE=='0' and WX_DEBUG=='0'">wx$(WX_PORT)$(WX_VERSION)</if>
        <if cond="WX_MONOLITHIC=='1' and WX_UNICODE=='0' and WX_DEBUG=='1'">wx$(WX_PORT)$(WX_VERSION)d</if>
        <if cond="WX_MONOLITHIC=='1' and WX_UNICODE=='1' and WX_DEBUG=='0'">wx$(WX_PORT)$(WX_VERSION)u</if>
        <if cond="WX_MONOLITHIC=='1' and WX_UNICODE=='1' and WX_DEBUG=='1'">wx$(WX_PORT)$(WX_VERSION)ud</if>
    </set>


    <!--   Libraries whose name is prefixed with 'wxbase'            -->
    <define-global-tag name="define-wxbase-lib-name">
        <set var="WXLIB_$(value.upper())_NAME">
            <if cond="WX_MONOLITHIC=='0' and WX_UNICODE=='0' and WX_DEBUG=='0'">
                wxbase$(WX_VERSION)_$(value)
            </if>
            <if cond="WX_MONOLITHIC=='0' and WX_UNICODE=='0' and WX_DEBUG=='1'">
                wxbase$(WX_VERSION)d_$(value)
            </if>
            <if cond="WX_MONOLITHIC=='0' and WX_UNICODE=='1' and WX_DEBUG=='0'">
                wxbase$(WX_VERSION)u_$(value)
            </if>
            <if cond="WX_MONOLITHIC=='0' and WX_UNICODE=='1' and WX_DEBUG=='1'">
                wxbase$(WX_VERSION)ud_$(value)
            </if>
    </set>
    </define-global-tag>

    <define-wxbase-lib-name>net</define-wxbase-lib-name>
    <define-wxbase-lib-name>xml</define-wxbase-lib-name>


    <!--   Libraries whose name is prefixed with 'wx' only          -->
    <define-global-tag name="define-wxlib-name">
        <set var="WXLIB_$(value.upper())_NAME">
            <if cond="WX_MONOLITHIC=='0' and WX_UNICODE=='0' and WX_DEBUG=='0'">
                wx$(WX_PORT)$(WX_VERSION)_$(value)
            </if>
            <if cond="WX_MONOLITHIC=='0' and WX_UNICODE=='0' and WX_DEBUG=='1'">
                wx$(WX_PORT)$(WX_VERSION)d_$(value)
            </if>
            <if cond="WX_MONOLITHIC=='0' and WX_UNICODE=='1' and WX_DEBUG=='0'">
                wx$(WX_PORT)$(WX_VERSION)u_$(value)
            </if>
            <if cond="WX_MONOLITHIC=='0' and WX_UNICODE=='1' and WX_DEBUG=='1'">
                wx$(WX_PORT)$(WX_VERSION)ud_$(value)
            </if>
        </set>
    </define-global-tag>

    <define-wxlib-name>core</define-wxlib-name>
    <define-wxlib-name>media</define-wxlib-name>
    <define-wxlib-name>xrc</define-wxlib-name>
    <define-wxlib-name>html</define-wxlib-name>
    <define-wxlib-name>adv</define-wxlib-name>
    <define-wxlib-name>qa</define-wxlib-name>
    <define-wxlib-name>gl</define-wxlib-name>
    <define-wxlib-name>aui</define-wxlib-name>
    <define-wxlib-name>stc</define-wxlib-name>
    <define-wxlib-name>richtext</define-wxlib-name>





    <!--                        WX TEMPLATE                         -->
    <!--                                                            -->
    <!--                                                            -->
    <!--    While not required, templates make your                 -->
    <!--    bakefiles much more readable.  Templates, in            -->
    <!--    essence, are abstract classes like c++.                 -->
    <!--                                                            -->
    <!--    Your build targets "inherit" the template,              -->
    <!--    along with the info associated with the template        -->

    <!--                                                            -->
    <!--                wxWidgets LIBRARY/APP TEMPLATE              -->
    <!--                                                            -->
    <!--    The "base class" of all our build targets               -->
    <!--    This links with the appropriate native                  -->
    <!--    libraries required by the platform, the libraries       -->
    <!--    we want for our stuff, and the wxWindows libs.          -->

    <!-- this tag is used to include wx libraries: -->
    <define-tag name="wx-lib" rules="exe,dll,module">
        <if cond="value=='base'"><sys-lib>$(WXLIB_BASE_NAME)</sys-lib></if>
        <if cond="value=='core'"><sys-lib>$(WXLIB_CORE_NAME)</sys-lib></if>

        <if cond="value=='net'"><sys-lib>$(WXLIB_NET_NAME)</sys-lib></if>
        <if cond="value=='xml'"><sys-lib>$(WXLIB_XML_NAME)</sys-lib></if>

        <if cond="value=='media'"><sys-lib>$(WXLIB_MEDIA_NAME)</sys-lib></if>
        <if cond="value=='xrc'"><sys-lib>$(WXLIB_XRC_NAME)</sys-lib></if>
        <if cond="value=='html'"><sys-lib>$(WXLIB_HTML_NAME)</sys-lib></if>
        <if cond="value=='adv'"><sys-lib>$(WXLIB_ADV_NAME)</sys-lib></if>
        <if cond="value=='gl'"><sys-lib>$(WXLIB_GL_NAME)</sys-lib></if>
        <if cond="value=='qa'"><sys-lib>$(WXLIB_QA_NAME)</sys-lib></if>
        <if cond="value=='aui'"><sys-lib>$(WXLIB_AUI_NAME)</sys-lib></if>
        <if cond="value=='richtext'"><sys-lib>$(WXLIB_RICHTEXT_NAME)</sys-lib></if>

        <if cond="value=='stc'">
            <!-- wxSTC requires also the basic scintilla library
                 which is built as a separate 3rd party library -->
            <sys-lib>$(WXLIB_STC_NAME)</sys-lib>
            <sys-lib>wxscintilla$(WX3RDPARTYLIBPOSTFIX)</sys-lib>
        </if>

        <if cond="value not in WX_LIB_LIST.split()">
            <error>Unknown wxWidgets library given in the wx-lib tag</error>
        </if>
    </define-tag>

    <!-- just a placeholder to mark the place where <wx-lib> will be placed,
         thanks to the order precedence declaration below it: -->
    <define-tag name="__wx-libs-point" rules="exe,dll,module"/>
    <tag-info name="wx-lib"
              position="before:__wx-libs-point"/>
    <tag-info name="__wx-syslibs"
              position="after:__wx-libs-point"/>


    <!-- template for static wx libraries: -->
    <template id="wx-lib">
        <!--                    MISCELLANEOUS                       -->
        <if cond="FORMAT=='mingw'">
            <define>HAVE_W32API_H</define>
            <ldflags>-mthreads</ldflags>
        </if>

        <define>$(substituteFromDict(WX_SHARED,{'1':'WXUSINGDLL','0':''}))</define>

        <define>$(WXUNICODE_DEFINE)</define>
        <define>$(WXDEBUG_DEFINE)</define>
        <define>__WXMSW__</define>

        <include>$(WX_DIR)$(WXLIBINCLUDE)</include>
        <include>$(WX_DIR)/include</include>
    </template>


    <!-- this ugly tag contains all sys-lib tags used by "wx" template,
         in order to make sure they are not reorder when wx-lib is moved
         after __wx-libs-point: -->
    <define-tag name="__wx-syslibs" rules="exe,dll,module">
        <!-- wx 3rd party libs, always use them: -->
        <sys-lib cond="FORMAT!='msevc4prj'">wxtiff$(WX3RDPARTYLIBPOSTFIX)</sys-lib>
        <sys-lib>wxjpeg$(WX3RDPARTYLIBPOSTFIX)</sys-lib>
        <sys-lib>wxpng$(WX3RDPARTYLIBPOSTFIX)</sys-lib>
        <sys-lib>wxzlib$(WX3RDPARTYLIBPOSTFIX)</sys-lib>
        <!-- For regex we won't use the WX3RDPARTYLIBPOSTIX postfix:
             unliked tiff, jpeg, png, zlib, expat, when building
             in Unicode mode, the "u" suffix is appended to regex -->
        <sys-lib cond="FORMAT!='msevc4prj'">wxregex$(WXLIBPOSTFIX)</sys-lib>
        <sys-lib>wxexpat$(WX3RDPARTYLIBPOSTFIX)</sys-lib>

        <!-- link-in system libs that wx depends on: -->
        <!-- If on borland, we don't need to do much            -->
        <if cond="FORMAT=='borland'">
            <sys-lib>ole2w32</sys-lib>
        </if>

        <!-- Non-borland, on the other hand...                  -->
        <if cond="FORMAT not in ['borland','msevc4prj']">
            <sys-lib>kernel32</sys-lib>
            <sys-lib>user32</sys-lib>
            <sys-lib>gdi32</sys-lib>
            <sys-lib>comdlg32</sys-lib>
            <sys-lib>winspool</sys-lib>
            <sys-lib>winmm</sys-lib>
            <sys-lib>shell32</sys-lib>
            <sys-lib>comctl32</sys-lib>
            <sys-lib>ole32</sys-lib>
            <sys-lib>oleaut32</sys-lib>
            <sys-lib>uuid</sys-lib>
            <sys-lib>rpcrt4</sys-lib>
            <sys-lib>advapi32</sys-lib>
            <sys-lib>wsock32</sys-lib>
        </if>

        <!-- Libs common to both borland and MSVC               -->
        <if cond="FORMAT=='msvc' or FORMAT=='msvc6prj' or FORMAT=='borland'">
            <sys-lib>oleacc</sys-lib>
        </if>
    </define-tag>

    <!-- template for wx executables/dlls: -->
    <template id="wx" template="wx-lib">
        <lib-path>$(WX_DIR)$(WXLIBPATH)</lib-path>

        <!-- wx libs must come before 3rd party and sys libs, this is
             the place where the hack explained above is carried on: -->
        <__wx-libs-point/>
        <__wx-syslibs/>
    </template>

    <if cond="FORMAT_SUPPORTS_ACTIONS=='1' and WX_TEST_FOR_SELECTED_WXBUILD=='1'">

        <!--
            VERY IMPORTANT: before starting to build all targets of the generated makefile,
                            we need to check if the selected wxWidgets build exists; we do
                            that simply creating the following target; if it fails the make
                            program will halt printing the following nice error message...
                            (much better than the 'could not find wx/*.h file')
        -->
        <action id="test_for_selected_wxbuild">
            <dependency-of>all</dependency-of>

            <!-- the @ is to hide these actions from the user -->
            <command>
                @if not exist $(WX_DIR)$(WXLIBINCLUDE)$(DIRSEP)wx$(DIRSEP)setup.h \
                    echo ----------------------------------------------------------------------------
                @if not exist $(WX_DIR)$(WXLIBINCLUDE)$(DIRSEP)wx$(DIRSEP)setup.h \
                    echo The selected wxWidgets build is not available!
                @if not exist $(WX_DIR)$(WXLIBINCLUDE)$(DIRSEP)wx$(DIRSEP)setup.h \
                    echo Please use the options prefixed with WX_ to select another wxWidgets build.
                @if not exist $(WX_DIR)$(WXLIBINCLUDE)$(DIRSEP)wx$(DIRSEP)setup.h \
                    echo ----------------------------------------------------------------------------
                @if not exist $(WX_DIR)$(WXLIBINCLUDE)$(DIRSEP)wx$(DIRSEP)setup.h \
                    exit 1
            </command>
        </action>
    </if>

</makefile>
