<?xml version="1.0" ?>
<!-- $Id: debugopt.bkl 40 2006-12-02 15:22:02Z frm $ -->

<!--

Adds the logic for handling a DEBUG=0/1 option, which switches between debug and
release builds.

Usage: use template "debugopt" for your targets:

  <include file="presets/debugopt.bkl"/>

  <exe id="myapp" template="debugopt">
    <sources>myapp.cpp</sources>
  </exe>

-->

<makefile>

    <set var="DEBUG_DEFAULT" overwrite="0">0</set>
    <option name="DEBUG">
        <values>0,1</values>
        <default-value>$(DEBUG_DEFAULT)</default-value>
        <values-description>Release,Debug</values-description>
        <description>Set to 1 to build debug version</description>
    </option>

    <template id="debugopt">
        <define>
            $(substituteFromDict(DEBUG,{'1':'','0':'NDEBUG'}))
        </define>
        <optimize>
            $(substituteFromDict(DEBUG,{'1':'off','0':'speed'}))
        </optimize>
        <debug-info>
            $(substituteFromDict(DEBUG,{'1':'on','0':'off'}))
        </debug-info>
        <warnings>
            $(substituteFromDict(DEBUG,{'1':'max','0':'no'}))
        </warnings>
        <debug-runtime-libs>
            $(substituteFromDict(DEBUG,{'1':'on','0':'off'}))
        </debug-runtime-libs>
    </template>


    <!-- The DEBUGBUILDPOSTFIX variable is useful to set the BUILDDIR variable
         as done in presets/setbuilddir.bkl -->
    <set var="DEBUGBUILDPOSTFIX">
        <if cond="DEBUG=='0'">rel</if>
        <if cond="DEBUG=='1'">dbg</if>
    </set>

</makefile>
