diff mbox series

[15/18] pkg-utils.mk: patch_sub_makefile

Message ID 20180820115519.24046-16-chrismcc@gmail.com
State Changes Requested
Headers show
Series perl modules again | expand

Commit Message

Christopher McCrory Aug. 20, 2018, 11:55 a.m. UTC
suggested and written by François
Fix incorrectly generated Makefiles in subdirectories, usually perl
packages.

Signed-off-by: Christopher McCrory <chrismcc@gmail.com>
---
 package/pkg-utils.mk | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Thomas Petazzoni Sept. 12, 2018, 9:15 p.m. UTC | #1
Hello,

On Mon, 20 Aug 2018 04:55:16 -0700, Christopher McCrory wrote:
> suggested and written by François
> Fix incorrectly generated Makefiles in subdirectories, usually perl
> packages.
> 
> Signed-off-by: Christopher McCrory <chrismcc@gmail.com>

François, you did not review/ack this patch. Could you have a look ?

I was wondering if there was really no way to pass these values through
the environment.

One comment below.

> diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
> index c3acc22b17..7dbdb427a6 100644
> --- a/package/pkg-utils.mk
> +++ b/package/pkg-utils.mk
> @@ -95,3 +95,19 @@ define legal-license-file # pkgname, pkgname-pkgver, pkgdir, filename, file-full
>  	} && \
>  	cp $(5) $(LICENSE_FILES_DIR_$(6))/$(2)/$(4)
>  endef
> +
> +# Used to fix makefiles in subdirectories, usually perl packages see 
> +# perl-template-toolkit and perl-xml-parser
> +# use: $(call patch_sub_makefile,$(@D)/xs/Makefile)
> +
> +define patch_sub_makefile
> +	$(SED) "s:^AR = .*:AR = $(TARGET_AR):g" $(1)
> +	$(SED) "s:^FULL_AR = .*:FULL_AR = $(TARGET_AR):g" $(1)
> +	$(SED) "s:^CC = .*:CC = $(TARGET_CC):g" $(1)
> +	$(SED) "s:^CCFLAGS = .*:CCFLAGS = $(TARGET_CFLAGS):g" $(1)
> +	$(SED) "s:^LD = .*:LD = $(TARGET_CC):g" $(1)
> +	$(SED) "s:^LDDLFLAGS = .*:LDDLFLAGS = -shared $(TARGET_LDFLAGS):g" $(1)
> +	$(SED) "s:^LDLFLAGS = .*:LDLFLAGS = $(TARGET_LDFLAGS):g" $(1)
> +	$(SED) "s:^DESTDIR = .*:DESTDIR = $(TARGET_DIR):g" $(1)
> +endef

To be more consistent with other package infrastructures, I think I'd
prefer a <pkg>_PATCH_XS_MAKEFILES variable that Perl packages can fill
in with the list of XS Makefiles that need to be patched.

So perhaps something like:

define PKG_PERL_PATCH_XS_MAKEFILE_HOOK

	... like you did, but using $($(PKG)_PATCH_XS_MAKEFILES)
endef

and then, in the inner-perl-package, do something like this:

ifneq ($$($(2)_PATCH_XS_MAKEFILES),)
$(2)_POST_PATCH_HOOKS += PKG_PERL_PATCH_XS_MAKEFILE_HOOK
endif

Best regards,

Thomas
Thomas Petazzoni Sept. 12, 2018, 9:33 p.m. UTC | #2
Hello,

On Wed, 12 Sep 2018 23:15:48 +0200, Thomas Petazzoni wrote:

> I was wondering if there was really no way to pass these values through
> the environment.

This problem was reported at
https://rt.cpan.org/Public/Bug/Display.html?id=28632, and apparently
fixed in 2013, at least for the "LD" variable. Why are we still seeing
this issue ?

Thanks,

Thomas
diff mbox series

Patch

diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
index c3acc22b17..7dbdb427a6 100644
--- a/package/pkg-utils.mk
+++ b/package/pkg-utils.mk
@@ -95,3 +95,19 @@  define legal-license-file # pkgname, pkgname-pkgver, pkgdir, filename, file-full
 	} && \
 	cp $(5) $(LICENSE_FILES_DIR_$(6))/$(2)/$(4)
 endef
+
+# Used to fix makefiles in subdirectories, usually perl packages see 
+# perl-template-toolkit and perl-xml-parser
+# use: $(call patch_sub_makefile,$(@D)/xs/Makefile)
+
+define patch_sub_makefile
+	$(SED) "s:^AR = .*:AR = $(TARGET_AR):g" $(1)
+	$(SED) "s:^FULL_AR = .*:FULL_AR = $(TARGET_AR):g" $(1)
+	$(SED) "s:^CC = .*:CC = $(TARGET_CC):g" $(1)
+	$(SED) "s:^CCFLAGS = .*:CCFLAGS = $(TARGET_CFLAGS):g" $(1)
+	$(SED) "s:^LD = .*:LD = $(TARGET_CC):g" $(1)
+	$(SED) "s:^LDDLFLAGS = .*:LDDLFLAGS = -shared $(TARGET_LDFLAGS):g" $(1)
+	$(SED) "s:^LDLFLAGS = .*:LDLFLAGS = $(TARGET_LDFLAGS):g" $(1)
+	$(SED) "s:^DESTDIR = .*:DESTDIR = $(TARGET_DIR):g" $(1)
+endef
+