Merge pull request #573 from stilor/add-libz-companion-lib

Add zlib as a companion lib
This commit is contained in:
Alexey Neyman 2017-02-05 20:41:46 -08:00 committed by GitHub
commit df7579f205
16 changed files with 448 additions and 9 deletions

View File

@ -2,6 +2,10 @@
if ARCH_BINFMT_FLAT
config ELF2FLT_REQUIRES_ZLIB
def_bool y
select ZLIB
comment "elf2flt"
choice

View File

@ -81,6 +81,9 @@ config CC_GCC_SYSTEM_ZLIB
help
Do not use bundled zlib, and use the zlib already available for
the host (eg. the system library).
If zlib is built as a companion library, selecting this option
will use it.
If you want to build a static toolchain, you will need to also
install the static version of zlib for your host.

View File

@ -119,6 +119,12 @@ config NCURSES
config NCURSES_TARGET
bool
config ZLIB
bool "Build local zlib"
if ZLIB
source "config/companion_libs/zlib.in"
endif
if LIBICONV
source "config/companion_libs/libiconv.in"
endif

View File

@ -0,0 +1,19 @@
# Zlib options
choice
bool
prompt "zlib version"
# Don't remove next line
# CT_INSERT_VERSION_BELOW
config ZLIB_V_1_2_11
bool
prompt "1.2.11"
endchoice
config ZLIB_VERSION
string
# Don't remove next line
# CT_INSERT_VERSION_STRING_BELOW
default "1.2.11" if ZLIB_V_1_2_11

View File

@ -0,0 +1,294 @@
From 9848b4f5b207d762a75d6cf0ccbb59c6486a1616 Mon Sep 17 00:00:00 2001
From: Alexey Neyman <stilor@att.net>
Date: Fri, 3 Feb 2017 22:01:48 -0800
Subject: [PATCH] Check for libz first
If building statically, linking libz before libbfd results in unresolved symbols
(compress/compressBound in libbfd.a).
Signed-off-by: Alexey Neyman <stilor@att.net>
---
configure | 108 +++++++++++++++++++++++++++++++++--------------------------
configure.ac | 10 +++---
2 files changed, 65 insertions(+), 53 deletions(-)
diff --git a/configure b/configure
index d8d14be..df612cb 100755
--- a/configure
+++ b/configure
@@ -675,6 +675,7 @@ infodir
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -758,6 +759,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}'
@@ -1010,6 +1012,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1147,7 +1158,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1300,6 +1311,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -3779,14 +3791,14 @@ if test "$ac_binutils_build_dir" != "NONE"; then
test "$ac_binutils_include_dir" = "NONE" && ac_binutils_include_dir="$ac_binutils_build_dir/include"
fi
-if test "$ac_libiberty" = "NONE"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objalloc_create in -liberty" >&5
-$as_echo_n "checking for objalloc_create in -liberty... " >&6; }
-if ${ac_cv_lib_iberty_objalloc_create+:} false; then :
+if test "$ac_zlib_prefix" = "NONE"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for deflate in -lz" >&5
+$as_echo_n "checking for deflate in -lz... " >&6; }
+if ${ac_cv_lib_z_deflate+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
-LIBS="-liberty $LIBS"
+LIBS="-lz $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -3796,47 +3808,46 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus
extern "C"
#endif
-char objalloc_create ();
+char deflate ();
int
main ()
{
-return objalloc_create ();
+return deflate ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_iberty_objalloc_create=yes
+ ac_cv_lib_z_deflate=yes
else
- ac_cv_lib_iberty_objalloc_create=no
+ ac_cv_lib_z_deflate=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iberty_objalloc_create" >&5
-$as_echo "$ac_cv_lib_iberty_objalloc_create" >&6; }
-if test "x$ac_cv_lib_iberty_objalloc_create" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_deflate" >&5
+$as_echo "$ac_cv_lib_z_deflate" >&6; }
+if test "x$ac_cv_lib_z_deflate" = xyes; then :
cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBIBERTY 1
+#define HAVE_LIBZ 1
_ACEOF
- LIBS="-liberty $LIBS"
+ LIBS="-lz $LIBS"
fi
- ac_libiberty=auto
else
- LIBS="$ac_libiberty $LIBS"
+ LIBS="-L$ac_zlib_prefix/lib -lz $LIBS"
fi
-if test "$ac_libbfd" = "NONE"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bfd_openr in -lbfd" >&5
-$as_echo_n "checking for bfd_openr in -lbfd... " >&6; }
-if ${ac_cv_lib_bfd_bfd_openr+:} false; then :
+if test "$ac_libiberty" = "NONE"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objalloc_create in -liberty" >&5
+$as_echo_n "checking for objalloc_create in -liberty... " >&6; }
+if ${ac_cv_lib_iberty_objalloc_create+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
-LIBS="-lbfd $LIBS"
+LIBS="-liberty $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -3846,47 +3857,47 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus
extern "C"
#endif
-char bfd_openr ();
+char objalloc_create ();
int
main ()
{
-return bfd_openr ();
+return objalloc_create ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_bfd_bfd_openr=yes
+ ac_cv_lib_iberty_objalloc_create=yes
else
- ac_cv_lib_bfd_bfd_openr=no
+ ac_cv_lib_iberty_objalloc_create=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bfd_bfd_openr" >&5
-$as_echo "$ac_cv_lib_bfd_bfd_openr" >&6; }
-if test "x$ac_cv_lib_bfd_bfd_openr" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iberty_objalloc_create" >&5
+$as_echo "$ac_cv_lib_iberty_objalloc_create" >&6; }
+if test "x$ac_cv_lib_iberty_objalloc_create" = xyes; then :
cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBBFD 1
+#define HAVE_LIBIBERTY 1
_ACEOF
- LIBS="-lbfd $LIBS"
+ LIBS="-liberty $LIBS"
fi
- ac_libbfd=auto
+ ac_libiberty=auto
else
- LIBS="$ac_libbfd $LIBS"
+ LIBS="$ac_libiberty $LIBS"
fi
-if test "$ac_zlib_prefix" = "NONE"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for deflate in -lz" >&5
-$as_echo_n "checking for deflate in -lz... " >&6; }
-if ${ac_cv_lib_z_deflate+:} false; then :
+if test "$ac_libbfd" = "NONE"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bfd_openr in -lbfd" >&5
+$as_echo_n "checking for bfd_openr in -lbfd... " >&6; }
+if ${ac_cv_lib_bfd_bfd_openr+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
-LIBS="-lz $LIBS"
+LIBS="-lbfd $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -3896,37 +3907,38 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus
extern "C"
#endif
-char deflate ();
+char bfd_openr ();
int
main ()
{
-return deflate ();
+return bfd_openr ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_z_deflate=yes
+ ac_cv_lib_bfd_bfd_openr=yes
else
- ac_cv_lib_z_deflate=no
+ ac_cv_lib_bfd_bfd_openr=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_deflate" >&5
-$as_echo "$ac_cv_lib_z_deflate" >&6; }
-if test "x$ac_cv_lib_z_deflate" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bfd_bfd_openr" >&5
+$as_echo "$ac_cv_lib_bfd_bfd_openr" >&6; }
+if test "x$ac_cv_lib_bfd_bfd_openr" = xyes; then :
cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBZ 1
+#define HAVE_LIBBFD 1
_ACEOF
- LIBS="-lz $LIBS"
+ LIBS="-lbfd $LIBS"
fi
+ ac_libbfd=auto
else
- LIBS="-L$ac_zlib_prefix/lib -lz $LIBS"
+ LIBS="$ac_libbfd $LIBS"
fi
bfd_include_dir=
diff --git a/configure.ac b/configure.ac
index dcf0f92..7dcc082 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,6 +114,11 @@ if test "$ac_binutils_build_dir" != "NONE"; then
fi
dnl Checks for libraries.
+if test "$ac_zlib_prefix" = "NONE"; then
+ AC_CHECK_LIB(z, deflate)
+else
+ LIBS="-L$ac_zlib_prefix/lib -lz $LIBS"
+fi
if test "$ac_libiberty" = "NONE"; then
AC_CHECK_LIB(iberty, objalloc_create)
ac_libiberty=auto
@@ -126,11 +131,6 @@ if test "$ac_libbfd" = "NONE"; then
else
LIBS="$ac_libbfd $LIBS"
fi
-if test "$ac_zlib_prefix" = "NONE"; then
- AC_CHECK_LIB(z, deflate)
-else
- LIBS="-L$ac_zlib_prefix/lib -lz $LIBS"
-fi
bfd_include_dir=
if test "$ac_bfd_include_dir" != "NONE"; then
--
2.9.3

View File

@ -0,0 +1,7 @@
CT_ARCH_m68k=y
CT_CANADIAN=y
CT_HOST="powerpc-unknown-linux-uclibc"
CT_KERNEL_linux=y
CT_THREADS_LT=y
# CT_LIBICONV is not set
# CT_GETTEXT is not set

View File

@ -0,0 +1,3 @@
reporter_name="Alexey Neyman"
reporter_url=""
reporter_comment="Sample configuration with canadian cross & elf2flt."

View File

@ -18,7 +18,7 @@ doHelp() {
'tool' in one of:
gcc, binutils, glibc, uClibc, uClibc-ng, newlib, linux, gdb,
duma, strace, ltrace, libelf, gmp, mpfr, isl, cloog, mpc,
mingw-w64, expat, ncurses, musl, gettext
mingw-w64, expat, ncurses, musl, gettext, zlib
Valid options for all tools:
--stable, -s, +x (default)
@ -210,6 +210,7 @@ while [ $# -gt 0 ]; do
--expat) EXP=; OBS=; cat=EXPAT; tool=expat; tool_prefix=companion_libs; dot2suffix=;;
--ncurses) EXP=; OBS=; cat=NCURSES; tool=ncurses; tool_prefix=companion_libs; dot2suffix=;;
--gettext) EXP=; OBS=; cat=GETTEXT; tool=gettext; tool_prefix=companion_libs; dot2suffix=;;
--zlib) EXP=; OBS=; cat=ZLIB; tool=zlib; tool_prefix=companion_tools; dot2suffix=;;
--make) EXP=; OBS=; cat=MAKE; tool=make; tool_prefix=companion_tools; dot2suffix=;;
--m4) EXP=; OBS=; cat=M4; tool=m4; tool_prefix=companion_tools; dot2suffix=;;
--autoconf) EXP=; OBS=; cat=AUTOCONF; tool=autoconf; tool_prefix=companion_tools; dot2suffix=;;

View File

