View | Details | Raw Unified | Return to bug 105494
Collapse All | Expand All

(-)book.sgml (-77 / +572 lines)
Lines 6182-6266 Link Here
6182
    </sect1>
6182
    </sect1>
6183
6183
6184
    <sect1 id="using-wx">
6184
    <sect1 id="using-wx">
6185
      <title>Using wxWidgets</title>
6185
      <title>Using <application>WxWidgets</application></title>
6186
6186
6187
      <para>If your port uses <application>wxWidgets</application>
6187
      <para>This section describes the status of the
6188
	cross-platform toolkit, define <literal>USE_WX</literal>.
6188
	<application>WxWidgets</application> libraries in the ports tree and
6189
	A specific version must be requested by setting
6189
	its integration with the ports system.</para>
6190
	<literal>USE_WX=2.6</literal>.  Ranges (<literal>2.4-2.6</literal>)
6190
6191
	and partial ranges (<literal>-2.4</literal>, <literal>2.6+</literal>)
6191
      <sect2 id="wx-introduction">
6192
	are also possible.</para>
6192
	<title>Introduction</title>
6193
6193
6194
      <para>List of required wxWidgets components can be set as
6194
	<para>There are many versions of the
6195
	<makevar>WX_COMPS</makevar>.  Unless specified otherwise, port will
6195
	  <application>WxWidgets</application> libraries which conflict
6196
	depend on wxWidgets library (<literal>wx</literal>).  Available
6196
	  between them (install files under the same name). In the ports tree
6197
	components are:</para>
6197
	  this problem has been solved by installing each version under a
6198
6198
	  different name using version number suffixes.</para>
6199
      <table frame="none">
6199
6200
	<title>Possible values for <makevar>WX_COMPS</makevar></title>
6200
	<para>The obvious disadvantage of this is that each application has to
6201
6201
	  be modified to found the expected version. Fortunately most of the
6202
	<tgroup cols="2">
6202
	  applications call the <command>wx-config</command> script to
6203
	  <thead>
6203
	  determine the necessary compiler and linker flags, which is named
6204
	    <row>
6204
	  differently for all the available versions, and the majority of them
6205
	      <entry>Value</entry>
6205
	  also have a variable or accept a parameter to allow modifying
6206
6206
	  it. Otherwise the applications could be modified to use one of
6207
	      <entry>Means</entry>
6207
	  them.</para>
6208
	    </row>
6208
      </sect2>
6209
	  </thead>
6209
6210
6210
      <sect2 id="wx-version">
6211
	  <tbody>
6211
	<title>Version selection</title>
6212
	    <row>
6212
6213
	      <entry><literal>wx</literal></entry>
6213
	<para>To make your port use a specific version of
6214
6214
	  <application>WxWidgets</application> there are two variables
6215
	      <entry>wxWidget libraries</entry>
6215
	  available for defining (if only one is defined the other will be set
6216
	    </row>
6216
	  to a default value):</para>
6217
6217
6218
	    <row>
6218
	<table id="wx-ver-sel-table" frame="none">
6219
	      <entry><literal>contrib</literal></entry>
6219
	  <title>Variables to select <application>WxWidgets</application>
6220
6220
	    versions</title>
6221
	      <entry>wxWidget contributed libraries</entry>
6221
6222
	    </row>
6222
	  <tgroup cols="3">
6223
6223
	    <thead>
6224
	    <row>
6224
	      <row>
6225
	      <entry><literal>python</literal></entry>
6225
		<entry>Variable</entry>
6226
6226
6227
	      <entry>wxPython</entry>
6227
		<entry>Description</entry>
6228
	    </row>
6228
6229
6229
		<entry>Default value</entry>
6230
	    <row>
6230
	      </row>
6231
	      <entry><literal>mozilla</literal></entry>
6231
	    </thead>
6232
6232
6233
	      <entry>wxMozilla (only available for 2.4)</entry>
6233
	    <tbody>
6234
	    </row>
6234
	      <row>
6235
6235
		<entry><makevar>USE_WX</makevar></entry>
6236
	    <row>
6236
6237
	      <entry><literal>svg</literal></entry>
6237
		<entry>List of versions the port can use</entry>
6238
6238
6239
	      <entry>wxSVG (only available for 2.6)</entry>
6239
		<entry>All available versions</entry>
6240
	    </row>
6240
	      </row>
6241
	  </tbody>
6241
6242
	</tgroup>
6242
	      <row>
6243
      </table>
6243
		<entry><makevar>USE_WX_NOT</makevar></entry>
