diff mbox

[01/13] perl: new package v6

Message ID 1347107325-4163-1-git-send-email-francois.perrad@gadz.org
State Superseded
Headers show

Commit Message

Francois Perrad Sept. 8, 2012, 12:28 p.m. UTC
---
 package/Config.in                      |    1 +
 package/perl/Config.in                 |   17 +++++
 package/perl/perl-configure-qemu.patch |   32 +++++++++
 package/perl/perl-make-ext.patch       |   24 +++++++
 package/perl/perl-mkppport.patch       |   37 ++++++++++
 package/perl/perl.mk                   |  121 ++++++++++++++++++++++++++++++++
 6 files changed, 232 insertions(+)
 create mode 100644 package/perl/Config.in
 create mode 100644 package/perl/perl-configure-qemu.patch
 create mode 100644 package/perl/perl-make-ext.patch
 create mode 100644 package/perl/perl-mkppport.patch
 create mode 100644 package/perl/perl.mk

Comments

Thomas Petazzoni Sept. 20, 2012, 7:56 p.m. UTC | #1
Dear Francois Perrad,

Thanks for your continued work on this. Some comments below.

First, do not put the patch version in the patch title. If you want to
have a version, it should be between the [] at the beginning of the
title. Here is how you can do that with git:

git format-patch --subject-prefix="PATCH v7" <yourbasebranch>

On Sat,  8 Sep 2012 14:28:33 +0200, Francois Perrad wrote:
> ---
>  package/Config.in                      |    1 +
>  package/perl/Config.in                 |   17 +++++
>  package/perl/perl-configure-qemu.patch |   32 +++++++++
>  package/perl/perl-make-ext.patch       |   24 +++++++
>  package/perl/perl-mkppport.patch       |   37 ++++++++++
>  package/perl/perl.mk                   |  121 ++++++++++++++++++++++++++++++++
>  6 files changed, 232 insertions(+)
>  create mode 100644 package/perl/Config.in
>  create mode 100644 package/perl/perl-configure-qemu.patch
>  create mode 100644 package/perl/perl-make-ext.patch
>  create mode 100644 package/perl/perl-mkppport.patch
>  create mode 100644 package/perl/perl.mk
> 
> diff --git a/package/Config.in b/package/Config.in
> index f308de7..00a79ab 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -262,6 +262,7 @@ source "package/wsapi/Config.in"
>  source "package/xavante/Config.in"
>  endmenu
>  endif
> +source "package/perl/Config.in"
>  source "package/microperl/Config.in"
>  source "package/php/Config.in"
>  source "package/python/Config.in"
> diff --git a/package/perl/Config.in b/package/perl/Config.in
> new file mode 100644
> index 0000000..286b09e
> --- /dev/null
> +++ b/package/perl/Config.in
> @@ -0,0 +1,17 @@
> +config BR2_PACKAGE_PERL
> +	bool "perl"
> +	help
> +	  Larry Wall's Practical Extraction and Report Language
> +	  An interpreted scripting language, known among some as "Unix's Swiss
> +	  Army Chainsaw".
> +
> +	  http://www.perl.org/
> +
> +if BR2_PACKAGE_PERL
> +
> +config BR2_PACKAGE_PERL_CUSTOM_CONFIGURE
> +	string "configuration flags"
> +	help
> +	  Allows to add some flags to Configure.

We don't typically offer such choice for packages. Is there a good
reason for doing so in the case of Perl, rather than providing a few
additional kconfig configuration options if needed?

> +endif
> diff --git a/package/perl/perl-configure-qemu.patch b/package/perl/perl-configure-qemu.patch
> new file mode 100644
> index 0000000..00f7539
> --- /dev/null
> +++ b/package/perl/perl-configure-qemu.patch
> @@ -0,0 +1,32 @@
> +Add qemu support
> +

Please explain in more details what this means, and whether this patch
has a chance of being upstream or not.

Also, it seems to imply that the build process of Perl would require
Qemu. Or, Qemu is not amongst the requirements of Buildroot, and there
is no host-qemu package in the dependencies of your package (and we
don't have a host-qemu package). Yann E. Morin has posted a target
package for qemu a while ago, but it hasn't been merged so far.

That said, even so it is certainly possible to create a host-qemu
package, I am a bit annoyed to see the build process of a package
requiring qemu. Is there really no other way? I guess it uses qemu to
run a bunch of tests on the target system. Is there no way to provide
pre-defined values for those tests, on a per-architecture basis, rather
than running those test applications in Qemu?

> diff --git a/package/perl/perl-make-ext.patch b/package/perl/perl-make-ext.patch
> new file mode 100644
> index 0000000..e0195e7
> --- /dev/null
> +++ b/package/perl/perl-make-ext.patch
> @@ -0,0 +1,24 @@
> +Don't use RUN with make (only for perl)
> +
> +Signed-off-by: Francois Perrad <francois.perrad@gadz.org>

Sorry, but the patch description is insufficient to understand what is
going on here.

> +
> +Index: b/make_ext.pl
> +===================================================================
> +--- a/make_ext.pl
> ++++ b/make_ext.pl
> +@@ -458,11 +458,13 @@
> + 	# Give makefile an opportunity to rewrite itself.
> + 	# reassure users that life goes on...
> + 	my @args = ('config', @$pass_through);
> +-	system(@run, @make, @args) and print "@run @make @args failed, continuing anyway...\n";
> ++#	system(@run, @make, @args) and print "@run @make @args failed, continuing anyway...\n";
> ++	system(@make, @args) and print "@make @args failed, continuing anyway...\n";
> +     }
> +     my @targ = ($target, @$pass_through);
> +     print "Making $target in $ext_dir\n@run @make @targ\n";
> +-    my $code = system(@run, @make, @targ);
> ++#    my $code = system(@run, @make, @targ);
> ++    my $code = system(@make, @targ);
> +     die "Unsuccessful make($ext_dir): code=$code" if $code != 0;
> + 
> +     chdir $return_dir || die "Cannot cd to $return_dir: $!";
> diff --git a/package/perl/perl-mkppport.patch b/package/perl/perl-mkppport.patch
> new file mode 100644
> index 0000000..97f27a2
> --- /dev/null
> +++ b/package/perl/perl-mkppport.patch
> @@ -0,0 +1,37 @@
> +Add RUN
> +
> +Signed-off-by: Francois Perrad <francois.perrad@gadz.org>

