Re: [LEDE-DEV] [PATCH 1/5] tools/zlib: move zlib build to tools

2018-04-21 Thread Koen Vandeputte




Previously I mentioned the following issue on imx6 (ubi):

- Make owrt build
- Add custom files using imagebuilder
- Flash (jtag or tftp via uboot)
- Boot 1st time (all is OK)
- Boot 2nd time (custom files are corrupt now)


After testing this a few times using JTAG on the same board (which had a
repro rate of 100%) .. the issue seems fixed at first glance.
I wasn't able to reproduce it in the last 5 tests.

Interesting problem, this is fixed now with the v2 patches, so probably
with the update to version 2.0.2, but there are not so many changes in
there.
Judging the changes for ubi in the jump from 2.0.1 to 2.0.2,  I'm 
guessing V1 solved it.

I actually didn't test the V1 of the series due to the build error. :)




Thanks again for your work!

Koen

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH 1/5] tools/zlib: move zlib build to tools

2018-04-20 Thread Hauke Mehrtens
On 04/20/2018 01:10 PM, Koen Vandeputte wrote:
> 
> 
> On 2018-04-20 00:15, Hauke Mehrtens wrote:
>> On 04/18/2018 12:24 AM, Koen Vandeputte wrote:
> 
>> 
> 
 I tested the patch series because I have a linking problem with zlib
 and python an I wanted to see if this fixes it (it does not) but on
 i686 I have this error


 make[8]: Entering directory
 '/home/build/proxy/build_dir/hostpkg/glib-2.56.1/gio'
    CCLD libgio-2.0.la
 /usr/bin/ld: /home/build/proxy/staging_dir/host/lib/libz.a(deflate.o):
 relocation R_X86_64_PC32 against symbol `_length_code' can not be used
 when making a shared object; recompile with -fPIC
 /usr/bin/ld: final link failed: Bad value
 collect2: error: ld returned 1 exit status
 Makefile:2183: recipe for target 'libgio-2.0.la' failed


>>> Hi Hauke,
>>>
>>> Probably related to the above?
>>>
>>> When I'm building using this patch series, I'm getting a python build
>>> error.
>>> Please see attached logfile.
>>> Reverting the series fixes the build issue.
>>>
>>>
>>> Do note that I'm also using my own config, which adds all feeds and uses
>>> a lot more packages than default OpenWrt.
>>>
>>> Thanks,
>>>
>>> Koen
>> I am not able to reproduce this problem and it looks strange because you
>> have some compile problems related to OpenSSL functions.
>>
>> Can you provide me with a configuration which triggers this problem
>> please? Are you only using these 5 patches on top of master or do you
>> use also some other patches on top of master?
>>
>> Hauke
> Hi Hauke,
> 
> I'm currently testing the V2 series.
> The fpic addition fixes the build issues.
> 
> 
> Also,
> 
> Previously I mentioned the following issue on imx6 (ubi):
> 
> - Make owrt build
> - Add custom files using imagebuilder
> - Flash (jtag or tftp via uboot)
> - Boot 1st time (all is OK)
> - Boot 2nd time (custom files are corrupt now)
> 
> 
> After testing this a few times using JTAG on the same board (which had a
> repro rate of 100%) .. the issue seems fixed at first glance.
> I wasn't able to reproduce it in the last 5 tests.

Interesting problem, this is fixed now with the v2 patches, so probably
with the update to version 2.0.2, but there are not so many changes in
there.

> There are 2 warnings left:
> 
> WARNING: Makefile 'package/feeds/packages/python/Makefile' has a build
> dependency on 'zlib/host', which does not exist
> WARNING: Makefile 'package/feeds/packages/python3/Makefile' has a build
> dependency on 'zlib/host', which does not exist
> 
> 
> So when applying the series, an extra fix is probably needed in the
> package repo to get rid of the warnings.

I will take care of these later.

> Besides this, no regression seen so far ..

Thanks for testing.

Hauke

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH 1/5] tools/zlib: move zlib build to tools

2018-04-20 Thread Koen Vandeputte



On 2018-04-20 00:15, Hauke Mehrtens wrote:

On 04/18/2018 12:24 AM, Koen Vandeputte wrote:







I tested the patch series because I have a linking problem with zlib
and python an I wanted to see if this fixes it (it does not) but on
i686 I have this error


make[8]: Entering directory
'/home/build/proxy/build_dir/hostpkg/glib-2.56.1/gio'
   CCLD libgio-2.0.la
/usr/bin/ld: /home/build/proxy/staging_dir/host/lib/libz.a(deflate.o):
relocation R_X86_64_PC32 against symbol `_length_code' can not be used
when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Makefile:2183: recipe for target 'libgio-2.0.la' failed