6244
6244
6245
      <para>If locating wxWidget libraries needs a configure argument in
6245
		<entry>List of versions the port can not use</entry>
6246
	addition to the <makevar>WX_CONFIG</makevar> variable, define
6246
6247
	<makevar>WX_CONF_ARGS</makevar> in your port.  Possible values
6247
		<entry>None</entry>
6248
	are <literal>absolute</literal> resulting in
6248
	      </row>
6249
	<literal>--with-wx-config=${WX_CONFIG}</literal>, and
6249
	    </tbody>
6250
	<literal>relative</literal> resulting in
6250
	  </tgroup>
6251
	<literal>--with-wx=${X11BASE} --with-wx-config=${WX_CONFIG}</literal>
6251
	</table>
6252
	being added to configure script arguments.</para>
6252
6253
6253
	<para>The following is a list of available
6254
      <para>Define <literal>WX_UNICODE=yes</literal> if your port needs
6254
	  <application>WxWidgets</application> versions and the corresponding
6255
	the Unicode version of the wxWidgets libraries.</para>
6255
	  port in the tree:</para>
6256
6256
6257
      <para>Example of port requiring Unicode versions of wxWidgets 2.6 and
6257
	<table frame="none">
6258
	contrib libraries:</para>
6258
	  <title>Available <application>WxWidgets</application>
6259
6259
	    versions</title>
6260
      <programlisting>USE_WX=      2.6
6260
6261
WX_COMPS=    wx contrib
6261
	  <tgroup cols="2">
6262
WX_UNICODE=  yes</programlisting>
6262
	    <thead>
6263
	      <row>
6264
		<entry>Version</entry>
6265
6266
		<entry>Port</entry>
6267
	      </row>
6268
	    </thead>
6269
6270
	    <tbody>
6271
	      <row>
6272
		<entry><literal>2.4</literal></entry>
6273
6274
		<entry><filename
6275
		    role="package">x11-toolkits/wxgtk24</filename></entry>
6276
	      </row>
6277
6278
	      <row>
6279
		<entry><literal>2.6</literal></entry>
6280
6281
		<entry><filename
6282
		    role="package">x11-toolkits/wxgtk26</filename></entry>
6283
	      </row>
6284
	    </tbody>
6285
	  </tgroup>
6286
	</table>
6287
6288
	<note>
6289
	  <para>The <literal>2.6</literal> version also comes in Unicode and
6290
	    is installed by the slave port <filename
6291
	      role="package">x11-toolkits/wxgtk26-unicode</filename>, but this
6292
	    can be handled with variables (see <xref
6293
	      linkend="wx-unicode">).</para>
6294
	</note>
6295
6296
	<para>The variables in <xref linkend="wx-ver-sel-table"> can be set
6297
	  to one or more of the following combinations separated by
6298
	  spaces:</para>
6299
6300
	<table frame="none">
6301
	  <title><application>WxWidgets</application> version
6302
	    specifications</title>
6303
6304
	  <tgroup cols="2">
6305
	    <thead>
6306
	      <row>
6307
		<entry>Description</entry>
6308
6309
		<entry>Example</entry>
6310
	      </row>
6311
	    </thead>
6312
6313
	    <tbody>
6314
	      <row>
6315
		<entry>Single version</entry>
6316
6317
		<entry><literal>2.4</literal></entry>
6318
	      </row>
6319
6320
	      <row>
6321
		<entry>Ascending range</entry>
6322
6323
		<entry><literal>2.4+</literal></entry>
6324
	      </row>
6325
6326
	      <row>
6327
		<entry>Descending range</entry>
6328
6329
		<entry><literal>2.6-</literal></entry>
6330
	      </row>
6331
6332
	      <row>
6333
		<entry>Full range (must be ascending)</entry>
6334
6335
		<entry><literal>2.4-2.6</literal></entry>
6336
	      </row>
6337
	    </tbody>
6338
	  </tgroup>
6339
	</table>
6340
6341
	<para>There are also some variables to select the preferred versions
6342
	  from the available ones. They can be set to a list of versions, the
6343
	  first ones will have higher priority.</para>
6344
6345
	<table frame="none">
6346
	  <title>Variables to select preferred
6347
	    <application>WxWidgets</application> versions</title>
6348
6349
	  <tgroup cols="2">
6350
	    <thead>
6351
	      <row>
6352
		<entry>Name</entry>
6353
6354
		<entry>Designed for</entry>
6355
	      </row>
6356
	    </thead>
6357
6358
	    <tbody>
6359
	      <row>
