File module-init-tools-insmod-zlib.diff of Package module-init-tools

---
 Makefile.am  |    6 ++----
 configure.ac |    9 ++++++++-
 insmod.c     |    7 ++++---
 3 files changed, 14 insertions(+), 8 deletions(-)

--- Makefile.am.orig
+++ Makefile.am
@@ -1,14 +1,12 @@
-insmod_SOURCES = insmod.c testing.h
+insmod_SOURCES = insmod.c zlibsupport.c testing.h zlibsupport.h
 lsmod_SOURCES = lsmod.c testing.h
 modprobe_SOURCES = modprobe.c zlibsupport.c config_filter.c testing.h zlibsupport.h config_filter.h
 rmmod_SOURCES = rmmod.c testing.h
 depmod_SOURCES = depmod.c moduleops.c tables.c zlibsupport.c config_filter.c depmod.h moduleops.h tables.h list.h testing.h  zlibsupport.h config_filter.h
 modinfo_SOURCES = modinfo.c zlibsupport.c testing.h zlibsupport.h
 
-insmod_static_SOURCES = insmod.c
+insmod_static_SOURCES = insmod.c zlibsupport.c zlibsupport.h
 insmod_static_LDFLAGS = -static
-# We don't want the $(zlib_flags) here: that makes a dynamic executable
-insmod_static_LDADD = 
 
 EXTRA_insmod_SOURCES = backwards_compat.c
 EXTRA_lsmod_SOURCES = backwards_compat.c
--- configure.ac.orig
+++ configure.ac
@@ -6,11 +6,15 @@ AM_INIT_AUTOMAKE(module-init-tools, "3.3
 
 # If zlib is required, libz must be linked static, modprobe is in
 # /sbin, libz is in /usr/lib and may not be available when it is run.
+AC_ARG_WITH(zlib_name,[ --with-zlib_name=z Give name of the libz library.],
+  ZLIB=$withval,
+  ZLIB=z)
 AC_ARG_ENABLE(zlib,
 [  --enable-zlib               Handle gzipped modules],
 [if test "$enableval" = "yes"; then
   AC_DEFINE(CONFIG_USE_ZLIB)
-  zlib_flags="-Wl,-Bstatic -lz -Wl,-Bdynamic"
+  zlib_flags="-Wl,-Bstatic -l$ZLIB -Wl,-Bdynamic"
+  zlib_flags_static="-l$ZLIB"
 fi])
 
 AC_PROG_CC
@@ -20,6 +24,9 @@ AC_PROG_CC
 LDADD="$LDADD $zlib_flags"
 AC_SUBST(LDADD)
 
+insmod_static_LDADD="$insmod_static_LDADD $zlib_flags_static"
+AC_SUBST(insmod_static_LDADD)
+
 case $target in
 *-*-linux*) ;;
 *) AC_MSG_ERROR([Linux only, dude!]);;
--- insmod.c.orig
+++ insmod.c
@@ -28,6 +28,7 @@
 #include <errno.h>
 #include <asm/unistd.h>
 
+#include "zlibsupport.h"
 #include "backwards_compat.c"
 
 #define streq(a,b) (strcmp((a),(b)) == 0)
@@ -57,7 +58,7 @@ static const char *moderror(int err)
 	}
 }
 
-static void *grab_file(const char *filename, unsigned long *size)
+static void *_grab_file(const char *filename, unsigned long *size)
 {
 	unsigned int max = 16384;
 	int ret, fd, err_save;
@@ -68,7 +69,7 @@ static void *grab_file(const char *filen
 	if (streq(filename, "-"))
 		fd = dup(STDIN_FILENO);
 	else
-		fd = open(filename, O_RDONLY, 0);
+		return grab_file(filename, size);
 
 	if (fd < 0)
 		return NULL;
@@ -152,7 +153,7 @@ int main(int argc, char *argv[])
 		strcat(options, " ");
 	}
 
-	file = grab_file(filename, &len);
+	file = _grab_file(filename, &len);
 	if (!file) {
 		fprintf(stderr, "insmod: can't read '%s': %s\n",
 			filename, strerror(errno));
openSUSE Build Service is sponsored by