UserExtensions: setbuilddir.bkl

File setbuilddir.bkl, 2.5 KB (added by Vaclav Slavik, 4 years ago)
Line 
1<?xml version="1.0" ?>
2<!-- $Id: simple.bkl,v 1.2 2004/04/30 21:55:10 vaclavslavik Exp $ -->
3
4<!--
5
6Adds the logic for setting BUILDDIR in a smart way, checking which other presets have been
7included. Include this preset after including all other presets.
8
9Usage:
10
11  <include file="presets/sharedopt.bkl"/>
12  <include file="presets/unicodeopt.bkl"/>
13  <include file="presets/debugopt.bkl"/>
14  <include file="presets/setbuilddir.bkl"/>
15
16  <lib id="mylib_static" template="debugopt,unicodeopt" cond="SHARED=='0'">
17    <sources>mylib.cpp</sources>
18  </lib>
19
20  <dll id="mylib_shared" template="debugopt,unicodeopt" cond="SHARED=='1'">
21    <sources>mylib.cpp</sources>
22  </dll>
23
24  <set var="MSVC6PRJ_MERGED_TARGETS">mylib=mylib_static+mylib_shared</set>
25-->
26
27<makefile>
28
29    <!--
30        Setting the BUILDDIR variable using the
31                   SHAREDBUILDPOSTFIX/DEBUGBUILDPOSTFIX/UNICODEBUILDPOSTFIX
32        variables we will keep separed the intermediate files (objects, compiled resources, exes, libs)
33        generated using SHARED/DEBUG/UNICODE=0 from those generated using SHARED/DEBUG/UNICODE=1.
34
35        Using the same BUILDDIR for these different configurations would force the
36        user to call a "make clean" (or equivalent) before rebuilding since it's not wise
37        mixing a shared build with a static one or a debug build with a release one
38        or a unicode build with an ansi one.
39
40        Last, using the COMPILER when setting BUILDDIR keeps separed the object files generated using
41        different compilers (in case makefiles for different compilers are generated in the same directory).
42
43        NOTE: the autoconf format requires BUILDDIR='.' since using different build directories
44               is already handled by the configure script.
45               E.g.
46                  for debug builds:     mkdir dbg && cd dbg && ../configure - -enable-debug
47                  for release builds:   mkdir rel && cd rel && ../configure - -disable-debug
48                  ...
49               See autoconf documentation for more info.
50    -->
51
52    <!-- some helpers -->
53    <set var="SHRDSTR"><if cond="isdefined('SHAREDBUILDPOSTFIX')">_$(SHAREDBUILDPOSTFIX)</if></set>
54    <set var="DBGSTR"><if cond="isdefined('DEBUGBUILDPOSTFIX')">_$(DEBUGBUILDPOSTFIX)</if></set>
55    <set var="UNICSTR"><if cond="isdefined('UNICODEBUILDPOSTFIX')">_$(UNICODEBUILDPOSTFIX)</if></set>
56
57    <if cond="FORMAT!='autoconf'">
58        <set var="BUILDDIR">
59            $(COMPILER)$(SHRDSTR)$(DBGSTR)$(UNICSTR)
60        </set>
61    </if>
62
63</makefile>