6360
		<entry><makevar>WANT_WX_VER</makevar></entry>
6361
6362
		<entry>the port</entry>
6363
	      </row>
6364
6365
	      <row>
6366
		<entry><makevar>WITH_WX_VER</makevar></entry>
6367
6368
		<entry>the user</entry>
6369
	      </row>
6370
	    </tbody>
6371
	  </tgroup>
6372
	</table>
6373
6374
      <sect2 id="wx-components">
6375
	<title>Component selection</title>
6376
6377
	<para>There are other applications that, while not being
6378
	  <application>WxWidgets</application> libraries, are related to them.
6379
	  These applications can be specified in the
6380
	  <makevar>WX_COMPS</makevar> variable. The following components are
6381
	  available:</para>
6382
6383
	<table frame="none">
6384
	  <title>Available <application>WxWidgets</application>
6385
	    components</title>
6386
6387
	  <tgroup cols="3">
6388
	    <thead>
6389
	      <row>
6390
		<entry>Name</entry>
6391
6392
		<entry>Description</entry>
6393
6394
		<entry>Version restriction</entry>
6395
	      </row>
6396
	    </thead>
6397
6398
	    <tbody>
6399
	      <row>
6400
		<entry><literal>wx</literal></entry>
6401
6402
		<entry>main library</entry>
6403
6404
		<entry>none</entry>
6405
	      </row>
6406
6407
	      <row>
6408
		<entry><literal>contrib</literal></entry>
6409
6410
		<entry>contributed libraries</entry>
6411
6412
		<entry><literal>none</literal></entry>
6413
	      </row>
6414
6415
	      <row>
6416
		<entry><literal>python</literal></entry>
6417
6418
		<entry><application>WxPython</application>
6419
		  (<application>Python</application> bindings)</entry>
6420
6421
		<entry><literal>none</literal></entry>
6422
	      </row>
6423
6424
	      <row>
6425
		<entry><literal>mozilla</literal></entry>
6426
6427
		<entry><application>WxMozilla</application></entry>
6428
6429
		<entry><literal>2.4</literal></entry>
6430
	      </row>
6431
6432
	      <row>
6433
		<entry><literal>svg</literal></entry>
6434
6435
		<entry><application>WxSVG</application></entry>
6436
6437
		<entry><literal>2.6</literal></entry>
6438
	      </row>
6439
	    </tbody>
6440
	  </tgroup>
6441
	</table>
6442
6443
	<para>The dependency type added when you select each component can be
6444
	  manually specified by adding a suffix separated by a
6445
	  <literal>:</literal>, or a default value will be used. The available
6446
	  dependency types are:</para>
6447
6448
	<table frame="none">
6449
	  <title>Available <application>WxWidgets</application> dependency
6450
	    types</title>
6451
6452
	  <tgroup cols="2">
6453
	    <thead>
6454
	      <row>
6455
		<entry>Name</entry>
6456
6457
		<entry>Description</entry>
6458
	      </row>
6459
	    </thead>
6263
6460
6461
	    <tbody>
6462
	      <row>
6463
		<entry><literal>build</literal></entry>
6464
6465
		<entry>Component is required for building, equivalent to
6466
		  <makevar>BUILD_DEPENDS</makevar></entry>
6467
	      </row>
6468
6469
	      <row>
6470
		<entry><literal>run</literal></entry>
6471
6472
		<entry>Component is required for running, equivalent to
6473
		  <makevar>RUN_DEPENDS</makevar></entry>
6474
	      </row>
6475
6476
	      <row>
6477
		<entry><literal>lib</literal></entry>
6478
6479
		<entry>Component is required for building and running,
6480
		  equivalent to <makevar>LIB_DEPENDS</makevar>
6481
	      </row>
6482
	    </tbody>
6483
	  </tgroup>
6484
	</table>
6485
6486
	<para>The default values for the components are detailed in the
6487
	  following table:</para>
6488
6489
	<table frame="none">
6490
	  <title>Default <application>WxWidgets</application> dependency
6491
	    types</title>
6492
6493
	  <tgroup cols="2">
6494
	    <thead>
6495
	      <row>
6496
		<entry>Component</entry>
6497
6498
		<entry>Dependency type</entry>
6499
	      </row>
6500
	    </thead>
6501
6502
	    <tbody>
6503
	      <row>
6504
		<entry><literal>wx</literal></entry>
6505
6506
		<entry><literal>lib</literal></entry>
6507
	      </row>
6508
6509
	      <row>
6510
		<entry><literal>contrib</literal></entry>
6511
6512
		<entry><literal>lib</literal></entry>
6513
	      </row>
6514
6515
	      <row>
6516
		<entry><literal>python</literal></entry>
6517
6518
		<entry><literal>run</literal></entry>
6519
	      </row>
6520
6521
	      <row>
6522
		<entry><literal>mozilla</literal></entry>
6523
6524
		<entry><literal>lib</literal></entry>
6525
	      </row>
6526
6527
	      <row>
6528
		<entry><literal>svg</literal></entry>
6529
6530
		<entry><literal>lib</literal></entry>
6531
	      </row>
6532
	    </tbody>
6533
	  </tgroup>
6534
	</table>
6535
6536
	<example id="wx-components-example">
6537
	  <title>Selecting <application>WxWidgets</application>
6538
	    components</title>
6539
6540
	  <para>The following fragment corresponds to a port which uses
6541
	    <application>WxWidgets</application> version
6542
	    <literal>2.4</literal> and its contributed libraries.</para>
6543
6544
	  <programlisting>USE_WX=       2.4
6545
WX_COMPS=     wx contrib</programlisting>
6546
	</example>
6547
      </sect2>
6548
      <sect2 id="wx-unicode">
6549
	<title>Unicode</title>
6550
6551
	<para>The <application>WxWidgets</application> library supports
6552
	  Unicode since version <literal>2.5</literal>. In the ports tree both
6553
	  versions are available and can be selected with the following
6554
	  variables:</para>
6555
6556
	<table id="wx-unicode-var-table" frame="none">
6557
	  <title>Variables to select Unicode in
6558
	    <application>WxWidgets</application>
6559
	    versions</title>
6560
6561
	  <tgroup cols="3">
6562
	    <thead>
6563
	      <row>
6564
		<entry>Variable</entry>
6565
6566
		<entry>Description</entry>
6567
6568
		<entry>Designed for</entry>
6569
	      </row>
6570
	    </thead>
6571
6572
	    <tbody>
6573
	      <row>
6574
		<entry><makevar>WX_UNICODE</makevar></entry>
6575
6576
		<entry>The port works <emphasis>only</emphasis> with the
6577
		  Unicode version</entry>
6578
6579
		<entry>the port</entry>
6580
	      </row>
6581
6582
	      <row>
6583
		<entry><makevar>WANT_UNICODE</makevar></entry>
6584
6585
		<entry>The port works with both versions but prefers the
6586
		  Unicode one</entry>
6587
6588
		<entry>the port</entry>
6589
	      </row>
6590
6591
	      <row>
6592
		<entry><makevar>WITH_UNICODE</makevar></entry>
6593
6594
		<entry>The port will use the Unicode version</entry>
6595
6596
		<entry>the user</entry>
6597
	      </row>
6598
6599
	      <row>
6600
		<entry><makevar>WITHOUT_UNICODE</makevar></entry>
6601
6602
		<entry>The port will use the normal version if
6603
		  supported (when <makevar>WX_UNICODE</makevar> is not
6604
		  defined)</entry>
6605
6606
		<entry>the user</entry>
6607
	      </row>
6608
	    </tbody>
6609
	  </tgroup>
6610
	</table>
6611
6612
	<warning>
6613
	  <para>Do not use <makevar>WX_UNICODE</makevar> for ports that can
6614
	    use both Unicode and normal versions. If you want the port to use
6615
	    Unicode by default define <makevar>WANT_UNICODE</makevar>
6616
	    instead.</para>
6617
	</warning>
6618
      </sect2>
6619
6620
      <sect2 id="wx-version-detection">
6621
	<title>Detecting installed versions</title>
6622
6623
	<para>To detect an installed version you have to define
6624
	  <makevar>WANT_WX</makevar>. If you do not set it to a specific
6625
	  version then the components will have a version suffix. The
6626
	  <makevar>HAVE_WX</makevar> variable will be filled after
6627
	  detection.</para>
6628
6629
	<example id="wx-ver-det-example">
6630
	  <title>Detecting installed <application>WxWidgets</application>
6631
	    versions and components</title>
6632
6633
	  <para>The following fragment can be used in a port that uses
6634
	    <application>WxWidgets</application> if it is installed, or an
6635
	    option is selected.</para>
6636
6637
	  <programlisting>WANT_WX=        yes
6638
6639
.include &lt;bsd.port.pre.mk&gt;
6640
6641
.if defined(WITH_WX) || ${HAVE_WX:Mwx-2.4} != ""
6642
USE_WX=         2.4
6643
CONFIGURE_ARGS+=--enable-wx
6644
.endif</programlisting>
6645
6646
	  <para>The following fragment can be used in a port that enables
6647
	    <application>WxPython</application> support if it is installed or
6648
	    if an option is selected, in addition to
6649
	    <application>WxWidgets</application>, both version
6650
	    <literal>2.6</literal>.</para>
6651
6652
	  <programlisting>USE_WX=         2.6
6653
WX_COMPS=       wx
6654
WANT_WX=        2.6
6655
6656
.include &lt;bsd.port.pre.mk&gt;
6657
6658
.if defined(WITH_WXPYTHON) || ${HAVE_WX:Mpython} != ""
6659
WX_COMPS+=      python
6660
CONFIGURE_ARGS+=--enable-wxpython
6661
.endif</programlisting>
6662
	</example>
6663
      </sect2>
6664
6665
      <sect2 id="wx-defined-variables">
6666
	<title>Defined variables</title>
6667
6668
	<para>The following variables are defined after defining one of the
6669
	  variables from <xref linkend="wx-ver-sel-table">.</para>
6670
6671
	<table frame="none">
6672
	  <title>Variables defined for ports that use
6673
	    <application>WxWidgets</application></title>
6674
6675
	  <tgroup cols="2">
6676
	    <thead>
6677
	      <row>
6678
		<entry>Name</entry>
6679
6680
		<entry>Description</entry>
6681
	      </row>
6682
	    </thead>
6683
6684
	    <tbody>
6685
	      <row>
6686
		<entry><makevar>WX_CONFIG</makevar></entry>
6687
6688
		<entry>The path to the <application>WxWidgets</application>
6689
		  <literal>wx-config</literal> script (with different
6690
		  name)</entry>
6691
	      </row>
6692
	      <row>
6693
		<entry><makevar>WXRC_CMD</makevar></entry>
6694
6695
		<entry>The path to the <application>WxWidgets</application>
6696
		  <literal>wxrc</literal> program (with differen name)</entry>
6697
	      </row>
6698
	      <row>
6699
		<entry><makevar>WX_VERSION</makevar></entry>
6700
6701
		<entry>The <application>WxWidgets</application> version that
6702
		  is going to be used (e.g., <literal>2.6</literal>)</entry>
6703
	      </row>
6704
6705
	      <row>
6706
		<entry><makevar>WX_UNICODE</makevar></entry>
6707
6708
		<entry>If not defined but Unicode is going to be used then it
6709
		  will be defined</entry>
6710
	      </row>
6711
	    </tbody>
6712
	  </tgroup>
6713
	</table>
6714
      </sect2>
6715
6716
      <sect2 id="wx-premk">
6717
	<title>Processing in <filename>bsd.port.pre.mk</filename></title>
6718
6719
	<para>If you need to use the variables for running commands right
6720
	  after including <filename>bsd.port.pre.mk</filename> you need to
6721
	  define <makevar>WX_PREMK</makevar>.</para>
6722
6723
	<important>
6724
	  <para>If you define <makevar>WX_PREMK</makevar>, then the version,
6725
	    dependencies, components and defined variables will not change if
6726
	    you modify the <application>Lua</application> port variables
6727
	    <emphasis>after</emphasis> including
6728
	    <filename>bsd.port.pre.mk</filename>.</para>
6729
	</important>
6730
6731
	<example id="wx-premk-example">
6732
	  <title>Using <application>WxWidgets</application> variables in
6733
	    commands</title>
6734
6735
	  <para>The following fragment illustrates the use of
6736
	    <makevar>WX_PREMK</makevar> by running the
6737
	    <application>Lua</application> interpreter to obtain the full
6738
	    version string, assign it to a variable and pass it to the
6739
	    program.</para>
6740
6741
	  <programlisting>USE_WX=         2.4
6742
WX_PREMK=       yes
6743
6744
.include &lt;bsd.port.pre.mk&gt;
6745
6746
.if exists(${WX_CONFIG})
6747
VER_STR!=       ${WX_CONFIG} --release
6748
6749
PLIST_SUB+=     VERSION="${VER_STR}"
6750
.endif</programlisting>
6751
	</example>
6752
6753
	<note>
6754
	  <para>The <application>WxWidgets</application> variables can be
6755
	    safely used in commands when they are inside targets without the
6756
	    need of <makevar>WX_PREMK</makevar>.</para>
6757
	</note>
6758
      </sect2>
6264
    </sect1>
6759
    </sect1>
6265
6760
6266
    <sect1 id="using-lua">
6761
    <sect1 id="using-lua">

Return to bug 105494