summaryrefslogtreecommitdiffstats
path: root/doc/ref_manual.rst
blob: 74685442c89ea497902950047180249838c70c2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
PTXdist Reference
=================

Variables Reference
-------------------

The following variables are provided by PTXdist to simplify creating
rule files. Every developer should use these variables in every single
line in the **rule file** to avoid any further adaption when external paths
are changed.

To get their content related to the current project, we can simply run
a:

.. parsed-literal::

    $ ptxdist print PTXDIST_TOPDIR
    /usr/local/lib/ptxdist-\ |release|

Replace the ``PTXDIST_TOPDIR`` with one of the other generic variables
PTXdist provides.

Global Variables
~~~~~~~~~~~~~~~~

``PTXDIST_TOPDIR``
  Points always to the installation directory of PTXdist.

``PTXDIST_WORKSPACE``
  Everything that references ``PTXDIST_WORKSPACE`` will use the active
  projects’s folder.

``PTXDIST_SYSROOT_CROSS``
  ``PTXDIST_SYSROOT_CROSS`` points to a directory tree all cross relevant
  executables, libraries and header files are installed to in the current
  project. All of the project’s packages built for the host to create data
  for the target are searching in this directory tree for their
  dependencies (executables, header and library files). Use
  ``$(PTXDIST_SYSROOT_CROSS)/bin`` to install executables,
  ``$(PTXDIST_SYSROOT_CROSS)/include`` for header files and
  ``$(PTXDIST_SYSROOT_CROSS)/lib`` for libraries.

``PTXDIST_SYSROOT_HOST``
  ``PTXDIST_SYSROOT_HOST`` points to a directory tree all host relevant
  executables, libraries and header files are installed to. All project’s
  packages built for the host are searching in this directory tree for
  their dependencies (executables, header and library files). Use
  ``$(PTXDIST_SYSROOT_HOST)/bin`` to install executables,
  ``$(PTXDIST_SYSROOT_HOST)/include`` for header files and
  ``$(PTXDIST_SYSROOT_HOST)/lib`` for libraries.

``PTXDIST_SYSROOT_TARGET``
  ``PTXDIST_SYSROOT_TARGET`` points to a directory tree all target
  relevant libraries and header files are installed to. All project’s
  packages built for the target are searching in this directory tree for
  their dependencies (header and library files). These files are for
  compile time only (for example to link a target executable against a
  target library), not for runtime! Use
  ``$(PTXDIST_SYSROOT_TARGET)/include`` for header files and
  ``$(PTXDIST_SYSROOT_TARGET)/lib`` for libraries.

Other useful variables:

``CROSS_PATH``
  Use to find cross tools. This path must be used to create anything that
  depends on the target’s architecture, but needs something running on the
  host to do the job. Examples:

  **Creating a UBI image from the target’s root filesystem**
      This will need a tool running on the host, but it will create data
      or code that runs on or is used on the target

  **Building a library for the target**
      If this library needs other resources to be built (other libraries)
      its ``configure`` finds the right information in this path.

``HOST_PATH``
  Used to find host tools. This path must be used to create anything that
  not depends on the architecture.

``ROOTDIR``
  ``ROOTDIR`` points to the root of the target’s root filesystem in the
  current project. Used in very rare cases (to create strange packages
  based on data in target’s root filesystem for example).

``PTXCONF_PLATFORM``
  ``PTXCONF_PLATFORM`` expands to the name of the currently selected
  platform. This name is used in various file names and paths.

``PTXDIST_PLATFORMSUFFIX``
  ``PTXDIST_PLATFORMSUFFIX`` expands to the name of the currently selected
  platform, but with a leading dot. This is used in various files PTXdist
  should search for.

``PTXDIST_PLATFORMCONFIGDIR``
  ``PTXDIST_PLATFORMCONFIGDIR`` points to the directory tree of the
  currently selected platform. This path is used in various search
  functions.

``PTXDIST_PLATFORMDIR``
  ``PTXDIST_PLATFORMDIR`` points to the directory build tree of the
  currently selected platform.

Package Specific Variables
~~~~~~~~~~~~~~~~~~~~~~~~~~

For the following variables ``<PKG>`` is a placeholder for the package
name. It is also the Kconfig symbol name (without the ``PTXCONF_`` prefix).

Package Definition
^^^^^^^^^^^^^^^^^^

``<PKG>``
  This is the name of the package including version. For most packages,
  this is the name of the source archive (without suffix) and the source
  directory. PTXdist will search for patches in a directory with this name.
  This is usually defined as ``<name>-$(<PKG>_VERSION)``. This variable is
  required for most packages. The only exception are packages that only
  install some files in the targetinstall stage (e.g. from projectroot/).

``<PKG>_VERSION``
  The version of the package. It is used as the version for the ipk
  packages. As such, it is required for all packages that create such
  packages. Most target packages fall in this category.

``<PKG>_MD5``
  The md5 checksum of the source archive. PTXdist calculates the checksum
  before extracting the archive and will abort if does not match. Upstream
  project occasionally change the content of an archive without releasing a
  new version. This check helps to ensure that all developers work with the
  same source code.

