2
1

perl.mk 4.0 KB

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