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.

162 lines
4.1 KiB

  1. # This makefile simplifies perl module builds.
  2. #
  3. PERL_VERSION:=5.22
  4. # Build environment
  5. HOST_PERL_PREFIX:=$(STAGING_DIR)/host/usr
  6. ifneq ($(CONFIG_USE_GLIBC),)
  7. EXTRA_LIBS:=bsd
  8. EXTRA_LIBDIRS:=$(STAGING_DIR)/lib
  9. endif
  10. PERL_CMD:=$(STAGING_DIR)/host/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)/host/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"; do "Makefile.PL"' \
  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/Install
  119. $(call perlmod/Install/NoStrip,$(1),$(2),$(3))
  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. # You probably don't want to use this directly. Look at perlmod/InstallTests
  129. define perlmod/_InstallTests
  130. $(INSTALL_DIR) $(strip $(1))
  131. (cd $(PKG_BUILD_DIR)/$(2) && \
  132. rsync --relative -rlHp --itemize-changes \
  133. --exclude=.packlist \
  134. --prune-empty-dirs \
  135. $(strip $(3)) $(strip $(1)))
  136. chmod -R u+w $(strip $(1))
  137. endef
  138. define perlmod/InstallBaseTests
  139. $(if $(CONFIG_PERL_TESTS),$(call perlmod/_InstallTests,$(1)$(PERL_TESTSDIR),,$(2)))
  140. endef
  141. define perlmod/InstallTests
  142. $(if $(CONFIG_PERL_TESTS),$(call perlmod/_InstallTests,$(1)$(PERL_TESTSDIR),$(2),$(3)))
  143. endef