You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
3.8 KiB

  1. # This makefile simplifies perl module builds.
  2. #
  3. # Build environment
  4. HOST_PERL_PREFIX:=$(STAGING_DIR_HOST)/usr
  5. ifneq ($(CONFIG_USE_EGLIBC),)
  6. EXTRA_LIBS:=bsd
  7. EXTRA_LIBDIRS:=$(STAGING_DIR)/lib
  8. endif
  9. PERL_CMD:=$(STAGING_DIR_HOST)/usr/bin/perl5.20.0
  10. # Module install prefix
  11. PERL_SITELIB:=/usr/lib/perl5/5.20
  12. PERL_TESTSDIR:=/usr/share/perl/perl-tests
  13. PERLBASE_TESTSDIR:=/usr/share/perl/perlbase-tests
  14. PERLMOD_TESTSDIR:=/usr/share/perl/perlmod-tests
  15. define perlmod/host/relink
  16. rm -f $(1)/Makefile.aperl
  17. $(MAKE) -C $(1) perl
  18. $(CP) $(1)/perl $(PERL_CMD)
  19. $(CP) $(1)/perl $(STAGING_DIR_HOST)/usr/bin/perl
  20. endef
  21. define perlmod/host/Configure
  22. (cd $(HOST_BUILD_DIR); \
  23. PERL_MM_USE_DEFAULT=1 \
  24. $(2) \
  25. $(PERL_CMD) Makefile.PL \
  26. $(1) \
  27. );
  28. endef
  29. define perlmod/host/Compile
  30. $(2) \
  31. $(MAKE) -C $(HOST_BUILD_DIR) \
  32. $(1) \
  33. install
  34. endef
  35. define perlmod/host/Install
  36. $(2) \
  37. $(MAKE) -C $(HOST_BUILD_DIR) \
  38. $(1) \
  39. install
  40. $(call perlmod/host/relink,$(HOST_BUILD_DIR))
  41. endef
  42. define perlmod/Configure
  43. (cd $(PKG_BUILD_DIR); \
  44. PERL_MM_USE_DEFAULT=1 \
  45. $(2) \
  46. $(PERL_CMD) Makefile.PL \
  47. $(1) \
  48. AR=ar \
  49. CC=$(GNU_TARGET_NAME)-gcc \
  50. CCFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
  51. CCCDLFLAGS=-fPIC \
  52. CCDLFLAGS=-Wl,-E \
  53. DLEXT=so \
  54. DLSRC=dl_dlopen.xs \
  55. EXE_EXT=" " \
  56. FULL_AR=$(GNU_TARGET_NAME)-ar \
  57. LD=$(GNU_TARGET_NAME)-gcc \
  58. LDDLFLAGS="-shared $(TARGET_LDFLAGS)" \
  59. LDFLAGS="$(EXTRA_LIBDIRS:%=-L%) $(EXTRA_LIBS:%=-l%) " \
  60. LIBC=" " \
  61. LIB_EXT=.a \
  62. OBJ_EXT=.o \
  63. OSNAME=linux \
  64. OSVERS=2.4.30 \
  65. RANLIB=: \
  66. SITELIBEXP=" " \
  67. SITEARCHEXP=" " \
  68. SO=so \
  69. VENDORARCHEXP=" " \
  70. VENDORLIBEXP=" " \
  71. SITEPREFIX=/usr \
  72. INSTALLPRIVLIB=$(PERL_SITELIB) \
  73. INSTALLSITELIB=$(PERL_SITELIB) \
  74. INSTALLVENDORLIB=" " \
  75. INSTALLARCHLIB=$(PERL_SITELIB) \
  76. INSTALLSITEARCH=$(PERL_SITELIB) \
  77. INSTALLVENDORARCH=" " \
  78. INSTALLBIN=/usr/bin \
  79. INSTALLSITEBIN=/usr/bin \
  80. INSTALLVENDORBIN=" " \
  81. INSTALLSCRIPT=/usr/bin \
  82. INSTALLSITESCRIPT=/usr/bin \
  83. INSTALLVENDORSCRIPT=" " \
  84. INSTALLMAN1DIR=/usr/man/man1 \
  85. INSTALLSITEMAN1DIR=/usr/man/man1 \
  86. INSTALLVENDORMAN1DIR=" " \
  87. INSTALLMAN3DIR=/usr/man/man3 \
  88. INSTALLSITEMAN3DIR=/usr/man/man3 \
  89. INSTALLVENDORMAN3DIR=" " \
  90. LINKTYPE=dynamic \
  91. DESTDIR=$(PKG_INSTALL_DIR) \
  92. );
  93. sed 's!^PERL_INC = .*!PERL_INC = $(STAGING_DIR)/usr/lib/perl5/5.20/CORE/!' -i $(PKG_BUILD_DIR)/Makefile
  94. endef
  95. define perlmod/Compile
  96. PERL5LIB=$(PERL_LIB) \
  97. $(2) \
  98. $(MAKE) -C $(PKG_BUILD_DIR) \
  99. $(1) \
  100. install
  101. endef
  102. define perlmod/Install/NoStrip
  103. $(INSTALL_DIR) $(strip $(1))$(PERL_SITELIB)
  104. (cd $(PKG_INSTALL_DIR)$(PERL_SITELIB) && \
  105. rsync --relative -rlHp --itemize-changes \
  106. --exclude=\*.pod \
  107. --exclude=.packlist \
  108. $(addprefix --exclude=/,$(strip $(3))) \
  109. --prune-empty-dirs \
  110. $(strip $(2)) $(strip $(1))$(PERL_SITELIB))
  111. chmod -R u+w $(strip $(1))$(PERL_SITELIB)
  112. endef
  113. define perlmod/Install
  114. $(call perlmod/Install/NoStrip,$(1),$(2),$(3))
  115. @echo "---> Stripping modules in: $(strip $(1))$(PERL_SITELIB)"
  116. find $(strip $(1))$(PERL_SITELIB) -name \*.pm -or -name \*.pl | \
  117. xargs -r sed -i \
  118. -e '/^=\(head\|pod\|item\|over\|back\|encoding\|begin\|end\|for\)/,/^=cut/d' \
  119. -e '/^=\(head\|pod\|item\|over\|back\|encoding\|begin\|end\|for\)/,$$$$d' \
  120. -e '/^#$$$$/d' \
  121. -e '/^#[^!"'"'"']/d'
  122. endef
  123. # You probably don't want to use this directly. Look at perlmod/InstallTests
  124. define perlmod/_InstallTests
  125. $(INSTALL_DIR) $(strip $(1))
  126. (cd $(PKG_BUILD_DIR)/$(2) && \
  127. rsync --relative -rlHp --itemize-changes \
  128. --exclude=.packlist \
  129. --prune-empty-dirs \
  130. $(strip $(3)) $(strip $(1)))
  131. chmod -R u+w $(strip $(1))
  132. endef
  133. define perlmod/InstallBaseTests
  134. $(if $(CONFIG_PERL_TESTS),$(call perlmod/_InstallTests,$(1)$(PERL_TESTSDIR),,$(2)))
  135. endef
  136. define perlmod/InstallTests
  137. $(if $(CONFIG_PERL_TESTS),$(call perlmod/_InstallTests,$(1)$(PERL_TESTSDIR),$(2),$(3)))
  138. endef