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.

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