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.

189 lines
5.3 KiB

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