[PATCH] build: put shared functions in static library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This helps eliminating unused functions, shrinking the binaries
a little bit.

Signed-off-by: Andreas Robinson <andr345@xxxxxxxxx>
---
 Makefile.am  |   30 ++++++++++++++++++++++--------
 configure.ac |    1 +
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e132049..56f5b6a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,17 +1,18 @@
 ACLOCAL_AMFLAGS = -I m4
 
-insmod_SOURCES = insmod.c util.c logging.c util.h logging.h testing.h
-lsmod_SOURCES = lsmod.c util.c logging.c util.h logging.h testing.h
-modprobe_SOURCES = modprobe.c util.c logging.c index.c zlibsupport.c config_filter.c util.h logging.h index.h testing.h zlibsupport.h config_filter.h
-rmmod_SOURCES = rmmod.c util.c logging.c util.h logging.h testing.h
-depmod_SOURCES = depmod.c util.c logging.c index.c moduleops.c tables.c zlibsupport.c config_filter.c util.h depmod.h logging.h index.h moduleops.h tables.h list.h testing.h  zlibsupport.h config_filter.h
-modinfo_SOURCES = modinfo.c util.c logging.c zlibsupport.c util.h testing.h zlibsupport.h
-modindex_SOURCES = modindex.c util.c logging.c index.c util.h logging.h index.h
+insmod_SOURCES = insmod.c testing.h
+lsmod_SOURCES = lsmod.c testing.h
+modprobe_SOURCES = modprobe.c zlibsupport.c zlibsupport.h testing.h
+rmmod_SOURCES = rmmod.c testing.h
+depmod_SOURCES = depmod.c zlibsupport.c moduleops.c tables.c \
+	zlibsupport.h moduleops.h tables.h testing.h
+modinfo_SOURCES = modinfo.c zlibsupport.c zlibsupport.h testing.h
+modindex_SOURCES = modindex.c zlibsupport.c zlibsupport.h testing.h
 
 insmod_static_SOURCES = insmod.c
 insmod_static_LDFLAGS = -static
 # We don't want the $(zlib_flags) here: that makes a dynamic executable
-insmod_static_LDADD = 
+insmod_static_LDADD = libmodtools.a
 
 EXTRA_insmod_SOURCES =
 EXTRA_lsmod_SOURCES =
@@ -21,6 +22,18 @@ EXTRA_insmod_static_SOURCES =
 EXTRA_depmod_SOURCES = moduleops_core.c
 EXTRA_modinfo_SOURCES =
 
+libmodtools_a_SOURCES = util.c logging.c index.c config_filter.c \
+	util.h depmod.h logging.h index.h list.h config_filter.h
+libmodtools_a_CFLAGS = -ffunction-sections
+
+insmod_LDADD = $(LDADD) libmodtools.a
+lsmod_LDADD = $(LDADD) libmodtools.a
+modprobe_LDADD = $(LDADD) libmodtools.a
+rmmod_LDADD = $(LDADD) libmodtools.a
+depmod_LDADD = $(LDADD) libmodtools.a
+modinfo_LDADD = $(LDADD) libmodtools.a
+modindex_LDADD = $(LDADD) libmodtools.a
+
 MAN5 = modprobe.conf.5 modules.dep.5 depmod.conf.5
 MAN8 = depmod.8 insmod.8 lsmod.8 rmmod.8 modprobe.8 modinfo.8
 SGML = $(addprefix doc/,  $(MAN5:%.5=%.sgml) $(MAN8:%.8=%.sgml))
@@ -36,6 +49,7 @@ sbin_PROGRAMS = insmod modprobe rmmod depmod modinfo insmod.static
 bin_PROGRAMS = lsmod
 sbin_SCRIPTS = generate-modprobe.conf
 noinst_PROGRAMS=modindex
+noinst_LIBRARIES = libmodtools.a
 INSTALL = $(SHELL) $(top_srcdir)/install-with-care
 
 DIST_DIR := /home/rusty/devel/kernel/www/modules/
diff --git a/configure.ac b/configure.ac
index 57d918b..5bee375 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,6 +18,7 @@ AC_ARG_ENABLE(zlib,
 fi])
 
 AC_PROG_CC
+AC_PROG_RANLIB
 
 AC_CHECK_PROGS(DOCBOOKTOMAN, docbook-to-man docbook2man, [no],)
 if test x"$DOCBOOKTOMAN" = xno
-- 
1.6.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux