adding-packages-perl.txt 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. === Infrastructure for Perl/CPAN packages
  4. [[perl-package-tutorial]]
  5. ==== +perl-package+ tutorial
  6. First, let's see how to write a +.mk+ file for a Perl/CPAN package,
  7. with an example :
  8. ------------------------
  9. 01: ################################################################################
  10. 02: #
  11. 03: # perl-foo-bar
  12. 04: #
  13. 05: ################################################################################
  14. 06:
  15. 07: PERL_FOO_BAR_VERSION = 0.02
  16. 08: PERL_FOO_BAR_SOURCE = Foo-Bar-$(PERL_FOO_BAR_VERSION).tar.gz
  17. 09: PERL_FOO_BAR_SITE = $(BR2_CPAN_MIRROR)/authors/id/M/MO/MONGER
  18. 10: PERL_FOO_BAR_DEPENDENCIES = perl-strictures
  19. 11: PERL_FOO_BAR_LICENSE = Artistic or GPL-1.0+
  20. 12: PERL_FOO_BAR_LICENSE_FILES = LICENSE
  21. 13:
  22. 14: $(eval $(perl-package))
  23. ------------------------
  24. On line 7, we declare the version of the package.
  25. On line 8 and 9, we declare the name of the tarball and the location
  26. of the tarball on a CPAN server. Buildroot will automatically download
  27. the tarball from this location.
  28. On line 10, we declare our dependencies, so that they are built
  29. before the build process of our package starts.
  30. On line 11 and 12, we give licensing details about the package (its
  31. license on line 11, and the file containing the license text on line
  32. 12).
  33. Finally, on line 14, we invoke the +perl-package+ macro that
  34. generates all the Makefile rules that actually allow the package to be
  35. built.
  36. Most of these data can be retrieved from https://metacpan.org/.
  37. So, this file and the Config.in can be generated by running
  38. the script +supports/scripts/scancpan Foo-Bar+ in the Buildroot directory
  39. (or in a br2-external tree).
  40. This script creates a Config.in file and foo-bar.mk file for the
  41. requested package, and also recursively for all dependencies specified by
  42. CPAN. You should still manually edit the result. In particular, the
  43. following things should be checked.
  44. * If the perl module links with a shared library that is provided by
  45. another (non-perl) package, this dependency is not added automatically.
  46. It has to be added manually to +PERL_FOO_BAR_DEPENDENCIES+.
  47. * The +package/Config.in+ file has to be updated manually to include the
  48. generated Config.in files. As a hint, the +scancpan+ script prints out
  49. the required +source "..."+ statements, sorted alphabetically.
  50. [[perl-package-reference]]
  51. ==== +perl-package+ reference
  52. As a policy, packages that provide Perl/CPAN modules should all be
  53. named +perl-<something>+ in Buildroot.
  54. This infrastructure handles various Perl build systems :
  55. +ExtUtils-MakeMaker+ (EUMM), +Module-Build+ (MB) and +Module-Build-Tiny+.
  56. +Build.PL+ is preferred by default when a package provides a +Makefile.PL+
  57. and a +Build.PL+.
  58. The main macro of the Perl/CPAN package infrastructure is
  59. +perl-package+. It is similar to the +generic-package+ macro. The ability to
  60. have target and host packages is also available, with the
  61. +host-perl-package+ macro.
  62. Just like the generic infrastructure, the Perl/CPAN infrastructure
  63. works by defining a number of variables before calling the
  64. +perl-package+ macro.
  65. First, all the package metadata information variables that exist in the
  66. generic infrastructure also exist in the Perl/CPAN infrastructure:
  67. +PERL_FOO_VERSION+, +PERL_FOO_SOURCE+,
  68. +PERL_FOO_PATCH+, +PERL_FOO_SITE+,
  69. +PERL_FOO_SUBDIR+, +PERL_FOO_DEPENDENCIES+,
  70. +PERL_FOO_INSTALL_TARGET+.
  71. Note that setting +PERL_FOO_INSTALL_STAGING+ to +YES+ has no effect
  72. unless a +PERL_FOO_INSTALL_STAGING_CMDS+ variable is defined. The perl
  73. infrastructure doesn't define these commands since Perl modules generally
  74. don't need to be installed to the +staging+ directory.
  75. A few additional variables, specific to the Perl/CPAN infrastructure,
  76. can also be defined. Many of them are only useful in very specific
  77. cases, typical packages will therefore only use a few of them.
  78. * +PERL_FOO_PREFER_INSTALLER+/+HOST_PERL_FOO_PREFER_INSTALLER+,
  79. specifies the preferred installation method. Possible values are
  80. +EUMM+ (for +Makefile.PL+ based installation using
  81. +ExtUtils-MakeMaker+) and +MB+ (for +Build.PL+ based installation
  82. using +Module-Build+). This variable is only used when the package
  83. provides both installation methods.
  84. * +PERL_FOO_CONF_ENV+/+HOST_PERL_FOO_CONF_ENV+, to specify additional
  85. environment variables to pass to the +perl Makefile.PL+ or +perl Build.PL+.
  86. By default, empty.
  87. * +PERL_FOO_CONF_OPTS+/+HOST_PERL_FOO_CONF_OPTS+, to specify additional
  88. configure options to pass to the +perl Makefile.PL+ or +perl Build.PL+.
  89. By default, empty.
  90. * +PERL_FOO_BUILD_OPTS+/+HOST_PERL_FOO_BUILD_OPTS+, to specify additional
  91. options to pass to +make pure_all+ or +perl Build build+ in the build step.
  92. By default, empty.
  93. * +PERL_FOO_INSTALL_TARGET_OPTS+, to specify additional options to
  94. pass to +make pure_install+ or +perl Build install+ in the install step.
  95. By default, empty.
  96. * +HOST_PERL_FOO_INSTALL_OPTS+, to specify additional options to
  97. pass to +make pure_install+ or +perl Build install+ in the install step.
  98. By default, empty.