From: "Richard W.M. Jones" <rjones@redhat.com> --- README | 2 +- configure.ac | 31 ++++++++++++++++++++++++++++++- helper/Makefile.am | 1 + helper/init.c | 8 ++++---- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/README b/README index 6542471..3461d9d 100644 --- a/README +++ b/README @@ -68,7 +68,7 @@ are building: qemu >= 0.13 kernel >= 2.6.36 - zlib - if your kernel uses gzipped modules + zlib (statically linked) - if your kernel uses gzipped modules Building and installing ----------------------- diff --git a/configure.ac b/configure.ac index c190e2c..b3144a4 100644 --- a/configure.ac +++ b/configure.ac @@ -102,7 +102,36 @@ dnl For ArchLinux handler. AC_CHECK_PROG(PACMAN,[pacman],[pacman],[no]) dnl Support for gzipped kernel modules. -AC_CHECK_LIB([z],[gzopen]) +AC_CHECK_HEADER([zlib.h],[ + AC_CHECK_LIB([z],[gzopen],[ + AC_MSG_CHECKING([for gzip static library]) + old_CFLAGS="$CFLAGS" + old_LDFLAGS="$LDFLAGS" + old_LIBS="$LIBS" + CFLAGS="$CFLAGS -static" + LDFLAGS="$LDFLAGS -static" + LIBS="$LIBS -lz" + AC_LINK_IFELSE([ + #include <stdio.h> + #include <stdlib.h> + #include <zlib.h> + int main () { gzFile g = gzopen ("test", "rb"); exit (g ? 1 : 0); } + ],[ + zlib_static=yes + ZLIB_STATIC_LIBS="-lz" + AC_MSG_RESULT([yes]) + ],[ + AC_MSG_RESULT([no]) + ]) + CFLAGS="$old_CFLAGS" + LDFLAGS="$old_LDFLAGS" + LIBS="$old_LIBS" + ]) +]) +if test "x$zlib_static" = "xyes"; then + AC_DEFINE([HAVE_ZLIB],[1],[Define if you have static zlib]) + AC_SUBST([ZLIB_STATIC_LIBS]) +fi dnl mke2fs. AC_PATH_PROG([MKE2FS],[mke2fs],[no], diff --git a/helper/Makefile.am b/helper/Makefile.am index 55826d7..de32299 100644 --- a/helper/Makefile.am +++ b/helper/Makefile.am @@ -43,6 +43,7 @@ noinst_PROGRAMS = init init_SOURCES = init.c init_CFLAGS = -static init_LDFLAGS = -static +init_LDADD = $(ZLIB_STATIC_LIBS) CLEANFILES = ext2init.S diff --git a/helper/init.c b/helper/init.c index c53bf9d..4c10bff 100644 --- a/helper/init.c +++ b/helper/init.c @@ -41,7 +41,7 @@ #include <asm/unistd.h> -#ifdef HAVE_LIBZ +#ifdef HAVE_ZLIB #include <zlib.h> #endif @@ -97,7 +97,7 @@ main () print_uptime (); fprintf (stderr, "supermin: ext2 mini initrd starting up: " PACKAGE_VERSION -#ifdef HAVE_LIBZ +#ifdef HAVE_ZLIB " zlib" #endif "\n"); @@ -268,7 +268,7 @@ insmod (const char *filename) if (verbose) fprintf (stderr, "supermin: internal insmod %s\n", filename); -#ifdef HAVE_LIBZ +#ifdef HAVE_ZLIB gzFile gzfp = gzopen (filename, "rb"); int capacity = 64*1024; char *buf = (char *) malloc (capacity); @@ -328,7 +328,7 @@ insmod (const char *filename) */ } -#ifdef HAVE_LIBZ +#ifdef HAVE_ZLIB free (buf); #endif } -- 1.8.3.1