``<PKG>_SUFFIX``
  The archive suffix without the leading '.', e.g. 'tar.gz' or 'zip'. This
  is only used locally to define ``<PKG>_URL`` and ``<PKG>_SOURCE``.

``<PKG>_URL``
  This is the download URL for the source archive. It is a space separated
  list of URLs. PTXdist will try each URL until it finds one that works.
  There are two main reasons to provide more than one URL: 1. Additional
  mirror(s) in case the main location is unavailable. 2. Some Projects move
  old versions into a separate directory when a new version is released.
  Providing both versions of the URL ensures that PTXdist still has a
  working URL after the next upstream release.

  URLs can have options. Options are appended to the URL separated by ';'.
  For normal downloads the following options are supported:

  ``no-check-certificate`` to indicate that SSL certificate checking should
  be disabled.

  ``no-proxy`` to disable any configured proxy.

  ``cookie:<value>`` to specify a cookie that should be sent.

  Files in the local filesystem can be addressed with 'file://' URLs. In
  this case, the URL can also point to a directory. In this case
  ``<PKG>_DIR`` will be a symlink to the specified directory. 'lndir://'
  can be used to create a shadow copy instead. For locations inside the BSP
  the URL should use ``$(PTXDIST_WORKSPACE)`` to define the correct
  absolute path.

  If no source archive is available, PTXdist can get the source from
  revision control systems. 'git' and 'svn' are currently supported. Note
  that this cannot be used to follow a branch! PTXdist will create the
  archive defined ``<PKG>_SOURCE`` and use it if available.

  Git URLs must either start with 'git://' or end with '.git'. They have a
  mandatory ``tag=<tagname>`` option.

  Svn URLs must start with 'svn://'. They have a mandatory
  ``rev=r<number>`` option.

``<PKG>_SOURCE``
  The location of the downloaded source archive. There should be no reason
  to set this to anything other than
  ``$(SRCDIR)/$(<PKG>).$(<PKG>_SUFFIX)``.

  For local URLs ('file://' or 'lndir://') ``<PKG>_SOURCE`` must not be
  set.

``<PKG>_DIR``
  This is the directory where the source archive is extracted. In most
  cases this is set to ``$(BUILDDIR)/$(<PKG>)``. However, if two packages
  use the same source archive, then something else must be used to make
  sure that they use different directories. See the rules for 'gdb' and
  'gdbserver' for an example.

``<PKG>_LICENSE``
  The license of the package. The SPDX license identifiers should be used
  here. Use ``proprietary`` for proprietary packages and ``ignore`` for
  packages without their own license, e.g. meta packages or packages that
  only install files from projectroot/.

``<PKG>_LICENSE_FILES``
  A space separated list of URLs of license text files. The URLs must be
  'file://' URLs relative to ``<PKG>_DIR``. Absolute URLs using
  ``$(PTXDIST_WORKSPACE)`` can be used in case the license text is missing
  in the upstream archive. Arguments are appended with ';' as separator.
  The ``md5=<md5sum>`` argument is mandatory. It defines the md5 checksum
  of the full license text. ``startline=<number>;endline=<number>`` can be
  used in case the specified file contains more than just the license text,
  e.g. if the license is in the header of a source file. For non ASCII or
  UTF-8 files the encoding can be specified with ``encoding=<enc>``.

For most packages the variables described above are undefined by default.
However, for cross and host packages these variables default to the value
of the corresponding target package if it exists.

``<PKG>_CONFIG``
  This variable specifies a configuration file of some kind for the
  packages. For packages with ``<PKG>_CONF_TOOL`` set to ``kconfig`` the
  variable must specify an absolute path to the kconfig file. For image
  packages that use genimage, PTXdist will look for
  ``config/images/$(<PKG>_CONFIG)`` in the BSP and PTXdist in the usual
  search order.

``<PKG>_STRIP_LEVEL``
  When PTXdist extracts source archives, it will create ``<PKG>_DIR``
  first and then extracts the archive there. If ``<PKG>_STRIP_LEVEL`` is
  set to 1 (the default) then PTXdist removes the first directory level
  defined inside the archive. For most packages that this is the same as
  just extracting the archive. However, this is useful for packages with
  badly named top-level directories or packages where the directory must be
  renamed to avoid collisions (e.g. gdbserver).

  The main use-case for ``<PKG>_STRIP_LEVEL`` is to set it to 0 for
  packages without a top-level directory.

  In theory ``<PKG>_STRIP_LEVEL`` could be set to 2 or more to remove more
  than one directory level.

``<PKG>_BUILD_OOT``
  If this is set to ``YES`` then PTXdist will build the package out of
  tree. This is only supported for autoconf, qmake and cmake packages. The
  default is ``YES`` for cmake packages and ``NO`` for everything else.
  It will use ``$(<PKG>_DIR)-build`` as build directory.

  This is especially useful for 'file://' URLS that point to directories to
  keep the source tree free of build files.

``<PKG>_SUBDIR``
  This is a directory relative to ``<PKG>_DIR``. If set, all build
  operations are executed in this directory instead. By default
  ``<PKG>_SUBDIR`` is undefined so all operations are executed in the
  top-level directory.

