1*4882a593Smuzhiyun################################################################################ 2*4882a593Smuzhiyun# Perl package infrastructure 3*4882a593Smuzhiyun# 4*4882a593Smuzhiyun# This file implements an infrastructure that eases development of 5*4882a593Smuzhiyun# package .mk files for Perl packages. 6*4882a593Smuzhiyun# 7*4882a593Smuzhiyun# See the Buildroot documentation for details on the usage of this 8*4882a593Smuzhiyun# infrastructure 9*4882a593Smuzhiyun# 10*4882a593Smuzhiyun# In terms of implementation, this perl infrastructure requires 11*4882a593Smuzhiyun# the .mk file to only specify metadata information about the 12*4882a593Smuzhiyun# package: name, version, download URL, etc. 13*4882a593Smuzhiyun# 14*4882a593Smuzhiyun# We still allow the package .mk file to override what the different 15*4882a593Smuzhiyun# steps are doing, if needed. For example, if <PKG>_BUILD_CMDS is 16*4882a593Smuzhiyun# already defined, it is used as the list of commands to perform to 17*4882a593Smuzhiyun# build the package, instead of the default perl behaviour. The 18*4882a593Smuzhiyun# package can also define some post operation hooks. 19*4882a593Smuzhiyun# 20*4882a593Smuzhiyun################################################################################ 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunPERL_ARCHNAME = $(ARCH)-linux 23*4882a593SmuzhiyunPERL_RUN = PERL5LIB= PERL_USE_UNSAFE_INC=1 $(HOST_DIR)/bin/perl 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun################################################################################ 26*4882a593Smuzhiyun# inner-perl-package -- defines how the configuration, compilation and 27*4882a593Smuzhiyun# installation of a perl package should be done, implements a 28*4882a593Smuzhiyun# few hooks to tune the build process for perl specifities and 29*4882a593Smuzhiyun# calls the generic package infrastructure to generate the necessary 30*4882a593Smuzhiyun# make targets 31*4882a593Smuzhiyun# 32*4882a593Smuzhiyun# argument 1 is the lowercase package name 33*4882a593Smuzhiyun# argument 2 is the uppercase package name, including a HOST_ prefix 34*4882a593Smuzhiyun# for host packages 35*4882a593Smuzhiyun# argument 3 is the uppercase package name, without the HOST_ prefix 36*4882a593Smuzhiyun# for host packages 37*4882a593Smuzhiyun# argument 4 is the type (target or host) 38*4882a593Smuzhiyun################################################################################ 39*4882a593Smuzhiyun 40*4882a593Smuzhiyundefine inner-perl-package 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun# Target packages need both the perl interpreter on the target (for 43*4882a593Smuzhiyun# runtime) and the perl interpreter on the host (for 44*4882a593Smuzhiyun# compilation). However, host packages only need the perl 45*4882a593Smuzhiyun# interpreter on the host. 46*4882a593Smuzhiyunifeq ($(4),target) 47*4882a593Smuzhiyun$(2)_DEPENDENCIES += host-perl perl 48*4882a593Smuzhiyunelse 49*4882a593Smuzhiyun$(2)_DEPENDENCIES += host-perl 50*4882a593Smuzhiyunendif 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun# From http://perldoc.perl.org/CPAN.html#Config-Variables - prefer_installer 53*4882a593Smuzhiyun# legal values are MB and EUMM: if a module comes 54*4882a593Smuzhiyun# with both a Makefile.PL and a Build.PL, use the 55*4882a593Smuzhiyun# former (EUMM) or the latter (MB); if the module 56*4882a593Smuzhiyun# comes with only one of the two, that one will be 57*4882a593Smuzhiyun# used no matter the setting 58*4882a593Smuzhiyun$(2)_PREFER_INSTALLER ?= MB 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun# 61*4882a593Smuzhiyun# Configure step. Only define it if not already defined by the package 62*4882a593Smuzhiyun# .mk file. And take care of the differences between host and target 63*4882a593Smuzhiyun# packages. 64*4882a593Smuzhiyun# 65*4882a593Smuzhiyunifndef $(2)_CONFIGURE_CMDS 66*4882a593Smuzhiyunifeq ($(4),target) 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun# Configure package for target 69*4882a593Smuzhiyundefine $(2)_CONFIGURE_CMDS 70*4882a593Smuzhiyun cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \ 71*4882a593Smuzhiyun $$($(2)_CONF_ENV) \ 72*4882a593Smuzhiyun PERL_MM_USE_DEFAULT=1 \ 73*4882a593Smuzhiyun $$(PERL_RUN) Build.PL \ 74*4882a593Smuzhiyun --config ar="$$(TARGET_AR)" \ 75*4882a593Smuzhiyun --config full_ar="$$(TARGET_AR)" \ 76*4882a593Smuzhiyun --config cc="$$(TARGET_CC)" \ 77*4882a593Smuzhiyun --config ccflags="$$(TARGET_CFLAGS)" \ 78*4882a593Smuzhiyun --config optimize=" " \ 79*4882a593Smuzhiyun --config ld="$$(TARGET_CC)" \ 80*4882a593Smuzhiyun --config lddlflags="-shared $$(TARGET_LDFLAGS)" \ 81*4882a593Smuzhiyun --config ldflags="$$(TARGET_LDFLAGS)" \ 82*4882a593Smuzhiyun --include_dirs $$(STAGING_DIR)/usr/lib/perl5/$$(PERL_VERSION)/$$(PERL_ARCHNAME)/CORE \ 83*4882a593Smuzhiyun --destdir $$(TARGET_DIR) \ 84*4882a593Smuzhiyun --installdirs vendor \ 85*4882a593Smuzhiyun --install_path lib=/usr/lib/perl5/site_perl/$$(PERL_VERSION) \ 86*4882a593Smuzhiyun --install_path arch=/usr/lib/perl5/site_perl/$$(PERL_VERSION)/$$(PERL_ARCHNAME) \ 87*4882a593Smuzhiyun --install_path bin=/usr/bin \ 88*4882a593Smuzhiyun --install_path script=/usr/bin \ 89*4882a593Smuzhiyun --install_path bindoc=/usr/share/man/man1 \ 90*4882a593Smuzhiyun --install_path libdoc=/usr/share/man/man3 \ 91*4882a593Smuzhiyun $$($(2)_CONF_OPTS); \ 92*4882a593Smuzhiyun else \ 93*4882a593Smuzhiyun $$($(2)_CONF_ENV) \ 94*4882a593Smuzhiyun PERL_MM_USE_DEFAULT=1 \ 95*4882a593Smuzhiyun PERL_AUTOINSTALL=--skipdeps \ 96*4882a593Smuzhiyun $$(PERL_RUN) Makefile.PL \ 97*4882a593Smuzhiyun AR="$$(TARGET_AR)" \ 98*4882a593Smuzhiyun FULL_AR="$$(TARGET_AR)" \ 99*4882a593Smuzhiyun CC="$$(TARGET_CC)" \ 100*4882a593Smuzhiyun CCFLAGS="$$(TARGET_CFLAGS)" \ 101*4882a593Smuzhiyun OPTIMIZE=" " \ 102*4882a593Smuzhiyun LD="$$(TARGET_CC)" \ 103*4882a593Smuzhiyun LDDLFLAGS="-shared $$(TARGET_LDFLAGS)" \ 104*4882a593Smuzhiyun LDFLAGS="$$(TARGET_LDFLAGS)" \ 105*4882a593Smuzhiyun PERL_ARCHLIB=$$(STAGING_DIR)/usr/lib/perl5/$$(PERL_VERSION)/$$(PERL_ARCHNAME) \ 106*4882a593Smuzhiyun DESTDIR=$$(TARGET_DIR) \ 107*4882a593Smuzhiyun INSTALLDIRS=vendor \ 108*4882a593Smuzhiyun INSTALLVENDORLIB=/usr/lib/perl5/site_perl/$$(PERL_VERSION) \ 109*4882a593Smuzhiyun INSTALLVENDORARCH=/usr/lib/perl5/site_perl/$$(PERL_VERSION)/$$(PERL_ARCHNAME) \ 110*4882a593Smuzhiyun INSTALLVENDORBIN=/usr/bin \ 111*4882a593Smuzhiyun INSTALLVENDORSCRIPT=/usr/bin \ 112*4882a593Smuzhiyun INSTALLVENDORMAN1DIR=/usr/share/man/man1 \ 113*4882a593Smuzhiyun INSTALLVENDORMAN3DIR=/usr/share/man/man3 \ 114*4882a593Smuzhiyun $$($(2)_CONF_OPTS); \ 115*4882a593Smuzhiyun fi 116*4882a593Smuzhiyunendef 117*4882a593Smuzhiyunelse 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun# Configure package for host 120*4882a593Smuzhiyundefine $(2)_CONFIGURE_CMDS 121*4882a593Smuzhiyun cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \ 122*4882a593Smuzhiyun $$($(2)_CONF_ENV) \ 123*4882a593Smuzhiyun PERL_MM_USE_DEFAULT=1 \ 124*4882a593Smuzhiyun $$(PERL_RUN) Build.PL \ 125*4882a593Smuzhiyun $$($(2)_CONF_OPTS); \ 126*4882a593Smuzhiyun else \ 127*4882a593Smuzhiyun $$($(2)_CONF_ENV) \ 128*4882a593Smuzhiyun PERL_MM_USE_DEFAULT=1 \ 129*4882a593Smuzhiyun PERL_AUTOINSTALL=--skipdeps \ 130*4882a593Smuzhiyun $$(PERL_RUN) Makefile.PL \ 131*4882a593Smuzhiyun $$($(2)_CONF_OPTS); \ 132*4882a593Smuzhiyun fi 133*4882a593Smuzhiyunendef 134*4882a593Smuzhiyunendif 135*4882a593Smuzhiyunendif 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun# 138*4882a593Smuzhiyun# Build step. Only define it if not already defined by the package .mk 139*4882a593Smuzhiyun# file. And take care of the differences between host and target 140*4882a593Smuzhiyun# packages. 141*4882a593Smuzhiyun# 142*4882a593Smuzhiyunifndef $(2)_BUILD_CMDS 143*4882a593Smuzhiyunifeq ($(4),target) 144*4882a593Smuzhiyun 145*4882a593Smuzhiyun# Build package for target 146*4882a593Smuzhiyundefine $(2)_BUILD_CMDS 147*4882a593Smuzhiyun cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \ 148*4882a593Smuzhiyun $$(PERL_RUN) Build $$($(2)_BUILD_OPTS) build; \ 149*4882a593Smuzhiyun else \ 150*4882a593Smuzhiyun $$(MAKE1) \ 151*4882a593Smuzhiyun FIXIN=: \ 152*4882a593Smuzhiyun $$($(2)_BUILD_OPTS) pure_all; \ 153*4882a593Smuzhiyun fi 154*4882a593Smuzhiyunendef 155*4882a593Smuzhiyunelse 156*4882a593Smuzhiyun 157*4882a593Smuzhiyun# Build package for host 158*4882a593Smuzhiyundefine $(2)_BUILD_CMDS 159*4882a593Smuzhiyun cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \ 160*4882a593Smuzhiyun $$(PERL_RUN) Build $$($(2)_BUILD_OPTS) build; \ 161*4882a593Smuzhiyun else \ 162*4882a593Smuzhiyun $$(MAKE1) $$($(2)_BUILD_OPTS) pure_all; \ 163*4882a593Smuzhiyun fi 164*4882a593Smuzhiyunendef 165*4882a593Smuzhiyunendif 166*4882a593Smuzhiyunendif 167*4882a593Smuzhiyun 168*4882a593Smuzhiyun# 169*4882a593Smuzhiyun# Host installation step. Only define it if not already defined by the 170*4882a593Smuzhiyun# package .mk file. 171*4882a593Smuzhiyun# 172*4882a593Smuzhiyunifndef $(2)_INSTALL_CMDS 173*4882a593Smuzhiyundefine $(2)_INSTALL_CMDS 174*4882a593Smuzhiyun cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \ 175*4882a593Smuzhiyun $$(PERL_RUN) Build $$($(2)_INSTALL_TARGET_OPTS) install; \ 176*4882a593Smuzhiyun else \ 177*4882a593Smuzhiyun $$(MAKE1) $$($(2)_INSTALL_TARGET_OPTS) pure_install; \ 178*4882a593Smuzhiyun fi 179*4882a593Smuzhiyunendef 180*4882a593Smuzhiyunendif 181*4882a593Smuzhiyun 182*4882a593Smuzhiyun# 183*4882a593Smuzhiyun# Target installation step. Only define it if not already defined by 184*4882a593Smuzhiyun# the package .mk file. 185*4882a593Smuzhiyun# 186*4882a593Smuzhiyunifndef $(2)_INSTALL_TARGET_CMDS 187*4882a593Smuzhiyundefine $(2)_INSTALL_TARGET_CMDS 188*4882a593Smuzhiyun cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \ 189*4882a593Smuzhiyun $$(PERL_RUN) Build $$($(2)_INSTALL_TARGET_OPTS) install; \ 190*4882a593Smuzhiyun else \ 191*4882a593Smuzhiyun $$(MAKE1) $$($(2)_INSTALL_TARGET_OPTS) pure_install; \ 192*4882a593Smuzhiyun fi 193*4882a593Smuzhiyunendef 194*4882a593Smuzhiyunendif 195*4882a593Smuzhiyun 196*4882a593Smuzhiyun# Call the generic package infrastructure to generate the necessary 197*4882a593Smuzhiyun# make targets 198*4882a593Smuzhiyun$(call inner-generic-package,$(1),$(2),$(3),$(4)) 199*4882a593Smuzhiyun 200*4882a593Smuzhiyun# Upgrade helper 201*4882a593Smuzhiyunifneq ($$($(3)_DISTNAME),) 202*4882a593Smuzhiyun$(1)-upgrade: 203*4882a593Smuzhiyun utils/scancpan -force -$(4) $$($(3)_DISTNAME) 204*4882a593Smuzhiyun 205*4882a593Smuzhiyun.PHONY: $(1)-upgrade 206*4882a593Smuzhiyunendif 207*4882a593Smuzhiyun 208*4882a593Smuzhiyunendef 209*4882a593Smuzhiyun 210*4882a593Smuzhiyun################################################################################ 211*4882a593Smuzhiyun# perl-package -- the target generator macro for Perl packages 212*4882a593Smuzhiyun################################################################################ 213*4882a593Smuzhiyun 214*4882a593Smuzhiyunperl-package = $(call inner-perl-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target) 215*4882a593Smuzhiyunhost-perl-package = $(call inner-perl-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host) 216