1 ################################################################################
2 # Perl package infrastructure
4 # This file implements an infrastructure that eases development of
5 # package .mk files for Perl packages.
7 # See the Buildroot documentation for details on the usage of this
10 # In terms of implementation, this perl infrastructure requires
11 # the .mk file to only specify metadata information about the
12 # package: name, version, download URL, etc.
14 # We still allow the package .mk file to override what the different
15 # steps are doing, if needed. For example, if <PKG>_BUILD_CMDS is
16 # already defined, it is used as the list of commands to perform to
17 # build the package, instead of the default perl behaviour. The
18 # package can also define some post operation hooks.
20 ################################################################################
22 PERL_ARCHNAME = $(ARCH)-linux
23 PERL_RUN = PERL5LIB= PERL_USE_UNSAFE_INC=1 $(HOST_DIR)/bin/perl
25 ################################################################################
26 # inner-perl-package -- defines how the configuration, compilation and
27 # installation of a perl package should be done, implements a
28 # few hooks to tune the build process for perl specifities and
29 # calls the generic package infrastructure to generate the necessary
32 # argument 1 is the lowercase package name
33 # argument 2 is the uppercase package name, including a HOST_ prefix
35 # argument 3 is the uppercase package name, without the HOST_ prefix
37 # argument 4 is the type (target or host)
38 ################################################################################
40 define inner-perl-package
42 # Target packages need both the perl interpreter on the target (for
43 # runtime) and the perl interpreter on the host (for
44 # compilation). However, host packages only need the perl
45 # interpreter on the host.
47 $(2)_DEPENDENCIES += host-perl perl
49 $(2)_DEPENDENCIES += host-perl
52 # From http://perldoc.perl.org/CPAN.html#Config-Variables - prefer_installer
53 # legal values are MB and EUMM: if a module comes
54 # with both a Makefile.PL and a Build.PL, use the
55 # former (EUMM) or the latter (MB); if the module
56 # comes with only one of the two, that one will be
57 # used no matter the setting
58 $(2)_PREFER_INSTALLER ?= MB
61 # Configure step. Only define it if not already defined by the package
62 # .mk file. And take care of the differences between host and target
65 ifndef $(2)_CONFIGURE_CMDS
68 # Configure package for target
69 define $(2)_CONFIGURE_CMDS
70 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
72 PERL_MM_USE_DEFAULT=1 \
73 $$(PERL_RUN) Build.PL \
74 --config ar="$$(TARGET_AR)" \
75 --config full_ar="$$(TARGET_AR)" \
76 --config cc="$$(TARGET_CC)" \
77 --config ccflags="$$(TARGET_CFLAGS)" \
78 --config optimize=" " \
79 --config ld="$$(TARGET_CC)" \
80 --config lddlflags="-shared $$(TARGET_LDFLAGS)" \
81 --config ldflags="$$(TARGET_LDFLAGS)" \
82 --include_dirs $$(STAGING_DIR)/usr/lib/perl5/$$(PERL_VERSION)/$$(PERL_ARCHNAME)/CORE \
83 --destdir $$(TARGET_DIR) \
84 --installdirs vendor \
85 --install_path lib=/usr/lib/perl5/site_perl/$$(PERL_VERSION) \
86 --install_path arch=/usr/lib/perl5/site_perl/$$(PERL_VERSION)/$$(PERL_ARCHNAME) \
87 --install_path bin=/usr/bin \
88 --install_path script=/usr/bin \
89 --install_path bindoc=/usr/share/man/man1 \
90 --install_path libdoc=/usr/share/man/man3 \
94 PERL_MM_USE_DEFAULT=1 \
95 PERL_AUTOINSTALL=--skipdeps \
96 $$(PERL_RUN) Makefile.PL \
98 FULL_AR="$$(TARGET_AR)" \
100 CCFLAGS="$$(TARGET_CFLAGS)" \
103 LDDLFLAGS="-shared $$(TARGET_LDFLAGS)" \
104 LDFLAGS="$$(TARGET_LDFLAGS)" \
105 DESTDIR=$$(TARGET_DIR) \
107 INSTALLVENDORLIB=/usr/lib/perl5/site_perl/$$(PERL_VERSION) \
108 INSTALLVENDORARCH=/usr/lib/perl5/site_perl/$$(PERL_VERSION)/$$(PERL_ARCHNAME) \
109 INSTALLVENDORBIN=/usr/bin \
110 INSTALLVENDORSCRIPT=/usr/bin \
111 INSTALLVENDORMAN1DIR=/usr/share/man/man1 \
112 INSTALLVENDORMAN3DIR=/usr/share/man/man3 \
113 $$($(2)_CONF_OPTS); \
118 # Configure package for host
119 define $(2)_CONFIGURE_CMDS
120 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
122 PERL_MM_USE_DEFAULT=1 \
123 $$(PERL_RUN) Build.PL \
124 $$($(2)_CONF_OPTS); \
127 PERL_MM_USE_DEFAULT=1 \
128 PERL_AUTOINSTALL=--skipdeps \
129 $$(PERL_RUN) Makefile.PL \
130 $$($(2)_CONF_OPTS); \
137 # Build step. Only define it if not already defined by the package .mk
138 # file. And take care of the differences between host and target
141 ifndef $(2)_BUILD_CMDS
144 # Build package for target
145 define $(2)_BUILD_CMDS
146 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
147 $$(PERL_RUN) Build $$($(2)_BUILD_OPTS) build; \
150 PERL_INC=$$(STAGING_DIR)/usr/lib/perl5/$$(PERL_VERSION)/$$(PERL_ARCHNAME)/CORE \
152 $$($(2)_BUILD_OPTS) pure_all; \
157 # Build package for host
158 define $(2)_BUILD_CMDS
159 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
160 $$(PERL_RUN) Build $$($(2)_BUILD_OPTS) build; \
162 $$(MAKE1) $$($(2)_BUILD_OPTS) pure_all; \
169 # Host installation step. Only define it if not already defined by the
172 ifndef $(2)_INSTALL_CMDS
173 define $(2)_INSTALL_CMDS
174 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
175 $$(PERL_RUN) Build $$($(2)_INSTALL_TARGET_OPTS) install; \
177 $$(MAKE1) $$($(2)_INSTALL_TARGET_OPTS) pure_install; \
183 # Target installation step. Only define it if not already defined by
184 # the package .mk file.
186 ifndef $(2)_INSTALL_TARGET_CMDS
187 define $(2)_INSTALL_TARGET_CMDS
188 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
189 $$(PERL_RUN) Build $$($(2)_INSTALL_TARGET_OPTS) install; \
191 $$(MAKE1) $$($(2)_INSTALL_TARGET_OPTS) pure_install; \
196 # Call the generic package infrastructure to generate the necessary
198 $(call inner-generic-package,$(1),$(2),$(3),$(4))
202 ################################################################################
203 # perl-package -- the target generator macro for Perl packages
204 ################################################################################
206 perl-package = $(call inner-perl-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
207 host-perl-package = $(call inner-perl-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)