Skip to contentSkip to conversation

mtd: add missing -lintl from util-linux when building statically

PATCH New Vicente Olivert Riera 2 participants 6 messages Sep 10, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: add missing -lintl from util-linux when building statically

mtd depends on util-linux when BR2_PACKAGE_MTD_MKFSUBIFS is selected. Also, util-linux depends on gettext and will need to link with -lintl if BR2_NEEDS_GETTEXT_IF_LOCALE is selected. So, when mtd tries to link with util-linux's uuid (-luuid) it should add -lintl as well, but it fails when building statically. The uuid.pc file lists -lintl as one of the needed libraries, but since mtd package doesn't have a configure phase we can't do the following:

MTD_DEPENDENCIES += host-pkgconf
MTD_CONF_ENV += LIBS=$(PKG_CONFIG_HOST_BINARY) --libs uuid"

So, in further investigations I have seen that mtd hardcodes the libs for mkfs.ubifs in the Makefile, in a variable called LDLIBS_mkfs.ubifs, and that variable can't be overwritten by passing options or environment variables to make.

So, to fix the problem, we use a sed command to append -lintl to the LDLIBS_mkfs.ubifs variable only when building statically, because it's the case when it fails, and only when BR2_NEEDS_GETTEXT_IF_LOCALE is selected, because is the case when you also need -lintl when linking with util-linux.

Fixes:

http://autobuild.buildroot.net/results/2dd/2ddd714446d9eb75701bd48c117dc5bbbd291a76/

---
 package/mtd/mtd.mk |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
package/mtd/mtd.mk +6 -0
index 0fb9fc2..a34c840 100644
@@ -18,6 +18,12 @@ endif
 
 ifeq ($(BR2_PACKAGE_MTD_MKFSUBIFS),y)
 MTD_DEPENDENCIES += util-linux zlib lzo
+ifeq ($(BR2_STATIC_LIBS)$(BR2_NEEDS_GETTEXT_IF_LOCALE),yy)
+define MTD_ADD_MISSING_LINTL
+	$(SED) '/^LDLIBS_mkfs\.ubifs/ s/$$/ -lintl/' $(@D)/Makefile
+endef
+MTD_PRE_BUILD_HOOKS += MTD_ADD_MISSING_LINTL
+endif
 endif
 
 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 mtd: add missing -lintl from util-linux when building statically

Hi Vincent,

Quoted 10 lines · Vicente Olivert Riera

mtd depends on util-linux when BR2_PACKAGE_MTD_MKFSUBIFS is selected. Also, util-linux depends on gettext and will need to link with -lintl if BR2_NEEDS_GETTEXT_IF_LOCALE is selected. So, when mtd tries to link with util-linux's uuid (-luuid) it should add -lintl as well, but it fails when building statically. The uuid.pc file lists -lintl as one of the needed libraries, but since mtd package doesn't have a configure phase we can't do the following:

MTD_DEPENDENCIES += host-pkgconf
MTD_CONF_ENV += LIBS=$(PKG_CONFIG_HOST_BINARY) --libs uuid"

So why not something like:

MTD_MKFS_UBIFS_LIBS = $(PKG_CONFIG_HOST_BINARY) --libs uuid"

and use $(MTD_MKFS_UBIFS_LIBS) instead of hard coding -lintl in the sed expression. This way you can remove the condition from the sed expression.

baruch

Quoted 37 lines

So, in further investigations I have seen that mtd hardcodes the libs for mkfs.ubifs in the Makefile, in a variable called LDLIBS_mkfs.ubifs, and that variable can't be overwritten by passing options or environment variables to make.

So, to fix the problem, we use a sed command to append -lintl to the LDLIBS_mkfs.ubifs variable only when building statically, because it's the case when it fails, and only when BR2_NEEDS_GETTEXT_IF_LOCALE is selected, because is the case when you also need -lintl when linking with util-linux.

Fixes:

http://autobuild.buildroot.net/results/2dd/2ddd714446d9eb75701bd48c117dc5bbbd291a76/

---
 package/mtd/mtd.mk |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
package/mtd/mtd.mk +6 -0
index 0fb9fc2..a34c840 100644
@@ -18,6 +18,12 @@ endif
 
 ifeq ($(BR2_PACKAGE_MTD_MKFSUBIFS),y)
 MTD_DEPENDENCIES += util-linux zlib lzo
+ifeq ($(BR2_STATIC_LIBS)$(BR2_NEEDS_GETTEXT_IF_LOCALE),yy)
+define MTD_ADD_MISSING_LINTL
+	$(SED) '/^LDLIBS_mkfs\.ubifs/ s/$$/ -lintl/' $(@D)/Makefile
+endef
+MTD_PRE_BUILD_HOOKS += MTD_ADD_MISSING_LINTL
+endif
 endif
 
 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#2 lore raw

