93efc57527c4dd8a76c63c86844db0894af36e9e
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / perl / perl.mk
1 ################################################################################
2 #
3 # perl
4 #
5 ################################################################################
6
7 PERL_VERSION_MAJOR = 20
8 PERL_VERSION = 5.$(PERL_VERSION_MAJOR).2
9 PERL_SITE = http://www.cpan.org/src/5.0
10 PERL_SOURCE = perl-$(PERL_VERSION).tar.bz2
11 PERL_LICENSE = Artistic or GPLv1+
12 PERL_LICENSE_FILES = Artistic Copying README
13 PERL_INSTALL_STAGING = YES
14
15 PERL_CROSS_VERSION = 0.9.6
16 PERL_CROSS_BASE_VERSION = 5.$(PERL_VERSION_MAJOR).2
17 # DO NOT refactor with the github helper (the result is not the same)
18 PERL_CROSS_SITE = http://raw.github.com/arsv/perl-cross/releases
19 PERL_CROSS_SOURCE = perl-$(PERL_CROSS_BASE_VERSION)-cross-$(PERL_CROSS_VERSION).tar.gz
20 PERL_EXTRA_DOWNLOADS = $(PERL_CROSS_SITE)/$(PERL_CROSS_SOURCE)
21
22 PERL_CROSS_OLD_POD = perl$(subst .,,$(PERL_CROSS_BASE_VERSION))delta.pod
23 PERL_CROSS_NEW_POD = perl$(subst .,,$(PERL_VERSION))delta.pod
24
25 # We use the perlcross hack to cross-compile perl. It should
26 # be extracted over the perl sources, so we don't define that
27 # as a separate package. Instead, it is downloaded and extracted
28 # together with perl
29 define PERL_CROSS_EXTRACT
30         $(call suitable-extractor,$(PERL_CROSS_SOURCE)) $(DL_DIR)/$(PERL_CROSS_SOURCE) | \
31         $(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $(@D) $(TAR_OPTIONS) -
32 endef
33 PERL_POST_EXTRACT_HOOKS += PERL_CROSS_EXTRACT
34
35 define PERL_CROSS_SET_POD
36         $(SED) s/$(PERL_CROSS_OLD_POD)/$(PERL_CROSS_NEW_POD)/g $(@D)/Makefile
37 endef
38 PERL_POST_PATCH_HOOKS += PERL_CROSS_SET_POD
39
40 ifeq ($(BR2_PACKAGE_BERKELEYDB),y)
41 PERL_DEPENDENCIES += berkeleydb
42 endif
43 ifeq ($(BR2_PACKAGE_GDBM),y)
44 PERL_DEPENDENCIES += gdbm
45 endif
46
47 # We have to override LD, because an external multilib toolchain ld is not
48 # wrapped to provide the required sysroot options.  We also can't use ccache
49 # because the configure script doesn't support it.
50 PERL_CONF_OPTS = \
51         --target=$(GNU_TARGET_NAME) \
52         --target-tools-prefix=$(TARGET_CROSS) \
53         --prefix=/usr \
54         -Dld="$(TARGET_CC_NOCCACHE)" \
55         -Dccflags="$(TARGET_CFLAGS)" \
56         -Dldflags="$(TARGET_LDFLAGS) -lm" \
57         -Dmydomain="" \
58         -Dmyhostname="$(BR2_TARGET_GENERIC_HOSTNAME)" \
59         -Dmyuname="Buildroot $(BR2_VERSION_FULL)" \
60         -Dosname=linux \
61         -Dosvers=$(LINUX_VERSION) \
62         -Dperladmin=root
63
64 ifeq ($(shell expr $(PERL_VERSION_MAJOR) % 2), 1)
65 PERL_CONF_OPTS += -Dusedevel
66 endif
67
68 ifeq ($(BR2_STATIC_LIBS),y)
69 PERL_CONF_OPTS += --all-static --no-dynaloader
70 endif
71
72 PERL_MODULES = $(call qstrip,$(BR2_PACKAGE_PERL_MODULES))
73 ifneq ($(PERL_MODULES),)
74 PERL_CONF_OPTS += --only-mod=$(subst $(space),$(comma),$(PERL_MODULES))
75 endif
76
77 define PERL_CONFIGURE_CMDS
78         (cd $(@D); HOSTCC='$(HOSTCC_NOCACHE)' ./configure $(PERL_CONF_OPTS))
79         $(SED) 's/UNKNOWN-/Buildroot $(BR2_VERSION_FULL) /' $(@D)/patchlevel.h
80 endef
81
82 define PERL_BUILD_CMDS
83         $(MAKE1) -C $(@D) all
84 endef
85
86 define PERL_INSTALL_STAGING_CMDS
87         $(MAKE1) -C $(@D) DESTDIR="$(STAGING_DIR)" install.perl
88 endef
89
90 define PERL_INSTALL_TARGET_CMDS
91         $(MAKE1) -C $(@D) DESTDIR="$(TARGET_DIR)" install.perl
92 endef
93
94 # We never want to have host-berkeleydb or host-gdbm as dependencies
95 # of host-perl.
96 HOST_PERL_DEPENDENCIES =
97
98 HOST_PERL_CONF_OPTS = \
99         -des \
100         -Dprefix="$(HOST_DIR)/usr" \
101         -Dcc="$(HOSTCC)"
102
103 define HOST_PERL_CONFIGURE_CMDS
104         (cd $(@D); HOSTCC='$(HOSTCC_NOCACHE)' ./Configure $(HOST_PERL_CONF_OPTS))
105 endef
106
107 define HOST_PERL_BUILD_CMDS
108         $(MAKE) -C $(@D)
109 endef
110
111 define HOST_PERL_INSTALL_CMDS
112         $(MAKE) -C $(@D) INSTALL_DEPENDENCE='' install
113 endef
114
115 $(eval $(generic-package))
116 $(eval $(host-generic-package))
117
118 define PERL_FINALIZE_TARGET
119         rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/pod
120         rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/$(PERL_ARCHNAME)/CORE
121         find $(TARGET_DIR)/usr/lib/perl5/ -name 'extralibs.ld' -print0 | xargs -0 rm -f
122         find $(TARGET_DIR)/usr/lib/perl5/ -name '*.bs' -print0 | xargs -0 rm -f
123         find $(TARGET_DIR)/usr/lib/perl5/ -name '.packlist' -print0 | xargs -0 rm -f
124 endef
125
126 TARGET_FINALIZE_HOOKS += PERL_FINALIZE_TARGET
127