Build Environment for all Stages
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``<PKG>_PATH``
  This variable defines the PATH used by all build stages. It is evaluated
  as is, so it must start with ``PATH=``. If undefined, PTXdist will use
  ``PATH=$(CROSS_PATH)`` for target packages ``PATH=$(HOST_PATH)`` for host
  packages and ``PATH=$(HOST_CROSS_PATH)`` for cross packages. It must be
  set by packages that use the variable locally in the make file or if more
  directories are added, e.g. to
  ``PATH=$(PTXDIST_SYSROOT_CROSS)/bin/qt5:$(CROSS_PATH)`` for packages that
  use qmake from Qt5.

``<PKG>_CFLAGS``, ``<PKG>_CPPFLAGS``, ``<PKG>_LDFLAGS``
  Compiler, preprocessor and linker are never called directly in PTXdist.
  Instead, wrapper scripts are called that expand the command line before
  calling the actual tool. These variables can be used to influence these
  wrappers. The specified flags are added to the command line when
  appropriate. In most cases this it the preferred way to add additional
  flags. Adding them via environment variables or ``make`` arguments can
  have unexpected side effects, such as as overwriting existing defaults.

``<PKG>_WRAPPER_BLACKLIST``
  PTXdist has several options in the platformconfig that inject options in
  the compiler command line. This is used, for example, to add hardening
  options or change the debug options. This can occasionally cause problems
  for packages that use the compiler in certain ways, such as the Linux
  kernel or various bootloaders. With this variable a package can disable
  individual options by setting it to a space separated list of the
  corresponding Kconfig symbols (without the ``PTXCONF_`` prefix).

Prepare Stage
^^^^^^^^^^^^^

``<PKG>_CONF_ENV``
  The environment for the prepare stage. If undefined, PTXdist will use
  ``$(CROSS_ENV)`` for target packages, ``$(HOST_ENV)`` for host packages
  and ``$(HOST_CROSS_ENV)`` for cross packages. It must be set by packages
  that use the variable locally in the make file or if extra variables are
  added. In this case the definition should start with the default value.

``<PKG>_CONF_TOOL``
  This variable defines what tool is used to configure the package in the
  prepare stage. Possible values are:

   - ``NO`` to do nothing in the prepare stage.
   - ``autoconf`` for packages that use autoconf
   - ``qmake`` for qmake based packages. Note: the required Qt version must
     be selected.
   - ``cmake`` for cmake based packages. Note ``HOST_CMAKE`` must be
     selected to ensure, that cmake is available for configuration.
   - ``kconfig`` for kconfig based packages. Note ``<PKG>_CONFIG`` must be
     set as described above.
   - ``perl`` for perl modules.
   - ``python`` or ``python3`` for Python packages with a normal setup.py.

``<PKG>_CONF_OPT``
  This variable adds arguments to the command-line of the configuration
  tool. If undefined, PTXdist will use a default value that depends on the
  configuration tool of the package. This default value should also be used
  when adding additional options. The following defaults exist:

   - autoconf:
     ``$(CROSS_AUTOCONF_USR)``/``$(HOST_AUTOCONF)``/``$(HOST_CROSS_AUTOCONF)``
     for target/host/cross packages.
   - cmake: ``$(CROSS_CMAKE_USR)``/``$(HOST_CMAKE_OPT)`` for target/host
     packages. Cross packages cannot be built with cmake
   - qmake: ``$(CROSS_QMAKE_OPT)`` for host packages. Host and cross
     packages cannot be built with qmake.

  All other configuration tools have no default options. This variable is
  ignored for kconfig and python/python3.

Compile Stage
^^^^^^^^^^^^^

``<PKG>_MAKE_ENV``
  This variables defines additional environment variables for the compile
  stage. In most cases this variable remains undefined because all
  necessary defines are picked up in the prepare stage. For python/python3
  packages PTXdist will use the default value from ``<PKG>_CONF_ENV``.
  For packages without configuration tool this must be set correctly,
  usually based on the ``<PKG>_CONF_ENV`` default values.

Install Stage
^^^^^^^^^^^^^

.. _reference_macros:

Rule File Macro Reference
-------------------------

Rules files in PTXdist are using macros to get things work. Its highly
recommended to use these macros instead of doing something by ourself. Using these
macros is portable and such easier to maintain in the case a project should be
upgraded to a more recent PTXdist version.

This chapter describes the predefined macros in PTXdist and their usage.

Whenever one of these macros installs something to the target's root filesystem,
it also accepts user and group IDs which are common in all filesystems Linux
supports. These IDs can be given as numerical values and as text strings.
In the case text strings are given PTXdist converts them into the
coresponding numerical value based on the BSP local files :file:`passwd` and :file:`group`.
If more than one file with these names are present in the BSP PTXdist follows
its regular rules which one it prefers.

Many paths shown here contains some parts in angle brackets. These have
special meanings in this document.

**<platform>**
  The name of a platform. Corresponds to the variable
  ``PTXCONF_PLATFORM``
