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.

166 lines
4.5 KiB

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