PATCH 1/1 mtd: add missing -lintl from util-linux when building statically

Dear Baruch Siach,

Quoted 14 lines · Baruch Siach

Hi Vincent,

Quoted 10 lines · Vicente Olivert Riera

mtd depends on util-linux when BR2_PACKAGE_MTD_MKFSUBIFS is selected. Also, util-linux depends on gettext and will need to link with -lintl if BR2_NEEDS_GETTEXT_IF_LOCALE is selected. So, when mtd tries to link with util-linux's uuid (-luuid) it should add -lintl as well, but it fails when building statically. The uuid.pc file lists -lintl as one of the needed libraries, but since mtd package doesn't have a configure phase we can't do the following:

MTD_DEPENDENCIES += host-pkgconf
MTD_CONF_ENV += LIBS=$(PKG_CONFIG_HOST_BINARY) --libs uuid"

Quoted 6 lines

So why not something like:

MTD_MKFS_UBIFS_LIBS = $(PKG_CONFIG_HOST_BINARY) --libs uuid"

and use $(MTD_MKFS_UBIFS_LIBS) instead of hard coding -lintl in the sed expression.

do you mean like this?:

$(SED) '/^LDLIBS_mkfs\.ubifs/ s/$$/$$(MTD_MKFS_UBIFS_LIBS)/' $(@D)/Makefile

That will end up with the string "$(MTD_MKFS_UBIFS_LIBS)" written in the Makefile.

Quoted 1 line

This way you can remove the condition from the sed expression.

What condition? I don't what you mean Baruch, sorry.

If you provide a patch that it fixes the problem following a different approach, I would be happy to review it and test it.

Regards,

Vincent.

Quoted 41 lines

baruch

Quoted 37 lines

So, in further investigations I have seen that mtd hardcodes the libs for mkfs.ubifs in the Makefile, in a variable called LDLIBS_mkfs.ubifs, and that variable can't be overwritten by passing options or environment variables to make.

So, to fix the problem, we use a sed command to append -lintl to the LDLIBS_mkfs.ubifs variable only when building statically, because it's the case when it fails, and only when BR2_NEEDS_GETTEXT_IF_LOCALE is selected, because is the case when you also need -lintl when linking with util-linux.

Fixes:

http://autobuild.buildroot.net/results/2dd/2ddd714446d9eb75701bd48c117dc5bbbd291a76/

---
 package/mtd/mtd.mk |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
package/mtd/mtd.mk +6 -0
index 0fb9fc2..a34c840 100644
@@ -18,6 +18,12 @@ endif
 
 ifeq ($(BR2_PACKAGE_MTD_MKFSUBIFS),y)
 MTD_DEPENDENCIES += util-linux zlib lzo
+ifeq ($(BR2_STATIC_LIBS)$(BR2_NEEDS_GETTEXT_IF_LOCALE),yy)
+define MTD_ADD_MISSING_LINTL
+	$(SED) '/^LDLIBS_mkfs\.ubifs/ s/$$/ -lintl/' $(@D)/Makefile
+endef
+MTD_PRE_BUILD_HOOKS += MTD_ADD_MISSING_LINTL
+endif
 endif
 
 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
#3 lore raw

PATCH 1/1 mtd: add missing -lintl from util-linux when building statically

Hi Vincent,

Quoted 20 lines · Vicente Olivert Riera
Quoted 12 lines · Baruch Siach
Quoted 10 lines · Vicente Olivert Riera

mtd depends on util-linux when BR2_PACKAGE_MTD_MKFSUBIFS is selected. Also, util-linux depends on gettext and will need to link with -lintl if BR2_NEEDS_GETTEXT_IF_LOCALE is selected. So, when mtd tries to link with util-linux's uuid (-luuid) it should add -lintl as well, but it fails when building statically. The uuid.pc file lists -lintl as one of the needed libraries, but since mtd package doesn't have a configure phase we can't do the following:

MTD_DEPENDENCIES += host-pkgconf
MTD_CONF_ENV += LIBS=$(PKG_CONFIG_HOST_BINARY) --libs uuid"

Quoted 6 lines

So why not something like:

MTD_MKFS_UBIFS_LIBS = $(PKG_CONFIG_HOST_BINARY) --libs uuid"

and use $(MTD_MKFS_UBIFS_LIBS) instead of hard coding -lintl in the sed expression.

Quoted 6 lines

do you mean like this?:

$(SED) '/^LDLIBS_mkfs\.ubifs/ s/$$/$$(MTD_MKFS_UBIFS_LIBS)/' $(@D)/Makefile

That will end up with the string "$(MTD_MKFS_UBIFS_LIBS)" written in the Makefile.

What happens when you put a single $ in $(MTD_MKFS_UBIFS_LIBS)?

Quoted 3 lines
Quoted 1 line

This way you can remove the condition from the sed expression.

What condition? I don't what you mean Baruch, sorry.

The

   ifeq ($(BR2_STATIC_LIBS)$(BR2_NEEDS_GETTEXT_IF_LOCALE),yy)

condition. pkg-config should know the right answer in any case.

Quoted 2 lines

If you provide a patch that it fixes the problem following a different approach, I would be happy to review it and test it.

I'll try doing so in the evening, if you don't beat me to it.

baruch

Quoted 37 lines
Quoted 37 lines
Quoted 37 lines

So, in further investigations I have seen that mtd hardcodes the libs for mkfs.ubifs in the Makefile, in a variable called LDLIBS_mkfs.ubifs, and that variable can't be overwritten by passing options or environment variables to make.

So, to fix the problem, we use a sed command to append -lintl to the LDLIBS_mkfs.ubifs variable only when building statically, because it's the case when it fails, and only when BR2_NEEDS_GETTEXT_IF_LOCALE is selected, because is the case when you also need -lintl when linking with util-linux.

Fixes:

http://autobuild.buildroot.net/results/2dd/2ddd714446d9eb75701bd48c117dc5bbbd291a76/

---
 package/mtd/mtd.mk |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
package/mtd/mtd.mk +6 -0
index 0fb9fc2..a34c840 100644
@@ -18,6 +18,12 @@ endif
 
 ifeq ($(BR2_PACKAGE_MTD_MKFSUBIFS),y)
 MTD_DEPENDENCIES += util-linux zlib lzo
+ifeq ($(BR2_STATIC_LIBS)$(BR2_NEEDS_GETTEXT_IF_LOCALE),yy)
+define MTD_ADD_MISSING_LINTL
+	$(SED) '/^LDLIBS_mkfs\.ubifs/ s/$$/ -lintl/' $(@D)/Makefile
+endef
+MTD_PRE_BUILD_HOOKS += MTD_ADD_MISSING_LINTL
+endif
 endif
 
 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#4 lore raw

PATCH 1/1 mtd: add missing -lintl from util-linux when building statically

Dear Baruch Siach,

Quoted 23 lines · Baruch Siach

Hi Vincent,

Quoted 20 lines · Vicente Olivert Riera
Quoted 18 lines · Baruch Siach
Quoted 10 lines · Vicente Olivert Riera

mtd depends on util-linux when BR2_PACKAGE_MTD_MKFSUBIFS is selected. Also, util-linux depends on gettext and will need to link with -lintl if BR2_NEEDS_GETTEXT_IF_LOCALE is selected. So, when mtd tries to link with util-linux's uuid (-luuid) it should add -lintl as well, but it fails when building statically. The uuid.pc file lists -lintl as one of the needed libraries, but since mtd package doesn't have a configure phase we can't do the following:

MTD_DEPENDENCIES += host-pkgconf
MTD_CONF_ENV += LIBS=$(PKG_CONFIG_HOST_BINARY) --libs uuid"

So why not something like:

MTD_MKFS_UBIFS_LIBS = $(PKG_CONFIG_HOST_BINARY) --libs uuid"

and use $(MTD_MKFS_UBIFS_LIBS) instead of hard coding -lintl in the sed expression.

Quoted 8 lines
Quoted 6 lines

do you mean like this?:

$(SED) '/^LDLIBS_mkfs\.ubifs/ s/$$/$$(MTD_MKFS_UBIFS_LIBS)/' $(@D)/Makefile

That will end up with the string "$(MTD_MKFS_UBIFS_LIBS)" written in the Makefile.

What happens when you put a single $ in $(MTD_MKFS_UBIFS_LIBS)?

It fails with an error like this one:

Quoted 1 line
Quoted 1 line
Quoted 1 line

mtd 1.5.2 Building

/bin/sed -i -e '/^LDLIBS_mkfs\.ubifs/ s/$/ "/br/output/host/usr/bin/pkg-config --libs uuid"/' /br/output/build/mtd-1.5.2/Makefile
/bin/sed: -e expression #1, char 31: unknown option to `s'
make: *** [/br/output/build/mtd-1.5.2/.stamp_built] Error 1

Before sending this patch I already tried to put the result of the pkg-config command in a variable and use it in the sed command, and I faced both problems, having the variable name written in the Makefile, and this error I said above.