Hi Hauke,

Probably related to the above?

When I'm building using this patch series, I'm getting a python build
error.
Please see attached logfile.
Reverting the series fixes the build issue.


Do note that I'm also using my own config, which adds all feeds and uses
a lot more packages than default OpenWrt.

Thanks,

Koen

I am not able to reproduce this problem and it looks strange because you
have some compile problems related to OpenSSL functions.

Can you provide me with a configuration which triggers this problem
please? Are you only using these 5 patches on top of master or do you
use also some other patches on top of master?

Hauke

Hi Hauke,

I'm currently testing the V2 series.
The fpic addition fixes the build issues.


Also,

Previously I mentioned the following issue on imx6 (ubi):

- Make owrt build
- Add custom files using imagebuilder
- Flash (jtag or tftp via uboot)
- Boot 1st time (all is OK)
- Boot 2nd time (custom files are corrupt now)


After testing this a few times using JTAG on the same board (which had a 
repro rate of 100%) .. the issue seems fixed at first glance.

I wasn't able to reproduce it in the last 5 tests.



There are 2 warnings left:

WARNING: Makefile 'package/feeds/packages/python/Makefile' has a build 
dependency on 'zlib/host', which does not exist
WARNING: Makefile 'package/feeds/packages/python3/Makefile' has a build 
dependency on 'zlib/host', which does not exist



So when applying the series, an extra fix is probably needed in the 
package repo to get rid of the warnings.


Besides this, no regression seen so far ..


Thank you for the efforts!

Koen

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH 1/5] tools/zlib: move zlib build to tools

2018-04-19 Thread Hauke Mehrtens
On 04/18/2018 09:44 AM, Lucian Cristian wrote:
> On 18.04.2018 01:24, Koen Vandeputte wrote:
>>
>>
>> On 17-04-18 19:16, Lucian Cristian wrote:
>>> On 16.04.2018 01:53, Hauke Mehrtens wrote:
 This allows us to link the other tools against our libz and we do not
 need the system zlib any more.

> [...]
 +endef
 +
 +$(eval $(call HostBuild))
>>>
>>> I tested the patch series because I have a linking problem with zlib
>>> and python an I wanted to see if this fixes it (it does not) but on
>>> i686 I have this error
>>>
>>>
>>> make[8]: Entering directory
>>> '/home/build/proxy/build_dir/hostpkg/glib-2.56.1/gio'
>>>   CCLD libgio-2.0.la
>>> /usr/bin/ld:
>>> /home/build/proxy/staging_dir/host/lib/libz.a(deflate.o): relocation
>>> R_X86_64_PC32 against symbol `_length_code' can not be used when
>>> making a shared object; recompile with -fPIC
>>> /usr/bin/ld: final link failed: Bad value
>>> collect2: error: ld returned 1 exit status
>>> Makefile:2183: recipe for target 'libgio-2.0.la' failed
>>>
>>>
>> Hi Hauke,
>>
>> Probably related to the above?
>>
>> When I'm building using this patch series, I'm getting a python build
>> error.
>> Please see attached logfile.
>> Reverting the series fixes the build issue.
>>
>>
>> Do note that I'm also using my own config, which adds all feeds and
>> uses a lot more packages than default OpenWrt.
>>
>> Thanks,
>>
>> Koen
> 
> /usr/bin/ld:
> /mnt/ramdisk/test/firmware/builds/generic_imx6/staging_dir/host/lib/libz.a(crc32.o):
> relocation R_X86_64_32S against `.rodata' can not be used when making a
> shared object; recompile with -fPIC
> /mnt/ramdisk/test/firmware/builds/generic_imx6/staging_dir/host/lib/libz.a:
> error adding symbols: Bad value
> collect2: error: ld returned 1 exit status
> 
> I looked in Makefile and there is TARGET_CFLAGS += $(FPIC) so it means
> it should already have -fPIC ?
> 

H,

I fixed the build error in glib2 by adding a -fPIC host cflag to the zlib.

Hauke

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH 1/5] tools/zlib: move zlib build to tools