**<platform-src>**
  The directory where the platform is defined. Corresponds to the variable
  ``PTXDIST_PLATFORMCONFIGDIR``
**<platform-dir>**
  Concatenated directory name with a leading *platform-* and the name of the
  selected platform name, e.g. <platform>. If the name of the currently active
  platform is *foo*, the final directory name is *platform-foo*.
  Corresponds to the variable ``PTXDIST_PLATFORMDIR``

.. note:: The list of supported macros is not complete yet.

targetinfo
~~~~~~~~~~

Usage:

.. code-block:: make

 $(call targetinfo)

Gives a feedback, what build *stage* is just started. Thats why it
should always be the first call for each *stage*. For the package
*foo* and the *compile stage* it will output:

.. code-block:: bash

 --------------------
 target: foo.compile
 --------------------

touch
------

Usage:

.. code-block:: make

 $(call touch)

Gives a feedback, what build *stage* is just finished. Thats why it
should always be the last call for each *stage*. For the package
*foo* and the *compile stage* it will output:

.. code-block:: bash

 finished target foo.compile

clean
~~~~~

Usage:

.. code-block:: make

 $(call clean, <directory path>)

Removes the given directory ``<directory path>``

.. _install_copy:

install_copy
~~~~~~~~~~~~~

Usage:

.. code-block:: make

 $(call install_copy, <package>, <UID>, <GID>, <permission>, <source> [, <dest> [, <strip> ]])

Installs given file or directory into:

* the project's ``<platform-dir>/root/``
* the project's ``<platform-dir>/root-debug/``
* an ipkg/opkg packet in the project's ``<platform-dir>/packages/``

Some of the parameters have fixed meanings:

**<package>**
  Name of the IPKG/OPKG the macro should work on
**<UID>**
  User ID the file should use in the target's root filesystem
**<GID>**
  Group ID the file should use in the target's root filesystem
**<permission>**
  Permission (in an octal value) the file should use in the target's root filesystem

The remaining parameters vary with the use case:

The ``<source>`` parameter can be:

* a directory path that should be created in the target's root filesystem.
  In this case the <destination> must be omitted.
  The given path must always start with a ``/`` and means the root
  of the target's filesystem.
* an absolute path to a file that should be copied to the target's root
  filesystem. To avoid fixed paths, all packages are providing the
  <package> _DIR variable. So, this parameter in our
  *foo* example package can be a ``$(FOO_DIR)/foo``.
* a minus sign (``-``). PTXdist uses the <destination>
  parameter in this case to locate the file to copy from. This only works
  if the package uses the default *install* stage. Only in this
  case an additional folder in ``<platform-dir>/packages`` will
  be created for the package and its files. For our *foo* example
  package this directory is ``<platform-dir>/packages/foo-1.1.0``.

The ``<dest>`` parameter can be:

* omitted if a directory in target's root filesystem should be created.
  For this case the directory to be created is in the <source> parameter.
* an absolute path and filename with its root in target's root filesysem.
  It must start with a slash (``//``). If also the <source>
  parameter was given, the file can be renamed while copying.
  If the <source> parameter was given as a minus
  sign (``-``) the <destination> is also used to
  locate the source. For our *foo* example package if we give
  <destination> as ``/usr/bin/foo``, PTXdist
  copies the file ``<platform-dir>/packages/foo-1.1.0/usr/bin/foo``

The ``<strip>`` is a complete optional parameter to prevent
this macro from the regular stripping process it does on files. Most of the cases
stripping debug information from files is intended. But some kind of files getting
destroyed when this stripping happens to them. One example is a Linux kernel module.
If it gets stripped, it can't be loaded into the kernel anymore.

**full strip**
  fully strip the file while installing when this parameter is **y** or not
  given at all (default case).
**partially strip**
  only strips real debug information from the file when this parameter is
  **k**. Useful to keep Linux kernel module loadable at run-time
**no strip**
  preserve the file from being stripped when this parameter is one of the
  following: **0**, **n**, **no**, **N** or **NO**.

Due to the complexity of this macro, here are some usage examples:

Create a directory in the root filesystem:

.. code-block:: make

 $(call install_copy, foo, 0, 0, 0755, /home/user-foo)

Copy a file from the package build directory to the root filesystem:

.. code-block:: make

 $(call install_copy, foo, 0, 0, 0755, $(FOO_DIR)/foo, /usr/bin/foo)

Copy a file from the package build directory to the root filesystem and rename
it:

.. code-block:: make

 $(call install_copy, foo, 0, 0, 0755, $(FOO_DIR)/foo, /usr/bin/bar)

Copy a file from the package install directory to the root filesystem:

.. code-block:: make

 $(call install_copy, foo, 0, 0, 0755, -, /usr/bin/foo)

install_tree
~~~~~~~~~~~~

Usage:

.. code-block:: make

 $(call install_tree, <package>, <UID>, <GID>, <source dir>, <destination dir>)

Installs the whole directory tree with all files from the given directory into:

* the project's ``<platform-dir>/root/``
* the project's ``<platform-dir>/root-debug/``
* an ipkg packet in the project's ``<platform-dir>/packages/``

Some of the parameters have fixed meanings:

**<package>**
  Name of the IPKG/OPKG the macro should work on
**<UID>**
  User ID the directories and files should use in the target's root filesystem
  or ``-`` to keep the UID from the source tree
**<GID>**
  Group ID the directories and files should use in the target's root filesystem
  or ``-`` to keep the GID from the source tree
**<source dir>**
  This is the path to the tree of directories and files to be installed. It can
  be ``-`` to use the package directory of the current package instead
**<destination dir>**
  The basename of the to-be-installed tree in the root filesystem

Note: This installation macro

* uses the same permission flags in the destination dir as found
  in the source dir. This is valid for directories and regular files
* skips all directories with names like ``.svn``, ``.git``, ``.pc`` and
  ``CVS`` in the source directory

Examples:

Install the whole tree found in ``/home/jbe/foo`` to the root filesystem
at location ``/usr/share/bar``.

.. code-block:: make

 $(call install_tree, foo, 0, 0, /home/jbe/foo, /usr/share/bar)

Install all files from the tree found in the current package FOO to the root
filesystem at location ``/usr/share/bar``.

.. code-block:: make

 $(call install_tree, foo, 0, 0, -, /usr/share/bar)

If the current package is ``foo-1.0`` the base path for the directory tree
will be ``$(PKGDIR)/foo-1.0/usr/share/bar``.

install_alternative_tree
~~~~~~~~~~~~~~~~~~~~~~~~

Usage:

.. code-block:: make

 $(call install_alternative_tree, <package>, <UID>, <GID>, <destination dir>)

Installs the whole source directory tree with all files from the given directory into:

* the project's ``<platform-dir>/root/``
* the project's ``<platform-dir>/root-debug/``
* an ipkg packet in the project's ``<platform-dir>/packages/``

The ``<destination dir>`` is used like in the ``install_alternative`` to let
PTXdist search in the same directories and order for the given directory.

Some of the parameters have fixed meanings:

**<package>**
  Name of the IPKG/OPKG the macro should work on
**<UID>**
  User ID the directories and files should use in the target's root filesystem
  or ``-`` to keep the UID from the source
**<GID>**
  Group ID the directories and files should use in the target's root
  filesystem or ``-`` to keep the GID from the source
**<destination dir>**
  The basename of the to-be-installed tree in the root filesystem

.. note:: This installation macro

  * uses the same permission flags in the destination dir as found in the source
    dir. This is valid for directories and regular files
  * skips all directories with names like ``.svn``, ``.git``, ``.pc`` and ``CVS``
    in the source directory

Examples:

Install the whole tree found in project's ``projectroot/usr/share/bar``
to the root filesystem at location ``/usr/share/bar``.

.. code-block:: make

 $(call install_alternative_tree, foo, 0, 0, /usr/share/bar)

install_alternative
~~~~~~~~~~~~~~~~~~~

Usage:

.. code-block:: make

 $(call install_alternative, <package>, <UID>, <GID>, <permission>, <destination>)

Installs given files or directories into:

* the project's ``<platform-dir>/root/``
* the project's ``<platform-dir>/root-debug/``
* an ipkg/opkg packet in the project's ``<platform-dir>/packages/``

The base parameters and their meanings:

**<package>**
  Name of the IPKG/OPKG the macro should work on
**<UID>**
  User ID the file should use in the target's root filesystem
**<GID>**
  Group ID the file should use in the target's root filesystem
**<permission>**
  Permission (in an octal value) the file should use in the target's root filesystem

The parameter <destination> is meant as an absolute path
and filename in target's root filesystem. PTXdist searches for the source
of this file in:

* the local project
* in the used platform
* PTXdist's install path
* in the current package

As this search algorithm is complex, here an example for the file
``/etc/foo`` in package ``FOO``. PTXdist will search for this
file in the following order:

* project's directory ``projectroot.<platform>/etc/foo``
* project's directory ``projectroot/etc/foo.<platform>``
* platform's directory ``<platform-src>/projectroot/etc/foo``
* project's directory ``projectroot/etc/foo``
* ptxdist's directory ``generic/etc/foo``
* project's directory ``$(FOO_DIR)/etc/foo``

The generic rules are looking like the following:

* ``$(PTXDIST_WORKSPACE)/projectroot.$(PTXDIST_PLATFORMSUFFIX)/etc/foo``
* ``$(PTXDIST_WORKSPACE)/projectroot/etc/foo$(PTXDIST_PLATFORMSUFFIX)``
* ``$(PTXDIST_PLATFORMCONFIGDIR)/projectroot/etc/foo``
* ``$(PTXDIST_WORKSPACE)/projectroot/etc/foo``
* ``$(PTXDIST_TOPDIR)/generic/etc/foo``
* ``$(FOO_DIR)/etc/foo``

Note: You can get the current values for the listed variables above via running
PTXdist with the ``print`` parameter:

.. code-block:: bash

 $ ptxdist print PTXDIST_PLATFORMSUFFIX

install_link
~~~~~~~~~~~~

Usage:

.. code-block:: make

 $(call install_link, <package>, <point to>, <where>)

Installs a symbolic link into:

* the project's ``<platform-dir>/root/``
* the project's ``<platform-dir>/root-debug/``
* an ipkg/opkg packet in the project's ``<platform-dir>/packages/``

The parameters and their meanings:

**<package>**
  Name of the IPKG/OPKG the macro should work on
**<point to>**
  Path and name the link should point to. Note: This macro rejects absolute
  paths. If needed use relative paths instead.
**<where>**
  Path and name of the symbolic link.

A few usage examples.

Create a symbolic link as ``/usr/lib/libfoo.so`` pointing to
``libfoo.so.1.1.0`` in the same directory:

.. code-block:: make

 $(call install_link, foo, libfoo.so.1.1.0, /usr/lib/libfoo.so)

Create a symbolic link as ``/usr/bin/foo`` pointing to ``/bin/bar``:

.. code-block:: make

 $(call install_link, foo, ../../bin/bar, /usr/bin/foo)

.. _install_archive:

install_archive
~~~~~~~~~~~~~~~

Usage:

.. code-block:: make

 $(call install_archive, <package>, <UID>, <GID>, <archive> , <base path>)

Installs archives content into:

* the project's ``<platform-dir>/root/``
* the project's ``<platform-dir>/root-debug/``
* an ipkg/opkg packet in the project's ``<platform-dir>/packages/``

All parameters have fixed meanings:

**<package>**
  Name of the IPKG/OPKG the macro should work on
**<UID>**
  User ID all files and directory of the archive should use in the target's
  root filesystem. A ``-`` uses the file's/directory's UID in the archive
**<GID>**
  Group ID the files and directories should use in the target's root filesystem.
  A ``-`` uses the file's/directory's GID in the archive
**<archive>**
  Name of the archive to be used in this call. The given path and filename is
  used as is
**<base path>**
  Base path component in the root filesystem the archive should be extracted
  to. Can be just ``/`` for root.

install_glob
~~~~~~~~~~~~

Usage:

.. code-block:: make

 $(call install_glob, <package>, <UID>, <GID>, <source dir>, <destination dir>, <yglob>, <nglob>[, <strip>])

Installs parts of a directory tree with all files from the given directory
into:

* the project's ``<platform-dir>/root/``
* the project's ``<platform-dir>/root-debug/``
* an ipkg packet in the project's ``<platform-dir>/packages/``

Some of the parameters have fixed meanings:

**<package>**
  Name of the IPKG/OPKG the macro should work on
**<UID>**
  User ID the directories and files should use in the target's root filesystem
  or ``-`` to keep the UID from the source tree
**<GID>**
  Group ID the directories and files should use in the target's root filesystem
  or ``-`` to keep the GID from the source tree
**<source dir>**
  This is the path to the tree of directories and files to be installed. It can
  be ``-`` to use the package directory of the current package instead
**<destination dir>**
  The basename of the to-be-installed tree in the root filesystem
**<yglob>**
  A list of pathname patterns. All files or directories that match _any_
  pattern in the list are installed. Note: the patterns must match the
  whole absolute path, e.g. ``*/foo``. An empty list is equivalent to a
  pattern that matches all files.
**<nglob>**
  Like ``<yglob>`` but any matching files or directories will not be
  installed. For directories, this includes the whole contents of the
  directory.

Except for the pathname patterns, this command works like ``install_tree``.
The ``<yglob>`` and ``<nglob>`` patterns are combined: Only files that
match ``<yglob>`` and do not match ``<nglob>`` are installed.

Examples:

Install all shared libraries found in ``$(PKGDIR)/usr/lib/foo`` except
libbar.so

.. code-block:: make

 $(call install_glob, foo, 0, 0, -, /usr/lib/foo, *.so, */libbar.so)

install_lib
~~~~~~~~~~~

Usage:

.. code-block:: make

 $(call install_lib, <package>, <UID>, <GID>, <permission>, <libname>)

Installs the shared library <libname> into the root filesystem.

* the project's ``<platform-dir>/root/``
* the project's ``<platform-dir>/root-debug/``
* an ipkg/opkg packet in the project's ``<platform-dir>/packages/``

The parameters and their meanings:

**<package>**
  Name of the IPKG/OPKG the macro should work on
**<UID>**
  User ID the file should use in the target's root filesystem
**<GID>**
  Group ID the directories and files should use in the target's root filesystem
**<permission>**
  Permission (as an octal value) the library should use in the target's root
  filesystem (mostly 0644)
**<libname>**
  Basename of the library without any extension and path

The ``install_lib`` macro searches for the library at the most
common directories ``/lib`` and ``/usr/lib``. And it searches always
in the package's corresponding directory in ``<platform-dir>/packages/``.
It also handles all required links to make the library work at runtime.

An example.

Lets assume the package 'foo-1.0.0' has installed the library ``libfoo`` into
its ``<platform-dir>/packages/foo-1.0.0`` at:

* the lib: ``<platform-dir>/packages/foo-1.0.0/usr/lib/libfoo1.so.0.0.0``
* first link: ``<platform-dir>/packages/foo-1.0.0/usr/lib/libfoo1.so.0``
* second link: ``<platform-dir>/packages/foo-1.0.0/usr/lib/libfoo1.so``

To install this library and its corresponding links, the following line does the job:

.. code-block:: make

 $(call install_lib, foo, 0, 0, 0644, libfoo1)

Note: The package's install stage must be 'DESTDIR' aware to be able to make
it install its content into the corresponding packages directory (in our example
``<platform-dir>/packages/foo-1.0.0/`` here).


.. _param_macros:

ptx/endis
~~~~~~~~~

To convert the state (set/unset) of a variable into an ``enable/disable``
string use the ``ptx/endis`` macro.
If the given <variable> is set this macro expands to
the string ``enable``, if unset to ``disable`` instead.

Usage:

.. code-block:: make

 --$(call ptx/endis, <variable>)-<parameter>

An example:

.. code-block:: make

 FOO_CONF_OPT += --$(call ptx/endis,FOO_VARIABLE)-something

Depending on the state of FOO_VARIABLE this line results into

.. code-block:: make

 FOO_CONF_OPT += --enable-something (if FOO_VARIABLE is set)
 FOO_CONF_OPT += --disable-something (if FOO_VARIABLE is unset)

Refer ``ptx/disen`` for the opposite string expansion.

ptx/disen
~~~~~~~~~

To convert the state (set/unset) of a variable into a ``disable/enable``
string use the ``ptx/disen`` macro.
If the given <variable> is set this macro expands to
the string ``disable``, if unset to ``enable`` instead.

Usage:

.. code-block:: make

 --$(call ptx/disen, <variable>)-<parameter>

An example:

.. code-block:: make

 FOO_CONF_OPT += --$(call ptx/disen,FOO_VARIABLE)-something

Depending on the state of FOO_VARIABLE this line results into

.. code-block:: make

 FOO_CONF_OPT += --disable-something (if FOO_VARIABLE is set)
 FOO_CONF_OPT += --enable-something (if FOO_VARIABLE is unset)

Refer ``ptx/endis`` for the opposite string expansion.

ptx/wwo
~~~~~~~

To convert the state (set/unset) of a variable into a ``with/without``
string use the ``ptx/wwo`` macro.
If the given <variable> is set this macro expands to
the string ``with``, if unset to ``without`` instead.

Usage:

.. code-block:: make

 --$(call ptx/wwo, <variable>)-<parameter>

An example:

.. code-block:: make

 FOO_CONF_OPT += --$(call ptx/wwo,FOO_VARIABLE)-something

Depending on the state of FOO_VARIABLE this line results into

.. code-block:: make

 FOO_CONF_OPT += --with-something (if FOO_VARIABLE is set)
 FOO_CONF_OPT += --without-something (if FOO_VARIABLE is unset)

ptx/ifdef
~~~~~~~~~

To convert the state (set/unset) of a variable into one of two strings use the
``ptx/ifdef`` macro.
If the given <variable> is set this macro expands to
the first given string, if unset to the second given string.

Usage:

.. code-block:: make

 --with-something=$(call ptx/ifdef, <variable>, <first-string>, <second-string)

An example:

.. code-block:: make

 FOO_CONF_OPT += --with-something=$(call ptx/ifdef,FOO_VARIABLE,/usr,none)

Depending on the state of FOO_VARIABLE this line results into

.. code-block:: make

 FOO_CONF_OPT += --with-something=/usr (if FOO_VARIABLE is set)
 FOO_CONF_OPT += --with-something=none (if FOO_VARIABLE is unset)

.. _rulefile:

Rule file layout
----------------

Each rule file provides PTXdist with the required steps to be done on a
per package base:

-  get

-  extract

-  prepare

-  compile

-  install

-  targetinstall

Default stage rules
~~~~~~~~~~~~~~~~~~~

As for most packages these steps can be done in a default way, PTXdist
provides generic rules for each package. If a package’s rule file does
not provide a specific stage rule, the default stage rule will be used
instead.

.. Important::
  Omitting one of the stage rules **does not mean** that PTXdist skips
  this stage!
  In this case the default stage rule is used instead.

get Stage Default Rule
^^^^^^^^^^^^^^^^^^^^^^

If the *get* stage is omitted, PTXdist runs instead:

.. code-block:: make

    $(STATEDIR)/@package@.get:
    		@$(call targetinfo)
    		@$(call touch)

Which means this step is skipped.

If the package is an archive that must be downloaded from the web, the
following rule must exist in this case:

.. code-block:: make

    $(@package@_SOURCE):
    		@$(call targetinfo)
		@$(call get, @package@)

extract Stage Default Rule
^^^^^^^^^^^^^^^^^^^^^^^^^^

If the *extract* stage is omitted, PTXdist runs instead:

.. code-block:: make

    $(STATEDIR)/@package@.extract:
    		@$(call targetinfo)
		@$(call clean, $(@package@_DIR))
		@$(call extract, @package@)
		@$(call patchin, @package@)
    		@$(call touch)

Which means a current existing directory of this package will be
removed, the archive gets freshly extracted again and (if corresponding
patches are found) patched.

prepare Stage Default Rule
^^^^^^^^^^^^^^^^^^^^^^^^^^

If the *prepare* stage is omitted, PTXdist runs a default stage rule
depending on some variable settings.

If the package’s rule file defines ``@package@_CONF_TOOL`` to ``NO``,
this stage is simply skipped.

All rules files shall create the ``@package@_CONF_ENV`` variable and
define it at least to ``$(CROSS_ENV)`` if the prepare stage is used.

If the package’s rule file defines ``@package@_CONF_TOOL`` to
``autoconf`` (``FOO_CONF_TOOL = autoconf`` for our *foo* example),
PTXdist treats this package as an autotoolized package and runs:

.. code-block:: make

    $(STATEDIR)/@package@.prepare:
    		@$(call targetinfo)
		@$(call clean, $(@package@_DIR)/config.cache)
		@cd $(@package@_DIR)/$(@package@_SUBDIR) && \
			$(@package@_PATH) $(@package@_CONF_ENV) \
			./configure $(@package@_CONF_OPT)
    		@$(call touch)

The ``@package@_CONF_OPT`` should at least be defined to
``$(CROSS_AUTOCONF_USR)`` or ``$(CROSS_AUTOCONF_ROOT)``.

If the package’s rule file defines ``@package@_CONF_TOOL`` to ``cmake``
(``FOO_CONF_TOOL = cmake`` for our *foo* example), PTXdist treats this
package as a *cmake* based package and runs:

.. code-block:: make

    $(STATEDIR)/@package@.prepare:
    		@$(call targetinfo)
		@cd $(@package@_DIR) && \
			$(@package@_PATH) $(@package@_CONF_ENV) \
			cmake $(@package@_CONF_OPT)
    		@$(call touch)

The ``@package@_CONF_OPT`` should at least be defined to
``$(CROSS_CMAKE_USR)`` or ``$(CROSS_CMAKE_ROOT)``.

If the package’s rule file defines ``@package@_CONF_TOOL`` to ``qmake``
(``FOO_CONF_TOOL = qmake`` for our *foo* example), PTXdist treats this
package as a *qmake* based package and runs:

.. code-block:: make

    $(STATEDIR)/@package@.prepare:
    		@$(call targetinfo)
		@cd $(@package@_DIR) && \
			$(@package@_PATH) $(@package@_CONF_ENV) \
			qmake $(@package@_CONF_OPT)
    		@$(call touch)

The ``@package@_CONF_OPT`` should at least be defined to
``$(CROSS_QMAKE_OPT)``.

compile Stage Default Rule
^^^^^^^^^^^^^^^^^^^^^^^^^^

If the *compile* stage is omitted, PTXdist runs instead:

.. code-block:: make

    $(STATEDIR)/@package@.compile:
    		@$(call targetinfo)
		@cd $(@package@_DIR) && \
			$(@package@_PATH) $(@package@_MAKE_ENV) \
			$(MAKE) $(@package@_MAKE_OPT) $(@package@_MAKE_PAR)
    		@$(call touch)

If the ``@package@_MAKE_ENV`` is not defined, it defaults to
``$(CROSS_ENV)``. If some additional variables should be added to the
``@package@_MAKE_ENV``, always begin with the ``$(CROSS_ENV)`` and then
add the additional variables.

If the ``@package@_MAKE_OPT`` is intended for additional parameters to
be forwarded to ``make`` or to overwrite some settings from the
``@package@_MAKE_ENV``. If not defined in the rule file it defaults to
an empty string.

Note: ``@package@_MAKE_PAR`` can be defined to ``YES`` or ``NO`` to
control if the package can be built in parallel.

install Stage Default Rule
^^^^^^^^^^^^^^^^^^^^^^^^^^

If the *install* stage is omitted, PTXdist runs instead:

.. code-block:: make

    $(STATEDIR)/@package@.install:
    		@$(call targetinfo)
		@cd $(@package@_DIR) && \
			$(@package@_PATH) $(@package@_MAKE_ENV) \
			$(MAKE) $(@package@_INSTALL_OPT)
    		@$(call touch)

Note: ``@package@_INSTALL_OPT`` is always defined to ``install`` if not
otherwise specified. This value can be replaced by a package’s rule file
definition.

targetinstall Stage Default Rule
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

There is no default rule for a package’s *targetinstall* state. PTXdist
has no idea what is required on the target at run-time. This stage is up
to the developer only. Refer to section :ref:`reference_macros`
for further info on how to select files to be included in the target’s
root filesystem.

Skipping a Stage
~~~~~~~~~~~~~~~~

For the case that a specific stage should be skipped, an empty rule must
be provided:

.. code-block:: make

    $(STATEDIR)/@package@.<stage_to_skip>:
    		@$(call targetinfo)
    		@$(call touch)

Replace the <stage_to_skip> by ``get``, ``extract``, ``prepare``,
``compile``, ``install`` or ``targetinstall``.

.. _ptxdist_parameter_reference:

PTXdist parameter reference
---------------------------

PTXdist is a command line tool, which is basicly called as:

.. code-block:: bash

    $  ptxdist <action [args]> [options]

.. include:: ref_parameter.rst