Ditto.

> diff --git a/package/perl/perl.mk b/package/perl/perl.mk
> new file mode 100644
> index 0000000..2a8da79
> --- /dev/null
> +++ b/package/perl/perl.mk
> @@ -0,0 +1,121 @@
> +#############################################################
> +#
> +# perl
> +#
> +#############################################################
> +
> +PERL_VERSION_MAJOR = 16
> +PERL_VERSION = 5.$(PERL_VERSION_MAJOR).1
> +PERL_SITE = http://www.cpan.org/src/5.0
> +PERL_SOURCE = perl-$(PERL_VERSION).tar.bz2
> +PERL_LICENSE = Artistic
> +PERL_LICENSE_FILES = Artistic
> +PERL_INSTALL_STAGING = YES
> +
> +ifeq ($(shell expr $(PERL_VERSION_MAJOR) % 2), 1)
> +    PERL_USE_DEVEL=-Dusedevel
> +endif
> +
> +ifneq ($(BR2_LARGEFILE),y)
> +    PERL_NO_LARGEFILE=-Uuselargefiles
> +endif
> +
> +PERL_ARCH=$(call qstrip,$(BR2_ARCH))

You can use ARCH directly, it is already qstripped.

> +ifeq ($(PERL_ARCH),i686)
> +    PERL_ARCH=i386
> +endif
> +PERL_QEMU_USER_MODE=qemu-$(PERL_ARCH)
> +
> +define PERL_CONFIGURE_CMDS
> +	rm -f $(@D)/config.sh
> +	cd $(@D); ./Configure -des \

We generally like to put such commands into parenthesis, i.e:

	(cd $(@D); .... \
		.....   \
		.....)

> +		-Dusecrosscompile \
> +		-Dtargetrun=$(PERL_QEMU_USER_MODE) \
> +		-Dqemulib=$(STAGING_DIR) \
> +		-Dtargethost=dummy \
> +		-Dar="$(TARGET_AR)" \
> +		-Dcc="$(TARGET_CC)" \
> +		-Dcpp="$(TARGET_CC)" \
> +		-Dld="$(TARGET_LD)" \
> +		-Dnm="$(TARGET_NM)" \
> +		-Dranlib="$(TARGET_RANLIB)" \
> +		-Dccflags="$(TARGET_CFLAGS)" \
> +		-Dldflags="$(TARGET_LDFLAGS) -l gcc_s" \
> +		-Dlddlflags="-shared" \
> +		-Dlibc=$(TARGET_HOST)/usr/$(GNU_TARGET_NAME)/sysroot/lib/libc.so \
> +		-Duseshrplib \
> +		-Dprefix=/usr \
> +		-Uoptimize \
> +		$(PERL_USE_DEVEL) \
> +		$(PERL_NO_LARGEFILE) \
> +		$(call qstrip,$(BR2_PACKAGE_PERL_CUSTOM_CONFIGURE))
> +	echo "# patched values"                 >>$(@D)/config.sh
> +	$(SED) '/^myarchname=/d' \
> +		-e '/^mydomain=/d' \
> +		-e '/^myhostname=/d' \
> +		-e '/^myuname=/d' \
> +		-e '/^osname=/d' \
> +		-e '/^osvers=/d' \
> +		-e '/^perladmin=/d' \
> +		$(@D)/config.sh
> +	echo "myarchname='$(GNU_TARGET_NAME)'"                  >>$(@D)/config.sh
> +	echo "mydomain=''"                                      >>$(@D)/config.sh
> +	echo "myhostname='$(BR2_TARGET_GENERIC_HOSTNAME)'"      >>$(@D)/config.sh
> +	echo "myuname='Buildroot $(BR2_VERSION_FULL)'"          >>$(@D)/config.sh
> +	echo "osname='linux'"                                   >>$(@D)/config.sh
> +	echo "osvers='$(BR2_LINUX_KERNEL_VERSION)'"             >>$(@D)/config.sh
> +	echo "perladmin='root'"                                 >>$(@D)/config.sh
> +	cd $(@D); ./Configure -S
> +	cp $(@D)/config.h $(@D)/xconfig.h
> +	$(SED) 's/UNKNOWN-/Buildroot $(BR2_VERSION_FULL) /' $(@D)/patchlevel.h
> +endef
> +
> +define PERL_BUILD_CMDS
> +	echo "#!/bin/sh"                                                        > $(@D)/Cross/miniperl
> +	echo "$(PERL_QEMU_USER_MODE) -L $(STAGING_DIR) $(@D)/miniperl \"\$$@\"" >>$(@D)/Cross/miniperl
> +	chmod +x $(@D)/Cross/miniperl
> +	PERL_MM_OPT="PERL=$(@D)/Cross/miniperl" \
> +	$(MAKE) -C $(@D) all
> +endef
> +
> +define PERL_INSTALL_STAGING_CMDS
> +	$(MAKE) INSTALL_DEPENDENCE= \

