perl.mk 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. ################################################################################
  2. #
  3. # perl
  4. #
  5. ################################################################################
  6. # When updating the version here, also update utils/scancpan
  7. PERL_VERSION_MAJOR = 26
  8. PERL_VERSION = 5.$(PERL_VERSION_MAJOR).1
  9. PERL_SITE = http://www.cpan.org/src/5.0
  10. PERL_SOURCE = perl-$(PERL_VERSION).tar.xz
  11. PERL_LICENSE = Artistic or GPL-1.0+
  12. PERL_LICENSE_FILES = Artistic Copying README
  13. PERL_INSTALL_STAGING = YES
  14. PERL_CROSS_VERSION = 1.1.7
  15. # DO NOT refactor with the github helper (the result is not the same)
  16. PERL_CROSS_SITE = https://github.com/arsv/perl-cross/releases/download/$(PERL_CROSS_VERSION)
  17. PERL_CROSS_SOURCE = perl-cross-$(PERL_CROSS_VERSION).tar.gz
  18. PERL_EXTRA_DOWNLOADS = $(PERL_CROSS_SITE)/$(PERL_CROSS_SOURCE)
  19. # We use the perlcross hack to cross-compile perl. It should
  20. # be extracted over the perl sources, so we don't define that
  21. # as a separate package. Instead, it is downloaded and extracted
  22. # together with perl
  23. define PERL_CROSS_EXTRACT
  24. $(call suitable-extractor,$(PERL_CROSS_SOURCE)) $(DL_DIR)/$(PERL_CROSS_SOURCE) | \
  25. $(TAR) --strip-components=1 -C $(@D) $(TAR_OPTIONS) -
  26. endef
  27. PERL_POST_EXTRACT_HOOKS += PERL_CROSS_EXTRACT
  28. # Even though perl is not an autotools-package, it uses config.sub and
  29. # config.guess. Up-to-date versions of these files may be needed to build perl
  30. # on newer host architectures, so we borrow the hook which updates them from the
  31. # autotools infrastructure.
  32. PERL_POST_PATCH_HOOKS += UPDATE_CONFIG_HOOK
  33. ifeq ($(BR2_PACKAGE_BERKELEYDB),y)
  34. PERL_DEPENDENCIES += berkeleydb
  35. endif
  36. ifeq ($(BR2_PACKAGE_GDBM),y)
  37. PERL_DEPENDENCIES += gdbm
  38. endif
  39. # We have to override LD, because an external multilib toolchain ld is not
  40. # wrapped to provide the required sysroot options.
  41. PERL_CONF_OPTS = \
  42. --target=$(GNU_TARGET_NAME) \
  43. --target-tools-prefix=$(TARGET_CROSS) \
  44. --prefix=/usr \
  45. -Dld="$(TARGET_CC)" \
  46. -Dccflags="$(TARGET_CFLAGS)" \
  47. -Dldflags="$(TARGET_LDFLAGS) -lm" \
  48. -Dmydomain="" \
  49. -Dmyhostname="noname" \
  50. -Dmyuname="Buildroot $(BR2_VERSION_FULL)" \
  51. -Dosname=linux \
  52. -Dosvers=$(LINUX_VERSION) \
  53. -Dperladmin=root
  54. ifeq ($(shell expr $(PERL_VERSION_MAJOR) % 2), 1)
  55. PERL_CONF_OPTS += -Dusedevel
  56. endif
  57. ifeq ($(BR2_STATIC_LIBS),y)
  58. PERL_CONF_OPTS += --all-static --no-dynaloader
  59. endif
  60. PERL_MODULES = $(call qstrip,$(BR2_PACKAGE_PERL_MODULES))
  61. ifneq ($(PERL_MODULES),)
  62. PERL_CONF_OPTS += --only-mod=$(subst $(space),$(comma),$(PERL_MODULES))
  63. endif
  64. define PERL_CONFIGURE_CMDS
  65. (cd $(@D); $(TARGET_MAKE_ENV) HOSTCC='$(HOSTCC_NOCCACHE)' \
  66. ./configure $(PERL_CONF_OPTS))
  67. $(SED) 's/UNKNOWN-/Buildroot $(BR2_VERSION_FULL) /' $(@D)/patchlevel.h
  68. endef
  69. define PERL_BUILD_CMDS
  70. $(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) all
  71. endef
  72. define PERL_INSTALL_STAGING_CMDS
  73. $(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) DESTDIR="$(STAGING_DIR)" install.perl install.sym
  74. endef
  75. define PERL_INSTALL_TARGET_CMDS
  76. $(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) DESTDIR="$(TARGET_DIR)" install.perl install.sym
  77. endef
  78. HOST_PERL_CONF_OPTS = \
  79. -des \
  80. -Dprefix="$(HOST_DIR)" \
  81. -Dcc="$(HOSTCC)"
  82. define HOST_PERL_CONFIGURE_CMDS
  83. (cd $(@D); $(HOST_MAKE_ENV) HOSTCC='$(HOSTCC_NOCCACHE)' \
  84. ./Configure $(HOST_PERL_CONF_OPTS))
  85. endef
  86. define HOST_PERL_BUILD_CMDS
  87. $(HOST_MAKE_ENV) $(MAKE) -C $(@D)
  88. endef
  89. define HOST_PERL_INSTALL_CMDS
  90. $(HOST_MAKE_ENV) $(MAKE) -C $(@D) INSTALL_DEPENDENCE='' install
  91. endef
  92. $(eval $(generic-package))
  93. $(eval $(host-generic-package))
  94. define PERL_FINALIZE_TARGET
  95. rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/pod
  96. rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/$(PERL_ARCHNAME)/CORE
  97. find $(TARGET_DIR)/usr/lib/perl5/ -name 'extralibs.ld' -print0 | xargs -0 rm -f
  98. find $(TARGET_DIR)/usr/lib/perl5/ -name '*.bs' -print0 | xargs -0 rm -f
  99. find $(TARGET_DIR)/usr/lib/perl5/ -name '.packlist' -print0 | xargs -0 rm -f
  100. endef
  101. PERL_TARGET_FINALIZE_HOOKS += PERL_FINALIZE_TARGET