2018-04-19 Thread Hauke Mehrtens
On 04/18/2018 12:24 AM, Koen Vandeputte wrote:
> 
> 
> On 17-04-18 19:16, Lucian Cristian wrote:
>> On 16.04.2018 01:53, Hauke Mehrtens wrote:
>>> This allows us to link the other tools against our libz and we do not
>>> need the system zlib any more.
>>>
>>> Only the static linked library is copied to the staging directory so we
>>> have a statically linked library on all systems and not only on Linux.
>>> This also adds the new dependencies of the packages which are depending
>>> on zlib.
>>>
>>> Signed-off-by: Hauke Mehrtens 
>>> ---
>>>   include/prereq-build.mk |  5 
>>>   package/libs/zlib/Makefile  |  2 --
>>>   tools/Makefile  | 14 +
>>>   tools/lzma-old/Makefile |  2 ++
>>>   tools/lzma-old/patches/120-add-cflags.patch | 11 +++
>>>   tools/make-ext4fs/Makefile  |  8 +
>>>   tools/make-ext4fs/patches/100-add-ldflags.patch | 11 +++
>>>   tools/squashfs4/Makefile    |  2 +-
>>>   tools/zlib/Makefile | 40
>>> +
>>>   9 files changed, 75 insertions(+), 20 deletions(-)
>>>   create mode 100644 tools/lzma-old/patches/120-add-cflags.patch
>>>   create mode 100644 tools/make-ext4fs/patches/100-add-ldflags.patch
>>>   create mode 100644 tools/zlib/Makefile
>>>
>>> diff --git a/include/prereq-build.mk b/include/prereq-build.mk
>>> index 6917716342..5b9a7e049d 100644
>>> --- a/include/prereq-build.mk
>>> +++ b/include/prereq-build.mk
>>> @@ -76,11 +76,6 @@ else
>>>     zlib_link_flags := -lz
>>>   endif
>>>   -$(eval $(call TestHostCommand,zlib, \
>>> -    Please install a static zlib. (Missing libz.a or zlib.h), \
>>> -    echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return
>>> 0; }' | \
>>> -    gcc -include zlib.h -x c -o $(TMP_DIR)/a.out -
>>> $(zlib_link_flags)))
>>> -
>>>   $(eval $(call TestHostCommand,perl-thread-queue, \
>>>   Please install the Perl Thread::Queue module, \
>>>   perl -MThread::Queue -e 1))
>>> diff --git a/package/libs/zlib/Makefile b/package/libs/zlib/Makefile
>>> index a7c61f7dd0..4a2a0e53b0 100644
>>> --- a/package/libs/zlib/Makefile
>>> +++ b/package/libs/zlib/Makefile
>>> @@ -21,7 +21,6 @@ PKG_CPE_ID:=cpe:/a:gnu:zlib
>>>     PKG_CONFIG_DEPENDS:= CONFIG_ZLIB_OPTIMIZE_SPEED
>>>   -include $(INCLUDE_DIR)/host-build.mk
>>>   include $(INCLUDE_DIR)/package.mk
>>>   include $(INCLUDE_DIR)/cmake.mk
>>>   @@ -95,6 +94,5 @@ define Package/zlib-dev/install
>>>     $(1)/usr/lib/pkgconfig/
>>>   endef
>>>   -$(eval $(call HostBuild))
>>>   $(eval $(call BuildPackage,zlib))
>>>   $(eval $(call BuildPackage,zlib-dev))
>>> diff --git a/tools/Makefile b/tools/Makefile
>>> index 50bd552d75..8dfab9892b 100644
>>> --- a/tools/Makefile
>>> +++ b/tools/Makefile
>>> @@ -22,7 +22,7 @@ ifneq
>>> ($(CONFIG_SDK)$(CONFIG_PACKAGE_kmod-b43)$(CONFIG_PACKAGE_b43legacy-firmwar
>>>
>>>   endif
>>>     tools-$(BUILD_TOOLCHAIN) += gmp mpfr mpc libelf expat
>>> -tools-y += m4 libtool autoconf automake flex bison pkg-config mklibs
>>> +tools-y += m4 libtool autoconf automake flex bison pkg-config mklibs
>>> zlib
>>>   tools-y += sstrip make-ext4fs e2fsprogs mtd-utils mkimage
>>>   tools-y += firmware-utils patch-image quilt padjffs2
>>>   tools-y += mm-macros missing-macros cmake scons bc findutils
>>> gengetopt patchelf
>>> @@ -43,16 +43,16 @@ $(curdir)/bison/compile := $(curdir)/flex/compile
>>>   $(curdir)/flex/compile := $(curdir)/libtool/compile
>>>   $(curdir)/libtool/compile := $(curdir)/m4/compile
>>> $(curdir)/autoconf/compile $(curdir)/automake/compile
>>> $(curdir)/missing-macros/compile
>>>   $(curdir)/squashfs/compile := $(curdir)/lzma-old/compile
>>> -$(curdir)/squashfs4/compile := $(curdir)/xz/compile
>>> +$(curdir)/squashfs4/compile := $(curdir)/xz/compile
>>> $(curdir)/zlib/compile
>>>   $(curdir)/quilt/compile := $(curdir)/autoconf/compile
>>> $(curdir)/findutils/compile
>>>   $(curdir)/autoconf/compile := $(curdir)/m4/compile
>>>   $(curdir)/automake/compile := $(curdir)/m4/compile
>>> $(curdir)/autoconf/compile $(curdir)/pkg-config/compile
>>> $(curdir)/xz/compile
>>>   $(curdir)/gmp/compile := $(curdir)/libtool/compile
>>>   $(curdir)/mpc/compile := $(curdir)/mpfr/compile $(curdir)/gmp/compile
>>>   $(curdir)/mpfr/compile := $(curdir)/gmp/compile
>>> -$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/compile
>>> +$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/compile
>>> $(curdir)/zlib/compile
>>>   $(curdir)/mklibs/compile := $(curdir)/libtool/compile
>>> -$(curdir)/qemu/compile := $(curdir)/e2fsprogs/compile
>>> +$(curdir)/qemu/compile := $(curdir)/e2fsprogs/compile
>>> $(curdir)/zlib/compile
>>>   $(curdir)/upslug2/compile := $(curdir)/libtool/compile
>>>   $(curdir)/mm-macros/compile := $(curdir)/libtool/compile
>>>   $(curdir)/missing-macros/compile := $(curdir)/autoconf/compile
>>> @@ -69,8 +69,12 @@ 

Re: [LEDE-DEV] [PATCH 1/5] tools/zlib: move zlib build to tools

2018-04-18 Thread Lucian Cristian

On 18.04.2018 01:24, Koen Vandeputte wrote:



On 17-04-18 19:16, Lucian Cristian wrote:

On 16.04.2018 01:53, Hauke Mehrtens wrote:

This allows us to link the other tools against our libz and we do not
need the system zlib any more.


[...]

+endef
+
+$(eval $(call HostBuild))


I tested the patch series because I have a linking problem with zlib 
and python an I wanted to see if this fixes it (it does not) but on 
i686 I have this error



make[8]: Entering directory 
'/home/build/proxy/build_dir/hostpkg/glib-2.56.1/gio'

  CCLD libgio-2.0.la
/usr/bin/ld: 
/home/build/proxy/staging_dir/host/lib/libz.a(deflate.o): relocation 
R_X86_64_PC32 against symbol `_length_code' can not be used when 
making a shared object; recompile with -fPIC

/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Makefile:2183: recipe for target 'libgio-2.0.la' failed



Hi Hauke,

Probably related to the above?

When I'm building using this patch series, I'm getting a python build 
error.

Please see attached logfile.
Reverting the series fixes the build issue.


Do note that I'm also using my own config, which adds all feeds and 
uses a lot more packages than default OpenWrt.


Thanks,

Koen


/usr/bin/ld: 
/mnt/ramdisk/test/firmware/builds/generic_imx6/staging_dir/host/lib/libz.a(crc32.o):
 relocation R_X86_64_32S against `.rodata' can not be used when making a shared 
object; recompile with -fPIC
/mnt/ramdisk/test/firmware/builds/generic_imx6/staging_dir/host/lib/libz.a: 
error adding symbols: Bad value
collect2: error: ld returned 1 exit status

I looked in Makefile and there is TARGET_CFLAGS += $(FPIC) so it means 
it should already have -fPIC ?



Regards


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH 1/5] tools/zlib: move zlib build to tools

2018-04-17 Thread Koen Vandeputte



On 17-04-18 19:16, Lucian Cristian wrote:

On 16.04.2018 01:53, Hauke Mehrtens wrote:

This allows us to link the other tools against our libz and we do not
need the system zlib any more.

Only the static linked library is copied to the staging directory so we
have a statically linked library on all systems and not only on Linux.
This also adds the new dependencies of the packages which are depending
on zlib.

Signed-off-by: Hauke Mehrtens 
---
  include/prereq-build.mk |  5 
  package/libs/zlib/Makefile  |  2 --
  tools/Makefile  | 14 +
  tools/lzma-old/Makefile |  2 ++
  tools/lzma-old/patches/120-add-cflags.patch | 11 +++
  tools/make-ext4fs/Makefile  |  8 +
  tools/make-ext4fs/patches/100-add-ldflags.patch | 11 +++
  tools/squashfs4/Makefile    |  2 +-
  tools/zlib/Makefile | 40 
+

  9 files changed, 75 insertions(+), 20 deletions(-)
  create mode 100644 tools/lzma-old/patches/120-add-cflags.patch
  create mode 100644 tools/make-ext4fs/patches/100-add-ldflags.patch
  create mode 100644 tools/zlib/Makefile

diff --git a/include/prereq-build.mk b/include/prereq-build.mk
index 6917716342..5b9a7e049d 100644
--- a/include/prereq-build.mk
+++ b/include/prereq-build.mk
@@ -76,11 +76,6 @@ else
    zlib_link_flags := -lz
  endif
  -$(eval $(call TestHostCommand,zlib, \
-    Please install a static zlib. (Missing libz.a or zlib.h), \
-    echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 
0; }' | \
-    gcc -include zlib.h -x c -o $(TMP_DIR)/a.out - 
$(zlib_link_flags)))