Is it really INSTALL_DEPENDENCE ?

> +		INSTALLFLAGS= \
> +		DESTDIR="$(STAGING_DIR)" \
> +		-C $(@D) install.perl
> +	$(INSTALL) -m 755 $(@D)/libperl.so $(STAGING_DIR)/usr/lib/libperl.so

Maybe just a comment above on why the manual installation of this .so
file is needed.

> +endef
> +
> +define PERL_INSTALL_TARGET_CMDS
> +	$(MAKE) INSTALL_DEPENDENCE= \
> +		INSTALLFLAGS=-p \
> +		DESTDIR="$(TARGET_DIR)" \
> +		-C $(@D) install.perl
> +endef
> +
> +define PERL_CLEAN_CMDS
> +	-$(MAKE) -C $(@D) clean
> +endef
> +
> +define HOST_PERL_CONFIGURE_CMDS
> +	cd $(@D); ./Configure -des \
> +		-Dcc="$(HOSTCC)" \
> +		-Dprefix="$(HOST_DIR)/usr" \
> +		$(PERL_USE_DEVEL)
> +endef
> +
> +define HOST_PERL_BUILD_CMDS
> +	$(MAKE) -C $(@D) all
> +endef
> +
> +define HOST_PERL_INSTALL_CMDS
> +	$(MAKE) INSTALL_DEPENDENCE= \
> +		-C $(@D) install
> +endef
> +
> +define HOST_PERL_CLEAN_CMDS
> +	-$(MAKE) -C $(@D) clean
> +endef
> +
> +$(eval $(generic-package))
> +$(eval $(host-generic-package))

The host variant of perl seems to be here only as a build dependency of
microperl, which your patch set is deprecating. Is it really necessary
to have this host variant?

Best regards,