@ -0,0 +1,108 @@
# This file adds the functions to build the zlib library
# Copyright 2017 Alexey Neyman
# Licensed under the GPL v2. See COPYING in the root of this package
do_zlib_get() { :; }
do_zlib_extract() { :; }
do_zlib_for_build() { :; }
do_zlib_for_host() { :; }
do_zlib_for_target() { :; }
# Overide functions depending on configuration
if [ "${CT_ZLIB}" = "y" ]; then
# Download zlib
do_zlib_get() {
CT_GetFile "zlib-${CT_ZLIB_VERSION}" \
"http://downloads.sourceforge.net/project/libpng/zlib/${CT_ZLIB_VERSION}"
}
# Extract zlib
do_zlib_extract() {
CT_Extract "zlib-${CT_ZLIB_VERSION}"
CT_Patch "zlib" "${CT_ZLIB_VERSION}"
}
# Build zlib for running on build
# - always build statically
# - install in build-tools prefix
do_zlib_for_build() {
local -a zlib_opts
case "${CT_TOOLCHAIN_TYPE}" in
native|cross) return 0;;
esac
CT_DoStep INFO "Installing zlib for build"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-zlib-build-${CT_BUILD}"
zlib_opts+=( "host=${CT_BUILD}" )
zlib_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
zlib_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
zlib_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
do_zlib_backend "${zlib_opts[@]}"
CT_Popd
CT_EndStep
}
# Build zlib for running on host
do_zlib_for_host() {
local -a zlib_opts
CT_DoStep INFO "Installing zlib for host"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-zlib-host-${CT_HOST}"
zlib_opts+=( "host=${CT_HOST}" )
zlib_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
zlib_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
zlib_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
do_zlib_backend "${zlib_opts[@]}"
CT_Popd
CT_EndStep
}
# Build zlib
# Parameter : description : type : default
# host : machine to run on : tuple : (none)
# prefix : prefix to install into : dir : (none)
# cflags : cflags to use : string : (empty)
# ldflags : ldflags to use : string : (empty)
do_zlib_backend() {
local host
local prefix
local cflags
local ldflags
local arg
local -a extra_config
for arg in "$@"; do
eval "${arg// /\\ }"
done
CT_DoLog EXTRA "Configuring zlib"
CT_DoExecLog CFG \
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
CROSS_PREFIX="${host}-" \
${CONFIG_SHELL} \
"${CT_SRC_DIR}/zlib-${CT_ZLIB_VERSION}/configure" \
--prefix="${prefix}" \
--static \
"${extra_config[@]}"
CT_DoLog EXTRA "Building zlib"
CT_DoExecLog ALL make ${JOBSFLAGS}
if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
CT_DoLog EXTRA "Checking zlib"
CT_DoExecLog ALL make ${JOBSFLAGS} -s check
fi
CT_DoLog EXTRA "Installing zlib"
CT_DoExecLog ALL make install
}
fi # CT_ZLIB

View File

@ -26,7 +26,6 @@ do_gmp_extract() {
# Build GMP for running on build
# - always build statically
# - we do not have build-specific CFLAGS
# - install in build-tools prefix
do_gmp_for_build() {
local -a gmp_opts
@ -101,7 +100,7 @@ do_gmp_backend() {
--enable-cxx \
--disable-shared \
--enable-static \
"${extra_config}"
"${extra_config[@]}"
CT_DoLog EXTRA "Building GMP"
CT_DoExecLog ALL make ${JOBSFLAGS}

View File

@ -68,7 +68,6 @@ do_mpfr_extract() {
# Build MPFR for running on build
# - always build statically
# - we do not have build-specific CFLAGS
# - install in build-tools prefix
do_mpfr_for_build() {
local -a mpfr_opts

View File

@ -25,7 +25,6 @@ do_isl_extract() {
# Build ISL for running on build
# - always build statically
# - we do not have build-specific CFLAGS
# - install in build-tools prefix
do_isl_for_build() {
local -a isl_opts

View File

@ -29,7 +29,6 @@ do_cloog_extract() {
# Build CLooG for running on build
# - always build statically
# - we do not have build-specific CFLAGS
# - install in build-tools prefix
do_cloog_for_build() {
local -a cloog_opts

View File

@ -26,7 +26,6 @@ do_mpc_extract() {
# Build MPC for running on build
# - always build statically
# - we do not have build-specific CFLAGS
# - install in build-tools prefix
do_mpc_for_build() {
local -a mpc_opts

View File

@ -24,7 +24,6 @@ if [ "${CT_LIBELF}" = "y" ]; then
# Build libelf for running on build
# - always build statically
# - we do not have build-specific CFLAGS
# - install in build-tools prefix
do_libelf_for_build() {
local -a libelf_opts

View File

@ -128,7 +128,7 @@ gen_menu() {
shift 4
local file entry _entry
# GEnerate the menuconfig
# Generate the menuconfig
exec >"${out_file}"
printf '# %s menu\n' "${label}"
printf '# Generated file, do not edit!!!\n'