lang/perl: Refactor Makefile

This is a kind of big commit. Summary:
- Integrate better into OpenWRT's infrastructure
- > Build host-perl using host-build.mk
- > Install host-perl to STAGING_DIR_HOST
- Remove microperl(for now)

Signed-off-by: Marcel Denia <naoir@gmx.net>
This commit is contained in:
Marcel Denia 2014-07-19 03:13:48 +02:00
parent a1e4dd4eba
commit 551609e848

View file

@ -27,15 +27,20 @@ PKG_LICENSE_FILES:=Copying Artistic README
PKG_MAINTAINER:=Marcel Denia <naoir@gmx.net> PKG_MAINTAINER:=Marcel Denia <naoir@gmx.net>
PKG_BUILD_DIR:=$(BUILD_DIR)/perl/$(PKG_NAME)-$(PKG_VERSION) PKG_BUILD_DIR:=$(BUILD_DIR)/perl/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL:=1
PKG_BUILD_DEPENDS:=perl/host
PKG_BUILD_PARALLEL:=1
HOST_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/host-build.mk
ifneq ($(CONFIG_USE_EGLIBC),) ifneq ($(CONFIG_USE_EGLIBC),)
EXTRA_LIBS:=bsd EXTRA_LIBS:=bsd
EXTRA_LIBDIRS:=$(STAGING_DIR)/lib EXTRA_LIBDIRS:=$(STAGING_DIR)/lib
endif endif
define Package/perl/Default define Package/perl
SUBMENU:=Perl SUBMENU:=Perl
SECTION:=lang SECTION:=lang
CATEGORY:=Languages CATEGORY:=Languages
@ -44,75 +49,24 @@ define Package/perl/Default
DEPENDS:=+USE_EGLIBC:libbsd DEPENDS:=+USE_EGLIBC:libbsd
endef endef
define Package/microperl
$(call Package/perl/Default)
TITLE+=(minimal version)
endef
define Package/microperl/description
A perl package without operating-specific functions such as readdir.
endef
define Build/Template
$(STAMP_CONFIGURED)-$(1): $(STAMP_PREPARED)
-$(MAKE) -C $(PKG_BUILD_DIR) clean
$(call Build/$(1)/Configure)
touch $$@
$(STAMP_BUILT)-$(1): $(STAMP_CONFIGURED)-$(1)
$(call Build/$(1)/Compile)
touch $$@
$(STAMP_BUILT): $(STAMP_BUILT)-$(1)
endef
define Build/microperl/Configure
endef
define Build/microperl/Compile
+$(MAKE) $(MAKE_J) -C $(PKG_BUILD_DIR) -f Makefile.micro \
CC="gcc" ugenerate_uudmap
+$(MAKE) $(MAKE_J) -C $(PKG_BUILD_DIR) -f Makefile.micro \
CC="$(TARGET_CC)" OPTIMIZE="$(TARGET_CFLAGS)"
$(INSTALL_DIR) $(PKG_INSTALL_DIR)/usr/bin/
$(CP) $(PKG_BUILD_DIR)/microperl $(PKG_INSTALL_DIR)/usr/bin/
endef
define Package/microperl/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/microperl $(1)/usr/bin/
endef
include perlmod.mk
define Package/perl
$(call Package/perl/Default)
endef
define Package/perl/description define Package/perl/description
Perl is a stable, cross platform programming language. Perl is a stable, cross platform programming language.
It is used for mission critical projects in the public and private sectors It is used for mission critical projects in the public and private sectors
and is widely used to program web applications of all needs. and is widely used to program web applications of all needs.
endef endef
define Build/perl/Configure HOST_PERL_DIR:=$(STAGING_DIR_HOST)/usr
@echo define Host/Configure
@echo "===> Stage 1: Configure host perl" ( cd $(HOST_BUILD_DIR); ./Configure -der -Uusedl -Dprefix=$(HOST_PERL_DIR) )
@echo endef
mkdir -p $(PKG_BUILD_DIR)/host-perl
(cd $(PKG_BUILD_DIR)/host-perl && sh ../Configure -der -Dmksymlinks -Uusedl -Dotherlibdirs=$(PERL_LIB))
@echo define Host/Install
@echo "===> Stage 2: Build host perl binary with static extensions" ( cd $(HOST_BUILD_DIR); ./miniperl installperl )
@echo #--destdir=$(STAGING_DIR_HOST)
+$(MAKE) $(MAKE_J) -C $(PKG_BUILD_DIR)/host-perl miniperl $(CP) $(HOST_BUILD_DIR)/generate_uudmap $(HOST_PERL_DIR)/bin/
endef
@echo define Build/Configure
@echo "===> Stage 3: Configure target perl"
@echo
-$(MAKE) -C $(PKG_BUILD_DIR) clean
sed \ sed \
-e 's!%%CC%%!$(TARGET_CC)!g' \ -e 's!%%CC%%!$(TARGET_CC)!g' \
-e 's!%%CFLAGS%%!$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)!g' \ -e 's!%%CFLAGS%%!$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)!g' \
@ -125,37 +79,16 @@ define Build/perl/Configure
-e 's!%%EXTRA_PERLLIBS%%!$(EXTRA_LIBS:%=-l%)!g' \ -e 's!%%EXTRA_PERLLIBS%%!$(EXTRA_LIBS:%=-l%)!g' \
-e 's!%%EXTRA_PERLLIBDIRS%%!$(EXTRA_LIBDIRS:%=-L%)!g' \ -e 's!%%EXTRA_PERLLIBDIRS%%!$(EXTRA_LIBDIRS:%=-L%)!g' \
-e 's!%%IPV6%%!$(if $($(CONFIG_IPV6)),define,undef)!g' \ -e 's!%%IPV6%%!$(if $($(CONFIG_IPV6)),define,undef)!g' \
-e 's!%%HOSTMINIPERL%%!$(PKG_BUILD_DIR)/host-perl/miniperl!g' \ -e 's!%%HOSTMINIPERL%%!$(HOST_PERL_DIR)/bin/perl!g' \
-e 's!%%HOSTGENERATE%%!$(PKG_BUILD_DIR)/host-perl/generate_uudmap!g' \ -e 's!%%HOSTGENERATE%%!$(HOST_PERL_DIR)/bin/generate_uudmap!g' \
files/config.sh-$(patsubst i386,i486,$(ARCH)).in \ files/config.sh-$(patsubst i386,i486,$(ARCH)).in \
> $(PKG_BUILD_DIR)/config.sh > $(PKG_BUILD_DIR)/config.sh
(cd $(PKG_BUILD_DIR) && ./Configure -S) (cd $(PKG_BUILD_DIR) && ./Configure -S)
install -m 0644 $(PKG_BUILD_DIR)/config.h $(PKG_BUILD_DIR)/xconfig.h
endef endef
define Build/perl/Compile define Build/Compile
@echo +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)
@echo "===> Stage 4: Build target perl binary"
@echo
install -m 0644 $(PKG_BUILD_DIR)/config.h $(PKG_BUILD_DIR)/xconfig.h
+$(MAKE) $(MAKE_J) -C $(PKG_BUILD_DIR) perl
mkdir -p $(PKG_BUILD_DIR)/target-bin
install -m 0755 $(PKG_BUILD_DIR)/perl $(PKG_BUILD_DIR)/target-bin/
@echo
@echo "===> Stage 5: Build target extensions and utils"
@echo
+$(MAKE) $(MAKE_J) -C $(PKG_BUILD_DIR)
@echo
@echo "===> Stage 6: Install Perl into staging dir"
@echo
(cd $(PKG_BUILD_DIR) && ./miniperl installperl --destdir=$(STAGING_DIR))
@echo
@echo "===> Stage 7: Install Perl into a temporary root"
@echo
mkdir -p $(PKG_INSTALL_DIR)
(cd $(PKG_BUILD_DIR) && ./miniperl installperl --destdir=$(PKG_INSTALL_DIR))
endef endef
define Package/perl/install define Package/perl/install
@ -164,31 +97,12 @@ define Package/perl/install
ln -nsf perl$(PKG_VERSION) $(1)/usr/bin/perl ln -nsf perl$(PKG_VERSION) $(1)/usr/bin/perl
endef endef
ifneq ($(CONFIG_PACKAGE_microperl),)
define Build/microperl
$(call Build/Template,microperl)
endef
endif
$(eval $(Build/microperl))
ifneq ($(CONFIG_PACKAGE_perl),)
define Build/perl
$(call Build/Template,perl)
endef
endif
$(eval $(Build/perl))
define Build/Configure
endef
define Build/Compile
endef
$(eval $(call RequireCommand,rsync, \ $(eval $(call RequireCommand,rsync, \
$(PKG_NAME) requires rsync installed on the host-system. \ $(PKG_NAME) requires rsync installed on the host-system. \
)) ))
$(eval $(call BuildPackage,microperl))
$(eval $(call BuildPackage,perl)) $(eval $(call BuildPackage,perl))
$(eval $(call HostBuild))
include perlmod.mk
-include perlbase.mk -include perlbase.mk