Thomas
Francois Perrad Sept. 21, 2012, 9:29 p.m. UTC | #2
2012/9/20 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>:
> Dear Francois Perrad,
>
> Thanks for your continued work on this. Some comments below.
>
> First, do not put the patch version in the patch title. If you want to
> have a version, it should be between the [] at the beginning of the
> title. Here is how you can do that with git:
>
> git format-patch --subject-prefix="PATCH v7" <yourbasebranch>
>
> On Sat,  8 Sep 2012 14:28:33 +0200, Francois Perrad wrote:
>> ---
>>  package/Config.in                      |    1 +
>>  package/perl/Config.in                 |   17 +++++
>>  package/perl/perl-configure-qemu.patch |   32 +++++++++
>>  package/perl/perl-make-ext.patch       |   24 +++++++
>>  package/perl/perl-mkppport.patch       |   37 ++++++++++
>>  package/perl/perl.mk                   |  121 ++++++++++++++++++++++++++++++++
>>  6 files changed, 232 insertions(+)
>>  create mode 100644 package/perl/Config.in
>>  create mode 100644 package/perl/perl-configure-qemu.patch
>>  create mode 100644 package/perl/perl-make-ext.patch
>>  create mode 100644 package/perl/perl-mkppport.patch
>>  create mode 100644 package/perl/perl.mk
>>
>> diff --git a/package/Config.in b/package/Config.in
>> index f308de7..00a79ab 100644
>> --- a/package/Config.in
>> +++ b/package/Config.in
>> @@ -262,6 +262,7 @@ source "package/wsapi/Config.in"
>>  source "package/xavante/Config.in"
>>  endmenu
>>  endif
>> +source "package/perl/Config.in"
>>  source "package/microperl/Config.in"
>>  source "package/php/Config.in"
>>  source "package/python/Config.in"
>> diff --git a/package/perl/Config.in b/package/perl/Config.in
>> new file mode 100644
>> index 0000000..286b09e
>> --- /dev/null
>> +++ b/package/perl/Config.in
>> @@ -0,0 +1,17 @@
>> +config BR2_PACKAGE_PERL
>> +     bool "perl"
>> +     help
>> +       Larry Wall's Practical Extraction and Report Language
>> +       An interpreted scripting language, known among some as "Unix's Swiss
>> +       Army Chainsaw".
>> +
>> +       http://www.perl.org/
>> +
>> +if BR2_PACKAGE_PERL
>> +
>> +config BR2_PACKAGE_PERL_CUSTOM_CONFIGURE
>> +     string "configuration flags"
>> +     help
>> +       Allows to add some flags to Configure.
>
> We don't typically offer such choice for packages. Is there a good
> reason for doing so in the case of Perl, rather than providing a few
> additional kconfig configuration options if needed?
>
>> +endif
>> diff --git a/package/perl/perl-configure-qemu.patch b/package/perl/perl-configure-qemu.patch
>> new file mode 100644
>> index 0000000..00f7539
>> --- /dev/null
>> +++ b/package/perl/perl-configure-qemu.patch
>> @@ -0,0 +1,32 @@
>> +Add qemu support
>> +
>
> Please explain in more details what this means, and whether this patch
> has a chance of being upstream or not.
>
> Also, it seems to imply that the build process of Perl would require
> Qemu. Or, Qemu is not amongst the requirements of Buildroot, and there
> is no host-qemu package in the dependencies of your package (and we
> don't have a host-qemu package). Yann E. Morin has posted a target
> package for qemu a while ago, but it hasn't been merged so far.
>
> That said, even so it is certainly possible to create a host-qemu
> package, I am a bit annoyed to see the build process of a package
> requiring qemu. Is there really no other way? I guess it uses qemu to
> run a bunch of tests on the target system. Is there no way to provide
> pre-defined values for those tests, on a per-architecture basis, rather
> than running those test applications in Qemu?
>

Qemu is not used for test, but for the configure and build step.
Perl is 'bootstrapped' by miniperl (a perl without any extension module),
during the build process, miniperl is running via qemu (user mode).

Perl doesn't use the "standard" autotools, Perl has a limited support
for cross-compiling
where the target executables are running on a real target through a
ssh connection.
The use of qemu (user mode) removes the need of a real target and the
ssh connection.

BR is shipped with 12 configs/qemu_*_defconfig files,
many users have already run 'apt-get install qemu-kvm qemu-kvm-extras'.

A host-qemu package (with the latest version) could be nice in the future.


>> diff --git a/package/perl/perl-make-ext.patch b/package/perl/perl-make-ext.patch
>> new file mode 100644
>> index 0000000..e0195e7
>> --- /dev/null
>> +++ b/package/perl/perl-make-ext.patch
>> @@ -0,0 +1,24 @@
>> +Don't use RUN with make (only for perl)
>> +
>> +Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
>
> Sorry, but the patch description is insufficient to understand what is
> going on here.
>
>> +
>> +Index: b/make_ext.pl
>> +===================================================================
>> +--- a/make_ext.pl
>> ++++ b/make_ext.pl
>> +@@ -458,11 +458,13 @@
>> +     # Give makefile an opportunity to rewrite itself.
>> +     # reassure users that life goes on...
>> +     my @args = ('config', @$pass_through);
>> +-    system(@run, @make, @args) and print "@run @make @args failed, continuing anyway...\n";
>> ++#   system(@run, @make, @args) and print "@run @make @args failed, continuing anyway...\n";
>> ++    system(@make, @args) and print "@make @args failed, continuing anyway...\n";
>> +     }
>> +     my @targ = ($target, @$pass_through);
>> +     print "Making $target in $ext_dir\n@run @make @targ\n";
>> +-    my $code = system(@run, @make, @targ);
>> ++#    my $code = system(@run, @make, @targ);
>> ++    my $code = system(@make, @targ);
>> +     die "Unsuccessful make($ext_dir): code=$code" if $code != 0;
>> +
>> +     chdir $return_dir || die "Cannot cd to $return_dir: $!";
>> diff --git a/package/perl/perl-mkppport.patch b/package/perl/perl-mkppport.patch
>> new file mode 100644
>> index 0000000..97f27a2
>> --- /dev/null
>> +++ b/package/perl/perl-mkppport.patch
>> @@ -0,0 +1,37 @@
>> +Add RUN
>> +
>> +Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
>
> Ditto.
>
>> diff --git a/package/perl/perl.mk b/package/perl/perl.mk
>> new file mode 100644
>> index 0000000..2a8da79
>> --- /dev/null
>> +++ b/package/perl/perl.mk
>> @@ -0,0 +1,121 @@
>> +#############################################################
>> +#
>> +# perl
>> +#
>> +#############################################################
>> +
>> +PERL_VERSION_MAJOR = 16
>> +PERL_VERSION = 5.$(PERL_VERSION_MAJOR).1
>> +PERL_SITE = http://www.cpan.org/src/5.0
>> +PERL_SOURCE = perl-$(PERL_VERSION).tar.bz2
>> +PERL_LICENSE = Artistic
>> +PERL_LICENSE_FILES = Artistic
>> +PERL_INSTALL_STAGING = YES
>> +
>> +ifeq ($(shell expr $(PERL_VERSION_MAJOR) % 2), 1)
>> +    PERL_USE_DEVEL=-Dusedevel
>> +endif
>> +
>> +ifneq ($(BR2_LARGEFILE),y)
>> +    PERL_NO_LARGEFILE=-Uuselargefiles
>> +endif
>> +
>> +PERL_ARCH=$(call qstrip,$(BR2_ARCH))
>
> You can use ARCH directly, it is already qstripped.

ok.

>
>> +ifeq ($(PERL_ARCH),i686)
>> +    PERL_ARCH=i386
>> +endif
>> +PERL_QEMU_USER_MODE=qemu-$(PERL_ARCH)
>> +
>> +define PERL_CONFIGURE_CMDS
>> +     rm -f $(@D)/config.sh
>> +     cd $(@D); ./Configure -des \
>
> We generally like to put such commands into parenthesis, i.e:
>
>         (cd $(@D); .... \
>                 .....   \
>                 .....)
>

ok.

>> +             -Dusecrosscompile \
>> +             -Dtargetrun=$(PERL_QEMU_USER_MODE) \
>> +             -Dqemulib=$(STAGING_DIR) \
>> +             -Dtargethost=dummy \
>> +             -Dar="$(TARGET_AR)" \
>> +             -Dcc="$(TARGET_CC)" \
>> +             -Dcpp="$(TARGET_CC)" \
>> +             -Dld="$(TARGET_LD)" \
>> +             -Dnm="$(TARGET_NM)" \
>> +             -Dranlib="$(TARGET_RANLIB)" \
>> +             -Dccflags="$(TARGET_CFLAGS)" \
>> +             -Dldflags="$(TARGET_LDFLAGS) -l gcc_s" \
>> +             -Dlddlflags="-shared" \
>> +             -Dlibc=$(TARGET_HOST)/usr/$(GNU_TARGET_NAME)/sysroot/lib/libc.so \
>> +             -Duseshrplib \
>> +             -Dprefix=/usr \
>> +             -Uoptimize \
>> +             $(PERL_USE_DEVEL) \
>> +             $(PERL_NO_LARGEFILE) \
>> +             $(call qstrip,$(BR2_PACKAGE_PERL_CUSTOM_CONFIGURE))
>> +     echo "# patched values"                 >>$(@D)/config.sh
>> +     $(SED) '/^myarchname=/d' \
>> +             -e '/^mydomain=/d' \
>> +             -e '/^myhostname=/d' \
>> +             -e '/^myuname=/d' \
>> +             -e '/^osname=/d' \
>> +             -e '/^osvers=/d' \
>> +             -e '/^perladmin=/d' \
>> +             $(@D)/config.sh
>> +     echo "myarchname='$(GNU_TARGET_NAME)'"                  >>$(@D)/config.sh
>> +     echo "mydomain=''"                                      >>$(@D)/config.sh
>> +     echo "myhostname='$(BR2_TARGET_GENERIC_HOSTNAME)'"      >>$(@D)/config.sh
>> +     echo "myuname='Buildroot $(BR2_VERSION_FULL)'"          >>$(@D)/config.sh
>> +     echo "osname='linux'"                                   >>$(@D)/config.sh
>> +     echo "osvers='$(BR2_LINUX_KERNEL_VERSION)'"             >>$(@D)/config.sh
>> +     echo "perladmin='root'"                                 >>$(@D)/config.sh
>> +     cd $(@D); ./Configure -S
>> +     cp $(@D)/config.h $(@D)/xconfig.h
>> +     $(SED) 's/UNKNOWN-/Buildroot $(BR2_VERSION_FULL) /' $(@D)/patchlevel.h
>> +endef
>> +
>> +define PERL_BUILD_CMDS
>> +     echo "#!/bin/sh"                                                        > $(@D)/Cross/miniperl
>> +     echo "$(PERL_QEMU_USER_MODE) -L $(STAGING_DIR) $(@D)/miniperl \"\$$@\"" >>$(@D)/Cross/miniperl
>> +     chmod +x $(@D)/Cross/miniperl
>> +     PERL_MM_OPT="PERL=$(@D)/Cross/miniperl" \
>> +     $(MAKE) -C $(@D) all
>> +endef
>> +
>> +define PERL_INSTALL_STAGING_CMDS
>> +     $(MAKE) INSTALL_DEPENDENCE= \
>
> Is it really INSTALL_DEPENDENCE ?

yes.
Makefile contains these 2 lines :
    # Set this to an empty string to avoid an attempt of rebuild before install
    INSTALL_DEPENDENCE = all

>
>> +             INSTALLFLAGS= \
>> +             DESTDIR="$(STAGING_DIR)" \
>> +             -C $(@D) install.perl
>> +     $(INSTALL) -m 755 $(@D)/libperl.so $(STAGING_DIR)/usr/lib/libperl.so
>
> Maybe just a comment above on why the manual installation of this .so
> file is needed.
>

In fact useless, so removed.

>> +endef
>> +
>> +define PERL_INSTALL_TARGET_CMDS
>> +     $(MAKE) INSTALL_DEPENDENCE= \
>> +             INSTALLFLAGS=-p \
>> +             DESTDIR="$(TARGET_DIR)" \
>> +             -C $(@D) install.perl
>> +endef
>> +
>> +define PERL_CLEAN_CMDS
>> +     -$(MAKE) -C $(@D) clean
>> +endef
>> +
>> +define HOST_PERL_CONFIGURE_CMDS
>> +     cd $(@D); ./Configure -des \
>> +             -Dcc="$(HOSTCC)" \
>> +             -Dprefix="$(HOST_DIR)/usr" \
>> +             $(PERL_USE_DEVEL)
>> +endef
>> +
>> +define HOST_PERL_BUILD_CMDS
>> +     $(MAKE) -C $(@D) all
>> +endef
>> +
>> +define HOST_PERL_INSTALL_CMDS
>> +     $(MAKE) INSTALL_DEPENDENCE= \
>> +             -C $(@D) install
>> +endef
>> +
>> +define HOST_PERL_CLEAN_CMDS
>> +     -$(MAKE) -C $(@D) clean
>> +endef
>> +
>> +$(eval $(generic-package))
>> +$(eval $(host-generic-package))
>
> The host variant of perl seems to be here only as a build dependency of
> microperl, which your patch set is deprecating. Is it really necessary
> to have this host variant?
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, Free Electrons
> Kernel, drivers, real-time and embedded Linux
> development, consulting, training and support.
> http://free-electrons.com
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Thomas Petazzoni Sept. 22, 2012, 3:38 a.m. UTC | #3
Dear François Perrad,

On Fri, 21 Sep 2012 23:29:57 +0200, François Perrad wrote:

> > Please explain in more details what this means, and whether this
> > patch has a chance of being upstream or not.
> >
> > Also, it seems to imply that the build process of Perl would require
> > Qemu. Or, Qemu is not amongst the requirements of Buildroot, and
> > there is no host-qemu package in the dependencies of your package
> > (and we don't have a host-qemu package). Yann E. Morin has posted a
> > target package for qemu a while ago, but it hasn't been merged so
> > far.
> >
> > That said, even so it is certainly possible to create a host-qemu
> > package, I am a bit annoyed to see the build process of a package
> > requiring qemu. Is there really no other way? I guess it uses qemu
> > to run a bunch of tests on the target system. Is there no way to
> > provide pre-defined values for those tests, on a per-architecture
> > basis, rather than running those test applications in Qemu?
> >
> 
> Qemu is not used for test, but for the configure and build step.
> Perl is 'bootstrapped' by miniperl (a perl without any extension
> module), during the build process, miniperl is running via qemu (user
> mode).
> 
> Perl doesn't use the "standard" autotools, Perl has a limited support
> for cross-compiling
> where the target executables are running on a real target through a
> ssh connection.
> The use of qemu (user mode) removes the need of a real target and the
> ssh connection.
> 
> BR is shipped with 12 configs/qemu_*_defconfig files,
> many users have already run 'apt-get install qemu-kvm
> qemu-kvm-extras'.
> 
> A host-qemu package (with the latest version) could be nice in the
> future.

I understand the need for Qemu in the Perl context (even though I
generally don't understand why they can't bring normal
cross-compilation support in the Perl build system), but the solution
you're proposing cannot be accepted as is. We need to either:

 * Make qemu a hard requirement to run Buildroot, and in that case, add
   a check for it in support/dependencies/dependencies.sh. Since it is
   such an unusual dependency, we may special case it, and add it as a
   dependency only if the Perl package is selected, a bit like we
   already do for the version control tools (that are only requested as
   dependencies if at least one package needing a given version control
   tool is selected)

 * Add a host-qemu package. We can quite certainly find a commonality
   here with Yann's work on Qemu.

At the moment, your package will break on auto-builders, because they
don't necessarily have Qemu installed.

Best regards,

Thomas
Arnout Vandecappelle Sept. 24, 2012, 8:20 p.m. UTC | #4
On 09/21/12 23:29, François Perrad wrote:
>> >  That said, even so it is certainly possible to create a host-qemu
>> >  package, I am a bit annoyed to see the build process of a package
>> >  requiring qemu. Is there really no other way? I guess it uses qemu to
>> >  run a bunch of tests on the target system. Is there no way to provide
>> >  pre-defined values for those tests, on a per-architecture basis, rather
>> >  than running those test applications in Qemu?
>> >
> Qemu is not used for test, but for the configure and build step.
> Perl is 'bootstrapped' by miniperl (a perl without any extension module),
> during the build process, miniperl is running via qemu (user mode).
>
> Perl doesn't use the "standard" autotools, Perl has a limited support
> for cross-compiling
> where the target executables are running on a real target through a
> ssh connection.
> The use of qemu (user mode) removes the need of a real target and the
> ssh connection.

  Probably a stupid question, but is it possible to build a host-miniperl
and use that for the perl build?  If necessary, we could patch the
host-miniperl a bit to point into the sysroot'ed perl directories, like
is done with host-pkg-config.  Or is the issue that the perl build generates
files with native endianness and struct layout?  That would be more or less
impossible to work around without qemu...


  Regards,
  Arnout
Francois Perrad Sept. 25, 2012, 5:17 p.m. UTC | #5
2012/9/24 Arnout Vandecappelle <arnout@mind.be>:
> On 09/21/12 23:29, François Perrad wrote:
>>>
>>> >  That said, even so it is certainly possible to create a host-qemu
>>> >  package, I am a bit annoyed to see the build process of a package
>>> >  requiring qemu. Is there really no other way? I guess it uses qemu to
>>> >  run a bunch of tests on the target system. Is there no way to provide
>>> >  pre-defined values for those tests, on a per-architecture basis,
>>> > rather
>>> >  than running those test applications in Qemu?
>>> >
>>
>> Qemu is not used for test, but for the configure and build step.
>> Perl is 'bootstrapped' by miniperl (a perl without any extension module),
>> during the build process, miniperl is running via qemu (user mode).
>>
>> Perl doesn't use the "standard" autotools, Perl has a limited support
>> for cross-compiling
>> where the target executables are running on a real target through a
>> ssh connection.
>> The use of qemu (user mode) removes the need of a real target and the
>> ssh connection.
>
>
>  Probably a stupid question, but is it possible to build a host-miniperl
> and use that for the perl build?  If necessary, we could patch the
> host-miniperl a bit to point into the sysroot'ed perl directories, like
> is done with host-pkg-config.  Or is the issue that the perl build generates
> files with native endianness and struct layout?  That would be more or less
> impossible to work around without qemu...
>

I've already explored this path.
A host-miniperl could be used during the build of target-perl, instead
of target-miniperl via qemu.

But qemu is also used during the configure step.
Without qemu, a target configuration could be obtained by a large
patching a host configuration.
So, most of the logic of configure must be rewrited/duplicated in perl.mk.

François

>
>  Regards,
>  Arnout
>
> --
> Arnout Vandecappelle                               arnout at mind be
> Senior Embedded Software Architect                 +32-16-286540
> Essensium/Mind                                     http://www.mind.be
> G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
> LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
> GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
diff mbox

Patch

diff --git a/package/Config.in b/package/Config.in
index f308de7..00a79ab 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -262,6 +262,7 @@  source "package/wsapi/Config.in"
 source "package/xavante/Config.in"
 endmenu
 endif
+source "package/perl/Config.in"
 source "package/microperl/Config.in"
 source "package/php/Config.in"
 source "package/python/Config.in"
diff --git a/package/perl/Config.in b/package/perl/Config.in
new file mode 100644
index 0000000..286b09e
--- /dev/null
+++ b/package/perl/Config.in
@@ -0,0 +1,17 @@ 
+config BR2_PACKAGE_PERL
+	bool "perl"
+	help
+	  Larry Wall's Practical Extraction and Report Language
+	  An interpreted scripting language, known among some as "Unix's Swiss
+	  Army Chainsaw".
+
+	  http://www.perl.org/
+
+if BR2_PACKAGE_PERL
+
+config BR2_PACKAGE_PERL_CUSTOM_CONFIGURE
+	string "configuration flags"
+	help
+	  Allows to add some flags to Configure.
+
+endif
diff --git a/package/perl/perl-configure-qemu.patch b/package/perl/perl-configure-qemu.patch
new file mode 100644
index 0000000..00f7539
--- /dev/null
+++ b/package/perl/perl-configure-qemu.patch
@@ -0,0 +1,32 @@ 
+Add qemu support
+
+Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
+
+Index: b/Configure
+===================================================================
+--- a/Configure
++++ b/Configure
+@@ -2908,6 +2908,14 @@
+ $targetrun -l $targetuser $targethost "cd \$cwd && ./\$exe \$@"
+ EOF
+ 	    ;;
++	qemu*)
++	    to=:
++	    from=:
++	    cat >$run <<EOF
++#!/bin/sh
++$targetrun -L $qemulib "\$@"
++EOF
++	    ;;
+ 	*)  echo "Unknown targetrun '$targetrun'" >&4
+ 	    exit 1
+ 	    ;;
+@@ -5048,7 +5056,7 @@
+ echo " ";
+ echo "Checking if your compiler accepts $flag" 2>&1;
+ echo "int main(void) { return 0; }" > gcctest.c;
+-if $cc -O2 $flag -o gcctest gcctest.c 2>gcctest.out && ./gcctest; then
++if $cc -O2 $flag -o gcctest gcctest.c 2>gcctest.out && $run ./gcctest; then
+     echo "Yes, it does." 2>&1;
+     if $test -s gcctest.out ; then
+         echo "But your platform does not like it:";
diff --git a/package/perl/perl-make-ext.patch b/package/perl/perl-make-ext.patch
new file mode 100644
index 0000000..e0195e7
--- /dev/null
+++ b/package/perl/perl-make-ext.patch
@@ -0,0 +1,24 @@ 
+Don't use RUN with make (only for perl)
+
+Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
+
+Index: b/make_ext.pl
+===================================================================
+--- a/make_ext.pl
++++ b/make_ext.pl
+@@ -458,11 +458,13 @@
+ 	# Give makefile an opportunity to rewrite itself.
+ 	# reassure users that life goes on...
+ 	my @args = ('config', @$pass_through);
+-	system(@run, @make, @args) and print "@run @make @args failed, continuing anyway...\n";
++#	system(@run, @make, @args) and print "@run @make @args failed, continuing anyway...\n";
++	system(@make, @args) and print "@make @args failed, continuing anyway...\n";
+     }
+     my @targ = ($target, @$pass_through);
+     print "Making $target in $ext_dir\n@run @make @targ\n";
+-    my $code = system(@run, @make, @targ);
++#    my $code = system(@run, @make, @targ);
++    my $code = system(@make, @targ);
+     die "Unsuccessful make($ext_dir): code=$code" if $code != 0;
+ 
+     chdir $return_dir || die "Cannot cd to $return_dir: $!";
diff --git a/package/perl/perl-mkppport.patch b/package/perl/perl-mkppport.patch
new file mode 100644
index 0000000..97f27a2
--- /dev/null
+++ b/package/perl/perl-mkppport.patch
@@ -0,0 +1,37 @@ 
+Add RUN
+
+Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
+
+Index: b/mkppport
+===================================================================
+--- a/mkppport
++++ b/mkppport
+@@ -1,6 +1,7 @@
+ use strict;
+ use warnings;
+ 
++use Config;
+ use Getopt::Long;
+ use File::Spec;
+ use File::Compare qw( compare );
+@@ -136,14 +137,18 @@
+ #----------------------------------------------
+ sub run
+ {
++  my @run = $Config{run};
++  @run = () if not defined $run[0] or $run[0] eq '';
+   my @args = ("-I" . File::Spec->catdir((File::Spec->updir) x 2, 'lib'), @_);
+   my $run = $perl =~ m/\s/ ? qq("$perl") : $perl;
+   for (@args) {
+     $_ = qq("$_") if $^O eq 'VMS' && /^[^"]/;
+     $run .= " $_";
+   }
+-  print "running $run\n";
+-  system $run and die "$run failed: $?\n";
++#  print "running $run\n";
++#  system $run and die "$run failed: $?\n";
++  print "running ", join(' ', @run, $run), "\n";
++  system join(' ', @run, $run) and die "@run $run failed: $?\n";
+ }
+ 
+ __END__
diff --git a/package/perl/perl.mk b/package/perl/perl.mk
new file mode 100644
index 0000000..2a8da79
--- /dev/null
+++ b/package/perl/perl.mk
@@ -0,0 +1,121 @@ 
+#############################################################
+#
+# perl
+#
+#############################################################
+
+PERL_VERSION_MAJOR = 16
+PERL_VERSION = 5.$(PERL_VERSION_MAJOR).1
+PERL_SITE = http://www.cpan.org/src/5.0
+PERL_SOURCE = perl-$(PERL_VERSION).tar.bz2
+PERL_LICENSE = Artistic
+PERL_LICENSE_FILES = Artistic
+PERL_INSTALL_STAGING = YES
+
+ifeq ($(shell expr $(PERL_VERSION_MAJOR) % 2), 1)
+    PERL_USE_DEVEL=-Dusedevel
+endif
+
+ifneq ($(BR2_LARGEFILE),y)
+    PERL_NO_LARGEFILE=-Uuselargefiles
+endif
+
+PERL_ARCH=$(call qstrip,$(BR2_ARCH))
+ifeq ($(PERL_ARCH),i686)
+    PERL_ARCH=i386
+endif
+PERL_QEMU_USER_MODE=qemu-$(PERL_ARCH)
+
+define PERL_CONFIGURE_CMDS
+	rm -f $(@D)/config.sh
+	cd $(@D); ./Configure -des \
+		-Dusecrosscompile \
+		-Dtargetrun=$(PERL_QEMU_USER_MODE) \
+		-Dqemulib=$(STAGING_DIR) \
+		-Dtargethost=dummy \
+		-Dar="$(TARGET_AR)" \
+		-Dcc="$(TARGET_CC)" \
+		-Dcpp="$(TARGET_CC)" \
+		-Dld="$(TARGET_LD)" \
+		-Dnm="$(TARGET_NM)" \
+		-Dranlib="$(TARGET_RANLIB)" \
+		-Dccflags="$(TARGET_CFLAGS)" \
+		-Dldflags="$(TARGET_LDFLAGS) -l gcc_s" \
+		-Dlddlflags="-shared" \
+		-Dlibc=$(TARGET_HOST)/usr/$(GNU_TARGET_NAME)/sysroot/lib/libc.so \
+		-Duseshrplib \
+		-Dprefix=/usr \
+		-Uoptimize \
+		$(PERL_USE_DEVEL) \
+		$(PERL_NO_LARGEFILE) \
+		$(call qstrip,$(BR2_PACKAGE_PERL_CUSTOM_CONFIGURE))
+	echo "# patched values"                 >>$(@D)/config.sh
+	$(SED) '/^myarchname=/d' \
+		-e '/^mydomain=/d' \
+		-e '/^myhostname=/d' \
+		-e '/^myuname=/d' \
+		-e '/^osname=/d' \
+		-e '/^osvers=/d' \
+		-e '/^perladmin=/d' \
+		$(@D)/config.sh
+	echo "myarchname='$(GNU_TARGET_NAME)'"                  >>$(@D)/config.sh
+	echo "mydomain=''"                                      >>$(@D)/config.sh
+	echo "myhostname='$(BR2_TARGET_GENERIC_HOSTNAME)'"      >>$(@D)/config.sh
+	echo "myuname='Buildroot $(BR2_VERSION_FULL)'"          >>$(@D)/config.sh
+	echo "osname='linux'"                                   >>$(@D)/config.sh
+	echo "osvers='$(BR2_LINUX_KERNEL_VERSION)'"             >>$(@D)/config.sh
+	echo "perladmin='root'"                                 >>$(@D)/config.sh
+	cd $(@D); ./Configure -S
+	cp $(@D)/config.h $(@D)/xconfig.h
+	$(SED) 's/UNKNOWN-/Buildroot $(BR2_VERSION_FULL) /' $(@D)/patchlevel.h
+endef
+
+define PERL_BUILD_CMDS
+	echo "#!/bin/sh"                                                        > $(@D)/Cross/miniperl
+	echo "$(PERL_QEMU_USER_MODE) -L $(STAGING_DIR) $(@D)/miniperl \"\$$@\"" >>$(@D)/Cross/miniperl
+	chmod +x $(@D)/Cross/miniperl
+	PERL_MM_OPT="PERL=$(@D)/Cross/miniperl" \
+	$(MAKE) -C $(@D) all
+endef
+
+define PERL_INSTALL_STAGING_CMDS
+	$(MAKE) INSTALL_DEPENDENCE= \
+		INSTALLFLAGS= \
+		DESTDIR="$(STAGING_DIR)" \
+		-C $(@D) install.perl
+	$(INSTALL) -m 755 $(@D)/libperl.so $(STAGING_DIR)/usr/lib/libperl.so
+endef
+
+define PERL_INSTALL_TARGET_CMDS
+	$(MAKE) INSTALL_DEPENDENCE= \
+		INSTALLFLAGS=-p \
+		DESTDIR="$(TARGET_DIR)" \
+		-C $(@D) install.perl
+endef
+
+define PERL_CLEAN_CMDS
+	-$(MAKE) -C $(@D) clean
+endef
+
+define HOST_PERL_CONFIGURE_CMDS
+	cd $(@D); ./Configure -des \
+		-Dcc="$(HOSTCC)" \
+		-Dprefix="$(HOST_DIR)/usr" \
+		$(PERL_USE_DEVEL)
+endef
+
+define HOST_PERL_BUILD_CMDS
+	$(MAKE) -C $(@D) all
+endef
+
+define HOST_PERL_INSTALL_CMDS
+	$(MAKE) INSTALL_DEPENDENCE= \
+		-C $(@D) install
+endef
+
+define HOST_PERL_CLEAN_CMDS
+	-$(MAKE) -C $(@D) clean
+endef
+
+$(eval $(generic-package))
+$(eval $(host-generic-package))