erlang: bump to version 18.3
[buildroot-gz.git] / package / pkg-perl.mk
bloba02781015654fe61b34e1dd5197b8d8c53b2f672
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= $(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
53 # Configure step. Only define it if not already defined by the package
54 # .mk file. And take care of the differences between host and target
55 # packages.
57 ifndef $(2)_CONFIGURE_CMDS
58 ifeq ($(4),target)
60 # Configure package for target
61 define $(2)_CONFIGURE_CMDS
62 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] ; then \
63 $$($(2)_CONF_ENV) \
64 PERL_MM_USE_DEFAULT=1 \
65 $$(PERL_RUN) Build.PL \
66 --config ar="$$(TARGET_AR)" \
67 --config full_ar="$$(TARGET_AR)" \
68 --config cc="$$(TARGET_CC)" \
69 --config ccflags="$$(TARGET_CFLAGS)" \
70 --config optimize=" " \
71 --config ld="$$(TARGET_CC)" \
72 --config lddlflags="-shared $$(TARGET_LDFLAGS)" \
73 --config ldflags="$$(TARGET_LDFLAGS)" \
74 --include_dirs $$(STAGING_DIR)/usr/lib/perl5/$$(PERL_VERSION)/$$(PERL_ARCHNAME)/CORE \
75 --destdir $$(TARGET_DIR) \
76 --installdirs vendor \
77 --install_path lib=/usr/lib/perl5/site_perl/$$(PERL_VERSION) \
78 --install_path arch=/usr/lib/perl5/site_perl/$$(PERL_VERSION)/$$(PERL_ARCHNAME) \
79 --install_path bin=/usr/bin \
80 --install_path script=/usr/bin \
81 --install_path bindoc=/usr/share/man/man1 \
82 --install_path libdoc=/usr/share/man/man3 \
83 $$($(2)_CONF_OPTS); \
84 else \
85 $$($(2)_CONF_ENV) \
86 PERL_MM_USE_DEFAULT=1 \
87 PERL_AUTOINSTALL=--skipdeps \
88 $$(PERL_RUN) Makefile.PL \
89 AR="$$(TARGET_AR)" \
90 FULL_AR="$$(TARGET_AR)" \
91 CC="$$(TARGET_CC)" \
92 CCFLAGS="$$(TARGET_CFLAGS)" \
93 OPTIMIZE=" " \
94 LD="$$(TARGET_CC)" \
95 LDDLFLAGS="-shared $$(TARGET_LDFLAGS)" \
96 LDFLAGS="$$(TARGET_LDFLAGS)" \
97 DESTDIR=$$(TARGET_DIR) \
98 INSTALLDIRS=vendor \
99 INSTALLVENDORLIB=/usr/lib/perl5/site_perl/$$(PERL_VERSION) \
100 INSTALLVENDORARCH=/usr/lib/perl5/site_perl/$$(PERL_VERSION)/$$(PERL_ARCHNAME) \
101 INSTALLVENDORBIN=/usr/bin \
102 INSTALLVENDORSCRIPT=/usr/bin \
103 INSTALLVENDORMAN1DIR=/usr/share/man/man1 \
104 INSTALLVENDORMAN3DIR=/usr/share/man/man3 \
105 $$($(2)_CONF_OPTS); \
107 endef
108 else
110 # Configure package for host
111 define $(2)_CONFIGURE_CMDS
112 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] ; then \
113 $$($(2)_CONF_ENV) \
114 PERL_MM_USE_DEFAULT=1 \
115 $$(PERL_RUN) Build.PL \
116 $$($(2)_CONF_OPTS); \
117 else \
118 $$($(2)_CONF_ENV) \
119 PERL_MM_USE_DEFAULT=1 \
120 PERL_AUTOINSTALL=--skipdeps \
121 $$(PERL_RUN) Makefile.PL \
122 $$($(2)_CONF_OPTS); \
124 endef
125 endif
126 endif
129 # Build step. Only define it if not already defined by the package .mk
130 # file. And take care of the differences between host and target
131 # packages.
133 ifndef $(2)_BUILD_CMDS
134 ifeq ($(4),target)
136 # Build package for target
137 define $(2)_BUILD_CMDS
138 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] ; then \
139 $$(PERL_RUN) Build $$($(2)_BUILD_OPTS) build; \
140 else \
141 $$(MAKE1) \
142 PERL_INC=$$(STAGING_DIR)/usr/lib/perl5/$$(PERL_VERSION)/$$(PERL_ARCHNAME)/CORE \
143 FIXIN=: \
144 $$($(2)_BUILD_OPTS) pure_all; \
146 endef
147 else
149 # Build package for host
150 define $(2)_BUILD_CMDS
151 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] ; then \
152 $$(PERL_RUN) Build $$($(2)_BUILD_OPTS) build; \
153 else \
154 $$(MAKE1) $$($(2)_BUILD_OPTS) pure_all; \
156 endef
157 endif
158 endif
161 # Host installation step. Only define it if not already defined by the
162 # package .mk file.
164 ifndef $(2)_INSTALL_CMDS
165 define $(2)_INSTALL_CMDS
166 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] ; then \
167 $$(PERL_RUN) Build $$($(2)_INSTALL_TARGET_OPTS) install; \
168 else \
169 $$(MAKE1) $$($(2)_INSTALL_TARGET_OPTS) pure_install; \
171 endef
172 endif
175 # Target installation step. Only define it if not already defined by
176 # the package .mk file.
178 ifndef $(2)_INSTALL_TARGET_CMDS
179 define $(2)_INSTALL_TARGET_CMDS
180 cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] ; then \
181 $$(PERL_RUN) Build $$($(2)_INSTALL_TARGET_OPTS) install; \
182 else \
183 $$(MAKE1) $$($(2)_INSTALL_TARGET_OPTS) pure_install; \
185 endef
186 endif
188 # Call the generic package infrastructure to generate the necessary
189 # make targets
190 $(call inner-generic-package,$(1),$(2),$(3),$(4))
192 endef
194 ################################################################################
195 # perl-package -- the target generator macro for Perl packages
196 ################################################################################
198 perl-package = $(call inner-perl-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
199 host-perl-package = $(call inner-perl-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)