-
  $(eval $(call TestHostCommand,perl-thread-queue, \
  Please install the Perl Thread::Queue module, \
  perl -MThread::Queue -e 1))
diff --git a/package/libs/zlib/Makefile b/package/libs/zlib/Makefile
index a7c61f7dd0..4a2a0e53b0 100644
--- a/package/libs/zlib/Makefile
+++ b/package/libs/zlib/Makefile
@@ -21,7 +21,6 @@ PKG_CPE_ID:=cpe:/a:gnu:zlib
    PKG_CONFIG_DEPENDS:= CONFIG_ZLIB_OPTIMIZE_SPEED
  -include $(INCLUDE_DIR)/host-build.mk
  include $(INCLUDE_DIR)/package.mk
  include $(INCLUDE_DIR)/cmake.mk
  @@ -95,6 +94,5 @@ define Package/zlib-dev/install
    $(1)/usr/lib/pkgconfig/
  endef
  -$(eval $(call HostBuild))
  $(eval $(call BuildPackage,zlib))
  $(eval $(call BuildPackage,zlib-dev))
diff --git a/tools/Makefile b/tools/Makefile
index 50bd552d75..8dfab9892b 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -22,7 +22,7 @@ ifneq 
($(CONFIG_SDK)$(CONFIG_PACKAGE_kmod-b43)$(CONFIG_PACKAGE_b43legacy-firmwar

  endif
    tools-$(BUILD_TOOLCHAIN) += gmp mpfr mpc libelf expat
-tools-y += m4 libtool autoconf automake flex bison pkg-config mklibs
+tools-y += m4 libtool autoconf automake flex bison pkg-config mklibs 
zlib

  tools-y += sstrip make-ext4fs e2fsprogs mtd-utils mkimage
  tools-y += firmware-utils patch-image quilt padjffs2
  tools-y += mm-macros missing-macros cmake scons bc findutils 
gengetopt patchelf

@@ -43,16 +43,16 @@ $(curdir)/bison/compile := $(curdir)/flex/compile
  $(curdir)/flex/compile := $(curdir)/libtool/compile
  $(curdir)/libtool/compile := $(curdir)/m4/compile 
$(curdir)/autoconf/compile $(curdir)/automake/compile 
$(curdir)/missing-macros/compile

  $(curdir)/squashfs/compile := $(curdir)/lzma-old/compile
-$(curdir)/squashfs4/compile := $(curdir)/xz/compile
+$(curdir)/squashfs4/compile := $(curdir)/xz/compile 
$(curdir)/zlib/compile
  $(curdir)/quilt/compile := $(curdir)/autoconf/compile 
$(curdir)/findutils/compile

  $(curdir)/autoconf/compile := $(curdir)/m4/compile
  $(curdir)/automake/compile := $(curdir)/m4/compile 
$(curdir)/autoconf/compile $(curdir)/pkg-config/compile 
$(curdir)/xz/compile

  $(curdir)/gmp/compile := $(curdir)/libtool/compile
  $(curdir)/mpc/compile := $(curdir)/mpfr/compile $(curdir)/gmp/compile
  $(curdir)/mpfr/compile := $(curdir)/gmp/compile
-$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/compile
+$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/compile 
$(curdir)/zlib/compile

  $(curdir)/mklibs/compile := $(curdir)/libtool/compile
-$(curdir)/qemu/compile := $(curdir)/e2fsprogs/compile
+$(curdir)/qemu/compile := $(curdir)/e2fsprogs/compile 
$(curdir)/zlib/compile

  $(curdir)/upslug2/compile := $(curdir)/libtool/compile
  $(curdir)/mm-macros/compile := $(curdir)/libtool/compile
  $(curdir)/missing-macros/compile := $(curdir)/autoconf/compile
@@ -69,8 +69,12 @@ $(curdir)/patchelf/compile := 
$(curdir)/libtool/compile
  $(curdir)/dosfstools/compile := $(curdir)/autoconf/compile 
$(curdir)/automake/compile

  $(curdir)/libressl/compile := $(curdir)/pkg-config/compile
  $(curdir)/mkimage/compile += $(curdir)/libressl/compile
-$(curdir)/firmware-utils/compile += $(curdir)/libressl/compile
+$(curdir)/firmware-utils/compile += $(curdir)/libressl/compile 
$(curdir)/zlib/compile

  $(curdir)/cmake/compile += 

Re: [LEDE-DEV] [PATCH 1/5] tools/zlib: move zlib build to tools

2018-04-17 Thread Lucian Cristian

On 16.04.2018 01:53, Hauke Mehrtens wrote:

This allows us to link the other tools against our libz and we do not
need the system zlib any more.

Only the static linked library is copied to the staging directory so we
have a statically linked library on all systems and not only on Linux.
This also adds the new dependencies of the packages which are depending
on zlib.

Signed-off-by: Hauke Mehrtens 
---
  include/prereq-build.mk |  5 
  package/libs/zlib/Makefile  |  2 --
  tools/Makefile  | 14 +
  tools/lzma-old/Makefile |  2 ++
  tools/lzma-old/patches/120-add-cflags.patch | 11 +++
  tools/make-ext4fs/Makefile  |  8 +
  tools/make-ext4fs/patches/100-add-ldflags.patch | 11 +++
  tools/squashfs4/Makefile|  2 +-
  tools/zlib/Makefile | 40 +
  9 files changed, 75 insertions(+), 20 deletions(-)
  create mode 100644 tools/lzma-old/patches/120-add-cflags.patch
  create mode 100644 tools/make-ext4fs/patches/100-add-ldflags.patch
  create mode 100644 tools/zlib/Makefile

diff --git a/include/prereq-build.mk b/include/prereq-build.mk
index 6917716342..5b9a7e049d 100644
--- a/include/prereq-build.mk
+++ b/include/prereq-build.mk
@@ -76,11 +76,6 @@ else
zlib_link_flags := -lz
  endif
  
-$(eval $(call TestHostCommand,zlib, \

-   Please install a static zlib. (Missing libz.a or zlib.h), \
-   echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' 
| \
-   gcc -include zlib.h -x c -o $(TMP_DIR)/a.out - 
$(zlib_link_flags)))
-
  $(eval $(call TestHostCommand,perl-thread-queue, \
Please install the Perl Thread::Queue module, \
perl -MThread::Queue -e 1))
diff --git a/package/libs/zlib/Makefile b/package/libs/zlib/Makefile
index a7c61f7dd0..4a2a0e53b0 100644
--- a/package/libs/zlib/Makefile
+++ b/package/libs/zlib/Makefile
@@ -21,7 +21,6 @@ PKG_CPE_ID:=cpe:/a:gnu:zlib
  
  PKG_CONFIG_DEPENDS:= CONFIG_ZLIB_OPTIMIZE_SPEED
  
-include $(INCLUDE_DIR)/host-build.mk

  include $(INCLUDE_DIR)/package.mk
  include $(INCLUDE_DIR)/cmake.mk
  
@@ -95,6 +94,5 @@ define Package/zlib-dev/install

  $(1)/usr/lib/pkgconfig/
  endef
  
-$(eval $(call HostBuild))

  $(eval $(call BuildPackage,zlib))
  $(eval $(call BuildPackage,zlib-dev))
diff --git a/tools/Makefile b/tools/Makefile
index 50bd552d75..8dfab9892b 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -22,7 +22,7 @@ ifneq 
($(CONFIG_SDK)$(CONFIG_PACKAGE_kmod-b43)$(CONFIG_PACKAGE_b43legacy-firmwar
  endif
  
  tools-$(BUILD_TOOLCHAIN) += gmp mpfr mpc libelf expat

-tools-y += m4 libtool autoconf automake flex bison pkg-config mklibs
+tools-y += m4 libtool autoconf automake flex bison pkg-config mklibs zlib
  tools-y += sstrip make-ext4fs e2fsprogs mtd-utils mkimage
  tools-y += firmware-utils patch-image quilt padjffs2
  tools-y += mm-macros missing-macros cmake scons bc findutils gengetopt 
patchelf
@@ -43,16 +43,16 @@ $(curdir)/bison/compile := $(curdir)/flex/compile
  $(curdir)/flex/compile := $(curdir)/libtool/compile
  $(curdir)/libtool/compile := $(curdir)/m4/compile $(curdir)/autoconf/compile 
$(curdir)/automake/compile $(curdir)/missing-macros/compile
  $(curdir)/squashfs/compile := $(curdir)/lzma-old/compile
-$(curdir)/squashfs4/compile := $(curdir)/xz/compile
+$(curdir)/squashfs4/compile := $(curdir)/xz/compile $(curdir)/zlib/compile
  $(curdir)/quilt/compile := $(curdir)/autoconf/compile 
$(curdir)/findutils/compile
  $(curdir)/autoconf/compile := $(curdir)/m4/compile
  $(curdir)/automake/compile := $(curdir)/m4/compile $(curdir)/autoconf/compile 
$(curdir)/pkg-config/compile $(curdir)/xz/compile
  $(curdir)/gmp/compile := $(curdir)/libtool/compile
  $(curdir)/mpc/compile := $(curdir)/mpfr/compile $(curdir)/gmp/compile
  $(curdir)/mpfr/compile := $(curdir)/gmp/compile
-$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/compile
+$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/compile 
$(curdir)/zlib/compile
  $(curdir)/mklibs/compile := $(curdir)/libtool/compile
-$(curdir)/qemu/compile := $(curdir)/e2fsprogs/compile
+$(curdir)/qemu/compile := $(curdir)/e2fsprogs/compile $(curdir)/zlib/compile
  $(curdir)/upslug2/compile := $(curdir)/libtool/compile
  $(curdir)/mm-macros/compile := $(curdir)/libtool/compile
  $(curdir)/missing-macros/compile := $(curdir)/autoconf/compile
@@ -69,8 +69,12 @@ $(curdir)/patchelf/compile := $(curdir)/libtool/compile
  $(curdir)/dosfstools/compile := $(curdir)/autoconf/compile 
$(curdir)/automake/compile
  $(curdir)/libressl/compile := $(curdir)/pkg-config/compile
  $(curdir)/mkimage/compile += $(curdir)/libressl/compile
-$(curdir)/firmware-utils/compile += $(curdir)/libressl/compile
+$(curdir)/firmware-utils/compile += $(curdir)/libressl/compile 
$(curdir)/zlib/compile
  $(curdir)/cmake/compile += $(curdir)/libressl/compile

[LEDE-DEV] [PATCH 1/5] tools/zlib: move zlib build to tools

2018-04-15 Thread Hauke Mehrtens
This allows us to link the other tools against our libz and we do not
need the system zlib any more.

Only the static linked library is copied to the staging directory so we
have a statically linked library on all systems and not only on Linux.
This also adds the new dependencies of the packages which are depending
on zlib.

Signed-off-by: Hauke Mehrtens 
---
 include/prereq-build.mk |  5 
 package/libs/zlib/Makefile  |  2 --
 tools/Makefile  | 14 +
 tools/lzma-old/Makefile |  2 ++
 tools/lzma-old/patches/120-add-cflags.patch | 11 +++
 tools/make-ext4fs/Makefile  |  8 +
 tools/make-ext4fs/patches/100-add-ldflags.patch | 11 +++
 tools/squashfs4/Makefile|  2 +-
 tools/zlib/Makefile | 40 +
 9 files changed, 75 insertions(+), 20 deletions(-)
 create mode 100644 tools/lzma-old/patches/120-add-cflags.patch
 create mode 100644 tools/make-ext4fs/patches/100-add-ldflags.patch
 create mode 100644 tools/zlib/Makefile

diff --git a/include/prereq-build.mk b/include/prereq-build.mk
index 6917716342..5b9a7e049d 100644
--- a/include/prereq-build.mk
+++ b/include/prereq-build.mk
@@ -76,11 +76,6 @@ else
   zlib_link_flags := -lz
 endif
 
-$(eval $(call TestHostCommand,zlib, \
-   Please install a static zlib. (Missing libz.a or zlib.h), \
-   echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' 
| \
-   gcc -include zlib.h -x c -o $(TMP_DIR)/a.out - 
$(zlib_link_flags)))
-
 $(eval $(call TestHostCommand,perl-thread-queue, \
Please install the Perl Thread::Queue module, \
perl -MThread::Queue -e 1))
diff --git a/package/libs/zlib/Makefile b/package/libs/zlib/Makefile
index a7c61f7dd0..4a2a0e53b0 100644
--- a/package/libs/zlib/Makefile
+++ b/package/libs/zlib/Makefile
@@ -21,7 +21,6 @@ PKG_CPE_ID:=cpe:/a:gnu:zlib
 
 PKG_CONFIG_DEPENDS:= CONFIG_ZLIB_OPTIMIZE_SPEED
 
-include $(INCLUDE_DIR)/host-build.mk
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/cmake.mk
 
@@ -95,6 +94,5 @@ define Package/zlib-dev/install
  $(1)/usr/lib/pkgconfig/
 endef
 
-$(eval $(call HostBuild))
 $(eval $(call BuildPackage,zlib))
 $(eval $(call BuildPackage,zlib-dev))
diff --git a/tools/Makefile b/tools/Makefile
index 50bd552d75..8dfab9892b 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -22,7 +22,7 @@ ifneq 
($(CONFIG_SDK)$(CONFIG_PACKAGE_kmod-b43)$(CONFIG_PACKAGE_b43legacy-firmwar
 endif
 
 tools-$(BUILD_TOOLCHAIN) += gmp mpfr mpc libelf expat
-tools-y += m4 libtool autoconf automake flex bison pkg-config mklibs
+tools-y += m4 libtool autoconf automake flex bison pkg-config mklibs zlib
 tools-y += sstrip make-ext4fs e2fsprogs mtd-utils mkimage
 tools-y += firmware-utils patch-image quilt padjffs2
 tools-y += mm-macros missing-macros cmake scons bc findutils gengetopt patchelf
@@ -43,16 +43,16 @@ $(curdir)/bison/compile := $(curdir)/flex/compile
 $(curdir)/flex/compile := $(curdir)/libtool/compile
 $(curdir)/libtool/compile := $(curdir)/m4/compile $(curdir)/autoconf/compile 
$(curdir)/automake/compile $(curdir)/missing-macros/compile
 $(curdir)/squashfs/compile := $(curdir)/lzma-old/compile
-$(curdir)/squashfs4/compile := $(curdir)/xz/compile
+$(curdir)/squashfs4/compile := $(curdir)/xz/compile $(curdir)/zlib/compile
 $(curdir)/quilt/compile := $(curdir)/autoconf/compile 
$(curdir)/findutils/compile
 $(curdir)/autoconf/compile := $(curdir)/m4/compile
 $(curdir)/automake/compile := $(curdir)/m4/compile $(curdir)/autoconf/compile 
$(curdir)/pkg-config/compile $(curdir)/xz/compile
 $(curdir)/gmp/compile := $(curdir)/libtool/compile
 $(curdir)/mpc/compile := $(curdir)/mpfr/compile $(curdir)/gmp/compile
 $(curdir)/mpfr/compile := $(curdir)/gmp/compile
-$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/compile
+$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/compile 
$(curdir)/zlib/compile
 $(curdir)/mklibs/compile := $(curdir)/libtool/compile
-$(curdir)/qemu/compile := $(curdir)/e2fsprogs/compile
+$(curdir)/qemu/compile := $(curdir)/e2fsprogs/compile $(curdir)/zlib/compile
 $(curdir)/upslug2/compile := $(curdir)/libtool/compile
 $(curdir)/mm-macros/compile := $(curdir)/libtool/compile
 $(curdir)/missing-macros/compile := $(curdir)/autoconf/compile
@@ -69,8 +69,12 @@ $(curdir)/patchelf/compile := $(curdir)/libtool/compile
 $(curdir)/dosfstools/compile := $(curdir)/autoconf/compile 
$(curdir)/automake/compile
 $(curdir)/libressl/compile := $(curdir)/pkg-config/compile
 $(curdir)/mkimage/compile += $(curdir)/libressl/compile
-$(curdir)/firmware-utils/compile += $(curdir)/libressl/compile
+$(curdir)/firmware-utils/compile += $(curdir)/libressl/compile 
$(curdir)/zlib/compile
 $(curdir)/cmake/compile += $(curdir)/libressl/compile
+$(curdir)/zlib/compile := $(curdir)/cmake/compile
+$(curdir)/wrt350nv2-builder/compile := $(curdir)/zlib/compile