Regards,

Vincent.

Quoted 55 lines
Quoted 3 lines
Quoted 1 line

This way you can remove the condition from the sed expression.

What condition? I don't what you mean Baruch, sorry.

The

   ifeq ($(BR2_STATIC_LIBS)$(BR2_NEEDS_GETTEXT_IF_LOCALE),yy)

condition. pkg-config should know the right answer in any case.

Quoted 2 lines

If you provide a patch that it fixes the problem following a different approach, I would be happy to review it and test it.

I'll try doing so in the evening, if you don't beat me to it.

baruch

Quoted 37 lines
Quoted 37 lines
Quoted 37 lines

So, in further investigations I have seen that mtd hardcodes the libs for mkfs.ubifs in the Makefile, in a variable called LDLIBS_mkfs.ubifs, and that variable can't be overwritten by passing options or environment variables to make.

So, to fix the problem, we use a sed command to append -lintl to the LDLIBS_mkfs.ubifs variable only when building statically, because it's the case when it fails, and only when BR2_NEEDS_GETTEXT_IF_LOCALE is selected, because is the case when you also need -lintl when linking with util-linux.

Fixes:

http://autobuild.buildroot.net/results/2dd/2ddd714446d9eb75701bd48c117dc5bbbd291a76/

---
 package/mtd/mtd.mk |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
package/mtd/mtd.mk +6 -0
index 0fb9fc2..a34c840 100644
@@ -18,6 +18,12 @@ endif
 
 ifeq ($(BR2_PACKAGE_MTD_MKFSUBIFS),y)
 MTD_DEPENDENCIES += util-linux zlib lzo
+ifeq ($(BR2_STATIC_LIBS)$(BR2_NEEDS_GETTEXT_IF_LOCALE),yy)
+define MTD_ADD_MISSING_LINTL
+	$(SED) '/^LDLIBS_mkfs\.ubifs/ s/$$/ -lintl/' $(@D)/Makefile
+endef
+MTD_PRE_BUILD_HOOKS += MTD_ADD_MISSING_LINTL
+endif
 endif
 
 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
#5 lore raw

PATCH 1/1 mtd: add missing -lintl from util-linux when building statically

Hi Vincent,

Quoted 31 lines · Vicente Olivert Riera
Quoted 21 lines · Baruch Siach
Quoted 20 lines · Vicente Olivert Riera
Quoted 18 lines · Baruch Siach
Quoted 10 lines · Vicente Olivert Riera

mtd depends on util-linux when BR2_PACKAGE_MTD_MKFSUBIFS is selected. Also, util-linux depends on gettext and will need to link with -lintl if BR2_NEEDS_GETTEXT_IF_LOCALE is selected. So, when mtd tries to link with util-linux's uuid (-luuid) it should add -lintl as well, but it fails when building statically. The uuid.pc file lists -lintl as one of the needed libraries, but since mtd package doesn't have a configure phase we can't do the following:

MTD_DEPENDENCIES += host-pkgconf
MTD_CONF_ENV += LIBS=$(PKG_CONFIG_HOST_BINARY) --libs uuid"

So why not something like:

MTD_MKFS_UBIFS_LIBS = $(PKG_CONFIG_HOST_BINARY) --libs uuid"

and use $(MTD_MKFS_UBIFS_LIBS) instead of hard coding -lintl in the sed expression.

Quoted 8 lines
Quoted 6 lines

do you mean like this?:

$(SED) '/^LDLIBS_mkfs\.ubifs/ s/$$/$$(MTD_MKFS_UBIFS_LIBS)/' $(@D)/Makefile

That will end up with the string "$(MTD_MKFS_UBIFS_LIBS)" written in the Makefile.

What happens when you put a single $ in $(MTD_MKFS_UBIFS_LIBS)?

Quoted 8 lines

It fails with an error like this one:

Quoted 1 line
Quoted 1 line
Quoted 1 line

mtd 1.5.2 Building

/bin/sed -i -e '/^LDLIBS_mkfs\.ubifs/ s/$/ "/br/output/host/usr/bin/pkg-config --libs uuid"/' /br/output/build/mtd-1.5.2/Makefile
/bin/sed: -e expression #1, char 31: unknown option to `s'
make: *** [/br/output/build/mtd-1.5.2/.stamp_built] Error 1

The problem is that you need to use $(shell ...) when you want make to do command substitution. Also, since the output of pkg-config might include a library path with the '/' directory separator, you need to use a different character to delimit the sed 's' command. Please see
http://patchwork.ozlabs.org/patch/516419/ for my suggested solution.

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -