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.

173 lines
4.4 KiB

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