package/nbd: add option for the trdump utility
[buildroot-gz.git] / package / pkg-perl.mk
blobcc94cd9f8b34c65620407037725153f127b4c24e
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
8 # infrastructure
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)/usr/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
30 # make targets
32 # argument 1 is the lowercase package name
33 # argument 2 is the uppercase package name, including a HOST_ prefix
34 # for host packages
35 # argument 3 is the uppercase package name, without the HOST_ prefix
36 # for host packages
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.
46 ifeq ($(4),target)
47 $(2)_DEPENDENCIES += host-perl perl
48 else
49 $(2)_DEPENDENCIES += host-perl
50 endif
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
63 # packages.
65 ifndef $(2)_CONFIGURE_CMDS
66 ifeq ($(4),target)
68 # Configure package for target
69 define $(2)_CONFIGURE_CMDS
70 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
71 $$($(2)_CONF_ENV) \
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 \
91 $$($(2)_CONF_OPTS); \
92 else \
93 $$($(2)_CONF_ENV) \
94 PERL_MM_USE_DEFAULT=1 \
95 PERL_AUTOINSTALL=--skipdeps \
96 $$(PERL_RUN) Makefile.PL \
97 AR="$$(TARGET_AR)" \
98 FULL_AR="$$(TARGET_AR)" \
99 CC="$$(TARGET_CC)" \
100 CCFLAGS="$$(TARGET_CFLAGS)" \
101 OPTIMIZE=" " \
102 LD="$$(TARGET_CC)" \
103 LDDLFLAGS="-shared $$(TARGET_LDFLAGS)" \
104 LDFLAGS="$$(TARGET_LDFLAGS)" \
105 DESTDIR=$$(TARGET_DIR) \
106 INSTALLDIRS=vendor \
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); \
115 endef
116 else
118 # Configure package for host
119 define $(2)_CONFIGURE_CMDS
120 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
121 $$($(2)_CONF_ENV) \
122 PERL_MM_USE_DEFAULT=1 \
123 $$(PERL_RUN) Build.PL \
124 $$($(2)_CONF_OPTS); \
125 else \
126 $$($(2)_CONF_ENV) \
127 PERL_MM_USE_DEFAULT=1 \
128 PERL_AUTOINSTALL=--skipdeps \
129 $$(PERL_RUN) Makefile.PL \
130 $$($(2)_CONF_OPTS); \
132 endef
133 endif
134 endif
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
139 # packages.
141 ifndef $(2)_BUILD_CMDS
142 ifeq ($(4),target)
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; \
148 else \
149 $$(MAKE1) \
150 PERL_INC=$$(STAGING_DIR)/usr/lib/perl5/$$(PERL_VERSION)/$$(PERL_ARCHNAME)/CORE \
151 FIXIN=: \
152 $$($(2)_BUILD_OPTS) pure_all; \
154 endef
155 else
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; \
161 else \
162 $$(MAKE1) $$($(2)_BUILD_OPTS) pure_all; \
164 endef
165 endif
166 endif
169 # Host installation step. Only define it if not already defined by the
170 # package .mk file.
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; \
176 else \
177 $$(MAKE1) $$($(2)_INSTALL_TARGET_OPTS) pure_install; \
179 endef
180 endif
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; \
190 else \
191 $$(MAKE1) $$($(2)_INSTALL_TARGET_OPTS) pure_install; \
193 endef
194 endif
196 # Call the generic package infrastructure to generate the necessary
197 # make targets
198 $(call inner-generic-package,$(1),$(2),$(3),$(4))
200 endef
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)