added <set-wxlike> tag (patch 1691429)
[wxWidgets.git] / build / bakefiles / wxpresets / presets / wx.bkl
1 <?xml version="1.0" ?>
2 <!-- $Id$ -->
3
4 <!--
5     Presets for building wxWidgets applications.
6
7     These presets provide the following "public" interface:
8
9     OPTIONS:
10
11     - WX_* : used to let the user of the generated makefile choose a wxWidgets
12              build among those available; you can use them in your project to
13              e.g. build a target only if WX_DEBUG is 0 or if WX_PORT is "msw".
14
15
16     VARIABLES:
17
18     - WXLIBPOSTFIX: contains the [u][d] string which is typically useful when
19                     defining names of directories/files which should coexist
20                     with other builds using different wxWidgets configurations.
21
22
23     TEMPLATES:
24
25     - wx, wx-lib: templates to be used respectively for <dll>/<exe> and <lib>
26                   targets; they add all the wxWidgets-related settings (e.g. the
27                   include and library search paths, the __WXDEBUG__ symbol, etc)
28
29     - wxconsole: to be used when building console-only libraries or apps
30                  (adds the wxUSE_GUI=0 define).
31
32     - wxlike: this template should be combined with "wx" or "wx-lib" and will
33               make your project build with the same Unicode, debug & shared
34               config as the wxWidgets build selected using the WX_* options.
35
36
37     TARGET TAGS:
38
39     - <wx-lib>: to define which wxWidgets libraries to link with;
40                 please note that you should use them in the right order or
41                 linking under Unix would result in errors, e.g.
42
43                     <wx-lib>core</wx-lib>
44                     <wx-lib>base</wx-lib>
45
46                 is correct, but the reverse is not (if lib A depends on lib B, then
47                 lib A must be listed before B). So <wx-lib>base</wx-lib>
48                 (which must always be present) should be the last wx-lib tag.
49
50     - <wxlike-libname>,
51       <wxlike-dllname>: useful if you want to have a build logic similar to the
52                         wxWidgets build logic which allows different builds to
53                         coexist without conflicts. These tags helps you to name
54                         libraries using the same wxWidgets rules and thus avoid
55                         conflicts between libraries compiled in e.g. Unicode,
56                         shared mode and those compiled in ANSI, shared mode &c.
57
58     - <wxlike-lib>: if your library/application needs to link with both
59                     wxWidgets and some other wx-based library, which in turn
60                     follows the wxWidgets naming conventions, then this tag is
61                     what you need to reference the wx-based additional library.
62
63     - <wxlike-dirname>: sets the output directory for the current target to $(value)
64                         when on Unix and to e.g. $(value)/vc_lib when on Windows,
65                         i.e. acts like <dirname> just following wxWidgets naming rules.
66                         Useful to allow multiple builds of the 
67
68     - <wxlike-paths>: if your library/application needs to compile & link with both
69                       wxWidgets and some other wx-based library, which in turn
70                       follows the wxWidgets naming conventions, then this tag is
71                       what you need to add to the compiler and linker flags the paths
72                       of the "include" and "lib" folders of the wx-based additional library.
73
74
75     GLOBAL TAGS:
76
77     - <set-wxlike-builddir>: sets BUILDDIR using wxWidgets naming rules to help
78                              to keep object files compiled with different
79                              settings separate.
80
81     - <set-wxlike>: sets a variable with the name of a library named with the same
82                     wxWidgets rules.
83
84
85  NOTE: as a reference here is a list of all wxWidgets libraries satisfying
86        the dependency constraints mentioned in <wx-lib> description:
87
88         <wx-lib>richtext</wx-lib>
89         <wx-lib>aui</wx-lib>
90         <wx-lib>qa</wx-lib>
91         <wx-lib>dbgrid</wx-lib>
92         <wx-lib>gl</wx-lib>
93         <wx-lib>odbc</wx-lib>
94         <wx-lib>xrc</wx-lib>
95         <wx-lib>html</wx-lib>
96         <wx-lib>media</wx-lib>
97         <wx-lib>adv</wx-lib>
98         <wx-lib>net</wx-lib>
99         <wx-lib>xml</wx-lib>
100         <wx-lib>core</wx-lib>
101         <wx-lib>base</wx-lib>
102
103 -->
104
105
106 <makefile>
107
108     <requires version="0.2.2"/>
109
110
111     <!-- this variable identifies the version of the wx presets.
112          this is changed only when major changes to wxpresets take place. -->
113     <set var="WX_PRESETS_VERSION">4</set>
114
115     <!-- list of known libraries used by wx-lib tag defined in wx_unix.bkl and wx_win32.bkl
116          VERY IMPORTANT: when updating this list also update the <wx-lib> and <wx-all-libs>
117                          tag definitions.
118     -->
119     <set var="LIB_LIST">
120         base core net xml odbc xrc html adv media gl dbgrid qa aui richtext
121     </set>
122
123     <!-- NOTE: refer to the NET contrib using NETUTILS instead of NET
124                (which is already in LIB_LIST)
125     -->
126     <set var="CONTRIBLIB_LIST">
127         applet deprecated fl foldbar gizmos mmedia netutils ogl plot stc svg
128     </set>
129     <set var="ALLLIB_LIST">$(LIB_LIST) $(CONTRIBLIB_LIST)</set>
130
131     <!-- this is a temporary variable until there is non general    -->
132     <!-- function in bakefiles for returning native markup for      -->
133     <!-- reading envrionment variables                              -->
134     <set var="ENV_VAR">
135         <if cond="FORMAT=='watcom'">%</if>
136         <if cond="FORMAT!='watcom'"></if>
137     </set>
138
139
140
141     <!--                        OPTIONS                             -->
142     <!--                                                            -->
143     <!--    These are essentially the configurations you            -->
144     <!--    want in bakefile.                                       -->
145     <!--                                                            -->
146     <!--    In MSVC these are the different build                   -->
147     <!--    configurations you can have (in the build menu),        -->
148     <!--    and in autoconf is enabled with enable-xxx=xx.          -->
149     <!--    For other compilers a separate configuration            -->
150     <!--    file is created (such as config.gcc on gcc)             -->
151     <!--    which has several options a user can modify.            -->
152     <!--                                                            -->
153     <!--    Note that the above only happens if an option           -->
154     <!--    is not constant, i.e. if it cannot be determined        -->
155     <!--    by bakefile itself.                                     -->
156     <!--    Also note that for 'autoconf' format these options      -->
157     <!--    are only useful when used together with wxpresets.m4    -->
158     <!--    macro file which contains macros for detecting the      -->
159     <!--    option values for wx-based projects. See wxpresets.m4   -->
160     <!--    comments for more info.                                 -->
161
162
163     <!-- Presets for limited dmars make.exe format: -->
164     <if cond="FORMAT=='dmars'">
165         <set var="WX_UNICODE">0</set>
166         <set var="WX_DEBUG">1</set>
167         <set var="WX_SHARED">0</set>
168     </if>
169
170     <!-- 'gnu' format needs to redefine the following options later in wx_unix.bkl -->
171     <if cond="FORMAT=='gnu'">
172         <set var="WX_UNICODE"/>
173         <set var="WX_DEBUG"/>
174         <set var="WX_SHARED"/>
175         <set var="WX_PORT"/>
176         <set var="WX_VERSION"/>
177     </if>
178
179
180     <!--    This is a standard option that determines               -->
181     <!--    whether the user wants to build this library as         -->
182     <!--    a dll or as a static library.                           -->
183     <if cond="not isdefined('WX_SHARED')">
184         <set var="WX_SHARED_DEFAULT" overwrite="0">0</set>
185         <option name="WX_SHARED">
186             <values>0,1</values>
187             <values-description>Static,DLL</values-description>
188             <default-value>$(WX_SHARED_DEFAULT)</default-value>
189             <description>
190                 Use DLL build of wx library?
191             </description>
192         </option>
193     </if>
194
195     <!-- Configuration for building the bakefile with               -->
196     <!-- unicode strings or not (unicode or ansi).                  -->
197     <if cond="not isdefined('WX_UNICODE')">
198         <set var="WX_UNICODE_DEFAULT" overwrite="0">0</set>
199         <option name="WX_UNICODE">
200             <values>0,1</values>
201             <values-description>ANSI,Unicode</values-description>
202             <default-value>$(WX_UNICODE_DEFAULT)</default-value>
203             <description>
204                 Use Unicode build of wxWidgets?
205             </description>
206         </option>
207     </if>
208
209     <if cond="not isdefined('WX_DEBUG')">
210         <set var="WX_DEBUG_DEFAULT" overwrite="0">1</set>
211         <option name="WX_DEBUG">
212             <values>0,1</values>
213             <values-description>Release,Debug</values-description>
214             <default-value>$(WX_DEBUG_DEFAULT)</default-value>
215             <description>
216                 Use debug build of wxWidgets (define __WXDEBUG__)?
217             </description>
218         </option>
219     </if>
220
221     <if cond="not isdefined('WX_VERSION')">
222         <set var="WX_VERSION_DEFAULT" overwrite="0">29</set>
223         <option name="WX_VERSION">
224             <default-value>$(WX_VERSION_DEFAULT)</default-value>
225             <description>
226                 Version of the wx library to build against.
227             </description>
228         </option>
229     </if>
230
231     <if cond="not isdefined('WX_MONOLITHIC')">
232         <set var="WX_MONOLITHIC_DEFAULT" overwrite="0">0</set>
233         <option name="WX_MONOLITHIC">
234             <values>0,1</values>
235             <values-description>Multilib,Monolithic</values-description>
236             <default-value>$(WX_MONOLITHIC_DEFAULT)</default-value>
237             <description>
238                 Use monolithic build of wxWidgets?
239             </description>
240         </option>
241     </if>
242
243     <!-- The directory where wxWidgets is installed: -->
244     <if cond="not isdefined('WX_DIR')">
245         <set var="WX_DIR_DEFAULT" overwrite="0">$(DOLLAR)($(ENV_VAR)WXWIN)</set>
246         <option name="WX_DIR" category="path">
247             <default-value>$(WX_DIR_DEFAULT)</default-value>
248             <description>
249                 The directory where wxWidgets library is installed
250             </description>
251         </option>
252     </if>
253
254
255
256     <!--                     HELPER VARIABLES                       -->
257     <!--                                                            -->
258
259     <!--    These are handy ways of dealing with the                -->
260     <!--    extensions in the library names of the                  -->
261     <!--    wxWindows library.                                      -->
262     <set var="WXLIBPOSTFIX">
263         <if cond="WX_DEBUG=='1' and WX_UNICODE=='1'">ud</if>
264         <if cond="WX_DEBUG=='1' and WX_UNICODE=='0'">d</if>
265         <if cond="WX_DEBUG=='0' and WX_UNICODE=='1'">u</if>
266     </set>
267
268
269
270
271     <!-- this is just a wrapper that includes the real implementation: -->
272
273     <set var="__wx_included_impl">0</set>
274
275     <if cond="FORMAT in ['autoconf','gnu']">
276         <include file="wx_unix.bkl"/>
277         <set var="__wx_included_impl">1</set>
278     </if>
279
280     <if cond="FORMAT!='autoconf' and PLATFORM_WIN32=='1'">
281         <include file="wx_win32.bkl"/>
282         <set var="__wx_included_impl">1</set>
283     </if>
284
285     <if cond="__wx_included_impl=='0'">
286         <error>This format is not (yet) supported by wx preset.</error>
287     </if>
288
289
290
291
292     <!--                     HIGH-LEVEL TEMPLATE                    -->
293     <!--                                                            -->
294
295     <!-- Combine 'wxlike' with 'wx' or 'wx-lib' templates to have your
296          project build in the same configuration used by the selected
297          wxWidgets build -->
298     <template id="wxlike">
299         <!-- WX_DEBUG-dependent -->
300         <set var="_OPT">
301             <if cond="WX_DEBUG=='1'">off</if>
302             <if cond="WX_DEBUG=='0'">speed</if>
303         </set>
304         <set var="_DEBUGINFO">
305             <if cond="WX_DEBUG=='1'">on</if>
306             <if cond="WX_DEBUG=='0'">off</if>
307         </set>
308
309         <if cond="FORMAT!='autoconf'">
310             <optimize>$(_OPT)</optimize>
311             <debug-info>$(_DEBUGINFO)</debug-info>
312         </if>
313     </template>
314
315     <!-- Template for building wx-based console applications -->
316     <template id="wxconsole" template="wx">
317         <define>wxUSE_GUI=0</define>
318         <app-type>console</app-type>
319     </template>
320
321
322
323     <!--                       UTILITY TAGS                         -->
324     <!--                                                            -->
325
326     <!-- private helper tag: does the same thing as for <set-wxlike> except that:
327          - the variable created is always named "__temp"
328          - can be used (only) inside targets as this is a non-global tag
329     -->
330     <define-tag name="__setlibname" rules="lib,dll,module,exe">
331         <set var="__temp">
332             <if cond="FORMAT!='autoconf' and FORMAT!='gnu'">
333                 $(attributes['prefix'])_$(WX_PORT)$(WX_VERSION)$(WXLIBPOSTFIX)_$(value)
334             </if>
335             <if cond="FORMAT=='autoconf' or FORMAT=='gnu'">
336                 $(attributes['prefix'])_$(WX_PORT)$(WXLIBPOSTFIX)_$(value)-$(WX_VERSION_MAJOR).$(WX_VERSION_MINOR)
337             </if>
338         </set>
339     </define-tag>
340
341     <!-- A simple tag which helps you to define a library name using the same rules used
342          by wxWidgets. Use the 'prefix' attribute to add your lib's prefix.
343          E.g.:
344              <wxlike-libname prefix='mylib'>module1</wxlike-libname>
345              <wxlike-libname prefix='mylib'>module2</wxlike-libname>
346     -->
347     <define-tag name="wxlike-libname" rules="lib">
348         <__setlibname prefix="$(attributes['prefix'])">$(value)</__setlibname>
349         <libname>$(__temp)</libname>
350     </define-tag>
351
352     <!-- exactly like <wxlike-libname> but this one sets the DLL name (and the DLL lib import name)
353          and thus must be used only inside a <dll> target...
354     -->
355     <define-tag name="wxlike-dllname" rules="dll,module">
356         <__setlibname prefix="$(attributes['prefix'])">$(value)</__setlibname>
357         <libname>$(__temp)</libname>
358         <dllname>$(__temp)</dllname>
359     </define-tag>
360
361     <!-- Links against a library which uses the same wxWidgets conventions.
362     -->
363     <define-tag name="wxlike-lib" rules="exe,lib,dll,module">
364         <__setlibname prefix="$(attributes['prefix'])">$(value)</__setlibname>
365         <sys-lib>$(__temp)</sys-lib>
366     </define-tag>
367
368     <!-- Sets as output folder for the current target a directory
369          called "$(value)/$(COMPILER)_lib|dll", just like wxWidgets does.
370          This makes it possible to keep separed the libraries/exes compiled with
371          different compilers and with a different value for WX_SHARED.
372     -->
373     <define-tag name="wxlike-dirname" rules="lib,dll,exe,module">
374         <if cond="FORMAT!='autoconf'">
375             <set var="_DIRNAME_SHARED_SUFFIX">
376                 <if cond="WX_SHARED=='0'">lib</if>
377                 <if cond="WX_SHARED=='1'">dll</if>
378             </set>
379             <set var="_DIRNAME">
380                 $(value)/$(COMPILER)_$(_DIRNAME_SHARED_SUFFIX)
381             </set>
382
383             <dirname>$(_DIRNAME)</dirname>
384
385             <if cond="FORMAT_SUPPORTS_ACTIONS=='1'">
386                 <set var="__mkdir_tgt">make_dir_$(id)</set>
387
388                 <add-target target="$(__mkdir_tgt)" type="action"/>
389                 <modify-target target="$(__mkdir_tgt)">
390                     <command cond="TOOLSET=='unix'">
391                         @mkdir -p $(_DIRNAME)
392                     </command>
393                     <command cond="TOOLSET in ['win32','os2','dos']">
394                         if not exist $(nativePaths(_DIRNAME)) mkdir $(nativePaths(_DIRNAME))
395                     </command>
396             </modify-target>
397
398                 <!-- the following code is mostly equivalent to a:
399                           <dependency-of>$(id)</dependency-of>
400                      put into the __mkdir_tgt target, except that it does _prepend_
401                      the __mkdir_tgt dependency instead of appending it.
402
403                      This is required because some compilers (e.g. MSVC) need to store in the
404                      output folder some files (e.g. the PDB file) while compiling and thus
405                      the library output folder must have been created before _any_ source file
406                      is compiled, not just before the library is linked.
407                 -->
408                 <modify-target target="$(id)">
409                     <set var="__deps" prepend="1">
410                         $(substitute(__mkdir_tgt, lambda x: ref('__depname', x), 'DEP'))
411                     </set>
412                 </modify-target>
413             </if>
414         </if>
415         <if cond="FORMAT=='autoconf'">
416             <set var="_DIRNAME">$(value)</set>
417             <dirname>$(_DIRNAME)</dirname>
418         </if>
419     </define-tag>
420
421     <!-- Adds to the compiler & linker flags the path for the "include" and the
422          "lib" folders of a library following wxWidgets conventions which is 
423          located in $(value).
424     -->
425     <define-tag name="wxlike-paths" rules="exe,lib,dll,module">
426         <if cond="FORMAT!='autoconf' and FORMAT!='gnu'">
427             <!-- WXLIBPATH is a path like "/lib/vc_lib"
428                  NOTE: even if this template is going to be used for a "lib"
429                        target (which does not uses lib-paths at all), we can still
430                        use the <lib-path> target: it will just be discarded
431              -->
432             <lib-path>$(value)$(WXLIBPATH)</lib-path>
433
434             <!-- no special include paths for a lib following wxWidgets naming
435                  conventions -->
436             <include>$(value)/include</include>
437         </if>
438
439         <!-- for autoconf format the user should use CPPFLAGS and LDFLAGS to
440              specify non-system paths since the wx-based library should have
441              been installed in standard paths
442         -->
443     </define-tag>
444
445
446
447     <!--                   UTILITY GLOBAL TAGS                      -->
448     <!--                                                            -->
449
450     <!-- Sets the BUILDDIR variable using the same rules used by wxWidgets itself.
451          This makes it possible to keep separed the object files compiled with
452          different configuration settings.
453     -->
454     <define-global-tag name="set-wxlike-builddir">
455         <!-- note that the builddir for autoconf should always be '.' -->
456         <if cond="FORMAT!='autoconf'">
457             <set var="_BUILDDIR_SHARED_SUFFIX">
458                 <if cond="WX_SHARED=='0'"></if>
459                 <if cond="WX_SHARED=='1'">_dll</if>
460             </set>
461
462             <set var="BUILDDIR">
463                 $(COMPILER)$(WX_PORT)$(WXLIBPOSTFIX)$(_BUILDDIR_SHARED_SUFFIX)
464             </set>
465         </if>
466     </define-global-tag>
467
468     <!-- Sets a variable with the name of the 'var' attribute value using the
469          same rules used for wxWidgets library naming.
470          E.g.
471
472             <set-wxlike var='MYMODULE_LIBNAME' prefix='mylib'>
473                 mymodule
474             </set-wxlike>
475
476          This tag also supports a 'cond' attribute making it very powerful
477          for conditional linking a wx-based library:
478
479             <option name="USE_MYMODULE">
480                 <values>0,1</values>
481             </option>
482             <set-wxlike var='MYMODULE_DEP'
483                         prefix='mylib'
484                         cond="USE_MYMODULE=='1'">
485                 mymodule
486             </set-wxlike>
487             ...
488             <exe id="myexe">
489                 <sys-lib>$(MYMODULE_DEP)</sys-lib>
490             </exe>
491     -->
492     <define-global-tag name="set-wxlike">
493         <if cond="FORMAT!='autoconf' and FORMAT!='gnu'">
494             <if cond="'cond' not in attributes">
495                 <set var="$(attributes['var'])">
496                     $(attributes['prefix'])_$(WX_PORT)$(WX_VERSION)$(WXLIBPOSTFIX)_$(value)
497                 </set>
498             </if>
499             <if cond="'cond' in attributes">
500                 <set var="$(attributes['var'])">
501                     <if cond="$(attributes['cond'])">
502                         $(attributes['prefix'])_$(WX_PORT)$(WX_VERSION)$(WXLIBPOSTFIX)_$(value)
503                     </if>
504                 </set>
505             </if>
506         </if>
507
508         <if cond="FORMAT=='autoconf' or FORMAT=='gnu'">
509             <if cond="'cond' not in attributes">
510                 <set var="$(attributes['var'])">
511                     $(attributes['prefix'])_$(WX_PORT)$(WXLIBPOSTFIX)_$(value)-$(WX_VERSION_MAJOR).$(WX_VERSION_MINOR)
512                 </set>
513             </if>
514             <if cond="'cond' in attributes">
515                 <set var="$(attributes['var'])">
516                     <if cond="$(attributes['cond'])">
517                         $(attributes['prefix'])_$(WX_PORT)$(WXLIBPOSTFIX)_$(value)-$(WX_VERSION_MAJOR).$(WX_VERSION_MINOR)
518                     </if>
519                 </set>
520             </if>
521         </if>
522     </define-global-tag>
523
524 </makefile>