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.

177 lines
4.5 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. define perlmod/host/relink
  28. rm -f $(1)/Makefile.aperl
  29. $(MAKE) -C $(1) perl
  30. $(CP) $(1)/perl $(PERL_CMD)
  31. $(CP) $(1)/perl $(STAGING_DIR_HOSTPKG)/usr/bin/perl
  32. endef
  33. define perlmod/host/Configure
  34. (cd $(HOST_BUILD_DIR); \
  35. PERL_MM_USE_DEFAULT=1 \
  36. $(2) \
  37. $(PERL_CMD) Makefile.PL \
  38. $(1) \
  39. );
  40. endef
  41. define perlmod/host/Compile
  42. $(2) \
  43. $(MAKE) -C $(HOST_BUILD_DIR) \
  44. $(1) \
  45. install
  46. endef
  47. define perlmod/host/Install
  48. $(2) \
  49. $(MAKE) -C $(HOST_BUILD_DIR) \
  50. $(1) \
  51. install
  52. $(call perlmod/host/relink,$(HOST_BUILD_DIR))
  53. endef
  54. define perlmod/Configure
  55. (cd $(if $(3),$(3),$(PKG_BUILD_DIR)); \
  56. (echo -e 'use Config;\n\n$$$${tied %Config::Config}{cpprun}="$(GNU_TARGET_NAME)-cpp -E";\n' ; cat Makefile.PL) | \
  57. PERL_MM_USE_DEFAULT=1 \
  58. $(2) \
  59. $(PERL_CMD) -I. -- - \
  60. $(1) \
  61. AR=ar \
  62. CC=$(GNU_TARGET_NAME)-gcc \
  63. CCFLAGS="$(MOD_CFLAGS_PERL)" \
  64. CCCDLFLAGS=-fPIC \
  65. CCDLFLAGS=-Wl,-E \
  66. DLEXT=so \
  67. DLSRC=dl_dlopen.xs \
  68. EXE_EXT=" " \
  69. FULL_AR=$(GNU_TARGET_NAME)-ar \
  70. LD=$(GNU_TARGET_NAME)-gcc \
  71. LDDLFLAGS="-shared -rdynamic $(TARGET_LDFLAGS)" \
  72. LDFLAGS="$(EXTRA_LIBDIRS:%=-L%) $(EXTRA_LIBS:%=-l%) " \
  73. LIBC=" " \
  74. LIB_EXT=.a \
  75. OBJ_EXT=.o \
  76. OSNAME=linux \
  77. OSVERS=2.4.30 \
  78. RANLIB=: \
  79. SITELIBEXP=" " \
  80. SITEARCHEXP=" " \
  81. SO=so \
  82. VENDORARCHEXP=" " \
  83. VENDORLIBEXP=" " \
  84. SITEPREFIX=/usr \
  85. INSTALLPRIVLIB=$(PERL_SITELIB) \
  86. INSTALLSITELIB=$(PERL_SITELIB) \
  87. INSTALLVENDORLIB=" " \
  88. INSTALLARCHLIB=$(PERL_SITELIB) \
  89. INSTALLSITEARCH=$(PERL_SITELIB) \
  90. INSTALLVENDORARCH=" " \
  91. INSTALLBIN=/usr/bin \
  92. INSTALLSITEBIN=/usr/bin \
  93. INSTALLVENDORBIN=" " \
  94. INSTALLSCRIPT=/usr/bin \
  95. INSTALLSITESCRIPT=/usr/bin \
  96. INSTALLVENDORSCRIPT=" " \
  97. INSTALLMAN1DIR=/usr/man/man1 \
  98. INSTALLSITEMAN1DIR=/usr/man/man1 \
  99. INSTALLVENDORMAN1DIR=" " \
  100. INSTALLMAN3DIR=/usr/man/man3 \
  101. INSTALLSITEMAN3DIR=/usr/man/man3 \
  102. INSTALLVENDORMAN3DIR=" " \
  103. LINKTYPE=dynamic \
  104. DESTDIR=$(PKG_INSTALL_DIR) \
  105. )
  106. sed -i -e 's!^PERL_INC = .*!PERL_INC = $(STAGING_DIR)/usr/lib/perl5/$(PERL_VERSION)/CORE/!' $(if $(3),$(3),$(PKG_BUILD_DIR))/Makefile
  107. endef
  108. define perlmod/Compile
  109. PERL5LIB=$(PERL_LIB) \
  110. $(2) \
  111. $(MAKE) -C $(if $(3),$(3),$(PKG_BUILD_DIR)) \
  112. $(1) \
  113. install
  114. endef
  115. define perlmod/Install/NoStrip
  116. $(INSTALL_DIR) $(strip $(1))$(PERL_SITELIB)
  117. (cd $(PKG_INSTALL_DIR)$(PERL_SITELIB) && \
  118. rsync --relative -rlHp --itemize-changes \
  119. --exclude=\*.pod \
  120. --exclude=.packlist \
  121. $(addprefix --exclude=/,$(strip $(3))) \
  122. --prune-empty-dirs \
  123. $(strip $(2)) $(strip $(1))$(PERL_SITELIB))
  124. chmod -R u+w $(strip $(1))$(PERL_SITELIB)
  125. endef
  126. define perlmod/_DoStrip
  127. @echo "---> Stripping modules in: $(strip $(1))$(PERL_SITELIB)"
  128. find $(strip $(1))$(PERL_SITELIB) -name \*.pm -or -name \*.pl | \
  129. xargs -r sed -i \
  130. -e '/^=\(head\|pod\|item\|over\|back\|encoding\|begin\|end\|for\)/,/^=cut/d' \
  131. -e '/^=\(head\|pod\|item\|over\|back\|encoding\|begin\|end\|for\)/,$$$$d' \
  132. -e '/^#$$$$/d' \
  133. -e '/^#[^!"'"'"']/d'
  134. endef
  135. define perlmod/Install
  136. $(call perlmod/Install/NoStrip,$(1),$(2),$(3))
  137. $(if $(CONFIG_PERL_NOCOMMENT),$(if $(PKG_LEAVE_COMMENTS),,$(call perlmod/_DoStrip,$(1),$(2),$(3))))
  138. endef
  139. # You probably don't want to use this directly. Look at perlmod/InstallTests
  140. define perlmod/_InstallTests
  141. $(INSTALL_DIR) $(strip $(1))
  142. (cd $(PKG_BUILD_DIR)/$(2) && \
  143. rsync --relative -rlHp --itemize-changes \
  144. --exclude=.packlist \
  145. --prune-empty-dirs \
  146. $(strip $(3)) $(strip $(1)))
  147. chmod -R u+w $(strip $(1))
  148. endef
  149. define perlmod/InstallBaseTests
  150. $(if $(CONFIG_PERL_TESTS),$(call perlmod/_InstallTests,$(1)$(PERL_TESTSDIR),,$(2)))
  151. endef
  152. define perlmod/InstallTests
  153. $(if $(CONFIG_PERL_TESTS),$(call perlmod/_InstallTests,$(1)$(PERL_TESTSDIR),$(2),$(3)))
  154. endef