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.

160 lines
3.9 KiB

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