Skip to contentSkip to conversation

add a flag to control linking of internal kmod library

PATCH In review Mike Frysinger 2 participants 2 messages Dec 9, 2013 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add a flag to control linking of internal kmod library

We shouldn't be penalizing everyone because some distros' initramfs tooling sucks. So add a configure flag for controlling the linkage of the internal kmod library and default it to off.

---
 Makefile.am  | 8 ++++++--
 configure.ac | 5 +++++
 2 files changed, 11 insertions(+), 2 deletions(-)
Makefile.am +6 -2
index bdf758e..ee89ab1 100644
@@ -116,8 +116,12 @@ tools_kmod_SOURCES = tools/kmod.c tools/kmod.h tools/lsmod.c \
 		     tools/modinfo.c tools/modprobe.c \
 		     tools/depmod.c tools/log.h tools/log.c \
 		     tools/static-nodes.c
-tools_kmod_LDADD = libkmod/libkmod-util.la \
-		   libkmod/libkmod-internal.la
+tools_kmod_LDADD = libkmod/libkmod-util.la
+if ENABLE_INTERNAL_STATIC
+tools_kmod_LDADD += libkmod/libkmod-internal.la
+else
+tools_kmod_LDADD += libkmod/libkmod.la
+endif
 
 ${noinst_SCRIPTS}: tools/kmod
 	$(AM_V_GEN) ($(RM) $@; \
configure.ac +5 -0
index 5b484d6..fe83541 100644
@@ -102,6 +102,11 @@ AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
 # --enable-
 #####################################################################
 
+AC_ARG_ENABLE([internal-static],
+        AS_HELP_STRING([--enable-internal-static], [enable static linking of internal kmod libraries for simple initramfs usage @<:@default=disabled@:>@]),
+	[], enable_internal_static=no)
+AM_CONDITIONAL([ENABLE_INTERNAL_STATIC], [test "x$enable_internal_static" = "xyes"])
+
 AC_ARG_ENABLE([tools],
         AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
 	[], enable_tools=yes)
Signature · 1 line
1.8.4.3
#1 lore raw

Hi Mike,

Quoted 3 lines · Mike Frysinger

We shouldn't be penalizing everyone because some distros' initramfs tooling sucks. So add a configure flag for controlling the linkage of the internal kmod library and default it to off.

Please write in the commit message why you are doing this instead of ranting others distro's initramfs. I can only see here a save in total disk space. Then please provide numbers.

Quoted 2 lines

we don't use s-o-f

Quoted 31 lines
---
 Makefile.am  | 8 ++++++--
 configure.ac | 5 +++++
 2 files changed, 11 insertions(+), 2 deletions(-)
Makefile.am +6 -2
index bdf758e..ee89ab1 100644
@@ -116,8 +116,12 @@ tools_kmod_SOURCES = tools/kmod.c tools/kmod.h tools/lsmod.c \
                     tools/modinfo.c tools/modprobe.c \
                     tools/depmod.c tools/log.h tools/log.c \
                     tools/static-nodes.c
-tools_kmod_LDADD = libkmod/libkmod-util.la \
-                  libkmod/libkmod-internal.la
+tools_kmod_LDADD = libkmod/libkmod-util.la
+if ENABLE_INTERNAL_STATIC
+tools_kmod_LDADD += libkmod/libkmod-internal.la
+else
+tools_kmod_LDADD += libkmod/libkmod.la
+endif
 
 ${noinst_SCRIPTS}: tools/kmod
        $(AM_V_GEN) ($(RM) $@; \
configure.ac +0 -0
index 5b484d6..fe83541 100644
@@ -102,6 +102,11 @@ AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
 # --enable-
 #####################################################################

configure.ac AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])

Quoted 10 lines
configure.ac +5 -1
 
+AC_ARG_ENABLE([internal-static],
+        AS_HELP_STRING([--enable-internal-static], [enable static linking of internal kmod libraries for simple initramfs usage @<:@default=disabled@:>@]),
+       [], enable_internal_static=no)
+AM_CONDITIONAL([ENABLE_INTERNAL_STATIC], [test "x$enable_internal_static" = "xyes"])
+
 AC_ARG_ENABLE([tools],
         AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
        [], enable_tools=yes)
--

It's not only for simple initramfs usage. Some symbols are only available in the internal version because they are not intended for public consumption. If numbers are compelling we could move those symbols to the utils internal lib instead (that's why I'm asking for a better commit message). However you also need to fix the testsuite then. It expects to be able to exec the just-compiled binaries. Wrappers don't work very well because libtool fails to maintain the same name (see 9de9e07 tools: Use test/kmod instead of kmod-nolib). Try "make check" to see that with your patch it now fails the tests that try to exec modprobe, modinfo and so on.

Regards,
Lucas De Marchi