Git init
authorKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:50:08 +0000 (00:50 +0900)
committerKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:50:08 +0000 (00:50 +0900)
287 files changed:
AUTHORS [new file with mode: 0644]
CODING [new file with mode: 0644]
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
FAQ [new file with mode: 0644]
INSTALL [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
Makefile.in [new file with mode: 0644]
NEWS [new file with mode: 0644]
README [new file with mode: 0644]
TODO [new file with mode: 0644]
aclocal.m4 [new file with mode: 0644]
config.guess [new file with mode: 0755]
config.sub [new file with mode: 0755]
config_filter.c [new file with mode: 0644]
config_filter.h [new file with mode: 0644]
configure [new file with mode: 0755]
configure.ac [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/module-init-tools-udeb.install [new file with mode: 0644]
debian/module-init-tools.init [new file with mode: 0644]
debian/module-init-tools.install [new file with mode: 0644]
debian/module-init-tools.postinst [new file with mode: 0644]
debian/module-init-tools.postrm [new file with mode: 0644]
debian/module-init-tools.preinst [new file with mode: 0644]
debian/patches/blacklist-warn.diff [new file with mode: 0644]
debian/patches/document_depmod_m [new file with mode: 0644]
debian/patches/modprobe_bad_output [new file with mode: 0644]
debian/patches/no_maps_by_default [new file with mode: 0644]
debian/patches/series [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/watch [new file with mode: 0644]
depcomp [new file with mode: 0755]
depmod.8 [new file with mode: 0644]
depmod.c [new file with mode: 0644]
depmod.conf.5 [new file with mode: 0644]
depmod.h [new file with mode: 0644]
doc/depmod.conf.sgml [new file with mode: 0644]
doc/depmod.sgml [new file with mode: 0644]
doc/insmod.sgml [new file with mode: 0644]
doc/lsmod.sgml [new file with mode: 0644]
doc/modinfo.sgml [new file with mode: 0644]
doc/modprobe.conf.sgml [new file with mode: 0644]
doc/modprobe.d.sgml [new file with mode: 0644]
doc/modprobe.sgml [new file with mode: 0644]
doc/modules.dep.sgml [new file with mode: 0644]
doc/rmmod.sgml [new file with mode: 0644]
elfops.c [new file with mode: 0644]
elfops.h [new file with mode: 0644]
elfops_core.c [new file with mode: 0644]
extra/modprobe.d/aliases.conf [new file with mode: 0644]
extra/modules.5 [new file with mode: 0644]
extra/modules.fr.5 [new file with mode: 0644]
generate-modprobe.conf [new file with mode: 0755]
index.c [new file with mode: 0644]
index.h [new file with mode: 0644]
insmod.8 [new file with mode: 0644]
insmod.c [new file with mode: 0644]
install-sh [new file with mode: 0755]
install-with-care [new file with mode: 0755]
list.h [new file with mode: 0644]
logging.c [new file with mode: 0644]
logging.h [new file with mode: 0644]
lsmod.8 [new file with mode: 0644]
lsmod.c [new file with mode: 0644]
m4/ax_configure_args.m4 [new file with mode: 0644]
m4/ax_enable_builddir.m4 [new file with mode: 0644]
missing [new file with mode: 0755]
modindex.c [new file with mode: 0644]
modinfo.8 [new file with mode: 0644]
modinfo.c [new file with mode: 0644]
modprobe.8 [new file with mode: 0644]
modprobe.c [new file with mode: 0644]
modprobe.conf.5 [new file with mode: 0644]
modprobe.d.5 [new file with mode: 0644]
modules.dep.5 [new file with mode: 0644]
rmmod.8 [new file with mode: 0644]
rmmod.c [new file with mode: 0644]
stress_modules.sh [new file with mode: 0755]
tables.c [new file with mode: 0644]
tables.h [new file with mode: 0644]
testing.h [new file with mode: 0644]
tests/data/32-be/alias/alias-32.ko [new file with mode: 0644]
tests/data/32-be/complex/complex_a-32.ko [new file with mode: 0644]
tests/data/32-be/complex/complex_b-32.ko [new file with mode: 0644]
tests/data/32-be/complex/complex_c-32.ko [new file with mode: 0644]
tests/data/32-be/complex/complex_d-32.ko [new file with mode: 0644]
tests/data/32-be/complex/complex_e-32.ko [new file with mode: 0644]
tests/data/32-be/loop/loop1-32.ko [new file with mode: 0644]
tests/data/32-be/loop/loop2-32.ko [new file with mode: 0644]
tests/data/32-be/loop/loop_dep-32.ko [new file with mode: 0644]
tests/data/32-be/map/ccw_map-32.ko [new file with mode: 0644]
tests/data/32-be/map/ieee1394_map-32.ko [new file with mode: 0644]
tests/data/32-be/map/input_map-32.ko [new file with mode: 0644]
tests/data/32-be/map/input_map_new-32.ko [new file with mode: 0644]
tests/data/32-be/map/of_map-32.ko [new file with mode: 0644]
tests/data/32-be/map/pci_map-32.ko [new file with mode: 0644]
tests/data/32-be/map/pnp_map-32.ko [new file with mode: 0644]
tests/data/32-be/map/usb_map-32.ko [new file with mode: 0644]
tests/data/32-be/modinfo/modinfo-32.ko [new file with mode: 0644]
tests/data/32-be/normal/export_dep-32.ko [new file with mode: 0644]
tests/data/32-be/normal/export_nodep-32.ko [new file with mode: 0644]
tests/data/32-be/normal/noexport_dep-32.ko [new file with mode: 0644]
tests/data/32-be/normal/noexport_doubledep-32.ko [new file with mode: 0644]
tests/data/32-be/normal/noexport_nodep-32.ko [new file with mode: 0644]
tests/data/32-be/rename/rename-new-32.ko [new file with mode: 0644]
tests/data/32-be/rename/rename-old-32.ko [new file with mode: 0644]
tests/data/32-be/rename/rename-version-32.ko [new file with mode: 0644]
tests/data/32-be/unknown/unknown-32.ko [new file with mode: 0644]
tests/data/32-le/alias/alias-32.ko [new file with mode: 0644]
tests/data/32-le/complex/complex_a-32.ko [new file with mode: 0644]
tests/data/32-le/complex/complex_b-32.ko [new file with mode: 0644]
tests/data/32-le/complex/complex_c-32.ko [new file with mode: 0644]
tests/data/32-le/complex/complex_d-32.ko [new file with mode: 0644]
tests/data/32-le/complex/complex_e-32.ko [new file with mode: 0644]
tests/data/32-le/loop/loop1-32.ko [new file with mode: 0644]
tests/data/32-le/loop/loop2-32.ko [new file with mode: 0644]
tests/data/32-le/loop/loop_dep-32.ko [new file with mode: 0644]
tests/data/32-le/map/ccw_map-32.ko [new file with mode: 0644]
tests/data/32-le/map/ieee1394_map-32.ko [new file with mode: 0644]
tests/data/32-le/map/input_map-32.ko [new file with mode: 0644]
tests/data/32-le/map/input_map_new-32.ko [new file with mode: 0644]
tests/data/32-le/map/of_map-32.ko [new file with mode: 0644]
tests/data/32-le/map/pci_map-32.ko [new file with mode: 0644]
tests/data/32-le/map/pnp_map-32.ko [new file with mode: 0644]
tests/data/32-le/map/usb_map-32.ko [new file with mode: 0644]
tests/data/32-le/modinfo/modinfo-32.ko [new file with mode: 0644]
tests/data/32-le/normal/export_dep-32.ko [new file with mode: 0644]
tests/data/32-le/normal/export_nodep-32.ko [new file with mode: 0644]
tests/data/32-le/normal/noexport_dep-32.ko [new file with mode: 0644]
tests/data/32-le/normal/noexport_doubledep-32.ko [new file with mode: 0644]
tests/data/32-le/normal/noexport_nodep-32.ko [new file with mode: 0644]
tests/data/32-le/rename/rename-new-32.ko [new file with mode: 0644]
tests/data/32-le/rename/rename-old-32.ko [new file with mode: 0644]
tests/data/32-le/rename/rename-version-32.ko [new file with mode: 0644]
tests/data/32-le/unknown/unknown-32.ko [new file with mode: 0644]
tests/data/64-be/alias/alias-64.ko [new file with mode: 0644]
tests/data/64-be/complex/complex_a-64.ko [new file with mode: 0644]
tests/data/64-be/complex/complex_b-64.ko [new file with mode: 0644]
tests/data/64-be/complex/complex_c-64.ko [new file with mode: 0644]
tests/data/64-be/complex/complex_d-64.ko [new file with mode: 0644]
tests/data/64-be/complex/complex_e-64.ko [new file with mode: 0644]
tests/data/64-be/loop/loop1-64.ko [new file with mode: 0644]
tests/data/64-be/loop/loop2-64.ko [new file with mode: 0644]
tests/data/64-be/loop/loop_dep-64.ko [new file with mode: 0644]
tests/data/64-be/map/ccw_map-64.ko [new file with mode: 0644]
tests/data/64-be/map/ieee1394_map-64.ko [new file with mode: 0644]
tests/data/64-be/map/input_map-64.ko [new file with mode: 0644]
tests/data/64-be/map/input_map_new-64.ko [new file with mode: 0644]
tests/data/64-be/map/of_map-64.ko [new file with mode: 0644]
tests/data/64-be/map/pci_map-64.ko [new file with mode: 0644]
tests/data/64-be/map/pnp_map-64.ko [new file with mode: 0644]
tests/data/64-be/map/usb_map-64.ko [new file with mode: 0644]
tests/data/64-be/modinfo/modinfo-64.ko [new file with mode: 0644]
tests/data/64-be/normal/export_dep-64.ko [new file with mode: 0644]
tests/data/64-be/normal/export_nodep-64.ko [new file with mode: 0644]
tests/data/64-be/normal/noexport_dep-64.ko [new file with mode: 0644]
tests/data/64-be/normal/noexport_doubledep-64.ko [new file with mode: 0644]
tests/data/64-be/normal/noexport_nodep-64.ko [new file with mode: 0644]
tests/data/64-be/rename/rename-new-64.ko [new file with mode: 0644]
tests/data/64-be/rename/rename-old-64.ko [new file with mode: 0644]
tests/data/64-be/rename/rename-version-64.ko [new file with mode: 0644]
tests/data/64-be/unknown/unknown-64.ko [new file with mode: 0644]
tests/data/64-le/alias/alias-64.ko [new file with mode: 0644]
tests/data/64-le/complex/complex_a-64.ko [new file with mode: 0644]
tests/data/64-le/complex/complex_b-64.ko [new file with mode: 0644]
tests/data/64-le/complex/complex_c-64.ko [new file with mode: 0644]
tests/data/64-le/complex/complex_d-64.ko [new file with mode: 0644]
tests/data/64-le/complex/complex_e-64.ko [new file with mode: 0644]
tests/data/64-le/loop/loop1-64.ko [new file with mode: 0644]
tests/data/64-le/loop/loop2-64.ko [new file with mode: 0644]
tests/data/64-le/loop/loop_dep-64.ko [new file with mode: 0644]
tests/data/64-le/map/ccw_map-64.ko [new file with mode: 0644]
tests/data/64-le/map/ieee1394_map-64.ko [new file with mode: 0644]
tests/data/64-le/map/input_map-64.ko [new file with mode: 0644]
tests/data/64-le/map/input_map_new-64.ko [new file with mode: 0644]
tests/data/64-le/map/of_map-64.ko [new file with mode: 0644]
tests/data/64-le/map/pci_map-64.ko [new file with mode: 0644]
tests/data/64-le/map/pnp_map-64.ko [new file with mode: 0644]
tests/data/64-le/map/usb_map-64.ko [new file with mode: 0644]
tests/data/64-le/modinfo/modinfo-64.ko [new file with mode: 0644]
tests/data/64-le/normal/export_dep-64.ko [new file with mode: 0644]
tests/data/64-le/normal/export_nodep-64.ko [new file with mode: 0644]
tests/data/64-le/normal/noexport_dep-64.ko [new file with mode: 0644]
tests/data/64-le/normal/noexport_doubledep-64.ko [new file with mode: 0644]
tests/data/64-le/normal/noexport_nodep-64.ko [new file with mode: 0644]
tests/data/64-le/rename/rename-new-64.ko [new file with mode: 0644]
tests/data/64-le/rename/rename-old-64.ko [new file with mode: 0644]
tests/data/64-le/rename/rename-version-64.ko [new file with mode: 0644]
tests/data/64-le/unknown/unknown-64.ko [new file with mode: 0644]
tests/data/Makefile [new file with mode: 0644]
tests/data/src/alias.c [new file with mode: 0644]
tests/data/src/ccw_map.c [new file with mode: 0644]
tests/data/src/complex_a.c [new file with mode: 0644]
tests/data/src/complex_b.c [new file with mode: 0644]
tests/data/src/complex_c.c [new file with mode: 0644]
tests/data/src/complex_d.c [new file with mode: 0644]
tests/data/src/complex_e.c [new file with mode: 0644]
tests/data/src/export_dep.c [new file with mode: 0644]
tests/data/src/export_nodep.c [new file with mode: 0644]
tests/data/src/ieee1394_map.c [new file with mode: 0644]
tests/data/src/input_map.c [new file with mode: 0644]
tests/data/src/input_map_new.c [new file with mode: 0644]
tests/data/src/loop1.c [new file with mode: 0644]
tests/data/src/loop2.c [new file with mode: 0644]
tests/data/src/loop_dep.c [new file with mode: 0644]
tests/data/src/modinfo.c [new file with mode: 0644]
tests/data/src/module.h [new file with mode: 0644]
tests/data/src/noexport_dep.c [new file with mode: 0644]
tests/data/src/noexport_doubledep.c [new file with mode: 0644]
tests/data/src/noexport_nodep.c [new file with mode: 0644]
tests/data/src/of_map.c [new file with mode: 0644]
tests/data/src/pci_map.c [new file with mode: 0644]
tests/data/src/pnp_map.c [new file with mode: 0644]
tests/data/src/rename-new.c [new file with mode: 0644]
tests/data/src/rename-old.c [new file with mode: 0644]
tests/data/src/rename-version.c [new file with mode: 0644]
tests/data/src/unknown.c [new file with mode: 0644]
tests/data/src/usb_map.c [new file with mode: 0644]
tests/runtests [new file with mode: 0755]
tests/test-depmod/02simple.sh [new file with mode: 0755]
tests/test-depmod/04maps.sh [new file with mode: 0755]
tests/test-depmod/05loop.sh [new file with mode: 0755]
tests/test-depmod/06undefined.sh [new file with mode: 0755]
tests/test-depmod/07complex.sh [new file with mode: 0755]
tests/test-depmod/08basedir.sh [new file with mode: 0755]
tests/test-depmod/09alias.sh [new file with mode: 0755]
tests/test-depmod/11quick.sh [new file with mode: 0755]
tests/test-depmod/12compressed.sh [new file with mode: 0755]
tests/test-depmod/13compressed-maps.sh [new file with mode: 0755]
tests/test-depmod/14updates.sh [new file with mode: 0755]
tests/test-depmod/15symlink.sh [new file with mode: 0755]
tests/test-depmod/16specific-modules.sh [new file with mode: 0755]
tests/test-insmod/02simple.sh [new file with mode: 0755]
tests/test-insmod/03options.sh [new file with mode: 0755]
tests/test-insmod/04stdin.sh [new file with mode: 0755]
tests/test-lsmod/01empty.sh [new file with mode: 0755]
tests/test-lsmod/03oldstyle.sh [new file with mode: 0755]
tests/test-lsmod/04newstyle.sh [new file with mode: 0755]
tests/test-modindex/05order.sh [new file with mode: 0644]
tests/test-modinfo/02all.sh [new file with mode: 0755]
tests/test-modinfo/03field.sh [new file with mode: 0755]
tests/test-modinfo/04compressed.sh [new file with mode: 0755]
tests/test-modprobe-indexed/02simple.sh [new file with mode: 0644]
tests/test-modprobe-indexed/03deps.sh [new file with mode: 0644]
tests/test-modprobe-indexed/03underscores.sh [new file with mode: 0644]
tests/test-modprobe-indexed/10alias.sh [new file with mode: 0644]
tests/test-modprobe-indexed/16showdepends.sh [new file with mode: 0644]
tests/test-modprobe/02proc.sh [new file with mode: 0755]
tests/test-modprobe/02simple.sh [new file with mode: 0755]
tests/test-modprobe/02sys.sh [new file with mode: 0755]
tests/test-modprobe/03deps.sh [new file with mode: 0755]
tests/test-modprobe/03underscores.sh [new file with mode: 0755]
tests/test-modprobe/04config.sh [new file with mode: 0755]
tests/test-modprobe/06rename.sh [new file with mode: 0755]
tests/test-modprobe/07wildalias.sh [new file with mode: 0755]
tests/test-modprobe/09configerrors.sh [new file with mode: 0755]
tests/test-modprobe/10alias.sh [new file with mode: 0755]
tests/test-modprobe/11stripversions.sh [new file with mode: 0755]
tests/test-modprobe/12whitespace.sh [new file with mode: 0755]
tests/test-modprobe/13dryrun.sh [new file with mode: 0755]
tests/test-modprobe/15env.sh [new file with mode: 0755]
tests/test-modprobe/16showdepends.sh [new file with mode: 0755]
tests/test-modprobe/17compressed.sh [new file with mode: 0755]
tests/test-modprobe/18multiremove.sh [new file with mode: 0755]
tests/test-modprobe/19quiet.sh [new file with mode: 0755]
tests/test-modprobe/20oldstyle.sh [new file with mode: 0755]
tests/test-modprobe/21wildinstall.sh [new file with mode: 0755]
tests/test-modprobe/22recursiveinstall.sh [new file with mode: 0755]
tests/test-modprobe/23recursive-deps.sh [new file with mode: 0755]
tests/test-modprobe/26blacklist.sh [new file with mode: 0755]
tests/test-modprobe/27cmdline-install-remove.sh [new file with mode: 0755]
tests/test-modprobe/28softdep.sh [new file with mode: 0644]
tests/test-rmmod/02namefix.sh [new file with mode: 0755]
tests/test-rmmod/03inuse.sh [new file with mode: 0755]
tests/test-rmmod/04flags.sh [new file with mode: 0755]
tests/test-rmmod/05noproc.sh [new file with mode: 0755]
tests/test-rmmod/06multi.sh [new file with mode: 0755]
tests/valgrind/suppressions [new file with mode: 0644]
tests/valgrind/valgrindme.sh [new file with mode: 0755]
util.c [new file with mode: 0644]
util.h [new file with mode: 0644]
zlibsupport.c [new file with mode: 0644]
zlibsupport.h [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..2a28456
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,12 @@
+Maintainer:
+       Jon Masters <jcm@jonmasters.org>
+
+Many thanks to:
+       Adam J. Richter <adam@yggdrasil.com>
+       Alan Jenkins <alan-jenkins@tuffmail.co.uk>
+       Jon Masters <jcm@jonmasters.org>
+       Kay Sievers <kay.sievers@vrfy.org>
+       Marco d'Itri <md@linux.it>
+       Michal Marek <mmarek@suse.cz>
+       Robby Workman <rworkman@slackware.com>
+       Rusty Russell <rusty@rustcorp.com.au>
diff --git a/CODING b/CODING
new file mode 100644 (file)
index 0000000..9dd6c18
--- /dev/null
+++ b/CODING
@@ -0,0 +1,68 @@
+module-init-tools coding standards
+----------------------------------
+
+Patches to module-init-tools are welcome.  Please note the following
+design goals:
+
+1) insmod and rmmod are designed to be as simple as possible.
+
+2) modprobe is designed to be a swiss-army-knife, but the config file
+   format is designed to be as simple as possible: let the user create
+   complexity if they wish. Having said that, the "install" and "remove"
+   commands serve as examples of what we don't want to do in the future,
+   due to the problems they cause with identifying module dependencies.
+
+3) module-init-tools contains a testsuite.  Patches which do not pass
+   the testsuite get a frowny face. It's easy to run the testsuite,
+   as you can see below. Please do test patches before posting.
+
+The testsuite
+-------------
+
+The testsuite is under tests/test-*: one directory for each tool. To
+run the testsuite, type the following from the top level directory:
+
+       ./tests/runtests
+
+To start the tests at a particular test, use that test name on the
+command line, eg. "./tests/runtests 26blacklist.sh".  To see exactly
+what the test is doing, use -vv, eg
+
+       ./tests/runtests -vv 26blacklist.sh
+
+To only test a given endianess or bitness, use
+
+       TEST_ENDIAN=32 TEST_BITS=le ./tests/runtests
+
+Each test is a shell script run with "-e": ie. if any command fails,
+the test will fail.  The path is set up with special test versions of
+the utilities (and possibly valgrind wrappers), so just invoke
+"modprobe" etc. as normal.  Environment variables can be used to
+control normally hardwired behaviour:
+
+1) $MODTEST_UNAME:
+       The result "uname" is to return.  Set to 2.6.27 by default.
+
+2) $MODTEST_OVERRIDE<n>, $MODTEST_OVERRIDE_WITH<n>
+       These cause file operations on $MODTEST_OVERRIDE1 to occur on
+       $MODTEST_OVERRIDE_WITH1, etc.  The numbers must be consecutive:
+       the code stops searching for a replacement when a number is not
+       found.  This is used to stop the utilities looking in 
+       /lib/modules/2.6.27/ for example.
+
+       Other environment variables can be found in testing.h.
+
+There are various pre-compiled test modules under tests/data/.  Each
+one has big and little endian and 32 and 64-bit variants: modprobe
+must handle both 32 and 64 bit (for x86-64, PPC64, Sparc64, IA64), and
+depmod and modinfo must handle any endianness as well.  If you need to
+add a new module to test something, put the source under tests/src,
+make sure it passes for the cases you can test, and I'll compile and
+test the others.
+
+When writing tests, make sure your test aborts on any unexpected
+behaviour: eg. compare the result is equal to what you expect, rather
+than not equal to something.
+
+Cheers!
+Rusty and Jon.
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..d60c31a
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,340 @@
+                   GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+\f
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+\f
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+\f
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+\f
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..3997ab0
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,395 @@
+3.11 Version:
+o modinfo: Fix crash if module recently deleted from system (Ozan)
+o modprobe: Handle built-in modules (Michal)
+
+3.10 Version:
+o modprobe: cleanup some option handling (Alan)
+o testsuite: Rebuild all the test modules (32/64/be/le) to avoid bitrot
+
+3.9 Version:
+o NOTE: tools now fail loudly in the case of non-ELF files being used
+o elfops: rename moduleops to elfops, remove struct module from it (Andreas)
+o depmod: various symbol lookup and dependency calculation fixes (Andreas)
+o doc: various cleanup of man pages (Robby)
+
+3.8 Version:
+o doc: Fix build documentation
+o zlib: allow dynamic linking (Michal)
+
+
+3.7 Version:
+o NOTE: *** support for pre-2.6 kernels was removed in this version ***
+o bindex: modules.order support and fallback in case trie is outdated (Alan)
+o depmod: fix is_higher_priority() (Michal)
+o depmod: officially disallow specifying modules using relative paths (Alan)
+o lib: fix underscore conversion (Alan)
+o modprobe: parse empty options correctly
+o testsuite: lots of random fixes and cleanups
+
+3.6 Version:
+o depmod: make building map files optional (does anyone use them anyway?)
+o demod: use shortened path names in index files (relative paths used)
+o modprobe: use /sys/module rather than /proc/modules (Andreas)
+o modprobe: remove legacy support for pre-2.6 kernels (Andreas)
+o modprobe: check that asprintf() calls actually allocate (Andreas)
+
+3.5 Version:
+o binary indexing file support (Alan Jenkins)
+o depmod: fix some memory leaks, reduce overhead (Alan Jenkins)
+o modprobe: fix some memory leaks, reduce overhead (Alan Jenkins)
+o rmmod: fix some memory leaks (Alan Jenkins)
+o testsuite: update the tests (Alan Jenkins)
+o various other fixes
+
+3.4 Version:
+o modprobe: add ability to parse kernel command line for module options.
+
+3.3 Version:
+o modinfo: add a kernel parameter for info on modules used by other kernels.
+o lsmod: modprobe: Comment fixes (thanks Satoru Takeuchi)
+o modprobe: don't mangle - in wildcards within [ ] (patch from Sam Morris)
+o new mintainer: Jon Masters <jcm@jonmasters.org>
+o switch to using git for project maintainance
+o misc. memory leakage/build/docs fixes (Luiz Fernando N. Capitulino)
+o correct error handling and insmod.static handling (Tobias Stoeckmann)
+o various other fixes to build/development process.
+       
+3.2.2 Version:
+o depmod: Try to generate correct input tables for 2.6.14 and above (thanks to report from Scott James Remnant)
+
+3.2.1 Version:
+o depmod: macio device support (patch from Jeff Mahoney)
+
+3.2 Version:
+o depmod: serio support (patch from Dmitry Torokhov)
+o modprobe: Fix load by symbol (thanks to Nathan Lutchansky)
+o modinfo: Handle parmtype: for 2.6.11
+o depmod: handle other endian (already handle 64 & 32 bit)
+o modprobe, rmmod, depmod: check for OOM (patch from Andreas Gruenbacher)
+o depmod: don't skip first argument for explicit files (patch from Andrew Snare)
+o depmod: handle relative paths in explicit files
+o modprobe: load all matching aliases (idea from Dominik Brodowski)
+o modprobe: new blacklist keyword (patch from Erik van Konijnenburg)
+o CODING: new document describing testsuite
+o Makefile: include testsuite inside all source releases
+o modprobe: slow down modprobe with gratuitous stat for Reiser4 braindamage (Reported by Gentoo)
+o Makefile.am: Use @mandir@, unless it's just prefix/mandir (discussion with Jeremy C. Reed)
+o Added $CMDLINE_OPTS substitution to install commands.
+o depmod: don't explode on invalid modules (patch from Bill Nottingham)
+o modprobe: unlock fd when module already in kernel (either a race, or a rename) (patch from Oliver Blin, reworked)
+o modprobe.conf.sgml: docbook2man uses last refentrytitle for output file (fixes endusers needing docbook utils for build)
+o modprobe: fix gcc-2.95 compilation by declaring va_list at top of warn() (thanks Rafiq Ismail)
+o modprobe: doco fix: -a takes module names, not wildcards.
+o depmod, modprobe: gcc 4 signedness warning fixes (thanks to Marco d'Itri)
+o modprobe: lock before seeing if module in kernel (might be doing init now!)
+o testsuite: use --log-fd (valgrind 3) not --logfile-fd.
+o modprobe: spin to avoid parallel load attempts when lock failed.  Fixes "unknown symbols for ehci_hcd" bug with parallel udev on ro root.  (Patch from Pozsar Balazs)
+
+3.1 Version:
+o modprobe, rmmod: Fix format string (thanks to Sergey Vlasov)
+o modinfo: support -n, and by default display filename.
+o modprobe: allow -o with -r to remove renamed modules with deps correct.
+o modprobe: fall back to /etc/modprobe.d if fail on /etc/modprobe.conf.
+o modprobe: allow config files to be directories, and recurse.
+o modprobe: Fix quoting of cmdline options.
+o insmod: remove quote handling, since we didn't do it right.
+o depmod: ignore symbols (eg. PCI ids) in BSS (patch from Marc Boucher).
+o depmod: exit after -h.
+o modprobe: file locking on modules to avoid spurious errors if they race (report from Marc Boucher)
+o modprobe: Fall back to read-only (no locking) if rw open on module fails
+o depmod: updates/ dir overrides (for RH, thanks to Thomas Vander Stichele)
+o depmod: don't follow symlinks, broken in updates/ rework (thanks to Marco d'Itri)
+o Bashisms removed (thanks to David Weinehall)
+o modinfo: use modules.dep, not manual search, so we get updates/ right.
+o Fix modinfo manpage missing word (thanks Debian)
+o modprobe.devfs: added apm_bios devices (thanks Debian)
+o modprobe: don't fatal() on missing includes (thanks Debian)
+o modprobe: install/remove commands must override modules.alias file.
+o Fix modprobe man page to document --show-depends and install commands (reported by Eric C. Cooper)
+o Fix modprobe man page: -t -a removed in 3.0 (report from Thomas Hood)
+o Document modprobe.d in modprobe(.conf) man page (report from Stefan Richter)
+       
+3.0 Version:
+o Update missing script (report from Robin Grindley)
+o "depmod <version>" implies -a (report from Robin Grindley)
+o modprobe: remove -t without -l: it didn't work, so obviously noone was
+       using it.
+o modprobe: Allow "-a mod1 mod2" (report from Frédéric L. W. Meunier).
+o modprobe: Fixed short alloc in merge_args.
+o testsuite: run everything under valgrind.
+o modprobe: change tabs to spaces in module parameters.
+o modprobe: define STT_REGISTER if not defined (report Bill Nottingham)
+o modinfo: -p means "parm" not "param" (report from Peter Cordes)
+o Rmmod man page description is wrong (report from Pawel)
+o modprobe: don't access off end of argv[] when '-c' used.
+o depmod: merged Takashi Iwai's isapnp table code (with changes).
+o modprobe.conf.sgml: Indicate that command is a shell command.
+o rmmod: exit with non-zero on any failure (thanks to Serue Hallyen)
+o generate-modprobe.conf: fix up char and block aliases
+       (thanks to OGAWA Hirofumi)
+o modprobe: Fix warning about passing (and fix that fix thanks to Keith Moore)
+o depmod: merged Andrey Borzenkov's input table code (with changes).
+o modprobe: install/remove commands can be wildcards, set $MODPROBE_MODULE.
+o modprobe: inserting already-inserted is fine, as is removing already-removed.
+o modprobe: Add --first-time for old behavior
+o generate-modprobe.conf: Use --first-time for above and below commands.
+o FAQ: Fix generate-modprobe.conf question (report from Norman Diamond)
+o generate-modprobe.conf: Don't complain about common (no longer required) options
+o generate-modprobe.conf: Prevent "modprobe.old: command not found" message.
+o modprobe: fix semantics of -t to match any dir part (thanks to Paul Whittaker)
+o testsuite: test-rmmod/05noproc.sh relies on not being root (thanks to Pierre)
+o modprobe: handle infinite recursion caused by already-inserted, where
+       dependency has install command but is already installed (thanks to Trond Myklebust)
+o configure.in: remove -Wcast-align, gives warnings on IA64 (thanks to
+       Andrew Morton). 
+o install-with-care: don't hardcode /usr/bin/install (thanks Pierre)
+o generate-modprobe.conf: handle "add" lines in modules.conf
+o modprobe: -q now only means "silently succeed on unknown modules".
+o modprobe: update usage message
+o modprobe: flush stdout on verbose, so we always print before children.
+o runtests: continue after (optional) test name.
+o Makefile.am: moveold checks for already having been run.
+o depmod: Handle -C correctly (thanks Richard Hirst)
+o Makefile.am: "make check" succeeds if no testcase, or no valgrind.
+o depmod: Remove non-working __start and __stop logic, and ignore unknown
+       "_GLOBAL_OFFSET_TABLE_" for s390 (patch from Arnd Bergmann)
+o modprobe: revert "innocuous change" to skip rest of depends on insertion,
+       if this module is already in kernel.  But in a depends on b and c,
+       and b is already inserted, we should not skip inserting c!
+o configure.in: remove unused $(stat_zlib_flags)
+o Makefile.am: build insmod.static properly with --enable-zlib
+       (thanks to Andy Wang)
+o generate-modprobe.conf: handle "add alias xxx off" correctly
+       (thanks to Martin Schlemmer)
+o modprobe.c: revert -q behaviour: silent, but exit code 1.
+       
+0.9.14 Version:
+o Don't use syscall macros, use libc wrappers instead
+  (patch from Marian Jancar)
+o insmod: Allow module from stdin (eg. zcat foo.ko.gz | insmod -).
+o depmod: Remove old compat code to recognise ".o" and ".klm" as modules.
+o depmod: Implement -A properly (zlib is too slow).
+o depmod: zlib support.
+o modinfo: zlib support.
+o modinfo: handle - vs _ when searching for module.
+o modprobe: zlib support.
+o modprobe: remove unused fd var (patch from Andrey Borzenkov)
+o depmod: fix .ko.gz short names in tables (patch from Andrey Borzenkov)
+o configure.in: --moddir (patch from Lucas Correia Villa Real, GoboLinux)
+o modprobe: -r with multiple args (as per modutils) (bug from Harald Dunkel)
+o modprobe: Make -q ignore unknown modules
+o modprobe: Make -q still set exit value (bug from Jamie Lokier).
+       
+0.9.13 Version:
+o generate-modprobe.conf: Add --stdin (patch from Bill Nottingham)
+o README: Spelling fix (patch from Alex Goddard)
+o modprobe: print options out after modules for --show-depends, and
+       prefix with "insmod" (in case we want to show commands later).
+o modprobe: make --show-depends show commands (prefix: install).
+o Always use syscall() in backwards_compat.c: other archs want it.
+o depmod.c: Fix fd leak for deep dirs (patch from Arjan van de Ven)
+o modprobe.sgml: document -o/--name option.
+o modprobe: include files aliases should override: modprobe.devfs wants this
+       so users can override (patch from Martin Schlemmer)
+o depmod: fix handling of bad args (reported by Gorik Van Steenberge)
+o insmod: do --version/-V
+o depmod: fix "all modules are inside loop" corner case
+o depmod: Temporary file then move (patch from Andrey Borzenkov).
+o generate-modprobe.conf: Added space to PREINSTALL and PREREMOVE
+       before semicolon (Patch from Marian Jancar)
+o insmod: Backwards compat for insmod.static, too (Thanks to Marian Jancar)
+       
+0.9.12 Version:
+o modprobe.8: Document --set-version (Debian bug #187123, thanks Herbert)
+o rmmod.8: Fix raw lsmod(8) references (use proper sgml markup).
+o modinfo.c, rmmod.c: Fix includes for when no backwards compat
+       (Thanks to Bill Nottingham).
+o Makefile.am: lsmod.old symlink from /bin to /sbin in move-old-targets
+o depmod: sparc gcc register variable fake undefined fix.
+o Makefile.am: Handle Mandrake's .bz2 man pages (Thanks to Paolo Giarrusso)
+o depmod: backwards compat at 2.5.48, not 2.5.47 (Thanks to Martin Schimschak)
+o depmod: ieee1394 support (Thanks to Ben Collins)
+o depmod: updated test suite for ieee1394
+o Makefile: make symlink from /sbin/lsmod to /bin/lsmod if that's where we're going.
+o modinfo: add manual page.
+o modprobe: --show-depends (Asked by Herbert Xu for mkinitrd).
+o depmod: Simply and fix loop detection for non-trivial loops
+       
+0.9.11a Version:
+o Makefile: docbook2man fix (Thanks to Terje Rosten)
+o Makefile: make install man pages work with autoconf 1.4 (Thanks to Terje Rosten)
+       
+0.9.11 Version:
+o generate-modprobe.conf: Avoid "modprobe version" in stdout.
+o generate-modprobe.conf: Fix translation of "options dummy0 -o dummy0"
+o modprobe: add --set-version
+o modprobe: Add MODPROBE_OPTIONS env. var, and use it to pass some options.
+o Fix make moveold: (Thanks to Pavel Roskin, Will Stephenson)
+o README: Mention modprobe.devfs for devfs users (Thanks to Pavel Roskin)
+o lsmod: belongs in /bin, not /sbin (Thanks to Marco d'Itri)
+o Makefile: create man directories (Thanks to John Levon)
+o Makefile: no, use normal automake (Thanks v. much to John Levon)
+o Makefile: docbook2man tweaks and cleanups (Thanks to Terje Rosten)
+o Makefile: include man pages in dist, and clean in maintainer-clean
+       (Martin Schlemmer's report).
+       
+0.9.10 Version:
+o modprobe: Remove old .gnu.linkonce.modname renaming code
+o modprobe: Add -q flag.
+o srpm: install generate-modprobe.conf, too.
+o install: move kallsyms and ksyms as well to point to insmod.old
+       (Andrew Morton's report)
+o generate-modprobe.conf: don't worry about if statements: modprobe -c
+       expands them already
+o modprobe: Look for __module section as well as
+       .gnu.linkonce.this_module in renaming code.
+o modprobe: modules.devfsd handling, too (thanks to Martin Schlemmer).
+o modprobe.devfs: New file for devfs people.
+o modprobe: Handle vermagic in .modinfo section as well as own section.
+o depmod: Handle aliases in .modinfo section as well as .modalias section
+o Warnings added to build process.
+o modinfo: new binary
+o modinfo: new testcases
+o generate-modprobe.conf: handle missing mktemp
+       
+0.9.9 Version:
+o Install generate-modprobe.conf, too.
+o Start an FAQ
+o generate-modprobe.conf: use mktemp with an arg (Luuk van der Duim's report)
+o Richard Henderson's weak symbol support.
+o Anton's .foo == foo support for PPC64.
+o --force for removing version information
+o generate-modprobe.conf: fix one arg usage (Bug from David van Hoose)
+o generate-modprobe.conf: add ; inside { } (from Martin Schlemmer)
+o Kai's --force-version patch, modified.
+o Zibx Verituse's multiple whitespace in parser patch.
+o depmod: Handle strings for GPL in separate section, too.
+o lsmod: remove double unistd include (Bug from Dennis Schulz)
+o modprobe: Document --force* and -s
+       
+0.9.8 Version:
+o Use docbook2man if docbook-to-man not found (Warren Togami's bug report) 
+o Implement -s in modprobe
+o If stderr is not open, act as if "--syslog" was given.
+o Remove documentation about aliases not overriding real modules.
+o Add support for modules.alias and modules.symbols to depmod and modprobe.
+o Fix handling of errors in modprobe.conf (Roger Luethi's bug report)
+o Petr Vandrovec's __gpl_ksymtab fix.
+       
+0.9.7 Version:
+o Man pages
+o modules.conf2modprobe.conf "above" and "below" support.
+o Silly typo in filename to modname conversion.
+o Double free fix (Marco d'Itri)
+o Add --dry-run as synonym for --show everywhere.
+o Change backwards compat test to sys_create_module(NULL, 0) != -ENOSYS,
+  for people who want /proc/ksyms.
+o modules.conf2modprobe.conf renamed to generate-modprobe.conf, uses
+  modprobe -c to get built-ins as well.
+       
+0.9.6 Version:
+o Fix aliases using - and _ (thanks to Roger Luethi)
+o Audit for more _ - comparisons: canonicalize at input.
+o Fix "include overrides alias" bug found during audit.
+o Testsuite added
+o lsmod ignores trailing (new-style) entries in /proc/modules, and deletes ,.
+o message segfault due to reusing varargs fixed.
+o Give 0 exit status with --dry-run with wildcards (Roger Luethi's bug report)
+o Add --all option (Roger Luethi's bug report)
+o Fix double-insert problem caused by symlinks (Roger Luethi's bug report)
+o Ignore undefined __start_ and __stop_ as future kernel might.
+o Report loops only once.
+o Fix complex duplicate elimination handling.
+o Implemented --ignore-command in modprobe
+o Implemented "remove" in modprobe's modprobe.conf parsing.
+o Don't die if /proc/modules can't be opened.
+o Modprobe -r checks for in-use modules before trying.
+o Warn about lines in modprobe.conf which aren't understood.
+o Remove extra spaces in options generated by modprobe.
+o Extract 64/32 moduleops into common code.
+o Reimplemented wildcard aliases.
+o Horrible workaround for devfsd.
+o Fix handling of wildcards in modules.conf2modprobe.conf
+
+0.9.5 Version:
+o Fix bogus compare code where "modprobe tuner" loaded tun module
+  (Thanks to Marco d'Itri's bug report).
+o Handle rth-style modules in modprobe namechange code.
+o Marco d'Itri's patch to correct quotes
+o Marco d'Itri's patch to implement -A.
+o Fixed rmmod's message when no unload support.
+o Fix backwards compat recursion protection to compare PIDs (Petr Vandrovec)
+o Implement -F and -e.
+o Tweak message when invalid parameter given (Roger Luethi's report)
+       
+0.9.4 Version
+o Implement loop detection and duplicate elimination (thanks to Jeff
+  Chua's ide.ko / ide-io.ko bug report)
+o Fix stress_modules.sh script for new names and dir layout
+o Updated README to put autoconf at the bottom (most people don't need it)
+o Implemented -v in depmod
+o Implemented -l and -t in modprobe.
+o Implemented -a in modprobe.
+o Removed gratuitous configure.in target test (we do 64/32 dynamically)
+o Adam Richter's depmod patch to traverse above kernel/ dir.
+o Fix -r to be properly ignored (Chris Cheney's bug report)
+
+0.9.3 Version
+o Fix modprobe -r ordering (tried to remove backwards) (Jim Radford's report)
+o David Brownell's extra rmmod options (modified)
+
+0.9.2 Version
+o Matthieu Verbert <mve@zurich.ibm.com>'s objdir != srcdir install fix.
+o Fixed insmod option ignores (Petr Vandrovec's bug report)
+o Arnd Bergmann <arnd@bergmann-dalldorf.de>'s modules.ccwmap implementation.
+o Jim Radford <radford@blackbean.org>'s modprobe -r implementation.
+       
+0.9.1 Version
+o Include install-with-care script in dist
+
+0.9 Version
+o Added install-with-care script to check we're not destroying old utils
+o Split moveold into two targets for gentoo
+o Don't use readlink in moveold: RH8.0 doesn't have it by default
+o Fix ia64 _syscall5 problem (undefined reference to `__ia64_syscall')
+       
+0.9-alpha Version
+o Fixed patch in NEWS to leave #include linux/elf.h, needed for
+  CONFIG_KALLSYMS.
+o Fixed extra newline in "in use by" message.
+o Fixed parsing for new-style /proc/modules.
+o Fixed version parsing code (thanks to Adam Richter's report)
+o Fixed "running out of filedescriptors" (Adam Richter)        
+o Implemented options in modprobe
+o Implemented install in modprobe
+o Implemented options in modules.conf2modprobe.conf
+o Implemented install in modules.conf2modprobe.conf
+o Implemented probeall in modules.conf2modprobe.conf
+o Implemented probe in modules.conf2modprobe.conf
+o Changed modprobe version to be constant string, for "strings" to work easily.
+       
+0.8a Version
+o Fixed erroneous warning on rmmod saying it didn't find module in
+  /proc/modules
+       
+0.8 Version
+o Chris Cheney's automake patch
+o Adam J. Richter's "use depmod" patch (simplifies aliases, handles include)
+o Cleaned up error handling a little
+o Implemented --name/-o to change module name (requires Kai's modname patch)
+o David Hardeman's dummy options patch for Debian.
+o Updated version number (thanks to David Hardeman).
+o Fix "sbin not in path" .old exec problem.
+o Remove assumptions about module extension.
+o Added "links" and "moveold" targets, and leave using them to the user.
+o Implemented new depmod which works with current kernels, calls old
+  one for previous kernels.
+o First cut of modules.conf2modprobe.conf
+o Implemented dummy insmod -p, -s and -f options, requested by Petr Vandrovec
+
+0.7a Version
+o 64/32 bit autodetection thanks to Dave Miller
+o Preliminary alias support.
+o Very primitive /etc/modprobe.conf support
+o Fix for "rmmod ide-cd" (bug from Jens Axboe)
+o Options args for modprobe
diff --git a/FAQ b/FAQ
new file mode 100644 (file)
index 0000000..3db4716
--- /dev/null
+++ b/FAQ
@@ -0,0 +1,13 @@
+Frequently Asked Module User Questions
+--------------------------------------
+
+Q) Where should I report bugs?
+A) Please post to the linux-modules@vger.kernel.org mailing list, along with
+   a description of how to reproduce. Copy Jon Masters <jcm@jonmasters.org>.
+
+Q) I get "/usr/bin/ld: cannot find -lc"
+A) You need to install a development package which contains libc.a.
+   For example, on Fedora systems, you would type "yum install glibc-static".
+
+Q) I'm having trouble inserting out-of-tree modules
+A) See kernel source tree documentation: Documentation/kbuild/modules.txt
diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..d3c5b40
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,237 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+  6. Often, you can also type `make uninstall' to remove the installed
+     files again.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+     Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..6f83c12
--- /dev/null
@@ -0,0 +1,114 @@
+ACLOCAL_AMFLAGS = -I m4
+
+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 tables.c \
+       zlibsupport.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 = libmodtools.a
+
+EXTRA_insmod_SOURCES =
+EXTRA_lsmod_SOURCES =
+EXTRA_modprobe_SOURCES = 
+EXTRA_rmmod_SOURCES =
+EXTRA_insmod_static_SOURCES =
+EXTRA_depmod_SOURCES =
+EXTRA_modinfo_SOURCES =
+
+libmodtools_a_SOURCES = util.c logging.c index.c config_filter.c elfops.c \
+       util.h depmod.h logging.h index.h list.h config_filter.h elfops.h
+libmodtools_a_CFLAGS = -ffunction-sections
+
+EXTRA_libmodtools_a_SOURCES = elfops_core.c
+
+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 modprobe.d.5
+MAN8 = depmod.8 insmod.8 lsmod.8 rmmod.8 modprobe.8 modinfo.8
+SGML = $(addprefix doc/,  $(MAN5:%.5=%.sgml) $(MAN8:%.8=%.sgml))
+dist_man_MANS = $(MAN5) $(MAN8)
+# If they haven't overridden mandir, fix it (never /man!)
+mandir =$(shell if [ @mandir@ = $(prefix)/man ]; then if [ $(prefix) = / ]; then echo /usr/share/man; else echo $(prefix)/share/man; fi; else echo @mandir@; fi)
+
+TESTSUITE := $(shell test -e @srcdir@/tests && find @srcdir@/tests -type f ! -name '*~')
+
+EXTRA_DIST = generate-modprobe.conf FAQ CODING stress_modules.sh install-with-care $(SGML) $(man_MANS) $(TESTSUITE)
+
+sbin_PROGRAMS = insmod modprobe rmmod depmod modinfo
+if BUILD_STATIC_UTILS
+sbin_PROGRAMS += insmod.static
+endif
+bin_PROGRAMS = lsmod
+noinst_PROGRAMS=modindex
+noinst_LIBRARIES = libmodtools.a
+INSTALL = $(SHELL) $(top_srcdir)/install-with-care
+
+DIST_DIR := /data/work/releases/module-init-tools/
+
+MAINTAINERCLEANFILES := $(man_MANS)
+
+# docbook2man writes file itself, doesn't do stdout.
+%.8: doc/%.sgml
+       if [ "$(DOCBOOKTOMAN)" = "docbook2man" ]; then                     \
+           $(DOCBOOKTOMAN) $< > /dev/null 2>&1;                       \
+       else                                                               \
+           $(DOCBOOKTOMAN) $< 2>&1 > $@ | sed 's/^[^:]*://';              \
+       fi
+
+%.5: doc/%.sgml
+       if [ "$(DOCBOOKTOMAN)" = "docbook2man" ]; then                     \
+           $(DOCBOOKTOMAN) $< > /dev/null 2>&1;                       \
+       else                                                               \
+           $(DOCBOOKTOMAN) $< 2>&1 > $@ | sed 's/^[^:]*://';              \
+       fi
+
+# docbook2man creates extra crap files which need cleaning.
+distclean-local: killbuildmanpages
+
+killbuildmanpages:
+       rm -f doc/*.tmp manpage.refs manpage.links
+
+tarball: $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz
+
+$(DIST_DIR)/module-init-tools-$(VERSION).tar.gz: dist
+       mv module-init-tools-$(VERSION).tar.gz $@
+
+srpm: $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz
+       ln -sf $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz /usr/src/rpm/SOURCES/
+       set -e; RELEASE=`grep '^Release:' /usr/src/rpm/SPECS/modutils.spec | awk '{ print $$2 }'`; \
+       if [ "`grep '%define mit_ver' /usr/src/rpm/SPECS/modutils.spec | awk '{print $$3}'`" != $(VERSION) ]; then \
+               sed -e "s/Release: $$RELEASE/Release: `expr $$RELEASE + 1`/" -e 's/%define mit_ver.*/%define mit_ver $(VERSION)/' < /usr/src/rpm/SPECS/modutils.spec > /tmp/modutils.spec; \
+               rpm -ba /tmp/modutils.spec; \
+               mv /usr/src/rpm/SRPMS/modutils-2.4.21-`expr $$RELEASE + 1`.src.rpm $(DIST_DIR); \
+               mv /tmp/modutils.spec /usr/src/rpm/SPECS/modutils.spec; \
+       else \
+               rpm -ba /usr/src/rpm/SPECS/modutils.spec; \
+               mv /usr/src/rpm/SRPMS/modutils-2.4.21-$$RELEASE.src.rpm $(DIST_DIR); \
+       fi
+
+# No testsuite?
+tests/runtests:
+       mkdir tests
+       echo '#! /bin/sh' > $@
+       echo '# Install the testsuite over this dir. ' >> $@
+       chmod a+x $@
+
+$(DIST_DIR)/module-init-tools-testsuite-$(VERSION).tar.gz:
+       ln -sfn `pwd` /tmp/module-init-tools-$(VERSION) 
+       cd /tmp && tar --exclude '*~' -c -z -f $@ module-init-tools-$(VERSION)/tests
+       rm /tmp/module-init-tools-$(VERSION)
+
+release: check clean tarball
diff --git a/Makefile.in b/Makefile.in
new file mode 100644 (file)
index 0000000..06e4931
--- /dev/null
@@ -0,0 +1,1051 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+sbin_PROGRAMS = insmod$(EXEEXT) modprobe$(EXEEXT) rmmod$(EXEEXT) \
+       depmod$(EXEEXT) modinfo$(EXEEXT) $(am__EXEEXT_1)
+@BUILD_STATIC_UTILS_TRUE@am__append_1 = insmod.static
+bin_PROGRAMS = lsmod$(EXEEXT)
+noinst_PROGRAMS = modindex$(EXEEXT)
+subdir = .
+DIST_COMMON = README $(am__configure_deps) $(dist_man_MANS) \
+       $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+       $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
+       TODO config.guess config.sub depcomp install-sh missing
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_configure_args.m4 \
+       $(top_srcdir)/m4/ax_enable_builddir.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+libmodtools_a_AR = $(AR) $(ARFLAGS)
+libmodtools_a_LIBADD =
+am_libmodtools_a_OBJECTS = libmodtools_a-util.$(OBJEXT) \
+       libmodtools_a-logging.$(OBJEXT) libmodtools_a-index.$(OBJEXT) \
+       libmodtools_a-config_filter.$(OBJEXT) \
+       libmodtools_a-elfops.$(OBJEXT)
+libmodtools_a_OBJECTS = $(am_libmodtools_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" \
+       "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man8dir)"
+@BUILD_STATIC_UTILS_TRUE@am__EXEEXT_1 = insmod.static$(EXEEXT)
+PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) $(sbin_PROGRAMS)
+am_depmod_OBJECTS = depmod.$(OBJEXT) zlibsupport.$(OBJEXT) \
+       tables.$(OBJEXT)
+depmod_OBJECTS = $(am_depmod_OBJECTS)
+am__DEPENDENCIES_1 =
+depmod_DEPENDENCIES = $(am__DEPENDENCIES_1) libmodtools.a
+am_insmod_OBJECTS = insmod.$(OBJEXT)
+insmod_OBJECTS = $(am_insmod_OBJECTS)
+insmod_DEPENDENCIES = $(am__DEPENDENCIES_1) libmodtools.a
+am_insmod_static_OBJECTS = insmod.$(OBJEXT)
+insmod_static_OBJECTS = $(am_insmod_static_OBJECTS)
+insmod_static_DEPENDENCIES = libmodtools.a
+insmod_static_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(insmod_static_LDFLAGS) $(LDFLAGS) -o $@
+am_lsmod_OBJECTS = lsmod.$(OBJEXT)
+lsmod_OBJECTS = $(am_lsmod_OBJECTS)
+lsmod_DEPENDENCIES = $(am__DEPENDENCIES_1) libmodtools.a
+am_modindex_OBJECTS = modindex.$(OBJEXT) zlibsupport.$(OBJEXT)
+modindex_OBJECTS = $(am_modindex_OBJECTS)
+modindex_DEPENDENCIES = $(am__DEPENDENCIES_1) libmodtools.a
+am_modinfo_OBJECTS = modinfo.$(OBJEXT) zlibsupport.$(OBJEXT)
+modinfo_OBJECTS = $(am_modinfo_OBJECTS)
+modinfo_DEPENDENCIES = $(am__DEPENDENCIES_1) libmodtools.a
+am_modprobe_OBJECTS = modprobe.$(OBJEXT) zlibsupport.$(OBJEXT)
+modprobe_OBJECTS = $(am_modprobe_OBJECTS)
+modprobe_DEPENDENCIES = $(am__DEPENDENCIES_1) libmodtools.a
+am_rmmod_OBJECTS = rmmod.$(OBJEXT)
+rmmod_OBJECTS = $(am_rmmod_OBJECTS)
+rmmod_DEPENDENCIES = $(am__DEPENDENCIES_1) libmodtools.a
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libmodtools_a_SOURCES) $(EXTRA_libmodtools_a_SOURCES) \
+       $(depmod_SOURCES) $(EXTRA_depmod_SOURCES) $(insmod_SOURCES) \
+       $(EXTRA_insmod_SOURCES) $(insmod_static_SOURCES) \
+       $(EXTRA_insmod_static_SOURCES) $(lsmod_SOURCES) \
+       $(EXTRA_lsmod_SOURCES) $(modindex_SOURCES) $(modinfo_SOURCES) \
+       $(EXTRA_modinfo_SOURCES) $(modprobe_SOURCES) \
+       $(EXTRA_modprobe_SOURCES) $(rmmod_SOURCES) \
+       $(EXTRA_rmmod_SOURCES)
+DIST_SOURCES = $(libmodtools_a_SOURCES) $(EXTRA_libmodtools_a_SOURCES) \
+       $(depmod_SOURCES) $(EXTRA_depmod_SOURCES) $(insmod_SOURCES) \
+       $(EXTRA_insmod_SOURCES) $(insmod_static_SOURCES) \
+       $(EXTRA_insmod_static_SOURCES) $(lsmod_SOURCES) \
+       $(EXTRA_lsmod_SOURCES) $(modindex_SOURCES) $(modinfo_SOURCES) \
+       $(EXTRA_modinfo_SOURCES) $(modprobe_SOURCES) \
+       $(EXTRA_modprobe_SOURCES) $(rmmod_SOURCES) \
+       $(EXTRA_rmmod_SOURCES)
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+man5dir = $(mandir)/man5
+man8dir = $(mandir)/man8
+NROFF = nroff
+MANS = $(dist_man_MANS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  { test ! -d "$(distdir)" \
+    || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr "$(distdir)"; }; }
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DOCBOOKTOMAN = @DOCBOOKTOMAN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EXEEXT = @EXEEXT@
+INSTALL = $(SHELL) $(top_srcdir)/install-with-care
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDADD = @LDADD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MODULE_DIR = @MODULE_DIR@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+ax_enable_builddir_sed = @ax_enable_builddir_sed@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+# If they haven't overridden mandir, fix it (never /man!)
+mandir = $(shell if [ @mandir@ = $(prefix)/man ]; then if [ $(prefix) = / ]; then echo /usr/share/man; else echo $(prefix)/share/man; fi; else echo @mandir@; fi)
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+ACLOCAL_AMFLAGS = -I m4
+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 tables.c \
+       zlibsupport.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 = libmodtools.a
+EXTRA_insmod_SOURCES = 
+EXTRA_lsmod_SOURCES = 
+EXTRA_modprobe_SOURCES = 
+EXTRA_rmmod_SOURCES = 
+EXTRA_insmod_static_SOURCES = 
+EXTRA_depmod_SOURCES = 
+EXTRA_modinfo_SOURCES = 
+libmodtools_a_SOURCES = util.c logging.c index.c config_filter.c elfops.c \
+       util.h depmod.h logging.h index.h list.h config_filter.h elfops.h
+
+libmodtools_a_CFLAGS = -ffunction-sections
+EXTRA_libmodtools_a_SOURCES = elfops_core.c
+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 modprobe.d.5
+MAN8 = depmod.8 insmod.8 lsmod.8 rmmod.8 modprobe.8 modinfo.8
+SGML = $(addprefix doc/,  $(MAN5:%.5=%.sgml) $(MAN8:%.8=%.sgml))
+ifdef dont-disable-documentation-for-slp
+dist_man_MANS = $(MAN5) $(MAN8)
+else
+dist_man_MANS =
+endif
+TESTSUITE := $(shell test -e @srcdir@/tests && find @srcdir@/tests -type f ! -name '*~')
+EXTRA_DIST = generate-modprobe.conf FAQ CODING stress_modules.sh install-with-care $(SGML) $(man_MANS) $(TESTSUITE)
+noinst_LIBRARIES = libmodtools.a
+DIST_DIR := /data/work/releases/module-init-tools/
+MAINTAINERCLEANFILES := $(man_MANS)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
+am--refresh:
+       @:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
+             $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
+               && exit 0; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           echo ' $(SHELL) ./config.status'; \
+           $(SHELL) ./config.status;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       $(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       $(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+       -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libmodtools.a: $(libmodtools_a_OBJECTS) $(libmodtools_a_DEPENDENCIES) 
+       -rm -f libmodtools.a
+       $(libmodtools_a_AR) libmodtools.a $(libmodtools_a_OBJECTS) $(libmodtools_a_LIBADD)
+       $(RANLIB) libmodtools.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       for p in $$list; do echo "$$p $$p"; done | \
+       sed 's/$(EXEEXT)$$//' | \
+       while read p p1; do if test -f $$p; \
+         then echo "$$p"; echo "$$p"; else :; fi; \
+       done | \
+       sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+           -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+       sed 'N;N;N;s,\n, ,g' | \
+       $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+         { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+           if ($$2 == $$4) files[d] = files[d] " " $$1; \
+           else { print "f", $$3 "/" $$4, $$1; } } \
+         END { for (d in files) print "f", d, files[d] }' | \
+       while read type dir files; do \
+           if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+           test -z "$$files" || { \
+             echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+             $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+           } \
+       ; done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       files=`for p in $$list; do echo "$$p"; done | \
+         sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+             -e 's/$$/$(EXEEXT)/' `; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+       -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+
+clean-noinstPROGRAMS:
+       -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
+install-sbinPROGRAMS: $(sbin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)"
+       @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
+       for p in $$list; do echo "$$p $$p"; done | \
+       sed 's/$(EXEEXT)$$//' | \
+       while read p p1; do if test -f $$p; \
+         then echo "$$p"; echo "$$p"; else :; fi; \
+       done | \
+       sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+           -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+       sed 'N;N;N;s,\n, ,g' | \
+       $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+         { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+           if ($$2 == $$4) files[d] = files[d] " " $$1; \
+           else { print "f", $$3 "/" $$4, $$1; } } \
+         END { for (d in files) print "f", d, files[d] }' | \
+       while read type dir files; do \
+           if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+           test -z "$$files" || { \
+             echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \
+             $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \
+           } \
+       ; done
+
+uninstall-sbinPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
+       files=`for p in $$list; do echo "$$p"; done | \
+         sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+             -e 's/$$/$(EXEEXT)/' `; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(sbindir)" && rm -f $$files
+
+clean-sbinPROGRAMS:
+       -test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+depmod$(EXEEXT): $(depmod_OBJECTS) $(depmod_DEPENDENCIES) 
+       @rm -f depmod$(EXEEXT)
+       $(LINK) $(depmod_OBJECTS) $(depmod_LDADD) $(LIBS)
+insmod$(EXEEXT): $(insmod_OBJECTS) $(insmod_DEPENDENCIES) 
+       @rm -f insmod$(EXEEXT)
+       $(LINK) $(insmod_OBJECTS) $(insmod_LDADD) $(LIBS)
+insmod.static$(EXEEXT): $(insmod_static_OBJECTS) $(insmod_static_DEPENDENCIES) 
+       @rm -f insmod.static$(EXEEXT)
+       $(insmod_static_LINK) $(insmod_static_OBJECTS) $(insmod_static_LDADD) $(LIBS)
+lsmod$(EXEEXT): $(lsmod_OBJECTS) $(lsmod_DEPENDENCIES) 
+       @rm -f lsmod$(EXEEXT)
+       $(LINK) $(lsmod_OBJECTS) $(lsmod_LDADD) $(LIBS)
+modindex$(EXEEXT): $(modindex_OBJECTS) $(modindex_DEPENDENCIES) 
+       @rm -f modindex$(EXEEXT)
+       $(LINK) $(modindex_OBJECTS) $(modindex_LDADD) $(LIBS)
+modinfo$(EXEEXT): $(modinfo_OBJECTS) $(modinfo_DEPENDENCIES) 
+       @rm -f modinfo$(EXEEXT)
+       $(LINK) $(modinfo_OBJECTS) $(modinfo_LDADD) $(LIBS)
+modprobe$(EXEEXT): $(modprobe_OBJECTS) $(modprobe_DEPENDENCIES) 
+       @rm -f modprobe$(EXEEXT)
+       $(LINK) $(modprobe_OBJECTS) $(modprobe_LDADD) $(LIBS)
+rmmod$(EXEEXT): $(rmmod_OBJECTS) $(rmmod_DEPENDENCIES) 
+       @rm -f rmmod$(EXEEXT)
+       $(LINK) $(rmmod_OBJECTS) $(rmmod_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/depmod.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insmod.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmodtools_a-config_filter.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmodtools_a-elfops.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmodtools_a-elfops_core.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmodtools_a-index.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmodtools_a-logging.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmodtools_a-util.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsmod.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modindex.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modinfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modprobe.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rmmod.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tables.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zlibsupport.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+libmodtools_a-util.o: util.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -MT libmodtools_a-util.o -MD -MP -MF $(DEPDIR)/libmodtools_a-util.Tpo -c -o libmodtools_a-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libmodtools_a-util.Tpo $(DEPDIR)/libmodtools_a-util.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='util.c' object='libmodtools_a-util.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -c -o libmodtools_a-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c
+
+libmodtools_a-util.obj: util.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -MT libmodtools_a-util.obj -MD -MP -MF $(DEPDIR)/libmodtools_a-util.Tpo -c -o libmodtools_a-util.obj `if test -f 'util.c'; then $(CYGPATH_W) 'util.c'; else $(CYGPATH_W) '$(srcdir)/util.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libmodtools_a-util.Tpo $(DEPDIR)/libmodtools_a-util.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='util.c' object='libmodtools_a-util.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -c -o libmodtools_a-util.obj `if test -f 'util.c'; then $(CYGPATH_W) 'util.c'; else $(CYGPATH_W) '$(srcdir)/util.c'; fi`
+
+libmodtools_a-logging.o: logging.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -MT libmodtools_a-logging.o -MD -MP -MF $(DEPDIR)/libmodtools_a-logging.Tpo -c -o libmodtools_a-logging.o `test -f 'logging.c' || echo '$(srcdir)/'`logging.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libmodtools_a-logging.Tpo $(DEPDIR)/libmodtools_a-logging.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='logging.c' object='libmodtools_a-logging.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -c -o libmodtools_a-logging.o `test -f 'logging.c' || echo '$(srcdir)/'`logging.c
+
+libmodtools_a-logging.obj: logging.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -MT libmodtools_a-logging.obj -MD -MP -MF $(DEPDIR)/libmodtools_a-logging.Tpo -c -o libmodtools_a-logging.obj `if test -f 'logging.c'; then $(CYGPATH_W) 'logging.c'; else $(CYGPATH_W) '$(srcdir)/logging.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libmodtools_a-logging.Tpo $(DEPDIR)/libmodtools_a-logging.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='logging.c' object='libmodtools_a-logging.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -c -o libmodtools_a-logging.obj `if test -f 'logging.c'; then $(CYGPATH_W) 'logging.c'; else $(CYGPATH_W) '$(srcdir)/logging.c'; fi`
+
+libmodtools_a-index.o: index.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -MT libmodtools_a-index.o -MD -MP -MF $(DEPDIR)/libmodtools_a-index.Tpo -c -o libmodtools_a-index.o `test -f 'index.c' || echo '$(srcdir)/'`index.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libmodtools_a-index.Tpo $(DEPDIR)/libmodtools_a-index.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='index.c' object='libmodtools_a-index.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -c -o libmodtools_a-index.o `test -f 'index.c' || echo '$(srcdir)/'`index.c
+
+libmodtools_a-index.obj: index.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -MT libmodtools_a-index.obj -MD -MP -MF $(DEPDIR)/libmodtools_a-index.Tpo -c -o libmodtools_a-index.obj `if test -f 'index.c'; then $(CYGPATH_W) 'index.c'; else $(CYGPATH_W) '$(srcdir)/index.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libmodtools_a-index.Tpo $(DEPDIR)/libmodtools_a-index.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='index.c' object='libmodtools_a-index.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -c -o libmodtools_a-index.obj `if test -f 'index.c'; then $(CYGPATH_W) 'index.c'; else $(CYGPATH_W) '$(srcdir)/index.c'; fi`
+
+libmodtools_a-config_filter.o: config_filter.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -MT libmodtools_a-config_filter.o -MD -MP -MF $(DEPDIR)/libmodtools_a-config_filter.Tpo -c -o libmodtools_a-config_filter.o `test -f 'config_filter.c' || echo '$(srcdir)/'`config_filter.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libmodtools_a-config_filter.Tpo $(DEPDIR)/libmodtools_a-config_filter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='config_filter.c' object='libmodtools_a-config_filter.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -c -o libmodtools_a-config_filter.o `test -f 'config_filter.c' || echo '$(srcdir)/'`config_filter.c
+
+libmodtools_a-config_filter.obj: config_filter.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -MT libmodtools_a-config_filter.obj -MD -MP -MF $(DEPDIR)/libmodtools_a-config_filter.Tpo -c -o libmodtools_a-config_filter.obj `if test -f 'config_filter.c'; then $(CYGPATH_W) 'config_filter.c'; else $(CYGPATH_W) '$(srcdir)/config_filter.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libmodtools_a-config_filter.Tpo $(DEPDIR)/libmodtools_a-config_filter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='config_filter.c' object='libmodtools_a-config_filter.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -c -o libmodtools_a-config_filter.obj `if test -f 'config_filter.c'; then $(CYGPATH_W) 'config_filter.c'; else $(CYGPATH_W) '$(srcdir)/config_filter.c'; fi`
+
+libmodtools_a-elfops.o: elfops.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -MT libmodtools_a-elfops.o -MD -MP -MF $(DEPDIR)/libmodtools_a-elfops.Tpo -c -o libmodtools_a-elfops.o `test -f 'elfops.c' || echo '$(srcdir)/'`elfops.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libmodtools_a-elfops.Tpo $(DEPDIR)/libmodtools_a-elfops.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='elfops.c' object='libmodtools_a-elfops.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -c -o libmodtools_a-elfops.o `test -f 'elfops.c' || echo '$(srcdir)/'`elfops.c
+
+libmodtools_a-elfops.obj: elfops.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -MT libmodtools_a-elfops.obj -MD -MP -MF $(DEPDIR)/libmodtools_a-elfops.Tpo -c -o libmodtools_a-elfops.obj `if test -f 'elfops.c'; then $(CYGPATH_W) 'elfops.c'; else $(CYGPATH_W) '$(srcdir)/elfops.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libmodtools_a-elfops.Tpo $(DEPDIR)/libmodtools_a-elfops.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='elfops.c' object='libmodtools_a-elfops.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -c -o libmodtools_a-elfops.obj `if test -f 'elfops.c'; then $(CYGPATH_W) 'elfops.c'; else $(CYGPATH_W) '$(srcdir)/elfops.c'; fi`
+
+libmodtools_a-elfops_core.o: elfops_core.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -MT libmodtools_a-elfops_core.o -MD -MP -MF $(DEPDIR)/libmodtools_a-elfops_core.Tpo -c -o libmodtools_a-elfops_core.o `test -f 'elfops_core.c' || echo '$(srcdir)/'`elfops_core.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libmodtools_a-elfops_core.Tpo $(DEPDIR)/libmodtools_a-elfops_core.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='elfops_core.c' object='libmodtools_a-elfops_core.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -c -o libmodtools_a-elfops_core.o `test -f 'elfops_core.c' || echo '$(srcdir)/'`elfops_core.c
+
+libmodtools_a-elfops_core.obj: elfops_core.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -MT libmodtools_a-elfops_core.obj -MD -MP -MF $(DEPDIR)/libmodtools_a-elfops_core.Tpo -c -o libmodtools_a-elfops_core.obj `if test -f 'elfops_core.c'; then $(CYGPATH_W) 'elfops_core.c'; else $(CYGPATH_W) '$(srcdir)/elfops_core.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libmodtools_a-elfops_core.Tpo $(DEPDIR)/libmodtools_a-elfops_core.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='elfops_core.c' object='libmodtools_a-elfops_core.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmodtools_a_CFLAGS) $(CFLAGS) -c -o libmodtools_a-elfops_core.obj `if test -f 'elfops_core.c'; then $(CYGPATH_W) 'elfops_core.c'; else $(CYGPATH_W) '$(srcdir)/elfops_core.c'; fi`
+install-man5: $(dist_man_MANS)
+       @$(NORMAL_INSTALL)
+       test -z "$(man5dir)" || $(MKDIR_P) "$(DESTDIR)$(man5dir)"
+       @list=''; test -n "$(man5dir)" || exit 0; \
+       { for i in $$list; do echo "$$i"; done; \
+       l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.5[a-z]*$$/p'; \
+       } | while read p; do \
+         if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; echo "$$p"; \
+       done | \
+       sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+       sed 'N;N;s,\n, ,g' | { \
+       list=; while read file base inst; do \
+         if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+           echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \
+           $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst" || exit $$?; \
+         fi; \
+       done; \
+       for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+       while read files; do \
+         test -z "$$files" || { \
+           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man5dir)'"; \
+           $(INSTALL_DATA) $$files "$(DESTDIR)$(man5dir)" || exit $$?; }; \
+       done; }
+
+uninstall-man5:
+       @$(NORMAL_UNINSTALL)
+       @list=''; test -n "$(man5dir)" || exit 0; \
+       files=`{ for i in $$list; do echo "$$i"; done; \
+       l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.5[a-z]*$$/p'; \
+       } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+       test -z "$$files" || { \
+         echo " ( cd '$(DESTDIR)$(man5dir)' && rm -f" $$files ")"; \
+         cd "$(DESTDIR)$(man5dir)" && rm -f $$files; }
+install-man8: $(dist_man_MANS)
+       @$(NORMAL_INSTALL)
+       test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)"
+       @list=''; test -n "$(man8dir)" || exit 0; \
+       { for i in $$list; do echo "$$i"; done; \
+       l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.8[a-z]*$$/p'; \
+       } | while read p; do \
+         if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; echo "$$p"; \
+       done | \
+       sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+       sed 'N;N;s,\n, ,g' | { \
+       list=; while read file base inst; do \
+         if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+           echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \
+           $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \
+         fi; \
+       done; \
+       for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+       while read files; do \
+         test -z "$$files" || { \
+           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \
+           $(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \
+       done; }
+
+uninstall-man8:
+       @$(NORMAL_UNINSTALL)
+       @list=''; test -n "$(man8dir)" || exit 0; \
+       files=`{ for i in $$list; do echo "$$i"; done; \
+       l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.8[a-z]*$$/p'; \
+       } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+       test -z "$$files" || { \
+         echo " ( cd '$(DESTDIR)$(man8dir)' && rm -f" $$files ")"; \
+         cd "$(DESTDIR)$(man8dir)" && rm -f $$files; }
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @list='$(MANS)'; if test -n "$$list"; then \
+         list=`for p in $$list; do \
+           if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+           if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
+         if test -n "$$list" && \
+           grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
+           echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
+           grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/         /' >&2; \
+           echo "       to fix them, install help2man, remove and regenerate the man pages;" >&2; \
+           echo "       typically \`make maintainer-clean' will remove them" >&2; \
+           exit 1; \
+         else :; fi; \
+       else :; fi
+       $(am__remove_distdir)
+       test -d "$(distdir)" || mkdir "$(distdir)"
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+       -test -n "$(am__skip_mode_fix)" \
+       || find "$(distdir)" -type d ! -perm -755 \
+               -exec chmod u+rwx,go+rx {} \; -o \
+         ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+       || chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+dist-bzip2: distdir
+       tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+       $(am__remove_distdir)
+
+dist-lzma: distdir
+       tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+       $(am__remove_distdir)
+
+dist-xz: distdir
+       tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
+       $(am__remove_distdir)
+
+dist-tarZ: distdir
+       tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+       $(am__remove_distdir)
+
+dist-shar: distdir
+       shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+       $(am__remove_distdir)
+
+dist-zip: distdir
+       -rm -f $(distdir).zip
+       zip -rq $(distdir).zip $(distdir)
+       $(am__remove_distdir)
+
+dist dist-all: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+       case '$(DIST_ARCHIVES)' in \
+       *.tar.gz*) \
+         GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+       *.tar.bz2*) \
+         bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+       *.tar.lzma*) \
+         lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
+       *.tar.xz*) \
+         xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+       *.tar.Z*) \
+         uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+       *.shar.gz*) \
+         GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+       *.zip*) \
+         unzip $(distdir).zip ;;\
+       esac
+       chmod -R a-w $(distdir); chmod a+w $(distdir)
+       mkdir $(distdir)/_build
+       mkdir $(distdir)/_inst
+       chmod a-w $(distdir)
+       test -d $(distdir)/_build || exit 0; \
+       dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+         && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+         && am__cwd=`pwd` \
+         && $(am__cd) $(distdir)/_build \
+         && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+           $(DISTCHECK_CONFIGURE_FLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) dvi \
+         && $(MAKE) $(AM_MAKEFLAGS) check \
+         && $(MAKE) $(AM_MAKEFLAGS) install \
+         && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+         && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+         && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+               distuninstallcheck \
+         && chmod -R a-w "$$dc_install_base" \
+         && ({ \
+              (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+                   distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+             } || { rm -rf "$$dc_destdir"; exit 1; }) \
+         && rm -rf "$$dc_destdir" \
+         && $(MAKE) $(AM_MAKEFLAGS) dist \
+         && rm -rf $(DIST_ARCHIVES) \
+         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+         && cd "$$am__cwd" \
+         || exit 1
+       $(am__remove_distdir)
+       @(echo "$(distdir) archives ready for distribution: "; \
+         list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+         sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+       @$(am__cd) '$(distuninstallcheck_dir)' \
+       && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+          || { echo "ERROR: files left after uninstall:" ; \
+               if test -n "$(DESTDIR)"; then \
+                 echo "  (check DESTDIR support)"; \
+               fi ; \
+               $(distuninstallcheck_listfiles) ; \
+               exit 1; } >&2
+distcleancheck: distclean
+       @if test '$(srcdir)' = . ; then \
+         echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+         exit 1 ; \
+       fi
+       @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+         || { echo "ERROR: files left in build directory after distclean:" ; \
+              $(distcleancheck_listfiles) ; \
+              exit 1; } >&2
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(MANS)
+installdirs:
+       for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man8dir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+       -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \
+       clean-noinstPROGRAMS clean-sbinPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-local distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS install-sbinPROGRAMS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man5 install-man8
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf $(top_srcdir)/autom4te.cache
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-man \
+       uninstall-sbinPROGRAMS
+
+uninstall-man: uninstall-man5 uninstall-man8
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
+       clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \
+       clean-noinstPROGRAMS clean-sbinPROGRAMS ctags dist dist-all \
+       dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ dist-xz \
+       dist-zip distcheck distclean distclean-compile \
+       distclean-generic distclean-local distclean-tags \
+       distcleancheck distdir distuninstallcheck dvi dvi-am html \
+       html-am info info-am install install-am install-binPROGRAMS \
+       install-data install-data-am install-dvi install-dvi-am \
+       install-exec install-exec-am install-html install-html-am \
+       install-info install-info-am install-man install-man5 \
+       install-man8 install-pdf install-pdf-am install-ps \
+       install-ps-am install-sbinPROGRAMS install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
+       uninstall-am uninstall-binPROGRAMS uninstall-man \
+       uninstall-man5 uninstall-man8 uninstall-sbinPROGRAMS
+
+
+# docbook2man writes file itself, doesn't do stdout.
+%.8: doc/%.sgml
+       if [ "$(DOCBOOKTOMAN)" = "docbook2man" ]; then                     \
+           $(DOCBOOKTOMAN) $< > /dev/null 2>&1;                       \
+       else                                                               \
+           $(DOCBOOKTOMAN) $< 2>&1 > $@ | sed 's/^[^:]*://';              \
+       fi
+
+%.5: doc/%.sgml
+       if [ "$(DOCBOOKTOMAN)" = "docbook2man" ]; then                     \
+           $(DOCBOOKTOMAN) $< > /dev/null 2>&1;                       \
+       else                                                               \
+           $(DOCBOOKTOMAN) $< 2>&1 > $@ | sed 's/^[^:]*://';              \
+       fi
+
+# docbook2man creates extra crap files which need cleaning.
+distclean-local: killbuildmanpages
+
+killbuildmanpages:
+       rm -f doc/*.tmp manpage.refs manpage.links
+
+tarball: $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz
+
+$(DIST_DIR)/module-init-tools-$(VERSION).tar.gz: dist
+       mv module-init-tools-$(VERSION).tar.gz $@
+
+srpm: $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz
+       ln -sf $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz /usr/src/rpm/SOURCES/
+       set -e; RELEASE=`grep '^Release:' /usr/src/rpm/SPECS/modutils.spec | awk '{ print $$2 }'`; \
+       if [ "`grep '%define mit_ver' /usr/src/rpm/SPECS/modutils.spec | awk '{print $$3}'`" != $(VERSION) ]; then \
+               sed -e "s/Release: $$RELEASE/Release: `expr $$RELEASE + 1`/" -e 's/%define mit_ver.*/%define mit_ver $(VERSION)/' < /usr/src/rpm/SPECS/modutils.spec > /tmp/modutils.spec; \
+               rpm -ba /tmp/modutils.spec; \
+               mv /usr/src/rpm/SRPMS/modutils-2.4.21-`expr $$RELEASE + 1`.src.rpm $(DIST_DIR); \
+               mv /tmp/modutils.spec /usr/src/rpm/SPECS/modutils.spec; \
+       else \
+               rpm -ba /usr/src/rpm/SPECS/modutils.spec; \
+               mv /usr/src/rpm/SRPMS/modutils-2.4.21-$$RELEASE.src.rpm $(DIST_DIR); \
+       fi
+
+# No testsuite?
+tests/runtests:
+       mkdir tests
+       echo '#! /bin/sh' > $@
+       echo '# Install the testsuite over this dir. ' >> $@
+       chmod a+x $@
+
+$(DIST_DIR)/module-init-tools-testsuite-$(VERSION).tar.gz:
+       ln -sfn `pwd` /tmp/module-init-tools-$(VERSION) 
+       cd /tmp && tar --exclude '*~' -c -z -f $@ module-init-tools-$(VERSION)/tests
+       rm /tmp/module-init-tools-$(VERSION)
+
+release: check clean tarball
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..94aa424
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,5 @@
+NEWS for module-init-tools
+--------------------------
+
+2010-03-01 - New wiki created (http://modules.wiki.kernel.org/). Please
+            help to add documentation to aid other developers.
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..b78be8e
--- /dev/null
+++ b/README
@@ -0,0 +1,84 @@
+module-init-tools - Linux userspace module loading utilities
+------------------------------------------------------------
+
+Handy Resources:
+       - Bugs: Please send email to list
+       - Git:  git://git.kernel.org/pub/scm/utils/kernel/module-init-tools/module-init-tools.git
+       - IRC:  irc.freenode.org/#module-init-tools
+       - Mail: linux-modules@vger.kernel.org
+       - Web:  http://modules.wiki.kernel.org/
+
+The module-init-tools are used by modern 2.6 series Linux systems to provide
+userspace-side assistance in loading kernel modules and their dependencies.
+Originally written to replace the older "modutils", the utilities include
+the "modprobe" (load modules and their dependencies), "insmod" (load just
+a single module), "modinfo" (retrieve module information), and other related
+module management commands. These are intended to be relatively lightweight
+in their design, since 2.6 series kernels do much of the work internally.
+
+You will find documentation within the man pages and in this README file,
+as well as some hints on development within the HACKING file. You are
+encouraged to get involved by signing up to the linux-modules@vger.kernel.org
+project mailing list, and posting patches (git pull requests are welcome).
+You can also find further information, including the address of the mailing
+list, this git repository, and so forth on the module-init-tools wiki.
+
+Development takes place against the latest upstream Linux kernels (2.6.33
+as of this writing, though kernel development moves quickly). Backward
+compatibility is generally attempted, but forward compatibility (i.e. the
+ability for a specific release of module-init-tools to work against data
+files created by a later version as yet unreleased version) is not. In
+particular, the generated data files within /lib/modules/<kernel version>
+must not be assumed to have any particular format, nor should they be
+parsed be any other tools. There is a specific "modinfo" utility intended
+for the purposes of providing the information stored within those files.
+
+Recent Changes:
+       - There is no backwards compatibility for pre-2.6 series kernels. If
+         you intend to use an older kernel (wherein the module utilities
+         must perform various linking stages in userspace), use an older
+         tool such as provided in the "modutils" legacy kernel package.
+
+       - Explicit locking of kernel modules is no longer being performed at
+         load time (the existing implementation required a writeable mount
+         in /lib/modules that is by no means assured - an alternative of
+         using SYSV locks was experimented with but deemed unnecessary).
+         The kernel will handle one modprobe instance racing with another
+         by denying the load and returning an error message.
+
+Work in progress:
+       - We are working on soft-dependency support that will allow modules
+         to provide hints as to dependencies that may not be explicit.
+
+Requirements:
+       - A 2.6 series Linux kernel with sysfs, procfs, and loadable module
+         support enabled in the kernel configuration. It is also required
+         that sysfs and procfs be mounted in their usual /proc and /sys
+         locations in order for certain functionality to be provided.
+
+       - Module remove support must be enabled if removing is required. Yo
+         can also enable other options such as forced removal, but this is
+         really a bad idea for anything other than development.
+
+       - Module versioning (MODVERSIONS) must be enabled if you would
+         like to try to use modules from one kernel with another, similar
+         one without the kernel complaining loudly at the difference.
+
+Quickstart:
+       - Make sure you have appropriate development tools (gcc, GNU autotools,
+         docbook2man, etc. Some distributions may require optional packages
+         for a static version of glibc, as an example).
+
+       - To begin hacking on module-init-tools, you can do the following:
+
+       1). aclocal -I m4 && automake --add-missing --copy && autoconf
+           (or run "autoreconf" from an existing setup)
+       2). ./configure
+           (optionally specify "--prefix" or "--mandir" for non /usr/local)
+       3). make
+       4). make install
+       5). depmod
+           (to update /lib/modules/<kernel version> for the latest release)
+
+Please direct any comment/question to the linux-modules mailing list at:
+       linux-modules@vger.kernel.org
diff --git a/TODO b/TODO
new file mode 100644 (file)
index 0000000..87a5ded
--- /dev/null
+++ b/TODO
@@ -0,0 +1,18 @@
+Some TODOs, grouped by the individual utilty
+--------------------------------------------
+
+build
+-----
+       * Fix "make dist" to build documentation.
+       * Fix "make distcheck" at the same time.
+
+depmod
+------
+       * Kill off the "map" files. They aren't really needed any more.
+
+modprobe
+--------
+       * Kill off some of the legacy options.
+       * Fix grab_elf_file_fd error handling for test-module/10alias.sh.
+       * Enforce use of *.conf files in /etc/modprobe.d as filename extension.
+       * Add a "depends" config file directive to obviate "install" hacks.
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644 (file)
index 0000000..581b302
--- /dev/null
@@ -0,0 +1,953 @@
+# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.63],,
+[m4_warning([this file was generated for autoconf 2.63.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically `autoreconf'.])])
+
+# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.11'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.11.1], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.11.1])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
+# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is `.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL                                            -*- Autoconf -*-
+
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 9
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ(2.52)dnl
+ ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 10
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
+       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
+       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
+       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                   [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  am__universal=false
+  m4_case([$1], [CC],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac],
+    [CXX],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac])
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+])
+
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+#serial 5
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`AS_DIRNAME("$mf")`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`AS_DIRNAME(["$file"])`
+      AS_MKDIR_P([$dirpart/$fdir])
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each `.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Do all the work for Automake.                             -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 16
+
+# This macro actually does too much.  Some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.62])dnl
+dnl Autoconf wants to disallow AM_ names.  We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
+AM_MISSING_PROG(AUTOCONF, autoconf)
+AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
+AM_MISSING_PROG(AUTOHEADER, autoheader)
+AM_MISSING_PROG(MAKEINFO, makeinfo)
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+             [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+                            [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+                 [_AM_DEPENDENCIES(CC)],
+                 [define([AC_PROG_CC],
+                         defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+                 [_AM_DEPENDENCIES(CXX)],
+                 [define([AC_PROG_CXX],
+                         defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+                 [_AM_DEPENDENCIES(OBJC)],
+                 [define([AC_PROG_OBJC],
+                         defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+])
+_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
+dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
+dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
+dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+])
+
+dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001, 2003, 2005, 2008  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+AC_SUBST(install_sh)])
+
+# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 2
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Check to see how 'make' treats includes.                 -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 4
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 6
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  AC_MSG_WARN([`missing' script is too old or missing])
+fi
+])
+
+# Copyright (C) 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_MKDIR_P
+# ---------------
+# Check for `mkdir -p'.
+AC_DEFUN([AM_PROG_MKDIR_P],
+[AC_PREREQ([2.60])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
+dnl while keeping a definition of mkdir_p for backward compatibility.
+dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
+dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
+dnl Makefile.ins that do not define MKDIR_P, so we do our own
+dnl adjustment using top_builddir (which is defined more often than
+dnl MKDIR_P).
+AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
+case $mkdir_p in
+  [[\\/$]]* | ?:[[\\/]]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+])
+
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2008  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 4
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# ------------------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 5
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \   ]]*)
+    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
+esac
+
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+   if test "$[*]" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$[*]" != "X $srcdir/configure conftest.file" \
+      && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+alias in your environment])
+   fi
+
+   test "$[2]" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT(yes)])
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor `install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in `make install-strip', and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006, 2008  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 2
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
+# Check how to create a tarball.                            -*- Autoconf -*-
+
+# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 2
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of `v7', `ustar', or `pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+     [m4_case([$1], [ustar],, [pax],,
+              [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+_am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# Do not fold the above two line into one, because Tru64 sh and
+# Solaris sh will not grok spaces in the rhs of `-'.
+for _am_tool in $_am_tools
+do
+  case $_am_tool in
+  gnutar)
+    for _am_tar in tar gnutar gtar;
+    do
+      AM_RUN_LOG([$_am_tar --version]) && break
+    done
+    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+    am__untar="$_am_tar -xf -"
+    ;;
+  plaintar)
+    # Must skip GNU tar: if it does not support --format= it doesn't create
+    # ustar tarball either.
+    (tar --version) >/dev/null 2>&1 && continue
+    am__tar='tar chf - "$$tardir"'
+    am__tar_='tar chf - "$tardir"'
+    am__untar='tar xf -'
+    ;;
+  pax)
+    am__tar='pax -L -x $1 -w "$$tardir"'
+    am__tar_='pax -L -x $1 -w "$tardir"'
+    am__untar='pax -r'
+    ;;
+  cpio)
+    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+    am__untar='cpio -i -H $1 -d'
+    ;;
+  none)
+    am__tar=false
+    am__tar_=false
+    am__untar=false
+    ;;
+  esac
+
+  # If the value was cached, stop now.  We just wanted to have am__tar
+  # and am__untar set.
+  test -n "${am_cv_prog_tar_$1}" && break
+
+  # tar/untar a dummy directory, and stop if the command works
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  echo GrepMe > conftest.dir/file
+  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+  rm -rf conftest.dir
+  if test -s conftest.tar; then
+    AM_RUN_LOG([$am__untar <conftest.tar])
+    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+  fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
+m4_include([m4/ax_configure_args.m4])
+m4_include([m4/ax_enable_builddir.m4])
diff --git a/config.guess b/config.guess
new file mode 100755 (executable)
index 0000000..dc84c68
--- /dev/null
@@ -0,0 +1,1501 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+#   Free Software Foundation, Inc.
+
+timestamp='2009-11-20'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner.  Please send patches (context
+# diff format) to <config-patches@gnu.org> and include a ChangeLog
+# entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+       for c in cc gcc c89 c99 ; do
+         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+            CC_FOR_BUILD="$c"; break ;
+         fi ;
+       done ;
+       if test x"$CC_FOR_BUILD" = x ; then
+         CC_FOR_BUILD=no_compiler_found ;
+       fi
+       ;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+       PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+       # NetBSD (nbsd) targets should (where applicable) match one or
+       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+       # switched to ELF, *-*-netbsd* would select the old
+       # object file format.  This provides both forward
+       # compatibility and a consistent mechanism for selecting the
+       # object file format.
+       #
+       # Note: NetBSD doesn't particularly care about the vendor
+       # portion of the name.  We always set it to "unknown".
+       sysctl="sysctl -n hw.machine_arch"
+       UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+           /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+       case "${UNAME_MACHINE_ARCH}" in
+           armeb) machine=armeb-unknown ;;
+           arm*) machine=arm-unknown ;;
+           sh3el) machine=shl-unknown ;;
+           sh3eb) machine=sh-unknown ;;
+           sh5el) machine=sh5le-unknown ;;
+           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+       esac
+       # The Operating System including object format, if it has switched
+       # to ELF recently, or will in the future.
+       case "${UNAME_MACHINE_ARCH}" in
+           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+               eval $set_cc_for_build
+               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+                       | grep -q __ELF__
+               then
+                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+                   # Return netbsd for either.  FIX?
+                   os=netbsd
+               else
+                   os=netbsdelf
+               fi
+               ;;
+           *)
+               os=netbsd
+               ;;
+       esac
+       # The OS release
+       # Debian GNU/NetBSD machines have a different userland, and
+       # thus, need a distinct triplet. However, they do not need
+       # kernel version information, so it can be replaced with a
+       # suitable tag, in the style of linux-gnu.
+       case "${UNAME_VERSION}" in
+           Debian*)
+               release='-gnu'
+               ;;
+           *)
+               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+               ;;
+       esac
+       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+       # contains redundant information, the shorter form:
+       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+       echo "${machine}-${os}${release}"
+       exit ;;
+    *:OpenBSD:*:*)
+       UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+       exit ;;
+    *:ekkoBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+       exit ;;
+    *:SolidBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+       exit ;;
+    macppc:MirBSD:*:*)
+       echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    *:MirBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    alpha:OSF1:*:*)
+       case $UNAME_RELEASE in
+       *4.0)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+               ;;
+       *5.*)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+               ;;
+       esac
+       # According to Compaq, /usr/sbin/psrinfo has been available on
+       # OSF/1 and Tru64 systems produced since 1995.  I hope that
+       # covers most systems running today.  This code pipes the CPU
+       # types through head -n 1, so we only detect the type of CPU 0.
+       ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+       case "$ALPHA_CPU_TYPE" in
+           "EV4 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "EV4.5 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "LCA4 (21066/21068)")
+               UNAME_MACHINE="alpha" ;;
+           "EV5 (21164)")
+               UNAME_MACHINE="alphaev5" ;;
+           "EV5.6 (21164A)")
+               UNAME_MACHINE="alphaev56" ;;
+           "EV5.6 (21164PC)")
+               UNAME_MACHINE="alphapca56" ;;
+           "EV5.7 (21164PC)")
+               UNAME_MACHINE="alphapca57" ;;
+           "EV6 (21264)")
+               UNAME_MACHINE="alphaev6" ;;
+           "EV6.7 (21264A)")
+               UNAME_MACHINE="alphaev67" ;;
+           "EV6.8CB (21264C)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8AL (21264B)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8CX (21264D)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.9A (21264/EV69A)")
+               UNAME_MACHINE="alphaev69" ;;
+           "EV7 (21364)")
+               UNAME_MACHINE="alphaev7" ;;
+           "EV7.9 (21364A)")
+               UNAME_MACHINE="alphaev79" ;;
+       esac
+       # A Pn.n version is a patched version.
+       # A Vn.n version is a released version.
+       # A Tn.n version is a released field test version.
+       # A Xn.n version is an unreleased experimental baselevel.
+       # 1.2 uses "1.2" for uname -r.
+       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       exit ;;
+    Alpha\ *:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # Should we change UNAME_MACHINE based on the output of uname instead
+       # of the specific Alpha model?
+       echo alpha-pc-interix
+       exit ;;
+    21064:Windows_NT:50:3)
+       echo alpha-dec-winnt3.5
+       exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+       echo m68k-unknown-sysv4
+       exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-amigaos
+       exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-morphos
+       exit ;;
+    *:OS/390:*:*)
+       echo i370-ibm-openedition
+       exit ;;
+    *:z/VM:*:*)
+       echo s390-ibm-zvmoe
+       exit ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+       exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+       echo arm-acorn-riscix${UNAME_RELEASE}
+       exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+       echo arm-unknown-riscos
+       exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+       echo hppa1.1-hitachi-hiuxmpp
+       exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+       if test "`(/bin/universe) 2>/dev/null`" = att ; then
+               echo pyramid-pyramid-sysv3
+       else
+               echo pyramid-pyramid-bsd
+       fi
+       exit ;;
+    NILE*:*:*:dcosx)
+       echo pyramid-pyramid-svr4
+       exit ;;
+    DRS?6000:unix:4.0:6*)
+       echo sparc-icl-nx6
+       exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+       case `/usr/bin/uname -p` in
+           sparc) echo sparc-icl-nx7; exit ;;
+       esac ;;
+    s390x:SunOS:*:*)
+       echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4H:SunOS:5.*:*)
+       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+       echo i386-pc-auroraux${UNAME_RELEASE}
+       exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+       eval $set_cc_for_build
+       SUN_ARCH="i386"
+       # If there is a compiler, see if it is configured for 64-bit objects.
+       # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+       # This test works for both compilers.
+       if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+           if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+               (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+               grep IS_64BIT_ARCH >/dev/null
+           then
+               SUN_ARCH="x86_64"
+           fi
+       fi
+       echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:6*:*)
+       # According to config.sub, this is the proper way to canonicalize
+       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+       # it's likely to be more like Solaris than SunOS4.
+       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:*:*)
+       case "`/usr/bin/arch -k`" in
+           Series*|S4*)
+               UNAME_RELEASE=`uname -v`
+               ;;
+       esac
+       # Japanese Language versions have a version number like `4.1.3-JL'.
+       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       exit ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit ;;
+    sun*:*:4.2BSD:*)
+       UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+       case "`/bin/arch`" in
+           sun3)
+               echo m68k-sun-sunos${UNAME_RELEASE}
+               ;;
+           sun4)
+               echo sparc-sun-sunos${UNAME_RELEASE}
+               ;;
+       esac
+       exit ;;
+    aushp:SunOS:*:*)
+       echo sparc-auspex-sunos${UNAME_RELEASE}
+       exit ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+       echo m68k-atari-mint${UNAME_RELEASE}
+        exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit ;;
+    m68k:machten:*:*)
+       echo m68k-apple-machten${UNAME_RELEASE}
+       exit ;;
+    powerpc:machten:*:*)
+       echo powerpc-apple-machten${UNAME_RELEASE}
+       exit ;;
+    RISC*:Mach:*:*)
+       echo mips-dec-mach_bsd4.3
+       exit ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    VAX*:ULTRIX*:*:*)
+       echo vax-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+       echo clipper-intergraph-clix${UNAME_RELEASE}
+       exit ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+       int main (int argc, char *argv[]) {
+#else
+       int main (argc, argv) int argc; char *argv[]; {
+#endif
+       #if defined (host_mips) && defined (MIPSEB)
+       #if defined (SYSTYPE_SYSV)
+         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_SVR4)
+         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+       #endif
+       #endif
+         exit (-1);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c &&
+         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+         SYSTEM_NAME=`$dummy $dummyarg` &&
+           { echo "$SYSTEM_NAME"; exit; }
+       echo mips-mips-riscos${UNAME_RELEASE}
+       exit ;;
+    Motorola:PowerMAX_OS:*:*)
+       echo powerpc-motorola-powermax
+       exit ;;
+    Motorola:*:4.3:PL8-*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+       echo powerpc-harris-powerunix
+       exit ;;
+    m88k:CX/UX:7*:*)
+       echo m88k-harris-cxux7
+       exit ;;
+    m88k:*:4*:R4*)
+       echo m88k-motorola-sysv4
+       exit ;;
+    m88k:*:3*:R3*)
+       echo m88k-motorola-sysv3
+       exit ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+       then
+           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+              [ ${TARGET_BINARY_INTERFACE}x = x ]
+           then
+               echo m88k-dg-dgux${UNAME_RELEASE}
+           else
+               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+           fi
+       else
+           echo i586-dg-dgux${UNAME_RELEASE}
+       fi
+       exit ;;
+    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
+       echo m88k-dolphin-sysv3
+       exit ;;
+    M88*:*:R3*:*)
+       # Delta 88k system running SVR3
+       echo m88k-motorola-sysv3
+       exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+       echo m88k-tektronix-sysv3
+       exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+       echo m68k-tektronix-bsd
+       exit ;;
+    *:IRIX*:*:*)
+       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       exit ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+       echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+       exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+       echo i386-ibm-aix
+       exit ;;
+    ia64:AIX:*:*)
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:2:3)
+       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+               eval $set_cc_for_build
+               sed 's/^                //' << EOF >$dummy.c
+               #include <sys/systemcfg.h>
+
+               main()
+                       {
+                       if (!__power_pc())
+                               exit(1);
+                       puts("powerpc-ibm-aix3.2.5");
+                       exit(0);
+                       }
+EOF
+               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+               then
+                       echo "$SYSTEM_NAME"
+               else
+                       echo rs6000-ibm-aix3.2.5
+               fi
+       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+               echo rs6000-ibm-aix3.2.4
+       else
+               echo rs6000-ibm-aix3.2
+       fi
+       exit ;;
+    *:AIX:*:[456])
+       IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+               IBM_ARCH=rs6000
+       else
+               IBM_ARCH=powerpc
+       fi
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+       echo romp-ibm-bsd4.4
+       exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+       echo rs6000-bull-bosx
+       exit ;;
+    DPX/2?00:B.O.S.:*:*)
+       echo m68k-bull-sysv3
+       exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+       echo m68k-hp-bsd
+       exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+       echo m68k-hp-bsd4.4
+       exit ;;
+    9000/[34678]??:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       case "${UNAME_MACHINE}" in
+           9000/31? )            HP_ARCH=m68000 ;;
+           9000/[34]?? )         HP_ARCH=m68k ;;
+           9000/[678][0-9][0-9])
+               if [ -x /usr/bin/getconf ]; then
+                   sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+               fi
+               if [ "${HP_ARCH}" = "" ]; then
+                   eval $set_cc_for_build
+                   sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+               {
+               case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+               case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+               case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+                   switch (bits)
+                       {
+                       case 64: puts ("hppa2.0w"); break;
+                       case 32: puts ("hppa2.0n"); break;
+                       default: puts ("hppa2.0"); break;
+                       } break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+                   puts ("hppa2.0"); break;
+              #endif
+               default: puts ("hppa1.0"); break;
+               }
+                  exit (0);
+              }
+EOF
+                   (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+                   test -z "$HP_ARCH" && HP_ARCH=hppa
+               fi ;;
+       esac
+       if [ ${HP_ARCH} = "hppa2.0w" ]
+       then
+           eval $set_cc_for_build
+
+           # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+           # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+           # generating 64-bit code.  GNU and HP use different nomenclature:
+           #
+           # $ CC_FOR_BUILD=cc ./config.guess
+           # => hppa2.0w-hp-hpux11.23
+           # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+           # => hppa64-hp-hpux11.23
+
+           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+               grep -q __LP64__
+           then
+               HP_ARCH="hppa2.0w"
+           else
+               HP_ARCH="hppa64"
+           fi
+       fi
+       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       exit ;;
+    ia64:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux${HPUX_REV}
+       exit ;;
+    3050*:HI-UX:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <unistd.h>
+       int
+       main ()
+       {
+         long cpu = sysconf (_SC_CPU_VERSION);
+         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+            results, however.  */
+         if (CPU_IS_PA_RISC (cpu))
+           {
+             switch (cpu)
+               {
+                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+                 default: puts ("hppa-hitachi-hiuxwe2"); break;
+               }
+           }
+         else if (CPU_IS_HP_MC68K (cpu))
+           puts ("m68k-hitachi-hiuxwe2");
+         else puts ("unknown-hitachi-hiuxwe2");
+         exit (0);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+               { echo "$SYSTEM_NAME"; exit; }
+       echo unknown-hitachi-hiuxwe2
+       exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+       echo hppa1.1-hp-bsd
+       exit ;;
+    9000/8??:4.3bsd:*:*)
+       echo hppa1.0-hp-bsd
+       exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+       echo hppa1.0-hp-mpeix
+       exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+       echo hppa1.1-hp-osf
+       exit ;;
+    hp8??:OSF1:*:*)
+       echo hppa1.0-hp-osf
+       exit ;;
+    i*86:OSF1:*:*)
+       if [ -x /usr/sbin/sysversion ] ; then
+           echo ${UNAME_MACHINE}-unknown-osf1mk
+       else
+           echo ${UNAME_MACHINE}-unknown-osf1
+       fi
+       exit ;;
+    parisc*:Lites*:*:*)
+       echo hppa1.1-hp-lites
+       exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+       echo c1-convex-bsd
+        exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+        exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+       echo c34-convex-bsd
+        exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+       echo c38-convex-bsd
+        exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+       echo c4-convex-bsd
+        exit ;;
+    CRAY*Y-MP:*:*:*)
+       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*[A-Z]90:*:*:*)
+       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+             -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*TS:*:*:*)
+       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*T3E:*:*:*)
+       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*SV1:*:*:*)
+       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    *:UNICOS/mp:*:*)
+       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+       exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       exit ;;
+    sparc*:BSD/OS:*:*)
+       echo sparc-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:BSD/OS:*:*)
+       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:FreeBSD:*:*)
+       case ${UNAME_MACHINE} in
+           pc98)
+               echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+           amd64)
+               echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+           *)
+               echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+       esac
+       exit ;;
+    i*:CYGWIN*:*)
+       echo ${UNAME_MACHINE}-pc-cygwin
+       exit ;;
+    *:MINGW*:*)
+       echo ${UNAME_MACHINE}-pc-mingw32
+       exit ;;
+    i*:windows32*:*)
+       # uname -m includes "-pc" on this system.
+       echo ${UNAME_MACHINE}-mingw32
+       exit ;;
+    i*:PW*:*)
+       echo ${UNAME_MACHINE}-pc-pw32
+       exit ;;
+    *:Interix*:*)
+       case ${UNAME_MACHINE} in
+           x86)
+               echo i586-pc-interix${UNAME_RELEASE}
+               exit ;;
+           authenticamd | genuineintel | EM64T)
+               echo x86_64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+           IA64)
+               echo ia64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+       esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+       echo i${UNAME_MACHINE}-pc-mks
+       exit ;;
+    8664:Windows_NT:*)
+       echo x86_64-pc-mks
+       exit ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+       # UNAME_MACHINE based on the output of uname instead of i386?
+       echo i586-pc-interix
+       exit ;;
+    i*:UWIN*:*)
+       echo ${UNAME_MACHINE}-pc-uwin
+       exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+       echo x86_64-unknown-cygwin
+       exit ;;
+    p*:CYGWIN*:*)
+       echo powerpcle-unknown-cygwin
+       exit ;;
+    prep*:SunOS:5.*:*)
+       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    *:GNU:*:*)
+       # the GNU system
+       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       exit ;;
+    *:GNU/*:*:*)
+       # other systems with GNU libc and userland
+       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+       exit ;;
+    i*86:Minix:*:*)
+       echo ${UNAME_MACHINE}-pc-minix
+       exit ;;
+    alpha:Linux:*:*)
+       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+         EV5)   UNAME_MACHINE=alphaev5 ;;
+         EV56)  UNAME_MACHINE=alphaev56 ;;
+         PCA56) UNAME_MACHINE=alphapca56 ;;
+         PCA57) UNAME_MACHINE=alphapca56 ;;
+         EV6)   UNAME_MACHINE=alphaev6 ;;
+         EV67)  UNAME_MACHINE=alphaev67 ;;
+         EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+       objdump --private-headers /bin/sh | grep -q ld.so.1
+       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+       exit ;;
+    arm*:Linux:*:*)
+       eval $set_cc_for_build
+       if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+           | grep -q __ARM_EABI__
+       then
+           echo ${UNAME_MACHINE}-unknown-linux-gnu
+       else
+           echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+       fi
+       exit ;;
+    avr32*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    cris:Linux:*:*)
+       echo cris-axis-linux-gnu
+       exit ;;
+    crisv32:Linux:*:*)
+       echo crisv32-axis-linux-gnu
+       exit ;;
+    frv:Linux:*:*)
+       echo frv-unknown-linux-gnu
+       exit ;;
+    i*86:Linux:*:*)
+       LIBC=gnu
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #ifdef __dietlibc__
+       LIBC=dietlibc
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+       echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+       exit ;;
+    ia64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m32r*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    mips:Linux:*:* | mips64:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef ${UNAME_MACHINE}
+       #undef ${UNAME_MACHINE}el
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=${UNAME_MACHINE}el
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=${UNAME_MACHINE}
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+       ;;
+    or32:Linux:*:*)
+       echo or32-unknown-linux-gnu
+       exit ;;
+    padre:Linux:*:*)
+       echo sparc-unknown-linux-gnu
+       exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+       echo hppa64-unknown-linux-gnu
+       exit ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+       # Look for CPU level
+       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+         PA7*) echo hppa1.1-unknown-linux-gnu ;;
+         PA8*) echo hppa2.0-unknown-linux-gnu ;;
+         *)    echo hppa-unknown-linux-gnu ;;
+       esac
+       exit ;;
+    ppc64:Linux:*:*)
+       echo powerpc64-unknown-linux-gnu
+       exit ;;
+    ppc:Linux:*:*)
+       echo powerpc-unknown-linux-gnu
+       exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+       echo ${UNAME_MACHINE}-ibm-linux
+       exit ;;
+    sh64*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sh*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    vax:Linux:*:*)
+       echo ${UNAME_MACHINE}-dec-linux-gnu
+       exit ;;
+    x86_64:Linux:*:*)
+       echo x86_64-unknown-linux-gnu
+       exit ;;
+    xtensa*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    i*86:DYNIX/ptx:4*:*)
+       # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+       # earlier versions are messed up and put the nodename in both
+       # sysname and nodename.
+       echo i386-sequent-sysv4
+       exit ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+       # I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+       exit ;;
+    i*86:OS/2:*:*)
+       # If we were able to find `uname', then EMX Unix compatibility
+       # is probably installed.
+       echo ${UNAME_MACHINE}-pc-os2-emx
+       exit ;;
+    i*86:XTS-300:*:STOP)
+       echo ${UNAME_MACHINE}-unknown-stop
+       exit ;;
+    i*86:atheos:*:*)
+       echo ${UNAME_MACHINE}-unknown-atheos
+       exit ;;
+    i*86:syllable:*:*)
+       echo ${UNAME_MACHINE}-pc-syllable
+       exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+       echo i386-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    i*86:*DOS:*:*)
+       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       exit ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+       else
+               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+       fi
+       exit ;;
+    i*86:*:5:[678]*)
+       # UnixWare 7.x, OpenUNIX and OpenServer 6.
+       case `/bin/uname -X | grep "^Machine"` in
+           *486*)           UNAME_MACHINE=i486 ;;
+           *Pentium)        UNAME_MACHINE=i586 ;;
+           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+       esac
+       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+       exit ;;
+    i*86:*:3.2:*)
+       if test -f /usr/options/cb.name; then
+               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+       elif /bin/uname -X 2>/dev/null >/dev/null ; then
+               UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+               (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+               (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+                       && UNAME_MACHINE=i586
+               (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+       else
+               echo ${UNAME_MACHINE}-pc-sysv32
+       fi
+       exit ;;
+    pc:*:*:*)
+       # Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i586.
+       # Note: whatever this is, it MUST be the same as what config.sub
+       # prints for the "djgpp" host, or else GDB configury will decide that
+       # this is a cross-build.
+       echo i586-pc-msdosdjgpp
+        exit ;;
+    Intel:Mach:3*:*)
+       echo i386-pc-mach3
+       exit ;;
+    paragon:*:*:*)
+       echo i860-intel-osf1
+       exit ;;
+    i860:*:4.*:*) # i860-SVR4
+       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+       else # Add other i860-SVR4 vendors below as they are discovered.
+         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+       fi
+       exit ;;
+    mini*:CTIX:SYS*5:*)
+       # "miniframe"
+       echo m68010-convergent-sysv
+       exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+       echo m68k-convergent-sysv
+       exit ;;
+    M680?0:D-NIX:5.3:*)
+       echo m68k-diab-dnix
+       exit ;;
+    M68*:*:R3V[5678]*:*)
+       test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+       OS_REL=''
+       test -r /etc/.relid \
+       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+       OS_REL='.3'
+       test -r /etc/.relid \
+           && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+           && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+           && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+           && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+       echo m68k-atari-sysv4
+       exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    rs6000:LynxOS:2.*:*)
+       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+       echo mips-dde-sysv${UNAME_RELEASE}
+       exit ;;
+    RM*:ReliantUNIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    RM*:SINIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    *:SINIX-*:*:*)
+       if uname -p 2>/dev/null >/dev/null ; then
+               UNAME_MACHINE=`(uname -p) 2>/dev/null`
+               echo ${UNAME_MACHINE}-sni-sysv4
+       else
+               echo ns32k-sni-sysv
+       fi
+       exit ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
+    *:UNIX_System_V:4*:FTX*)
+       # From Gerald Hewes <hewes@openmarket.com>.
+       # How about differentiating between stratus architectures? -djm
+       echo hppa1.1-stratus-sysv4
+       exit ;;
+    *:*:*:FTX*)
+       # From seanf@swdc.stratus.com.
+       echo i860-stratus-sysv4
+       exit ;;
+    i*86:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo ${UNAME_MACHINE}-stratus-vos
+       exit ;;
+    *:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo hppa1.1-stratus-vos
+       exit ;;
+    mc68*:A/UX:*:*)
+       echo m68k-apple-aux${UNAME_RELEASE}
+       exit ;;
+    news*:NEWS-OS:6*:*)
+       echo mips-sony-newsos6
+       exit ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+       if [ -d /usr/nec ]; then
+               echo mips-nec-sysv${UNAME_RELEASE}
+       else
+               echo mips-unknown-sysv${UNAME_RELEASE}
+       fi
+        exit ;;
+    BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
+       echo powerpc-be-beos
+       exit ;;
+    BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
+       echo powerpc-apple-beos
+       exit ;;
+    BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
+       echo i586-pc-beos
+       exit ;;
+    BePC:Haiku:*:*)    # Haiku running on Intel PC compatible.
+       echo i586-pc-haiku
+       exit ;;
+    SX-4:SUPER-UX:*:*)
+       echo sx4-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-5:SUPER-UX:*:*)
+       echo sx5-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-6:SUPER-UX:*:*)
+       echo sx6-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-7:SUPER-UX:*:*)
+       echo sx7-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8:SUPER-UX:*:*)
+       echo sx8-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8R:SUPER-UX:*:*)
+       echo sx8r-nec-superux${UNAME_RELEASE}
+       exit ;;
+    Power*:Rhapsody:*:*)
+       echo powerpc-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Rhapsody:*:*)
+       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Darwin:*:*)
+       UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+       case $UNAME_PROCESSOR in
+           i386)
+               eval $set_cc_for_build
+               if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+                 if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+                     (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+                     grep IS_64BIT_ARCH >/dev/null
+                 then
+                     UNAME_PROCESSOR="x86_64"
+                 fi
+               fi ;;
+           unknown) UNAME_PROCESSOR=powerpc ;;
+       esac
+       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+       exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+       UNAME_PROCESSOR=`uname -p`
+       if test "$UNAME_PROCESSOR" = "x86"; then
+               UNAME_PROCESSOR=i386
+               UNAME_MACHINE=pc
+       fi
+       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+       exit ;;
+    *:QNX:*:4*)
+       echo i386-pc-qnx
+       exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+       echo nse-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    *:NonStop-UX:*:*)
+       echo mips-compaq-nonstopux
+       exit ;;
+    BS2000:POSIX*:*:*)
+       echo bs2000-siemens-sysv
+       exit ;;
+    DS/*:UNIX_System_V:*:*)
+       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       exit ;;
+    *:Plan9:*:*)
+       # "uname -m" is not consistent, so use $cputype instead. 386
+       # is converted to i386 for consistency with other x86
+       # operating systems.
+       if test "$cputype" = "386"; then
+           UNAME_MACHINE=i386
+       else
+           UNAME_MACHINE="$cputype"
+       fi
+       echo ${UNAME_MACHINE}-unknown-plan9
+       exit ;;
+    *:TOPS-10:*:*)
+       echo pdp10-unknown-tops10
+       exit ;;
+    *:TENEX:*:*)
+       echo pdp10-unknown-tenex
+       exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+       echo pdp10-dec-tops20
+       exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+       echo pdp10-xkl-tops20
+       exit ;;
+    *:TOPS-20:*:*)
+       echo pdp10-unknown-tops20
+       exit ;;
+    *:ITS:*:*)
+       echo pdp10-unknown-its
+       exit ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+       exit ;;
+    *:DragonFly:*:*)
+       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit ;;
+    *:*VMS:*:*)
+       UNAME_MACHINE=`(uname -p) 2>/dev/null`
+       case "${UNAME_MACHINE}" in
+           A*) echo alpha-dec-vms ; exit ;;
+           I*) echo ia64-dec-vms ; exit ;;
+           V*) echo vax-dec-vms ; exit ;;
+       esac ;;
+    *:XENIX:*:SysV)
+       echo i386-pc-xenix
+       exit ;;
+    i*86:skyos:*:*)
+       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+       exit ;;
+    i*86:rdos:*:*)
+       echo ${UNAME_MACHINE}-pc-rdos
+       exit ;;
+    i*86:AROS:*:*)
+       echo ${UNAME_MACHINE}-pc-aros
+       exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+         ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+       printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+       printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+       { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+       echo c1-convex-bsd
+       exit ;;
+    c2*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit ;;
+    c34*)
+       echo c34-convex-bsd
+       exit ;;
+    c38*)
+       echo c38-convex-bsd
+       exit ;;
+    c4*)
+       echo c4-convex-bsd
+       exit ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config.sub b/config.sub
new file mode 100755 (executable)
index 0000000..2a55a50
--- /dev/null
@@ -0,0 +1,1705 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+#   Free Software Foundation, Inc.
+
+timestamp='2009-11-20'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted GNU ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#      CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit ;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  kopensolaris*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+       -sun*os*)
+               # Prevent following clause from handling this invalid input.
+               ;;
+       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+       -apple | -axis | -knuth | -cray | -microblaze)
+               os=
+               basic_machine=$1
+               ;;
+        -bluegene*)
+               os=-cnk
+               ;;
+       -sim | -cisco | -oki | -wec | -winbond)
+               os=
+               basic_machine=$1
+               ;;
+       -scout)
+               ;;
+       -wrs)
+               os=-vxworks
+               basic_machine=$1
+               ;;
+       -chorusos*)
+               os=-chorusos
+               basic_machine=$1
+               ;;
+       -chorusrdb)
+               os=-chorusrdb
+               basic_machine=$1
+               ;;
+       -hiux*)
+               os=-hiuxwe2
+               ;;
+       -sco6)
+               os=-sco5v6
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco5)
+               os=-sco3.2v5
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco4)
+               os=-sco3.2v4
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2.[4-9]*)
+               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2v[4-9]*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco5v6*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco*)
+               os=-sco3.2v2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -udk*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -isc)
+               os=-isc2.2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -clix*)
+               basic_machine=clipper-intergraph
+               ;;
+       -isc*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -lynx*)
+               os=-lynxos
+               ;;
+       -ptx*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+               ;;
+       -windowsnt*)
+               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+               ;;
+       -psos*)
+               os=-psos
+               ;;
+       -mint | -mint[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+       # Recognize the basic CPU types without company name.
+       # Some are omitted here because they have special meanings below.
+       1750a | 580 \
+       | a29k \
+       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+       | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+       | am33_2.0 \
+       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+       | bfin \
+       | c4x | clipper \
+       | d10v | d30v | dlx | dsp16xx \
+       | fido | fr30 | frv \
+       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+       | i370 | i860 | i960 | ia64 \
+       | ip2k | iq2000 \
+       | lm32 \
+       | m32c | m32r | m32rle | m68000 | m68k | m88k \
+       | maxq | mb | microblaze | mcore | mep | metag \
+       | mips | mipsbe | mipseb | mipsel | mipsle \
+       | mips16 \
+       | mips64 | mips64el \
+       | mips64octeon | mips64octeonel \
+       | mips64orion | mips64orionel \
+       | mips64r5900 | mips64r5900el \
+       | mips64vr | mips64vrel \
+       | mips64vr4100 | mips64vr4100el \
+       | mips64vr4300 | mips64vr4300el \
+       | mips64vr5000 | mips64vr5000el \
+       | mips64vr5900 | mips64vr5900el \
+       | mipsisa32 | mipsisa32el \
+       | mipsisa32r2 | mipsisa32r2el \
+       | mipsisa64 | mipsisa64el \
+       | mipsisa64r2 | mipsisa64r2el \
+       | mipsisa64sb1 | mipsisa64sb1el \
+       | mipsisa64sr71k | mipsisa64sr71kel \
+       | mipstx39 | mipstx39el \
+       | mn10200 | mn10300 \
+       | moxie \
+       | mt \
+       | msp430 \
+       | nios | nios2 \
+       | ns16k | ns32k \
+       | or32 \
+       | pdp10 | pdp11 | pj | pjl \
+       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+       | pyramid \
+       | rx \
+       | score \
+       | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+       | sh64 | sh64le \
+       | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+       | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+       | spu | strongarm \
+       | tahoe | thumb | tic4x | tic80 | tron \
+       | ubicom32 \
+       | v850 | v850e \
+       | we32k \
+       | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+       | z8k | z80)
+               basic_machine=$basic_machine-unknown
+               ;;
+       m6811 | m68hc11 | m6812 | m68hc12 | picochip)
+               # Motorola 68HC11/12.
+               basic_machine=$basic_machine-unknown
+               os=-none
+               ;;
+       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+               ;;
+       ms1)
+               basic_machine=mt-unknown
+               ;;
+
+       # We use `pc' rather than `unknown'
+       # because (1) that's what they normally are, and
+       # (2) the word "unknown" tends to confuse beginning users.
+       i*86 | x86_64)
+         basic_machine=$basic_machine-pc
+         ;;
+       # Object if more than one company name word.
+       *-*-*)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+       # Recognize the basic CPU types with company name.
+       580-* \
+       | a29k-* \
+       | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+       | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+       | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+       | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+       | avr-* | avr32-* \
+       | bfin-* | bs2000-* \
+       | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+       | clipper-* | craynv-* | cydra-* \
+       | d10v-* | d30v-* | dlx-* \
+       | elxsi-* \
+       | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+       | h8300-* | h8500-* \
+       | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+       | i*86-* | i860-* | i960-* | ia64-* \
+       | ip2k-* | iq2000-* \
+       | lm32-* \
+       | m32c-* | m32r-* | m32rle-* \
+       | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+       | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
+       | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+       | mips16-* \
+       | mips64-* | mips64el-* \
+       | mips64octeon-* | mips64octeonel-* \
+       | mips64orion-* | mips64orionel-* \
+       | mips64r5900-* | mips64r5900el-* \
+       | mips64vr-* | mips64vrel-* \
+       | mips64vr4100-* | mips64vr4100el-* \
+       | mips64vr4300-* | mips64vr4300el-* \
+       | mips64vr5000-* | mips64vr5000el-* \
+       | mips64vr5900-* | mips64vr5900el-* \
+       | mipsisa32-* | mipsisa32el-* \
+       | mipsisa32r2-* | mipsisa32r2el-* \
+       | mipsisa64-* | mipsisa64el-* \
+       | mipsisa64r2-* | mipsisa64r2el-* \
+       | mipsisa64sb1-* | mipsisa64sb1el-* \
+       | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+       | mipstx39-* | mipstx39el-* \
+       | mmix-* \
+       | mt-* \
+       | msp430-* \
+       | nios-* | nios2-* \
+       | none-* | np1-* | ns16k-* | ns32k-* \
+       | orion-* \
+       | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+       | pyramid-* \
+       | romp-* | rs6000-* | rx-* \
+       | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+       | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+       | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+       | sparclite-* \
+       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+       | tahoe-* | thumb-* \
+       | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
+       | tron-* \
+       | ubicom32-* \
+       | v850-* | v850e-* | vax-* \
+       | we32k-* \
+       | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+       | xstormy16-* | xtensa*-* \
+       | ymp-* \
+       | z8k-* | z80-*)
+               ;;
+       # Recognize the basic CPU types without company name, with glob match.
+       xtensa*)
+               basic_machine=$basic_machine-unknown
+               ;;
+       # Recognize the various machine names and aliases which stand
+       # for a CPU type and a company and sometimes even an OS.
+       386bsd)
+               basic_machine=i386-unknown
+               os=-bsd
+               ;;
+       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+               basic_machine=m68000-att
+               ;;
+       3b*)
+               basic_machine=we32k-att
+               ;;
+       a29khif)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       abacus)
+               basic_machine=abacus-unknown
+               ;;
+       adobe68k)
+               basic_machine=m68010-adobe
+               os=-scout
+               ;;
+       alliant | fx80)
+               basic_machine=fx80-alliant
+               ;;
+       altos | altos3068)
+               basic_machine=m68k-altos
+               ;;
+       am29k)
+               basic_machine=a29k-none
+               os=-bsd
+               ;;
+       amd64)
+               basic_machine=x86_64-pc
+               ;;
+       amd64-*)
+               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       amdahl)
+               basic_machine=580-amdahl
+               os=-sysv
+               ;;
+       amiga | amiga-*)
+               basic_machine=m68k-unknown
+               ;;
+       amigaos | amigados)
+               basic_machine=m68k-unknown
+               os=-amigaos
+               ;;
+       amigaunix | amix)
+               basic_machine=m68k-unknown
+               os=-sysv4
+               ;;
+       apollo68)
+               basic_machine=m68k-apollo
+               os=-sysv
+               ;;
+       apollo68bsd)
+               basic_machine=m68k-apollo
+               os=-bsd
+               ;;
+       aros)
+               basic_machine=i386-pc
+               os=-aros
+               ;;
+       aux)
+               basic_machine=m68k-apple
+               os=-aux
+               ;;
+       balance)
+               basic_machine=ns32k-sequent
+               os=-dynix
+               ;;
+       blackfin)
+               basic_machine=bfin-unknown
+               os=-linux
+               ;;
+       blackfin-*)
+               basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       bluegene*)
+               basic_machine=powerpc-ibm
+               os=-cnk
+               ;;
+       c90)
+               basic_machine=c90-cray
+               os=-unicos
+               ;;
+        cegcc)
+               basic_machine=arm-unknown
+               os=-cegcc
+               ;;
+       convex-c1)
+               basic_machine=c1-convex
+               os=-bsd
+               ;;
+       convex-c2)
+               basic_machine=c2-convex
+               os=-bsd
+               ;;
+       convex-c32)
+               basic_machine=c32-convex
+               os=-bsd
+               ;;
+       convex-c34)
+               basic_machine=c34-convex
+               os=-bsd
+               ;;
+       convex-c38)
+               basic_machine=c38-convex
+               os=-bsd
+               ;;
+       cray | j90)
+               basic_machine=j90-cray
+               os=-unicos
+               ;;
+       craynv)
+               basic_machine=craynv-cray
+               os=-unicosmp
+               ;;
+       cr16)
+               basic_machine=cr16-unknown
+               os=-elf
+               ;;
+       crds | unos)
+               basic_machine=m68k-crds
+               ;;
+       crisv32 | crisv32-* | etraxfs*)
+               basic_machine=crisv32-axis
+               ;;
+       cris | cris-* | etrax*)
+               basic_machine=cris-axis
+               ;;
+       crx)
+               basic_machine=crx-unknown
+               os=-elf
+               ;;
+       da30 | da30-*)
+               basic_machine=m68k-da30
+               ;;
+       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+               basic_machine=mips-dec
+               ;;
+       decsystem10* | dec10*)
+               basic_machine=pdp10-dec
+               os=-tops10
+               ;;
+       decsystem20* | dec20*)
+               basic_machine=pdp10-dec
+               os=-tops20
+               ;;
+       delta | 3300 | motorola-3300 | motorola-delta \
+             | 3300-motorola | delta-motorola)
+               basic_machine=m68k-motorola
+               ;;
+       delta88)
+               basic_machine=m88k-motorola
+               os=-sysv3
+               ;;
+       dicos)
+               basic_machine=i686-pc
+               os=-dicos
+               ;;
+       djgpp)
+               basic_machine=i586-pc
+               os=-msdosdjgpp
+               ;;
+       dpx20 | dpx20-*)
+               basic_machine=rs6000-bull
+               os=-bosx
+               ;;
+       dpx2* | dpx2*-bull)
+               basic_machine=m68k-bull
+               os=-sysv3
+               ;;
+       ebmon29k)
+               basic_machine=a29k-amd
+               os=-ebmon
+               ;;
+       elxsi)
+               basic_machine=elxsi-elxsi
+               os=-bsd
+               ;;
+       encore | umax | mmax)
+               basic_machine=ns32k-encore
+               ;;
+       es1800 | OSE68k | ose68k | ose | OSE)
+               basic_machine=m68k-ericsson
+               os=-ose
+               ;;
+       fx2800)
+               basic_machine=i860-alliant
+               ;;
+       genix)
+               basic_machine=ns32k-ns
+               ;;
+       gmicro)
+               basic_machine=tron-gmicro
+               os=-sysv
+               ;;
+       go32)
+               basic_machine=i386-pc
+               os=-go32
+               ;;
+       h3050r* | hiux*)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       h8300hms)
+               basic_machine=h8300-hitachi
+               os=-hms
+               ;;
+       h8300xray)
+               basic_machine=h8300-hitachi
+               os=-xray
+               ;;
+       h8500hms)
+               basic_machine=h8500-hitachi
+               os=-hms
+               ;;
+       harris)
+               basic_machine=m88k-harris
+               os=-sysv3
+               ;;
+       hp300-*)
+               basic_machine=m68k-hp
+               ;;
+       hp300bsd)
+               basic_machine=m68k-hp
+               os=-bsd
+               ;;
+       hp300hpux)
+               basic_machine=m68k-hp
+               os=-hpux
+               ;;
+       hp3k9[0-9][0-9] | hp9[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k2[0-9][0-9] | hp9k31[0-9])
+               basic_machine=m68000-hp
+               ;;
+       hp9k3[2-9][0-9])
+               basic_machine=m68k-hp
+               ;;
+       hp9k6[0-9][0-9] | hp6[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k7[0-79][0-9] | hp7[0-79][0-9])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k78[0-9] | hp78[0-9])
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][13679] | hp8[0-9][13679])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][0-9] | hp8[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hppa-next)
+               os=-nextstep3
+               ;;
+       hppaosf)
+               basic_machine=hppa1.1-hp
+               os=-osf
+               ;;
+       hppro)
+               basic_machine=hppa1.1-hp
+               os=-proelf
+               ;;
+       i370-ibm* | ibm*)
+               basic_machine=i370-ibm
+               ;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+       i*86v32)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv32
+               ;;
+       i*86v4*)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv4
+               ;;
+       i*86v)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv
+               ;;
+       i*86sol2)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-solaris2
+               ;;
+       i386mach)
+               basic_machine=i386-mach
+               os=-mach
+               ;;
+       i386-vsta | vsta)
+               basic_machine=i386-unknown
+               os=-vsta
+               ;;
+       iris | iris4d)
+               basic_machine=mips-sgi
+               case $os in
+                   -irix*)
+                       ;;
+                   *)
+                       os=-irix4
+                       ;;
+               esac
+               ;;
+       isi68 | isi)
+               basic_machine=m68k-isi
+               os=-sysv
+               ;;
+       m68knommu)
+               basic_machine=m68k-unknown
+               os=-linux
+               ;;
+       m68knommu-*)
+               basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       m88k-omron*)
+               basic_machine=m88k-omron
+               ;;
+       magnum | m3230)
+               basic_machine=mips-mips
+               os=-sysv
+               ;;
+       merlin)
+               basic_machine=ns32k-utek
+               os=-sysv
+               ;;
+        microblaze)
+               basic_machine=microblaze-xilinx
+               ;;
+       mingw32)
+               basic_machine=i386-pc
+               os=-mingw32
+               ;;
+       mingw32ce)
+               basic_machine=arm-unknown
+               os=-mingw32ce
+               ;;
+       miniframe)
+               basic_machine=m68000-convergent
+               ;;
+       *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+       mips3*-*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               ;;
+       mips3*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+               ;;
+       monitor)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       morphos)
+               basic_machine=powerpc-unknown
+               os=-morphos
+               ;;
+       msdos)
+               basic_machine=i386-pc
+               os=-msdos
+               ;;
+       ms1-*)
+               basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+               ;;
+       mvs)
+               basic_machine=i370-ibm
+               os=-mvs
+               ;;
+       ncr3000)
+               basic_machine=i486-ncr
+               os=-sysv4
+               ;;
+       netbsd386)
+               basic_machine=i386-unknown
+               os=-netbsd
+               ;;
+       netwinder)
+               basic_machine=armv4l-rebel
+               os=-linux
+               ;;
+       news | news700 | news800 | news900)
+               basic_machine=m68k-sony
+               os=-newsos
+               ;;
+       news1000)
+               basic_machine=m68030-sony
+               os=-newsos
+               ;;
+       news-3600 | risc-news)
+               basic_machine=mips-sony
+               os=-newsos
+               ;;
+       necv70)
+               basic_machine=v70-nec
+               os=-sysv
+               ;;
+       next | m*-next )
+               basic_machine=m68k-next
+               case $os in
+                   -nextstep* )
+                       ;;
+                   -ns2*)
+                     os=-nextstep2
+                       ;;
+                   *)
+                     os=-nextstep3
+                       ;;
+               esac
+               ;;
+       nh3000)
+               basic_machine=m68k-harris
+               os=-cxux
+               ;;
+       nh[45]000)
+               basic_machine=m88k-harris
+               os=-cxux
+               ;;
+       nindy960)
+               basic_machine=i960-intel
+               os=-nindy
+               ;;
+       mon960)
+               basic_machine=i960-intel
+               os=-mon960
+               ;;
+       nonstopux)
+               basic_machine=mips-compaq
+               os=-nonstopux
+               ;;
+       np1)
+               basic_machine=np1-gould
+               ;;
+       nsr-tandem)
+               basic_machine=nsr-tandem
+               ;;
+       op50n-* | op60c-*)
+               basic_machine=hppa1.1-oki
+               os=-proelf
+               ;;
+       openrisc | openrisc-*)
+               basic_machine=or32-unknown
+               ;;
+       os400)
+               basic_machine=powerpc-ibm
+               os=-os400
+               ;;
+       OSE68000 | ose68000)
+               basic_machine=m68000-ericsson
+               os=-ose
+               ;;
+       os68k)
+               basic_machine=m68k-none
+               os=-os68k
+               ;;
+       pa-hitachi)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       paragon)
+               basic_machine=i860-intel
+               os=-osf
+               ;;
+       parisc)
+               basic_machine=hppa-unknown
+               os=-linux
+               ;;
+       parisc-*)
+               basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       pbd)
+               basic_machine=sparc-tti
+               ;;
+       pbb)
+               basic_machine=m68k-tti
+               ;;
+       pc532 | pc532-*)
+               basic_machine=ns32k-pc532
+               ;;
+       pc98)
+               basic_machine=i386-pc
+               ;;
+       pc98-*)
+               basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium | p5 | k5 | k6 | nexgen | viac3)
+               basic_machine=i586-pc
+               ;;
+       pentiumpro | p6 | 6x86 | athlon | athlon_*)
+               basic_machine=i686-pc
+               ;;
+       pentiumii | pentium2 | pentiumiii | pentium3)
+               basic_machine=i686-pc
+               ;;
+       pentium4)
+               basic_machine=i786-pc
+               ;;
+       pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumpro-* | p6-* | 6x86-* | athlon-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium4-*)
+               basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pn)
+               basic_machine=pn-gould
+               ;;
+       power)  basic_machine=power-ibm
+               ;;
+       ppc)    basic_machine=powerpc-unknown
+               ;;
+       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppcle | powerpclittle | ppc-le | powerpc-little)
+               basic_machine=powerpcle-unknown
+               ;;
+       ppcle-* | powerpclittle-*)
+               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64)  basic_machine=powerpc64-unknown
+               ;;
+       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+               basic_machine=powerpc64le-unknown
+               ;;
+       ppc64le-* | powerpc64little-*)
+               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ps2)
+               basic_machine=i386-ibm
+               ;;
+       pw32)
+               basic_machine=i586-unknown
+               os=-pw32
+               ;;
+       rdos)
+               basic_machine=i386-pc
+               os=-rdos
+               ;;
+       rom68k)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       rm[46]00)
+               basic_machine=mips-siemens
+               ;;
+       rtpc | rtpc-*)
+               basic_machine=romp-ibm
+               ;;
+       s390 | s390-*)
+               basic_machine=s390-ibm
+               ;;
+       s390x | s390x-*)
+               basic_machine=s390x-ibm
+               ;;
+       sa29200)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       sb1)
+               basic_machine=mipsisa64sb1-unknown
+               ;;
+       sb1el)
+               basic_machine=mipsisa64sb1el-unknown
+               ;;
+       sde)
+               basic_machine=mipsisa32-sde
+               os=-elf
+               ;;
+       sei)
+               basic_machine=mips-sei
+               os=-seiux
+               ;;
+       sequent)
+               basic_machine=i386-sequent
+               ;;
+       sh)
+               basic_machine=sh-hitachi
+               os=-hms
+               ;;
+       sh5el)
+               basic_machine=sh5le-unknown
+               ;;
+       sh64)
+               basic_machine=sh64-unknown
+               ;;
+       sparclite-wrs | simso-wrs)
+               basic_machine=sparclite-wrs
+               os=-vxworks
+               ;;
+       sps7)
+               basic_machine=m68k-bull
+               os=-sysv2
+               ;;
+       spur)
+               basic_machine=spur-unknown
+               ;;
+       st2000)
+               basic_machine=m68k-tandem
+               ;;
+       stratus)
+               basic_machine=i860-stratus
+               os=-sysv4
+               ;;
+       sun2)
+               basic_machine=m68000-sun
+               ;;
+       sun2os3)
+               basic_machine=m68000-sun
+               os=-sunos3
+               ;;
+       sun2os4)
+               basic_machine=m68000-sun
+               os=-sunos4
+               ;;
+       sun3os3)
+               basic_machine=m68k-sun
+               os=-sunos3
+               ;;
+       sun3os4)
+               basic_machine=m68k-sun
+               os=-sunos4
+               ;;
+       sun4os3)
+               basic_machine=sparc-sun
+               os=-sunos3
+               ;;
+       sun4os4)
+               basic_machine=sparc-sun
+               os=-sunos4
+               ;;
+       sun4sol2)
+               basic_machine=sparc-sun
+               os=-solaris2
+               ;;
+       sun3 | sun3-*)
+               basic_machine=m68k-sun
+               ;;
+       sun4)
+               basic_machine=sparc-sun
+               ;;
+       sun386 | sun386i | roadrunner)
+               basic_machine=i386-sun
+               ;;
+       sv1)
+               basic_machine=sv1-cray
+               os=-unicos
+               ;;
+       symmetry)
+               basic_machine=i386-sequent
+               os=-dynix
+               ;;
+       t3e)
+               basic_machine=alphaev5-cray
+               os=-unicos
+               ;;
+       t90)
+               basic_machine=t90-cray
+               os=-unicos
+               ;;
+       tic54x | c54x*)
+               basic_machine=tic54x-unknown
+               os=-coff
+               ;;
+       tic55x | c55x*)
+               basic_machine=tic55x-unknown
+               os=-coff
+               ;;
+       tic6x | c6x*)
+               basic_machine=tic6x-unknown
+               os=-coff
+               ;;
+       tile*)
+               basic_machine=tile-unknown
+               os=-linux-gnu
+               ;;
+       tx39)
+               basic_machine=mipstx39-unknown
+               ;;
+       tx39el)
+               basic_machine=mipstx39el-unknown
+               ;;
+       toad1)
+               basic_machine=pdp10-xkl
+               os=-tops20
+               ;;
+       tower | tower-32)
+               basic_machine=m68k-ncr
+               ;;
+       tpf)
+               basic_machine=s390x-ibm
+               os=-tpf
+               ;;
+       udi29k)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       ultra3)
+               basic_machine=a29k-nyu
+               os=-sym1
+               ;;
+       v810 | necv810)
+               basic_machine=v810-nec
+               os=-none
+               ;;
+       vaxv)
+               basic_machine=vax-dec
+               os=-sysv
+               ;;
+       vms)
+               basic_machine=vax-dec
+               os=-vms
+               ;;
+       vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+       vxworks960)
+               basic_machine=i960-wrs
+               os=-vxworks
+               ;;
+       vxworks68)
+               basic_machine=m68k-wrs
+               os=-vxworks
+               ;;
+       vxworks29k)
+               basic_machine=a29k-wrs
+               os=-vxworks
+               ;;
+       w65*)
+               basic_machine=w65-wdc
+               os=-none
+               ;;
+       w89k-*)
+               basic_machine=hppa1.1-winbond
+               os=-proelf
+               ;;
+       xbox)
+               basic_machine=i686-pc
+               os=-mingw32
+               ;;
+       xps | xps100)
+               basic_machine=xps100-honeywell
+               ;;
+       ymp)
+               basic_machine=ymp-cray
+               os=-unicos
+               ;;
+       z8k-*-coff)
+               basic_machine=z8k-unknown
+               os=-sim
+               ;;
+       z80-*-coff)
+               basic_machine=z80-unknown
+               os=-sim
+               ;;
+       none)
+               basic_machine=none-none
+               os=-none
+               ;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+       w89k)
+               basic_machine=hppa1.1-winbond
+               ;;
+       op50n)
+               basic_machine=hppa1.1-oki
+               ;;
+       op60c)
+               basic_machine=hppa1.1-oki
+               ;;
+       romp)
+               basic_machine=romp-ibm
+               ;;
+       mmix)
+               basic_machine=mmix-knuth
+               ;;
+       rs6000)
+               basic_machine=rs6000-ibm
+               ;;
+       vax)
+               basic_machine=vax-dec
+               ;;
+       pdp10)
+               # there are many clones, so DEC is not a safe bet
+               basic_machine=pdp10-unknown
+               ;;
+       pdp11)
+               basic_machine=pdp11-dec
+               ;;
+       we32k)
+               basic_machine=we32k-att
+               ;;
+       sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+               basic_machine=sh-unknown
+               ;;
+       sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+               basic_machine=sparc-sun
+               ;;
+       cydra)
+               basic_machine=cydra-cydrome
+               ;;
+       orion)
+               basic_machine=orion-highlevel
+               ;;
+       orion105)
+               basic_machine=clipper-highlevel
+               ;;
+       mac | mpw | mac-mpw)
+               basic_machine=m68k-apple
+               ;;
+       pmac | pmac-mpw)
+               basic_machine=powerpc-apple
+               ;;
+       *-unknown)
+               # Make sure to match an already-canonicalized machine name.
+               ;;
+       *)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+       *-digital*)
+               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               ;;
+       *-commodore*)
+               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               ;;
+       *)
+               ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+       # -solaris* is a basic system type, with this one exception.
+        -auroraux)
+               os=-auroraux
+               ;;
+       -solaris1 | -solaris1.*)
+               os=`echo $os | sed -e 's|solaris1|sunos4|'`
+               ;;
+       -solaris)
+               os=-solaris2
+               ;;
+       -svr4*)
+               os=-sysv4
+               ;;
+       -unixware*)
+               os=-sysv4.2uw
+               ;;
+       -gnu/linux*)
+               os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+               ;;
+       # First accept the basic system types.
+       # The portable systems comes first.
+       # Each alternative MUST END IN A *, to match a version number.
+       # -sysv* is not here because it comes later, after sysvr4.
+       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+             | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+             | -sym* | -kopensolaris* \
+             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+             | -aos* | -aros* \
+             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+             | -openbsd* | -solidbsd* \
+             | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+             | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+             | -chorusos* | -chorusrdb* | -cegcc* \
+             | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+             | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+             | -uxpv* | -beos* | -mpeix* | -udk* \
+             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+             | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+             | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+             | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+             | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+             | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+       # Remember, each alternative MUST END IN *, to match a version number.
+               ;;
+       -qnx*)
+               case $basic_machine in
+                   x86-* | i*86-*)
+                       ;;
+                   *)
+                       os=-nto$os
+                       ;;
+               esac
+               ;;
+       -nto-qnx*)
+               ;;
+       -nto*)
+               os=`echo $os | sed -e 's|nto|nto-qnx|'`
+               ;;
+       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+             | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+             | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+               ;;
+       -mac*)
+               os=`echo $os | sed -e 's|mac|macos|'`
+               ;;
+       -linux-dietlibc)
+               os=-linux-dietlibc
+               ;;
+       -linux*)
+               os=`echo $os | sed -e 's|linux|linux-gnu|'`
+               ;;
+       -sunos5*)
+               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+               ;;
+       -sunos6*)
+               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+               ;;
+       -opened*)
+               os=-openedition
+               ;;
+        -os400*)
+               os=-os400
+               ;;
+       -wince*)
+               os=-wince
+               ;;
+       -osfrose*)
+               os=-osfrose
+               ;;
+       -osf*)
+               os=-osf
+               ;;
+       -utek*)
+               os=-bsd
+               ;;
+       -dynix*)
+               os=-bsd
+               ;;
+       -acis*)
+               os=-aos
+               ;;
+       -atheos*)
+               os=-atheos
+               ;;
+       -syllable*)
+               os=-syllable
+               ;;
+       -386bsd)
+               os=-bsd
+               ;;
+       -ctix* | -uts*)
+               os=-sysv
+               ;;
+       -nova*)
+               os=-rtmk-nova
+               ;;
+       -ns2 )
+               os=-nextstep2
+               ;;
+       -nsk*)
+               os=-nsk
+               ;;
+       # Preserve the version number of sinix5.
+       -sinix5.*)
+               os=`echo $os | sed -e 's|sinix|sysv|'`
+               ;;
+       -sinix*)
+               os=-sysv4
+               ;;
+        -tpf*)
+               os=-tpf
+               ;;
+       -triton*)
+               os=-sysv3
+               ;;
+       -oss*)
+               os=-sysv3
+               ;;
+       -svr4)
+               os=-sysv4
+               ;;
+       -svr3)
+               os=-sysv3
+               ;;
+       -sysvr4)
+               os=-sysv4
+               ;;
+       # This must come after -sysvr4.
+       -sysv*)
+               ;;
+       -ose*)
+               os=-ose
+               ;;
+       -es1800*)
+               os=-ose
+               ;;
+       -xenix)
+               os=-xenix
+               ;;
+       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+               os=-mint
+               ;;
+       -aros*)
+               os=-aros
+               ;;
+       -kaos*)
+               os=-kaos
+               ;;
+       -zvmoe)
+               os=-zvmoe
+               ;;
+       -dicos*)
+               os=-dicos
+               ;;
+       -none)
+               ;;
+       *)
+               # Get rid of the `-' at the beginning of $os.
+               os=`echo $os | sed 's/[^-]*-//'`
+               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+        score-*)
+               os=-elf
+               ;;
+        spu-*)
+               os=-elf
+               ;;
+       *-acorn)
+               os=-riscix1.2
+               ;;
+       arm*-rebel)
+               os=-linux
+               ;;
+       arm*-semi)
+               os=-aout
+               ;;
+        c4x-* | tic4x-*)
+               os=-coff
+               ;;
+       # This must come before the *-dec entry.
+       pdp10-*)
+               os=-tops20
+               ;;
+       pdp11-*)
+               os=-none
+               ;;
+       *-dec | vax-*)
+               os=-ultrix4.2
+               ;;
+       m68*-apollo)
+               os=-domain
+               ;;
+       i386-sun)
+               os=-sunos4.0.2
+               ;;
+       m68000-sun)
+               os=-sunos3
+               # This also exists in the configure program, but was not the
+               # default.
+               # os=-sunos4
+               ;;
+       m68*-cisco)
+               os=-aout
+               ;;
+        mep-*)
+               os=-elf
+               ;;
+       mips*-cisco)
+               os=-elf
+               ;;
+       mips*-*)
+               os=-elf
+               ;;
+       or32-*)
+               os=-coff
+               ;;
+       *-tti)  # must be before sparc entry or we get the wrong os.
+               os=-sysv3
+               ;;
+       sparc-* | *-sun)
+               os=-sunos4.1.1
+               ;;
+       *-be)
+               os=-beos
+               ;;
+       *-haiku)
+               os=-haiku
+               ;;
+       *-ibm)
+               os=-aix
+               ;;
+       *-knuth)
+               os=-mmixware
+               ;;
+       *-wec)
+               os=-proelf
+               ;;
+       *-winbond)
+               os=-proelf
+               ;;
+       *-oki)
+               os=-proelf
+               ;;
+       *-hp)
+               os=-hpux
+               ;;
+       *-hitachi)
+               os=-hiux
+               ;;
+       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+               os=-sysv
+               ;;
+       *-cbm)
+               os=-amigaos
+               ;;
+       *-dg)
+               os=-dgux
+               ;;
+       *-dolphin)
+               os=-sysv3
+               ;;
+       m68k-ccur)
+               os=-rtu
+               ;;
+       m88k-omron*)
+               os=-luna
+               ;;
+       *-next )
+               os=-nextstep
+               ;;
+       *-sequent)
+               os=-ptx
+               ;;
+       *-crds)
+               os=-unos
+               ;;
+       *-ns)
+               os=-genix
+               ;;
+       i370-*)
+               os=-mvs
+               ;;
+       *-next)
+               os=-nextstep3
+               ;;
+       *-gould)
+               os=-sysv
+               ;;
+       *-highlevel)
+               os=-bsd
+               ;;
+       *-encore)
+               os=-bsd
+               ;;
+       *-sgi)
+               os=-irix
+               ;;
+       *-siemens)
+               os=-sysv4
+               ;;
+       *-masscomp)
+               os=-rtu
+               ;;
+       f30[01]-fujitsu | f700-fujitsu)
+               os=-uxpv
+               ;;
+       *-rom68k)
+               os=-coff
+               ;;
+       *-*bug)
+               os=-coff
+               ;;
+       *-apple)
+               os=-macos
+               ;;
+       *-atari*)
+               os=-mint
+               ;;
+       *)
+               os=-none
+               ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+       *-unknown)
+               case $os in
+                       -riscix*)
+                               vendor=acorn
+                               ;;
+                       -sunos*)
+                               vendor=sun
+                               ;;
+                       -cnk*|-aix*)
+                               vendor=ibm
+                               ;;
+                       -beos*)
+                               vendor=be
+                               ;;
+                       -hpux*)
+                               vendor=hp
+                               ;;
+                       -mpeix*)
+                               vendor=hp
+                               ;;
+                       -hiux*)
+                               vendor=hitachi
+                               ;;
+                       -unos*)
+                               vendor=crds
+                               ;;
+                       -dgux*)
+                               vendor=dg
+                               ;;
+                       -luna*)
+                               vendor=omron
+                               ;;
+                       -genix*)
+                               vendor=ns
+                               ;;
+                       -mvs* | -opened*)
+                               vendor=ibm
+                               ;;
+                       -os400*)
+                               vendor=ibm
+                               ;;
+                       -ptx*)
+                               vendor=sequent
+                               ;;
+                       -tpf*)
+                               vendor=ibm
+                               ;;
+                       -vxsim* | -vxworks* | -windiss*)
+                               vendor=wrs
+                               ;;
+                       -aux*)
+                               vendor=apple
+                               ;;
+                       -hms*)
+                               vendor=hitachi
+                               ;;
+                       -mpw* | -macos*)
+                               vendor=apple
+                               ;;
+                       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+                               vendor=atari
+                               ;;
+                       -vos*)
+                               vendor=stratus
+                               ;;
+               esac
+               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config_filter.c b/config_filter.c
new file mode 100644 (file)
index 0000000..cf3c3df
--- /dev/null
@@ -0,0 +1,56 @@
+/* config_filter.c: handle hidden or non-configuration files in config dirs.
+
+   These functions are called whenever we will parse configuration files to
+   ensure we are not picking up backups, SCM meta data, package artifacts.
+   Eventually all config files will have to follow a convention so these
+   lists of possible exceptions should not have to grow by very much.
+*/
+
+#include <string.h>
+
+#include "util.h"
+#include "config_filter.h"
+
+int config_filter(const char *name)
+{
+       const char *const *p;
+
+       static const char *const skip_prefix[] = {
+               ".",
+               "~",
+               "CVS",
+               NULL
+       };
+
+       static const char *const skip_suffix[] = {
+               ".rpmsave",
+               ".rpmorig",
+               ".rpmnew",
+               ".dpkg-old",
+               ".dpkg-dist",
+               ".dpkg-new",
+               ".dpkg-bak",
+               ".bak",
+               ".orig",
+               ".rej",
+               ".YaST2save",
+               ".-",
+               "~",
+               ",v",
+               NULL
+       };
+
+       for (p = skip_prefix; *p; p++) {
+               if (strstarts(name, *p))
+                       return 0;
+       }
+
+       for (p = skip_suffix; *p; p++) {
+               if (strlen(name) >= strlen(*p) &&
+                   streq(*p, strchr(name, 0) - strlen(*p)))
+                   return 0;
+       }
+
+       return 1;
+}
+
diff --git a/config_filter.h b/config_filter.h
new file mode 100644 (file)
index 0000000..38dc957
--- /dev/null
@@ -0,0 +1,14 @@
+/* config_filter.h: handle hidden or non-configuration files in config dirs.
+
+   These functions are called whenever we will parse configuration files to
+   ensure we are not picking up backups, SCM meta data, package artifacts.
+   Eventually all config files will have to follow a convention so these
+   lists of possible exceptions should not have to grow by very much.
+*/
+#ifndef _MODINITTOOLS_CONFIG_FILTER_H
+#define _MODINITTOOLS_CONFIG_FILTER_H
+
+/* returns 0 if the name matches a well-known backup pattern */
+int config_filter(const char *name);
+
+#endif
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..7d79188
--- /dev/null
+++ b/configure
@@ -0,0 +1,5416 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.63 for module-init-tools 3.12-pre2.
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+if test "x$CONFIG_SHELL" = x; then
+  if (eval ":") 2>/dev/null; then
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+
+  if test $as_have_required = yes &&    (eval ":
+(as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0) || { (exit 1); exit 1; }
+
+(
+  as_lineno_1=\$LINENO
+  as_lineno_2=\$LINENO
+  test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
+  test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
+") 2> /dev/null; then
+  :
+else
+  as_candidate_shells=
+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  case $as_dir in
+        /*)
+          for as_base in sh bash ksh sh5; do
+            as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
+          done;;
+       esac
+done
+IFS=$as_save_IFS
+
+
+      for as_shell in $as_candidate_shells $SHELL; do
+        # Try only shells that exist, to save several forks.
+        if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+               { ("$as_shell") 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+_ASEOF
+}; then
+  CONFIG_SHELL=$as_shell
+              as_have_required=yes
+              if { "$as_shell" 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+(as_func_return () {
+  (exit $1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = "$1" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test $exitcode = 0) || { (exit 1); exit 1; }
+
+(
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
+
+_ASEOF
+}; then
+  break
+fi
+
+fi
+
+      done
+
+      if test "x$CONFIG_SHELL" != x; then
+  for as_var in BASH_ENV ENV
+       do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+       done
+       export CONFIG_SHELL
+       exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+
+    if test $as_have_required = no; then
+  echo This script requires a shell more modern than all the
+      echo shells that I found on your system.  Please install a
+      echo modern shell, or manually run the script under such a
+      echo shell if you do have one.
+      { (exit 1); exit 1; }
+fi
+
+
+fi
+
+fi
+
+
+
+(eval "as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0") || {
+  echo No shell found that supports shell functions.
+  echo Please tell bug-autoconf@gnu.org about your system,
+  echo including any error possibly output before this message.
+  echo This can help us improve future autoconf versions.
+  echo Configuration will now proceed without shell functions.
+}
+
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+  case `echo 'x\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  *)   ECHO_C='\c';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+       test -d "$1/.";
+      else
+       case $1 in
+       -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+
+exec 7<&0 </dev/null 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Identity of this package.
+PACKAGE_NAME='module-init-tools'
+PACKAGE_TARNAME='module-init-tools'
+PACKAGE_VERSION='3.12-pre2'
+PACKAGE_STRING='module-init-tools 3.12-pre2'
+PACKAGE_BUGREPORT=''
+
+ac_subst_vars='am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBOBJS
+MODULE_DIR
+BUILD_STATIC_UTILS_FALSE
+BUILD_STATIC_UTILS_TRUE
+LDADD
+DOCBOOKTOMAN
+RANLIB
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+ax_enable_builddir_sed
+target_os
+target_vendor
+target_cpu
+target
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_builddir
+enable_zlib
+enable_zlib_dynamic
+enable_dependency_tracking
+enable_static_utils
+with_moddir
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)   ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
+   { (exit 1); exit 1; }; }
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
+   { (exit 1); exit 1; }; }
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
+   { (exit 1); exit 1; }; }
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
+   { (exit 1); exit 1; }; }
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) { $as_echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; }
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+      { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+   { (exit 1); exit 1; }; }
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  { $as_echo "$as_me: error: missing argument to $ac_option" >&2
+   { (exit 1); exit 1; }; }
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2
+   { (exit 1); exit 1; }; } ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
+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
+do
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; }
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  { $as_echo "$as_me: error: working directory cannot be determined" >&2
+   { (exit 1); exit 1; }; }
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  { $as_echo "$as_me: error: pwd does not report name of working directory" >&2
+   { (exit 1); exit 1; }; }
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_myself" : 'X\(//\)[^/]' \| \
+        X"$as_myself" : 'X\(//\)$' \| \
+        X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+   { (exit 1); exit 1; }; }
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+       cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2
+   { (exit 1); exit 1; }; }
+       pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures module-init-tools 3.12-pre2 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --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]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root
+                          [DATAROOTDIR/doc/module-init-tools]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+
+System types:
+  --build=BUILD     configure for building on BUILD [guessed]
+  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
+  --target=TARGET   configure for building compilers for TARGET [HOST]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of module-init-tools 3.12-pre2:";;
+   esac
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --disable-builddir      disable automatic build in subdir of sources
+
+  --enable-zlib               Handle gzipped modules
+  --enable-zlib-dynamic       Handle gzipped modules, zlib will be linked
+                               dynamically. Note that libz must be installed
+                               in /lib for this to work.
+  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors
+  --disable-static-utils  Do not build static utils
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-moddir=path      Give the path for system modules directory.
+                          Defaults to /lib/modules
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+module-init-tools configure 3.12-pre2
+generated by GNU Autoconf 2.63
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by module-init-tools $as_me 3.12-pre2, which was
+generated by GNU Autoconf 2.63.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  $as_echo "PATH: $as_dir"
+done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+    2)
+      ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+       ac_must_keep_next=false # Got value, back to normal.
+      else
+       case $ac_arg in
+         *=* | --config-cache | -C | -disable-* | --disable-* \
+         | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+         | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+         | -with-* | --with-* | -without-* | --without-* | --x)
+           case "$ac_configure_args0 " in
+             "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+           esac
+           ;;
+         -* ) ac_must_keep_next=true ;;
+       esac
+      fi
+      ac_configure_args="$ac_configure_args '$ac_arg'"
+      ;;
+    esac
+  done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) $as_unset $ac_var ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+       "s/'\''/'\''\\\\'\'''\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      $as_echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+       eval ac_val=\$$ac_var
+       case $ac_val in
+       *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+       esac
+       $as_echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+  ac_site_file1=$CONFIG_SITE
+elif test "x$prefix" != xNONE; then
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+  test "x$ac_site_file" = xNONE && continue
+  if test -r "$ac_site_file"; then
+    { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special
+  # files actually), so we avoid doing that.
+  if test -f "$cache_file"; then
+    { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+       # differences in whitespace do not lead to failure.
+       ac_old_val_w=`echo x $ac_old_val`
+       ac_new_val_w=`echo x $ac_new_val`
+       if test "$ac_old_val_w" != "$ac_new_val_w"; then
+         { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+         ac_cache_corrupted=:
+       else
+         { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+         eval $ac_var=\$ac_old_val
+       fi
+       { $as_echo "$as_me:$LINENO:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+       { $as_echo "$as_me:$LINENO:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+  if test -f "$ac_dir/install-sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f "$ac_dir/install.sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  elif test -f "$ac_dir/shtool"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/shtool install -c"
+    break
+  fi
+done
+if test -z "$ac_aux_dir"; then
+  { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5
+$as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
+$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
+   { (exit 1); exit 1; }; }
+
+{ $as_echo "$as_me:$LINENO: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if test "${ac_cv_build+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+   { (exit 1); exit 1; }; }
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
+$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
+$as_echo "$as_me: error: invalid value of canonical build" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:$LINENO: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if test "${ac_cv_host+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
+$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
+$as_echo "$as_me: error: invalid value of canonical host" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:$LINENO: checking target system type" >&5
+$as_echo_n "checking target system type... " >&6; }
+if test "${ac_cv_target+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$target_alias" = x; then
+  ac_cv_target=$ac_cv_host
+else
+  ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
+    { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5
+$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_target" >&5
+$as_echo "$ac_cv_target" >&6; }
+case $ac_cv_target in
+*-*-*) ;;
+*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical target" >&5
+$as_echo "$as_me: error: invalid value of canonical target" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+target=$ac_cv_target
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_target
+shift
+target_cpu=$1
+target_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+target_os=$*
+IFS=$ac_save_IFS
+case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac
+
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+test -n "$target_alias" &&
+  test "$program_prefix$program_suffix$program_transform_name" = \
+    NONENONEs,x,x, &&
+  program_prefix=${target_alias}-
+
+
+   # [$]@ is unsable in 2.60+ but earlier autoconf had no ac_configure_args
+   if test "${ac_configure_args+set}" != "set" ; then
+      ac_configure_args=
+      for ac_arg in ${1+"$@"}; do
+         ac_configure_args="$ac_configure_args '$ac_arg'"
+      done
+   fi
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+
+ax_enable_builddir="."
+# Check whether --enable-builddir was given.
+if test "${enable_builddir+set}" = set; then
+  enableval=$enable_builddir; ax_enable_builddir="$enableval"
+else
+  ax_enable_builddir="auto"
+fi
+
+if test ".$ac_srcdir_defaulted" != ".no" ; then
+if test ".$srcdir" = ".." ; then
+  if test -f config.status ; then
+    { $as_echo "$as_me:$LINENO: toplevel srcdir already configured... skipping subdir build" >&5
+$as_echo "$as_me: toplevel srcdir already configured... skipping subdir build" >&6;}
+  else
+    test ".$ax_enable_builddir" = "."  && ax_enable_builddir="."
+    test ".$ax_enable_builddir" = ".no"  && ax_enable_builddir="."
+    test ".$TARGET" = "." && TARGET="$target"
+    test ".$ax_enable_builddir" = ".auto" && ax_enable_builddir="build"
+    if test ".$ax_enable_builddir" != ".." ; then    # we know where to go and
+      { as_dir=$ax_enable_builddir
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
+   { (exit 1); exit 1; }; }; }
+      echo __.$ax_enable_builddir.__ > $ax_enable_builddir/conftest.tmp
+      cd $ax_enable_builddir
+      if grep __.$ax_enable_builddir.__ conftest.tmp >/dev/null 2>/dev/null ; then
+        rm conftest.tmp
+        { $as_echo "$as_me:$LINENO: result: continue configure in default builddir \"./$ax_enable_builddir\"" >&5
+$as_echo "continue configure in default builddir \"./$ax_enable_builddir\"" >&6; }
+      else
+        { { $as_echo "$as_me:$LINENO: error: could not change to default builddir \"./$ax_enable_builddir\"" >&5
+$as_echo "$as_me: error: could not change to default builddir \"./$ax_enable_builddir\"" >&2;}
+   { (exit 1); exit 1; }; }
+      fi
+      srcdir=`echo "$ax_enable_builddir" |
+              sed -e 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g;s,[/]$,,;'`
+      # going to restart from subdirectory location
+      test -f $srcdir/config.log   && mv $srcdir/config.log   .
+      test -f $srcdir/confdefs.h   && mv $srcdir/confdefs.h   .
+      test -f $srcdir/conftest.log && mv $srcdir/conftest.log .
+      test -f $srcdir/$cache_file  && mv $srcdir/$cache_file  .
+      { $as_echo "$as_me:$LINENO: result: ....exec $SHELL $srcdir/$0 \"--srcdir=$srcdir\" \"--enable-builddir=$ax_enable_builddir\" ${1+\"$@\"}" >&5
+$as_echo "....exec $SHELL $srcdir/$0 \"--srcdir=$srcdir\" \"--enable-builddir=$ax_enable_builddir\" ${1+\"$@\"}" >&6; }
+      case "$0" in # restart
+       /\\*) eval $SHELL "'$0'" "'--srcdir=$srcdir'" "'--enable-builddir=$ax_enable_builddir'" $ac_configure_args ;;
+       *) eval $SHELL "'$srcdir/$0'" "'--srcdir=$srcdir'" "'--enable-builddir=$ax_enable_builddir'" $ac_configure_args ;;
+      esac ; exit $?
+    fi
+  fi
+fi fi
+test ".$ax_enable_builddir" = ".auto" && ax_enable_builddir="."
+# Extract the first word of "gsed sed", so it can be a program name with args.
+set dummy gsed sed; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_ax_enable_builddir_sed+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  case $ax_enable_builddir_sed in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ax_enable_builddir_sed="$ax_enable_builddir_sed" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_ax_enable_builddir_sed="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_path_ax_enable_builddir_sed" && ac_cv_path_ax_enable_builddir_sed="sed"
+  ;;
+esac
+fi
+ax_enable_builddir_sed=$ac_cv_path_ax_enable_builddir_sed
+if test -n "$ax_enable_builddir_sed"; then
+  { $as_echo "$as_me:$LINENO: result: $ax_enable_builddir_sed" >&5
+$as_echo "$ax_enable_builddir_sed" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ax_enable_builddir_auxdir="$am_aux_dir"
+ac_config_commands="$ac_config_commands buildir"
+
+
+# Use -no-portability since we're never going to use module-init-tools on
+# non-Linux systems and it's reasonable to expect GNU-compatibility here.
+am__api_version='1.11'
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+  ./ | .// | /cC/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+       if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+         if test $ac_prog = install &&
+           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # AIX install.  It has an incompatible calling convention.
+           :
+         elif test $ac_prog = install &&
+           grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # program-specific install script used by HP pwplus--don't use.
+           :
+         else
+           rm -rf conftest.one conftest.two conftest.dir
+           echo one > conftest.one
+           echo two > conftest.two
+           mkdir conftest.dir
+           if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+             test -s conftest.one && test -s conftest.two &&
+             test -s conftest.dir/conftest.one &&
+             test -s conftest.dir/conftest.two
+           then
+             ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+             break 3
+           fi
+         fi
+       fi
+      done
+    done
+    ;;
+esac
+
+done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:$LINENO: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[\\\"\#\$\&\'\`$am_lf]*)
+    { { $as_echo "$as_me:$LINENO: error: unsafe absolute working directory name" >&5
+$as_echo "$as_me: error: unsafe absolute working directory name" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+case $srcdir in
+  *[\\\"\#\$\&\'\`$am_lf\ \    ]*)
+    { { $as_echo "$as_me:$LINENO: error: unsafe srcdir value: \`$srcdir'" >&5
+$as_echo "$as_me: error: unsafe srcdir value: \`$srcdir'" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+   if test "$*" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$*" != "X $srcdir/configure conftest.file" \
+      && test "$*" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      { { $as_echo "$as_me:$LINENO: error: ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" >&5
+$as_echo "$as_me: error: ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" >&2;}
+   { (exit 1); exit 1; }; }
+   fi
+
+   test "$2" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   { { $as_echo "$as_me:$LINENO: error: newly created file is older than distributed files!
+Check your system clock" >&5
+$as_echo "$as_me: error: newly created file is older than distributed files!
+Check your system clock" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+test "$program_prefix" != NONE &&
+  program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  { $as_echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:$LINENO: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+{ $as_echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+  if test "${ac_cv_path_mkdir+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in mkdir gmkdir; do
+        for ac_exec_ext in '' $ac_executable_extensions; do
+          { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+          case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+            'mkdir (GNU coreutils) '* | \
+            'mkdir (coreutils) '* | \
+            'mkdir (fileutils) '4.1*)
+              ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+              break 3;;
+          esac
+        done
+       done
+done
+IFS=$as_save_IFS
+
+fi
+
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    test -d ./--version && rmdir ./--version
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+mkdir_p="$MKDIR_P"
+case $mkdir_p in
+  [\\/$]* | ?:[\\/]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AWK+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:$LINENO: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+       @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  am__isrc=' -I$(srcdir)'
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    { { $as_echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
+$as_echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE='module-init-tools'
+ VERSION='3.12-pre2'
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+
+
+
+
+
+
+# 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.
+# Check whether --enable-zlib was given.
+if test "${enable_zlib+set}" = set; then
+  enableval=$enable_zlib; if test "$enableval" = "yes"; then
+  cat >>confdefs.h <<\_ACEOF
+#define CONFIG_USE_ZLIB 1
+_ACEOF
+
+  zlib_flags="-Wl,-Bstatic -lz -Wl,-Bdynamic"
+fi
+fi
+
+
+# Check whether --enable-zlib-dynamic was given.
+if test "${enable_zlib_dynamic+set}" = set; then
+  enableval=$enable_zlib_dynamic; if test "$enableval" = "yes"; then
+  cat >>confdefs.h <<\_ACEOF
+#define CONFIG_USE_ZLIB 1
+_ACEOF
+
+  zlib_flags="-lz"
+fi
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:$LINENO: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { (ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+       ;;
+    [ab].out )
+       # We found the default executable, but exeext='' is most
+       # certainly right.
+       break;;
+    *.* )
+        if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+       then :; else
+          ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+       fi
+       # We set ac_cv_exeext here because the later test for it is not
+       # safe: cross compilers may not add the suffix if given an `-o'
+       # argument, so we may need to know it at that point already.
+       # Even if this section looks crufty: it has the advantage of
+       # actually working.
+       break;;
+    * )
+       break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+
+{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+if test -z "$ac_file"; then
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+  if { ac_try='./$ac_file'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+       cross_compiling=yes
+    else
+       { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+         break;;
+    * ) break;;
+  esac
+done
+else
+  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if test "${ac_cv_objext+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_compiler_gnu=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_g=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       CFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_c_werror_flag=$ac_save_c_werror_flag
+        CFLAGS="-g"
+        cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_g=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_c89=$ac_arg
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:$LINENO: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:$LINENO: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ $as_echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+
+
+{ $as_echo "$as_me:$LINENO: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then
+  enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+
+depcc="$CC"   am_compiler_list=
+
+{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_RANLIB+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:$LINENO: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+
+for ac_prog in docbook-to-man docbook2man
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_DOCBOOKTOMAN+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DOCBOOKTOMAN"; then
+  ac_cv_prog_DOCBOOKTOMAN="$DOCBOOKTOMAN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DOCBOOKTOMAN="$ac_prog"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+DOCBOOKTOMAN=$ac_cv_prog_DOCBOOKTOMAN
+if test -n "$DOCBOOKTOMAN"; then
+  { $as_echo "$as_me:$LINENO: result: $DOCBOOKTOMAN" >&5
+$as_echo "$DOCBOOKTOMAN" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$DOCBOOKTOMAN" && break
+done
+test -n "$DOCBOOKTOMAN" || DOCBOOKTOMAN="no"
+
+if test x"$DOCBOOKTOMAN" = xno
+then
+       { $as_echo "$as_me:$LINENO: WARNING: docbook2man not found" >&5
+$as_echo "$as_me: WARNING: docbook2man not found" >&2;}
+       # fail with a meaningfull error if $DOCBOOKTOMAN called by the makefile
+       DOCBOOKTOMAN=docbook2man
+fi
+
+# Delay adding the zlib_flags until after AC_PROG_CC, so we can distinguish
+# between a broken cc and a working cc but missing libz.a.
+LDADD="$LDADD $zlib_flags"
+
+
+case $target in
+*-*-linux*) ;;
+*) { { $as_echo "$as_me:$LINENO: error: Linux only, dude!" >&5
+$as_echo "$as_me: error: Linux only, dude!" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+
+# Thanks to Martin Pool
+if test x"$GCC" = xyes
+then
+    CFLAGS="$CFLAGS -Wunused -Wall"
+    { $as_echo "$as_me:$LINENO: Adding gcc options: $CFLAGS" >&5
+$as_echo "$as_me: Adding gcc options: $CFLAGS" >&6;}
+fi
+
+# Check whether --enable-static-utils was given.
+if test "${enable_static_utils+set}" = set; then
+  enableval=$enable_static_utils;
+else
+  enable_static_utils=yes
+fi
+
+ if test "$enable_static_utils" = "yes"; then
+  BUILD_STATIC_UTILS_TRUE=
+  BUILD_STATIC_UTILS_FALSE='#'
+else
+  BUILD_STATIC_UTILS_TRUE='#'
+  BUILD_STATIC_UTILS_FALSE=
+fi
+
+
+
+# Check whether --with-moddir was given.
+if test "${with_moddir+set}" = set; then
+  withval=$with_moddir; if test ! -z "$withval"; then
+  MODULE_DIR="\\\"$withval/\\\""
+  CFLAGS="$CFLAGS -DMODULE_DIR=$MODULE_DIR"
+fi
+fi
+
+
+
+ac_config_files="$ac_config_files Makefile"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) $as_unset $ac_var ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # `set' does not quote correctly, so add quotes (double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \).
+      sed -n \
+       "s/'/'\\\\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    test "x$cache_file" != "x/dev/null" &&
+      { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+    cat confcache >$cache_file
+  else
+    { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+#
+# If the first sed substitution is executed (which looks for macros that
+# take arguments), then branch to the quote section.  Otherwise,
+# look for a macro that doesn't take arguments.
+ac_script='
+:mline
+/\\$/{
+ N
+ s,\\\n,,
+ b mline
+}
+t clear
+:clear
+s/^[    ]*#[    ]*define[       ][      ]*\([^  (][^    (]*([^)]*)\)[   ]*\(.*\)/-D\1=\2/g
+t quote
+s/^[    ]*#[    ]*define[       ][      ]*\([^  ][^     ]*\)[   ]*\(.*\)/-D\1=\2/g
+t quote
+b any
+:quote
+s/[     `~#$^&*(){}\\|;'\''"<>?]/\\&/g
+s/\[/\\&/g
+s/\]/\\&/g
+s/\$/$$/g
+H
+:any
+${
+       g
+       s/^\n//
+       s/\n/ /g
+       p
+}
+'
+DEFS=`sed -n "$ac_script" confdefs.h`
+
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+ if test -n "$EXEEXT"; then
+  am__EXEEXT_TRUE=
+  am__EXEEXT_FALSE='#'
+else
+  am__EXEEXT_TRUE='#'
+  am__EXEEXT_FALSE=
+fi
+
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+  { { $as_echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${BUILD_STATIC_UTILS_TRUE}" && test -z "${BUILD_STATIC_UTILS_FALSE}"; then
+  { { $as_echo "$as_me:$LINENO: error: conditional \"BUILD_STATIC_UTILS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"BUILD_STATIC_UTILS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+: ${CONFIG_STATUS=./config.status}
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+  case `echo 'x\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  *)   ECHO_C='\c';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+       test -d "$1/.";
+      else
+       case $1 in
+       -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+
+# Save the log message, to keep $[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by module-init-tools $as_me 3.12-pre2, which was
+generated by GNU Autoconf 2.63.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTION]... [FILE]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+
+Configuration files:
+$config_files
+
+Configuration commands:
+$config_commands
+
+Report bugs to <bug-autoconf@gnu.org>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_version="\\
+module-init-tools config.status 3.12-pre2
+configured by $0, generated by GNU Autoconf 2.63,
+  with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2008 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    CONFIG_FILES="$CONFIG_FILES '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h |  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) { $as_echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; } ;;
+
+  *) ac_config_targets="$ac_config_targets $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  shift
+  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  CONFIG_SHELL='$SHELL'
+  export CONFIG_SHELL
+  exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+ax_enable_builddir_srcdir="$srcdir"                    # $srcdir
+ax_enable_builddir_host="$HOST"                        # $HOST / $host
+ax_enable_builddir_version="$VERSION"                  # $VERSION
+ax_enable_builddir_package="$PACKAGE"                  # $PACKAGE
+ax_enable_builddir_auxdir="$ax_enable_builddir_auxdir" # $AUX
+ax_enable_builddir_sed="$ax_enable_builddir_sed"       # $SED
+ax_enable_builddir="$ax_enable_builddir"               # $SUB
+
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "buildir") CONFIG_COMMANDS="$CONFIG_COMMANDS buildir" ;;
+    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+
+  *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+   { (exit 1); exit 1; }; };;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp=
+  trap 'exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+  trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} ||
+{
+   $as_echo "$as_me: cannot create a temporary directory in ." >&2
+   { (exit 1); exit 1; }
+}
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr='\r'
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\).*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\).*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = "\a"
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+  || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5
+$as_echo "$as_me: error: could not setup config files machinery" >&2;}
+   { (exit 1); exit 1; }; }
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[         ]*VPATH[        ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[    ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[      ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+
+eval set X "  :F $CONFIG_FILES      :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5
+$as_echo "$as_me: error: invalid tag $ac_tag" >&2;}
+   { (exit 1); exit 1; }; };;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+        # (if the path is not absolute).  The absolute path cannot be DOS-style,
+        # because $ac_f cannot contain `:'.
+        test -f "$ac_f" ||
+          case $ac_f in
+          [\\/$]*) false;;
+          *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+          esac ||
+          { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
+$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;}
+   { (exit 1); exit 1; }; };;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      ac_file_inputs="$ac_file_inputs '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+         $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+       `' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:$LINENO: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin" \
+      || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+   { (exit 1); exit 1; }; } ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$ac_file" : 'X\(//\)[^/]' \| \
+        X"$ac_file" : 'X\(//\)$' \| \
+        X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  { as_dir="$ac_dir"
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
+   { (exit 1); exit 1; }; }; }
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+  esac
+  ac_MKDIR_P=$MKDIR_P
+  case $MKDIR_P in
+  [\\/$]* | ?:[\\/]* ) ;;
+  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+  esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p
+'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+    s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+  || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+   { (exit 1); exit 1; }; }
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[         ]*datarootdir[  ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&2;}
+
+  rm -f "$tmp/stdin"
+  case $ac_file in
+  -) cat "$tmp/out" && rm -f "$tmp/out";;
+  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+  esac \
+  || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+   { (exit 1); exit 1; }; }
+ ;;
+
+
+  :C)  { $as_echo "$as_me:$LINENO: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+  esac
+
+
+  case $ac_file$ac_mode in
+    "buildir":C)   ac_top_srcdir="$ax_enable_builddir_srcdir"
+  if test ".$ax_enable_builddir" = ".." ; then
+    if test -f "$top_srcdir/Makefile" ; then
+      { $as_echo "$as_me:$LINENO: skipping top_srcdir/Makefile - left untouched" >&5
+$as_echo "$as_me: skipping top_srcdir/Makefile - left untouched" >&6;}
+    else
+      { $as_echo "$as_me:$LINENO: skipping top_srcdir/Makefile - not created" >&5
+$as_echo "$as_me: skipping top_srcdir/Makefile - not created" >&6;}
+    fi
+  else
+    if test -f "$ac_top_srcdir/Makefile" ; then
+      a=`grep "^VERSION " "$ac_top_srcdir/Makefile"` ; b=`grep "^VERSION " Makefile`
+      test "$a" != "$b" && rm "$ac_top_srcdir/Makefile"
+    fi
+    if test -f "$ac_top_srcdir/Makefile" ; then
+       echo "$ac_top_srcdir/Makefile : $ac_top_srcdir/Makefile.in" > $tmp/conftemp.mk
+       echo "  @ echo 'REMOVED,,,' >\$@" >> $tmp/conftemp.mk
+      eval "${MAKE-make} -f $tmp/conftemp.mk 2>/dev/null >/dev/null"
+      if grep '^REMOVED,,,' "$ac_top_srcdir/Makefile" >/dev/null
+      then rm $ac_top_srcdir/Makefile ; fi
+      cp $tmp/conftemp.mk $ac_top_srcdir/makefiles.mk~      ## DEBUGGING
+    fi
+    if test ! -f "$ac_top_srcdir/Makefile" ; then
+      { $as_echo "$as_me:$LINENO: create top_srcdir/Makefile guessed from local Makefile" >&5
+$as_echo "$as_me: create top_srcdir/Makefile guessed from local Makefile" >&6;}
+      x='`' ; cat >$tmp/conftemp.sed <<_EOF
+/^\$/n
+x
+/^\$/bS
+x
+/\\\\\$/{H;d;}
+{H;s/.*//;x;}
+bM
+:S
+x
+/\\\\\$/{h;d;}
+{h;s/.*//;x;}
+:M
+s/\\(\\n\\)    /\\1 /g
+/^     /d
+/^[    ]*[\\#]/d
+/^VPATH *=/d
+s/^srcdir *=.*/srcdir = ./
+s/^top_srcdir *=.*/top_srcdir = ./
+/[:=]/!d
+/^\\./d
+/ = /b
+/ .= /b
+/:/!b
+s/:.*/:/
+s/ /  /g
+s/ \\([a-z][a-z-]*[a-zA-Z0-9]\\)\\([ :]\\)/ \\1 \\1-all\\2/g
+s/^\\([a-z][a-z-]*[a-zA-Z0-9]\\)\\([ :]\\)/\\1 \\1-all\\2/
+s/  / /g
+/^all all-all[ :]/i\\
+all-configured : all-all
+s/ [a-zA-Z0-9-]*-all [a-zA-Z0-9-]*-all-all//g
+/-all-all/d
+a\\
+       @ HOST="\$(HOST)\" \\\\\\
+       ; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\
+       ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+       ; use=$x basename "\$\@" -all $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
+       ; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" = "0" ; then : \\\\\\
+       ; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\
+       ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
+       ; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\
+       ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done
+/dist-all *:/a\\
+       @ HOST="\$(HOST)\" \\\\\\
+       ; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\
+       ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+       ; found=$x echo \$\$BUILD | wc -w $x \\\\\\
+       ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\
+       ; if test "\$\$found" = "0" ; then : \\\\\\
+       ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\
+       ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\
+       ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done
+/dist-[a-zA-Z0-9]*-all *:/a\\
+       @ HOST="\$(HOST)\" \\\\\\
+       ; test ".\$\$HOST" = "." && HOST=$x sh ./config.guess $x \\\\\\
+       ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+       ; found=$x echo \$\$BUILD | wc -w $x \\\\\\
+       ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).*" \\\\\\
+       ; if test "\$\$found" = "0" ; then : \\\\\\
+       ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\
+       ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).* \\\\\\
+       ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done
+/distclean-all *:/a\\
+       @ HOST="\$(HOST)\" \\\\\\
+       ; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\
+       ; BUILD=$x grep "^#### .*|" Makefile | sed -e 's/.*|//' $x \\\\\\
+       ; use=$x basename "\$\@" -all $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
+       ; echo "MAKE \$\$HOST : \$\$n * \$\@ (all local builds)" \\\\\\
+       ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
+       ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; echo "# rm -r \$\$i"; done ; echo "# (sleep 3)" ; sleep 3 \\\\\\
+       ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; echo "\$\$i" | grep "^/" > /dev/null && continue \\\\\\
+       ; echo "\$\$i" | grep "^../" > /dev/null && continue \\\\\\
+       ; echo "rm -r \$\$i"; (rm -r "\$\$i") ; done ; rm Makefile
+_EOF
+      cp "$tmp/conftemp.sed" "$ac_top_srcdir/makefile.sed~"            ## DEBUGGING
+      $ax_enable_builddir_sed -f $tmp/conftemp.sed Makefile >$ac_top_srcdir/Makefile
+      if test -f "$ac_top_srcdir/Makefile.mk" ; then
+        { $as_echo "$as_me:$LINENO: extend top_srcdir/Makefile with top_srcdir/Makefile.mk" >&5
+$as_echo "$as_me: extend top_srcdir/Makefile with top_srcdir/Makefile.mk" >&6;}
+        cat $ac_top_srcdir/Makefile.mk >>$ac_top_srcdir/Makefile
+      fi ; xxxx="####"
+      echo "$xxxx CONFIGURATIONS FOR TOPLEVEL MAKEFILE: " >>$ac_top_srcdir/Makefile
+      # sanity check
+      if grep '^; echo "MAKE ' $ac_top_srcdir/Makefile >/dev/null ; then
+        { $as_echo "$as_me:$LINENO: buggy sed found - it deletes tab in \"a\" text parts" >&5
+$as_echo "$as_me: buggy sed found - it deletes tab in \"a\" text parts" >&6;}
+        $ax_enable_builddir_sed -e '/^@ HOST=/s/^/     /' -e '/^; /s/^/        /' $ac_top_srcdir/Makefile \
+          >$ac_top_srcdir/Makefile~
+        (test -s $ac_top_srcdir/Makefile~ && mv $ac_top_srcdir/Makefile~ $ac_top_srcdir/Makefile) 2>/dev/null
+      fi
+    else
+      xxxx="\\#\\#\\#\\#"
+      # echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed
+      echo "s!^$xxxx [^|]* | *$ax_enable_builddir *\$!$xxxx ...... $ax_enable_builddir!" >$tmp/conftemp.sed
+      $ax_enable_builddir_sed -f "$tmp/conftemp.sed" "$ac_top_srcdir/Makefile" >$tmp/mkfile.tmp
+        cp "$tmp/conftemp.sed" "$ac_top_srcdir/makefiles.sed~"         ## DEBUGGING
+        cp "$tmp/mkfile.tmp"   "$ac_top_srcdir/makefiles.out~"         ## DEBUGGING
+      if cmp -s "$ac_top_srcdir/Makefile" "$tmp/mkfile.tmp" 2>/dev/null ; then
+        { $as_echo "$as_me:$LINENO: keeping top_srcdir/Makefile from earlier configure" >&5
+$as_echo "$as_me: keeping top_srcdir/Makefile from earlier configure" >&6;}
+        rm "$tmp/mkfile.tmp"
+      else
+        { $as_echo "$as_me:$LINENO: reusing top_srcdir/Makefile from earlier configure" >&5
+$as_echo "$as_me: reusing top_srcdir/Makefile from earlier configure" >&6;}
+        mv "$tmp/mkfile.tmp" "$ac_top_srcdir/Makefile"
+      fi
+    fi
+    { $as_echo "$as_me:$LINENO: build in $ax_enable_builddir (HOST=$ax_enable_builddir_host)" >&5
+$as_echo "$as_me: build in $ax_enable_builddir (HOST=$ax_enable_builddir_host)" >&6;}
+    xxxx="####"
+    echo "$xxxx" "$ax_enable_builddir_host" "|$ax_enable_builddir" >>$ac_top_srcdir/Makefile
+  fi
+ ;;
+    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`$as_dirname -- "$mf" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$mf" : 'X\(//\)[^/]' \| \
+        X"$mf" : 'X\(//\)$' \| \
+        X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$file" : 'X\(//\)[^/]' \| \
+        X"$file" : 'X\(//\)$' \| \
+        X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      { as_dir=$dirpart/$fdir
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
+   { (exit 1); exit 1; }; }; }
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+ ;;
+
+  esac
+done # for ac_tag
+
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+  { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || { (exit 1); exit 1; }
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
+
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..5d549ce
--- /dev/null
@@ -0,0 +1,72 @@
+AC_INIT(module-init-tools,3.12-pre2)
+
+AC_CANONICAL_SYSTEM
+
+AX_ENABLE_BUILDDIR([build])
+
+# Use -no-portability since we're never going to use module-init-tools on
+# non-Linux systems and it's reasonable to expect GNU-compatibility here.
+AM_INIT_AUTOMAKE([-Wno-portability])
+
+# 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_ENABLE(zlib,
+[  --enable-zlib               Handle gzipped modules],
+[if test "$enableval" = "yes"; then
+  AC_DEFINE(CONFIG_USE_ZLIB)
+  zlib_flags="-Wl,-Bstatic -lz -Wl,-Bdynamic"
+fi])
+
+AC_ARG_ENABLE(zlib-dynamic,
+[  --enable-zlib-dynamic       Handle gzipped modules, zlib will be linked
+                               dynamically. Note that libz must be installed
+                               in /lib for this to work.],
+[if test "$enableval" = "yes"; then
+  AC_DEFINE(CONFIG_USE_ZLIB)
+  zlib_flags="-lz"
+fi])
+
+AC_PROG_CC
+AC_PROG_RANLIB
+
+AC_CHECK_PROGS(DOCBOOKTOMAN, docbook-to-man docbook2man, [no],)
+if test x"$DOCBOOKTOMAN" = xno
+then
+       AC_MSG_WARN([docbook2man not found])
+       # fail with a meaningfull error if $DOCBOOKTOMAN called by the makefile
+       DOCBOOKTOMAN=docbook2man
+fi
+# Delay adding the zlib_flags until after AC_PROG_CC, so we can distinguish
+# between a broken cc and a working cc but missing libz.a.
+LDADD="$LDADD $zlib_flags"
+AC_SUBST(LDADD)
+
+case $target in
+*-*-linux*) ;;
+*) AC_MSG_ERROR([Linux only, dude!]);;
+esac
+
+# Thanks to Martin Pool
+if test x"$GCC" = xyes 
+then
+    CFLAGS="$CFLAGS -Wunused -Wall"
+    AC_MSG_NOTICE([Adding gcc options: $CFLAGS])
+fi
+
+AC_ARG_ENABLE(static-utils,
+AS_HELP_STRING([--disable-static-utils], [Do not build static utils]),
+[],[enable_static_utils=yes])
+AM_CONDITIONAL(BUILD_STATIC_UTILS, test "$enable_static_utils" = "yes")
+
+AC_ARG_WITH(moddir,
+[  --with-moddir=path      Give the path for system modules directory.]
+[                         [ Defaults to /lib/modules ]],
+[if test ! -z "$withval"; then
+  MODULE_DIR="\\\"$withval/\\\""
+  CFLAGS="$CFLAGS -DMODULE_DIR=$MODULE_DIR"
+fi])
+AC_SUBST(MODULE_DIR)
+
+AC_OUTPUT([Makefile])
+
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..980af28
--- /dev/null
@@ -0,0 +1,697 @@
+module-init-tools (3.12~pre2-3slp2+s1) unstable; urgency=low
+
+  * Don't build documentation - drop docbook-utils build dep
+  * Don't build -udeb package
+
+ -- Karol Lewandowski <k.lewandowsk@samsung.com>  Thu, 06 May 2010 18:56:40 +0200
+
+module-init-tools (3.12~pre2-3) unstable; urgency=high
+
+  * Fixed spurious output of modprobe. (Closes: #574584, #574797)
+
+ -- Marco d'Itri <md@linux.it>  Thu, 15 Apr 2010 03:04:10 +0200
+
+module-init-tools (3.12~pre2-2) unstable; urgency=high
+
+  * Fixed an init scripts dependency loop introduced in -1. (Closes: #574535)
+
+ -- Marco d'Itri <md@linux.it>  Mon, 22 Mar 2010 12:21:18 +0100
+
+module-init-tools (3.12~pre2-1) unstable; urgency=medium
+
+  * New upstream snapshot.
+
+ -- Marco d'Itri <md@linux.it>  Fri, 12 Mar 2010 19:39:28 +0100
+
+module-init-tools (3.12~pre1-1) unstable; urgency=low
+
+  * New upstream snapshot.
+
+ -- Marco d'Itri <md@linux.it>  Tue, 26 Jan 2010 22:51:50 +0100
+
+module-init-tools (3.11-1) unstable; urgency=low
+
+  * New upstream release.
+    + Fixes a fork bombing issue with kernels <= 2.6.19. (Closes: #524940)
+  * Removed a bashism from the init script. (Closes: #547754)
+
+ -- Marco d'Itri <md@linux.it>  Sat, 17 Oct 2009 00:39:38 +0200
+
+module-init-tools (3.10-3) unstable; urgency=high
+
+  * Remove for real this time the architecture-specific aliases for
+    architectures != i386. (Closes: #543616)
+
+ -- Marco d'Itri <md@linux.it>  Wed, 26 Aug 2009 14:36:27 +0200
+
+module-init-tools (3.10-2) unstable; urgency=low
+
+  * Do not fail in preinst if the arch directory does not exist.
+    (Closes: #542357)
+
+ -- Marco d'Itri <md@linux.it>  Thu, 20 Aug 2009 23:44:38 +0200
+
+module-init-tools (3.10-1) unstable; urgency=low
+
+  * New upstream release.
+  * After two years removed /sbin/update-modules to break the packages
+    still trying to use it. (Closes: #539988)
+  * Removed the architecture-specific aliases. If your platform needs one
+    you will have to fix the kernel instead.
+  * Removed patch ignore_arch_directory.
+  * Renamed /etc/modprobe.d/aliases to /etc/modprobe.d/aliases.conf.
+  * Removed patch suppress_conf_warnings.
+  * Make sure that the man pages are regenerated. (Closes: #523837)
+
+ -- Marco d'Itri <md@linux.it>  Mon, 17 Aug 2009 23:47:30 +0200
+
+module-init-tools (3.9-2) unstable; urgency=medium
+
+  * Fixed a postinst failure on some architectures. (Closes: #533174)
+  * Added a 60 seconds sleep in update-modules to annoy whoever may still
+    be using it.
+
+ -- Marco d'Itri <md@linux.it>  Mon, 15 Jun 2009 15:57:45 +0200
+
+module-init-tools (3.9-1) unstable; urgency=medium
+
+  * New upstream release.
+  * /etc/modprobe.d/aliases: load ehci-hcd using --use-blacklist.
+    (Closes: #521331)
+  * Documented the -m option of depmod. (Closes: #523837)
+  * Removed the obsolete parts from the code supporting architecture-specific
+    alias files. (Closes: #532548)
+
+ -- Marco d'Itri <md@linux.it>  Mon, 15 Jun 2009 04:00:20 +0200
+
+module-init-tools (3.7-pre9-1) unstable; urgency=medium
+
+  * Since we are already providing workarounds for kernel shortcomings,
+    add to the aliases file directives to load ehci-hcd before the other
+    HCD drivers. (Closes: #500001)
+  * docbook-to-man build-dependency replaced by docbook-utils which is
+    less broken.
+  * debhelper version upgraded from 4 to 5.
+
+ -- Marco d'Itri <md@linux.it>  Fri, 13 Mar 2009 00:42:17 +0100
+
+module-init-tools (3.7-pre5-1) unstable; urgency=low
+
+  * New upstream snapshot.
+    + Fixed some issues when modprobing multiple modules.
+      (Closes: #321662, #500035, #504088)
+    + Removed modules file locking. (Closes: #414711)
+  * Install the architecture-specific aliases on i386 systems using a
+    64 bit kernel. (Closes: #517958)
+  * Added patch suppress_conf_warnings: suppress .conf warnings for our
+    own files. (Closes: #517954)
+  * Escaped the backslashes in the man pages to work around some
+    unexplained brokeness in docbook-to-man. (Closes: #517924) 
+
+ -- Marco d'Itri <md@linux.it>  Tue, 03 Mar 2009 17:55:42 +0100
+
+module-init-tools (3.7-pre2-1) unstable; urgency=low
+
+  * New upstream snapshot. (Closes: #506557)
+    + Reads the configuration files in a deterministic order. (Closes: #397765)
+    + Mentions modinfo(8) in other man pages. (Closes: #486716)
+    + Documents the -b modprobe argument. (Closes: #491437)
+  * Added patch no_maps_by_default: stop building the maps files by default
+    and see what happens.
+  * Removed patch runparts_like_names which has been replaced by a similar
+    official feature.
+  * Removed a wrong vcs-git URL. (Closes: #504090)
+  * Fixed the URL in the debian/watch file. (Closes: #506367)
+  * Commented some redundant module aliases.
+  * Tries harder to clean up the old diversions. (Closes: #509575)
+  * Removed support for /lib/modules/boot/.
+
+ -- Marco d'Itri <md@linux.it>  Mon, 02 Mar 2009 23:07:40 +0100
+
+module-init-tools (3.4-1) unstable; urgency=medium
+
+  * Package converted to quilt.
+  * New patch fix_empty_options prevents a segfault if $MODPROBE_OPTIONS
+    is defined but empty. (Closes: #463227)
+  * New alias: nfs4.
+  * Renamed alias net-pf-26 from llc to llc2, and commented all the
+    net-pf-* aliases which are built-in in 2.6.24. (Closes: #471856)
+  * Removed the built-in aliases xfrm-type-*.
+  * Tried harder to fix #428650.
+  * Made update-modules.8 unnecessarily verbose. (Closes: #441734)
+
+ -- Marco d'Itri <md@linux.it>  Sat, 05 Apr 2008 03:00:24 +0200
+
+module-init-tools (3.3-pre11-4) unstable; urgency=high
+
+  * Try harder to clean up the diversions. Apparently some old dpkg version
+    used to leave around diverted files which got removed. (Closes: #428650)
+  * Clean up after modutils by deleting /etc/rcS.d/S20modutils.
+  * Make update-modules complain about its uselessness.
+
+ -- Marco d'Itri <md@linux.it>  Sun, 08 Jul 2007 22:59:13 +0200
+
+module-init-tools (3.3-pre11-3) unstable; urgency=high
+
+  * The modutils diversions must be removed in postinst, because preinst
+    is run before the old files are removed. (Closes: #428650)
+
+ -- Marco d'Itri <md@linux.it>  Wed, 13 Jun 2007 13:39:07 +0200
+
+module-init-tools (3.3-pre11-2) unstable; urgency=high
+
+  * Disabled modutils compatibility, now the package conflicts with it.
+  * Removed the modutils_extension patch and extra/fixmanpages, which
+    dealt with modutils.
+  * New patch insmod-segv: prevents insmod from segfaulting if called without
+    an explicit path, courtesy of Mikko Ylinen. (Closes: #425458)
+  * Add .orig to the list of forbidden extensions. (See #295755.)
+  * Removed from preinst the code needed to upgrade from pre-sarge versions
+    of the package (< 3.1-pre2-1).
+  * Stop installing the TODO, FAQ, generate-modprobe.conf and modprobe.devfs
+    files because they are useless.
+  * New patch use_blacklist_doc to document the --use-blacklist command line
+    parameter.
+
+ -- Marco d'Itri <md@linux.it>  Wed, 13 Jun 2007 04:11:34 +0200
+
+module-init-tools (3.3-pre11-1) unstable; urgency=medium
+
+  * New upstream release. (Closes: #421115)
+  * Removed patch hotplug_blacklist: /etc/hotplug/blacklist.d/ is not
+    supported anymore.
+  * Removed backported patches: cmdline_opts_fix, format_64bit_fix.
+  * Depend on docbook-to-man, since pre-build man pages are not in the
+    upstream tree anymore.
+  * Fixed misc documentation issues. (Closes: #348121, #401972, #401973)
+  * New alias: binfmt-0064 [x86_64]. (Closes: #421978)
+  * Removed alias: binfmt-332 [x86].
+
+ -- Marco d'Itri <md@linux.it>  Sun, 20 May 2007 19:44:47 +0200
+
+module-init-tools (3.3-pre4-2) unstable; urgency=medium
+
+  * New aliases: net-pf-16-proto-*. (Closes: #411048)
+
+ -- Marco d'Itri <md@linux.it>  Sun, 18 Feb 2007 17:53:37 +0100
+
+module-init-tools (3.3-pre4-1) unstable; urgency=medium
+
+  * New upstream release (3.3-pre6), only bug fixes.
+  * Added patch cmdline_opts_fix to prevent passing command line options
+    to modules depended on. From Altlinux. (Closes: #336205)
+  * Added patch format_64bit_fix to fix a possible bug on some 64 bit
+    architectures. From Altlinux.
+  * Moved modprobe.conf to modprobe.d/ in the udeb to stop ignoring other
+    files in the directory.
+
+ -- Marco d'Itri <md@linux.it>  Sat,  6 Jan 2007 16:01:00 +0100
+
+module-init-tools (3.3-pre3-1) unstable; urgency=medium
+
+  * New upstream release.
+  * patches/hotplug_blacklist: fixed typo. (Closes: #382443)
+  * Only use LSB message functions in the init script to properly support
+    usplash. Based on code contributed by David Härdeman (see #384916).
+  * New alias: char-major-10-187.
+
+ -- Marco d'Itri <md@linux.it>  Tue, 14 Nov 2006 15:23:46 +0100
+
+module-init-tools (3.2.2-3) unstable; urgency=medium
+
+  * Do not run anymore depmod -A in the init script. (Closes: #358239)
+    All packages installing kernel modules will need to run depmod in their
+    maintainer scripts.
+  * Build-depend on autotools-dev to get recent config.{sub,guess} files.
+    (Closes: #357954)
+  * Remove /etc/modprobe.d/arch-aliases when the package is purged.
+    (Closes: #355699)
+  * Added patch always_apply_blacklist from the Ubuntu package, to make
+    blacklist directives apply to user-defined aliases too.
+
+ -- Marco d'Itri <md@linux.it>  Sat,  3 Jun 2006 14:10:21 +0200
+
+module-init-tools (3.2.2-2) unstable; urgency=medium
+
+  * Added patch fix_wildcards from upstream 3.3-pre1, to fix matching
+    [a-b] expressions in aliases. (Closes: #350915)
+  * Updated the runparts_like_names patch to ignore CVS directories.
+
+ -- Marco d'Itri <md@linux.it>  Sun,  5 Feb 2006 12:35:34 +0100
+
+module-init-tools (3.2.2-1) unstable; urgency=medium
+
+  * New upstream release.
+    + Fixed the documentation about modprobe and wildcards. (Closes: #328527)
+    + Adds modules.inputmap support for 2.6.15 kernels.
+  * Remove the /sbin/k{all,}syms symlinks *before* undiverting the
+    modutils binaries in postrm (see #333522). (Closes: #342042)
+
+ -- Marco d'Itri <md@linux.it>  Mon, 28 Nov 2005 12:33:45 +0100
+
+module-init-tools (3.2-pre9-4) unstable; urgency=high
+
+  * Added two patches to prevent errors when concurrently loading modules.
+    (Closes: #333522)
+  * Removed the diversions for kallsyms(8) and ksyms(8).
+
+ -- Marco d'Itri <md@linux.it>  Sun,  6 Nov 2005 12:14:39 +0100
+
+module-init-tools (3.2-pre9-3) unstable; urgency=medium
+
+  * Added LSB data to the init script.
+
+ -- Marco d'Itri <md@linux.it>  Sun, 23 Oct 2005 12:42:34 +0200
+
+module-init-tools (3.2-pre9-2) unstable; urgency=medium
+
+  * Fixed debian/rules to not break if there are no arch-specific aliases.
+
+ -- Marco d'Itri <md@linux.it>  Sat,  8 Oct 2005 19:48:01 +0200
+
+module-init-tools (3.2-pre9-1) unstable; urgency=medium
+
+  * New upstream release.
+  * Removed the out of date French man pages from the source package.
+  * Added *temporary* support for /etc/hotplug/blacklist.d/.
+  * Added -* to every {char,block}-major- alias without a minor.
+  * Removed some unneeded aliases from the main aliases file.
+  * Added SuSE patch blacklist-warn.diff to warn when a blacklisted module
+    is not loaded.
+
+ -- Marco d'Itri <md@linux.it>  Sun, 25 Sep 2005 13:43:37 +0200
+
+module-init-tools (3.2-pre8-1) unstable; urgency=medium
+
+  * New upstream release.
+  * Switched the init script to lsb-base. (Closes: #294766)
+  * Added cross-compilation support to extra/installarchconf. (Closes: #308164)
+  * Added symlinks for kallsyms(8) and ksyms(8). (Closes: #304690)
+
+ -- Marco d'Itri <md@linux.it>  Wed,  3 Aug 2005 19:27:39 +0200
+
+module-init-tools (3.2-pre1-2) unstable; urgency=high
+
+  * Fixed the init script to not depend on /sbin/kernelversion, which is
+    part of modutils. (Closes: #292116)
+
+ -- Marco d'Itri <md@linux.it>  Wed, 26 Jan 2005 21:55:43 +0100
+
+module-init-tools (3.2-pre1-1) unstable; urgency=medium
+
+  * Make the init script support > 2.6 kernels too. (Closes: #282584)
+  * Added support for dpkg-cross, by NIIBE Yutaka. (Closes: #283722)
+  * Changed ide-probe-mod to ide-generic in the standard aliases file to
+    support kernels >= 2.6.7. (Closes: #291523)
+  * Added updated French man pages from Pierre Machard. (Closes: #283412)
+  * Removed aliases which now are provided by the kernel: loop, rd, xd,
+    floppy, swim3, rtc, nvram, ppdev, agpgart, obsolete CD drivers, wdt,
+    softdog, ide-tape, sg, tun, 8250, snd, soundcore, lp, isofs, ppp_generic.
+    This allowed removing arch/m68k.mac.
+    It would be nice if the maintainers for the doorstop kernel trees added
+    proper MODULE_ALIAS_* macros to their drivers.
+
+ -- Marco d'Itri <md@linux.it>  Mon, 24 Jan 2005 13:48:20 +0100
+
+module-init-tools (3.1-rel-2) unstable; urgency=medium
+
+  * Added patch no_man_rebuild: prevents rebuilding the man pages.
+
+ -- Marco d'Itri <md@linux.it>  Sun, 21 Nov 2004 02:19:36 +0100
+
+module-init-tools (3.1-rel-1) unstable; urgency=medium
+
+  * New upstream release.
+    + Fixes -t documentation. (Closes: #276660)
+  * Stop installing French man pages, because they are out of date.
+  * Removed patch manpage_warnings which has been merged upstream.
+
+ -- Marco d'Itri <md@linux.it>  Sat, 20 Nov 2004 18:05:26 +0100
+
+module-init-tools (3.1-pre6-1) unstable; urgency=medium
+
+  * New upstream release.
+    + Patches merged upstream and removed from the package:
+      modinfo.8_missing_word, modprobe.devfs_apm, robust_modprobe.d.
+    + Do not follow symlinks. (Closes: #270106)
+    + Fixes --show-depends documentation. (Closes: #274758)
+  * Removed patch disable_modprobe_locking because it only hides a kernel
+    bug which has been fixed since (see #259056).
+  * New aliases: xfrm-type-2-4, xfrm-type-10-41.
+
+ -- Marco d'Itri <md@linux.it>  Sat,  9 Oct 2004 01:59:42 +0200
+
+module-init-tools (3.1-pre5-7) unstable; urgency=medium
+
+  * Fixed a very obscure postinst failure. (Closes: #269481)
+  * Fixed a very obscure preinst failure.
+  * Silence md5sum in preinst.
+  * New patch manpage_warnings: adds warnings about modprobe.conf vs.
+    modprobe.d usage in the init script and the update-modprobe, modprobe
+    and modprobe.conf man pages, by Eduard Bloch. (Closes: Bug#269305)
+
+ -- Marco d'Itri <md@linux.it>  Sun, 12 Sep 2004 19:12:45 +0200
+
+module-init-tools (3.1-pre5-6) unstable; urgency=high
+
+  * Removed the autofs4 alias. (Closes: #267065, #261026)
+
+ -- Marco d'Itri <md@linux.it>  Fri, 20 Aug 2004 16:39:33 +0200
+
+module-init-tools (3.1-pre5-5) unstable; urgency=high
+
+  * Divert French man pages too. (Closes: #263735)
+
+ -- Marco d'Itri <md@linux.it>  Thu, 19 Aug 2004 13:58:26 +0200
+
+module-init-tools (3.1-pre5-4) unstable; urgency=high
+
+  * Added french man pages translated by Pierre Machard. (Closes: #263735)
+  * Fix "update-modules force". (Closes: #266127)
+  * Removed aliases tty-ldisc-*, md-personality-* and ppp-compress-*
+    because they are supplied by modern kernels. (Closes: #262481)
+  * New alias: autofs4. (Closes: #261026)
+  * Ignore *,v files in /etc/modprobe.d/. (Closes: #265805)
+  * Create /etc/modprobe.d/ before using it in preinst. (Closes: #261045)
+  * New patch: modinfo.8_missing_word. (Closes: #265965)
+  * New patch: robust_modprobe.d transforms some fatal errors in warnings.
+    (Closes: #261961)
+  * New patch: disable_modprobe_locking (see #259056).
+
+ -- Marco d'Itri <md@linux.it>  Wed, 18 Aug 2004 17:04:39 +0200
+
+module-init-tools (3.1-pre5-3) unstable; urgency=medium
+
+  * Updated patch runparts_like_names to accept anything but dot files,
+    dpkg files and backup~ files. (Closes: #260169)
+  * Run depmod -a when upgrading from 3.1-pre4-1. (Closes: #260180)
+  * New aliases: bt-proto-6, bt-proto-7, char-major-10-183.
+
+ -- Marco d'Itri <md@linux.it>  Wed, 21 Jul 2004 01:24:41 +0200
+
+module-init-tools (3.1-pre5-2) unstable; urgency=medium
+
+  * Fixed the installation of the arch file on sparc64 systems.
+    (Closes: #257833)
+  * Added patch runparts_like_names to make modprobe use only files
+    matching /^[a-zA-Z0-9_-]+$/ (by Joey Hess, code extracted from
+    the run-parts tool). (Closes: #259486)
+
+ -- Marco d'Itri <md@linux.it>  Fri, 16 Jul 2004 19:46:58 +0200
+
+module-init-tools (3.1-pre5-1) unstable; urgency=high
+
+  * New upstream release.
+    depmod does not follow the "build" symlink anymore.
+    (Closes: #257469, #257481, #257392, #257484, #257510)
+  * Removed /etc/modprobe.d/crypto because it's useless.
+
+ -- Marco d'Itri <md@linux.it>  Tue,  6 Jul 2004 01:16:00 +0200
+
+module-init-tools (3.1-pre4-1) unstable; urgency=high
+
+  * New upstream release.
+
+ -- Marco d'Itri <md@linux.it>  Wed, 23 Jun 2004 12:20:58 +0200
+
+module-init-tools (3.1-pre2-2) unstable; urgency=high
+
+  * New patch: open_ro which opens the files RO and probably breaks locking.
+    (Closes: #255180)
+  * New patch: ignore_arch_directory to ignore everything in
+    /etc/modprobe.d/arch/.
+
+ -- Marco d'Itri <md@linux.it>  Sat, 19 Jun 2004 17:26:37 +0200
+
+module-init-tools (3.1-pre2-1) unstable; urgency=medium
+
+  * New upstream release. (Closes: #254204)
+  * Now /etc/modprobe.d/ is processed by modprobe. This means that
+    /etc/modprobe.conf and /lib/modules/modprobe.conf are not needed
+    anymore and update-modules is now a no-op. Executable scripts in
+    /etc/modprobe.d/ are not supported anymore.
+    /etc/modprobe.conf will be removed or moved to /etc/modprobe.d/.
+  * /etc/modprobe.devfs is now installed as an example file: I don't think
+    it works as is on debian, I do not know how it's supposed to work
+    now that /etc/modprobe.conf does not exist anymore and I could not
+    find anybody using it.
+  * Updated char-major-4 in arch/powerpc.pmac. (Closes: #252602)
+
+ -- Marco d'Itri <md@linux.it>  Thu, 17 Jun 2004 17:14:17 +0200
+
+module-init-tools (3.0-pre10-4) unstable; urgency=high
+
+  * Added again module-init-tools.udeb. (Closes: #250048)
+
+ -- Marco d'Itri <md@linux.it>  Fri, 21 May 2004 18:32:31 +0200
+
+module-init-tools (3.0-pre10-3) unstable; urgency=high
+
+  * Removed module-init-tools.udeb. (Closes: #242337, #242826)
+  * Removed the irda-dongle-* aliases because the kernel provides his own.
+    (Closes: #243207)
+  * Added an alias for gre0.
+  * Fixed support for /lib/modules/*/boot/. (Closes: #243061, #242544)
+
+ -- Marco d'Itri <md@linux.it>  Sun, 16 May 2004 18:12:23 +0200
+
+module-init-tools (3.0-pre10-2) unstable; urgency=high
+
+  * Created module-init-tools.udeb. (Closes: #239301)
+
+ -- Marco d'Itri <md@linux.it>  Tue, 23 Mar 2004 00:58:12 +0100
+
+module-init-tools (3.0-pre10-1) unstable; urgency=medium
+
+  * New upstream release.
+    Reverted the change of semantics of -q. (Closes: #232222)
+  * Do not add /usr to the init script $PATH. (Closes: #230764)
+
+ -- Marco d'Itri <md@linux.it>  Sat, 21 Feb 2004 22:26:55 +0100
+
+module-init-tools (3.0-pre9-1) unstable; urgency=medium
+
+  * New upstream release.
+  * Fix psaux and cdc_acm aliases. (Closes: #227428)
+
+ -- Marco d'Itri <md@linux.it>  Fri, 30 Jan 2004 23:08:05 +0100
+
+module-init-tools (3.0-pre5-1) unstable; urgency=medium
+
+  * New upstream release. (Closes: #226199)
+  * Make Eduard Bloch happier. (Closes: #225236)
+
+ -- Marco d'Itri <md@linux.it>  Tue,  6 Jan 2004 17:02:37 +0100
+
+module-init-tools (3.0-pre4-1) unstable; urgency=medium
+
+  * New upstream release.
+  * Create /lib/modules/. (Closes: #225372)
+
+ -- Marco d'Itri <md@linux.it>  Fri,  2 Jan 2004 23:03:21 +0100
+
+module-init-tools (3.0-pre2-1) unstable; urgency=medium
+
+  * New upstream release.
+  * Optionally use /etc/modules-2.6 instead of /etc/modules. (Closes: #225005)
+
+ -- Marco d'Itri <md@linux.it>  Thu, 25 Dec 2003 02:24:30 +0100
+
+module-init-tools (0.9.15-pre4-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- Marco d'Itri <md@linux.it>  Tue, 25 Nov 2003 01:56:44 +0100
+
+module-init-tools (0.9.15-pre3-2) unstable; urgency=high
+
+  * Remove debugging code from update-modules. (Closes: #218544)
+
+ -- Marco d'Itri <md@linux.it>  Sat,  1 Nov 2003 02:20:37 +0100
+
+module-init-tools (0.9.15-pre3-1) unstable; urgency=high
+
+  * New upstream release. (Closes: #215202, #215614, #217647)
+  * Added support for hppa64 and s390x. (Closes: #211088, #216569)
+    Removed /etc/modprobe.d/arch/sparc64, the sparc configuration fragment
+    will be used instead.
+  * Fix bogus message when /etc/modules contains lines with only blanks.
+    (Closes: #216295)
+  * Install config files for the right architecture only. (Closes: #215548)
+
+ -- Marco d'Itri <md@linux.it>  Fri, 31 Oct 2003 17:25:22 +0100
+
+module-init-tools (0.9.15-pre2-2) unstable; urgency=medium
+
+  * Added support for sparc64 and a generic file. (Closes: #214128)
+  * Fixed a postrm bug triggered by upgrading without modutils being
+    installed. (Closes: #214126)
+  * New aliases: pg, acm, msr, cpuid, tub3270, usbcore, scanner, toshiba,
+    evdev, coda, specialix, videodev, vtx.
+
+ -- Marco d'Itri <md@linux.it>  Sun,  5 Oct 2003 14:33:13 +0200
+
+module-init-tools (0.9.15-pre2-1) unstable; urgency=medium
+
+  * New upstream release. (Closes: #213128)
+  * Fix preinst bug triggered by upgrade without modutils being installed.
+    (Closes: #213073)
+
+ -- Marco d'Itri <md@linux.it>  Tue, 30 Sep 2003 21:52:07 +0200
+
+module-init-tools (0.9.15-pre1-1) unstable; urgency=medium
+
+  * New upstream release.
+  * Added support for hppa, ia64, mips and sparc. (Closes: #212700, #211088)
+  * Added support for IrDA modules.
+  * Removed obsolete aliases busmouse, msbusmouse and atixlmouse.
+
+ -- Marco d'Itri <md@linux.it>  Thu, 25 Sep 2003 15:42:07 +0200
+
+module-init-tools (0.9.14-1) unstable; urgency=medium
+
+  * New upstream release.
+    Support multiple arguments to modprobe -r. (Closes: #207808)
+  * Fix small bugs in the init script. (Closes: #206413)
+  * Follow symlinks in /etc/modprobe.d/.
+
+ -- Marco d'Itri <md@linux.it>  Fri, 12 Sep 2003 22:06:24 +0200
+
+module-init-tools (0.9.13-rel-1) unstable; urgency=medium
+
+  * New upstream release.
+    Adds -V/--version arguments to insmod. (Closes: #201652)
+  * Fix /lib/modules/$KVER/boot the init script. (Closes: #205052)
+  * Fix the i386 serial module alias. (Closes: #200816)
+  * Add IPSEC-related aliases. (Closes: #203654)
+  * Add all known net-pf-* aliases.
+
+ -- Marco d'Itri <md@linux.it>  Mon, 18 Aug 2003 05:47:26 +0200
+
+module-init-tools (0.9.13-pre-1) unstable; urgency=high
+
+  * Add symlinks for kallsyms and ksyms. (Closes: #195013)
+  * Always use syscall(2) instead of the _syscall2() kernel macro.
+
+ -- Marco d'Itri <md@linux.it>  Sat, 14 Jun 2003 17:04:25 +0200
+
+module-init-tools (0.9.12-1) unstable; urgency=medium
+
+  * New upstream release. (Closes: #194316, #181996, #191493, #187123)
+  * s/ipsec/af_key/ in the aliases file. (Closes: #188804)
+  * s/.old/.modutils/ in the manpage. (Closes: #193832)
+
+ -- Marco d'Itri <md@linux.it>  Mon, 26 May 2003 18:17:07 +0200
+
+module-init-tools (0.9.11-1) unstable; urgency=medium
+
+  * New upstream release. (Closes: #181996, #184567)
+
+ -- Marco d'Itri <md@linux.it>  Sun, 30 Mar 2003 01:37:03 +0100
+
+module-init-tools (0.9.10-2) unstable; urgency=medium
+
+  * Install a init script and conflict with old modutils (see #173381).
+
+ -- Marco d'Itri <md@linux.it>  Sun,  9 Mar 2003 22:05:49 +0100
+
+module-init-tools (0.9.10-1) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Marco d'Itri <md@linux.it>  Tue, 25 Feb 2003 12:57:36 +0100
+
+module-init-tools (0.9.9-1) unstable; urgency=low
+
+  * New upstream release. (Closes: #177842)
+  * Make generate-modprobe.conf with debian paths. (Closes: #177409)
+
+ -- Marco d'Itri <md@linux.it>  Sat,  1 Feb 2003 18:19:19 +0100
+
+module-init-tools (0.9.8-1) unstable; urgency=low
+
+  * New upstream release. (Closes: #176935)
+  * Improve description. (Closes: #176909)
+
+ -- Marco d'Itri <md@linux.it>  Thu, 16 Jan 2003 02:53:18 +0100
+
+module-init-tools (0.9.7-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- Marco d'Itri <md@linux.it>  Sat, 28 Dec 2002 12:09:07 +0100
+
+module-init-tools (0.9.6-1) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Marco d'Itri <md@linux.it>  Thu, 26 Dec 2002 12:35:41 +0100
+
+module-init-tools (0.9.5-6) unstable; urgency=low
+
+  * I surrender to dpkg-divert. Users will be forced to purge old versions
+    of this packages before installing this one (Closes: #173942).
+  * Remove useless "you have to be root" check from update-modules
+    (Closes: #174188, #174179).
+
+ -- Marco d'Itri <md@linux.it>  Tue, 24 Dec 2002 20:22:15 +0100
+
+module-init-tools (0.9.5-5) unstable; urgency=low
+
+  * *Really* fix depmod.
+  * Fix upgrade from old packages (Closes:# 173942).
+
+ -- Marco d'Itri <md@linux.it>  Mon, 23 Dec 2002 02:56:00 +0100
+
+module-init-tools (0.9.5-3) unstable; urgency=low
+
+  * Fixed modutils-compatibility code in depmod.
+
+ -- Marco d'Itri <md@linux.it>  Sun, 22 Dec 2002 18:59:44 +0100
+
+module-init-tools (0.9.5-2) unstable; urgency=low
+
+  * Undivert diversions from < 0.9.5 packages.
+  * Update the default /etc/modprobe.d/ files with all known default aliases.
+
+ -- Marco d'Itri <md@linux.it>  Sat, 21 Dec 2002 20:22:04 +0100
+
+module-init-tools (0.9.5-1) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Marco d'Itri <md@linux.it>  Thu, 19 Dec 2002 21:15:05 +0100
+
+module-init-tools (0.9.4-1) unstable; urgency=low
+
+  * New Upstream.
+  * Updated description. (Closes: #171944)
+
+ -- Christopher L Cheney <ccheney@debian.org>  Mon, 16 Dec 2002 20:00:00 -0600
+
+module-init-tools (0.9.1-1) unstable; urgency=low
+
+  * New Upstream.
+       Fixed undefined reference to `__ia64_syscall'. (Closes: #171380)
+
+ -- Christopher L Cheney <ccheney@debian.org>  Thu,  5 Dec 2002 19:00:00 -0600
+
+module-init-tools (0.8+0.9-beta-1) unstable; urgency=low
+
+  * New Upstream.
+       Corrected system type matching. (Closes: #171118)
+
+ -- Christopher L Cheney <ccheney@debian.org>  Mon,  2 Dec 2002 14:00:00 -0600
+
+module-init-tools (0.8-1) unstable; urgency=low
+
+  * New Upstream.
+
+ -- Christopher L Cheney <ccheney@debian.org>  Wed, 27 Nov 2002 21:00:00 -0600
+
+module-init-tools (0.7-1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- Christopher L Cheney <ccheney@debian.org>  Thu, 21 Nov 2002 20:00:00 -0600
+
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..ebb4df1
--- /dev/null
@@ -0,0 +1,24 @@
+Source: module-init-tools
+Section: admin
+Priority: important
+Maintainer: Marco d'Itri <md@linux.it>
+Build-Depends: debhelper (>> 5), quilt (>= 0.40)
+Standards-Version: 3.8.4
+
+Package: module-init-tools
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, lsb-base (>= 3.0-6)
+Conflicts: modutils
+Description: tools for managing Linux kernel modules
+ This package contains a set of programs for loading, inserting, and 
+ removing kernel modules for Linux.
+Homepage: http://www.kerneltools.org/
+
+Package: module-init-tools-udeb
+Section: debian-installer
+Priority: extra
+Architecture: any
+XC-Package-Type: udeb
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: tools for managing Linux kernel modules
+ This is the debian-installer version of module-init-tools.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..6f7706a
--- /dev/null
@@ -0,0 +1,13 @@
+This package was debianized by Christopher L Cheney <ccheney@debian.org>
+and Marco d'Itri <md@linux.it> on Thu, 19 Dec 2002 21:15:05 +0100.
+
+It was downloaded from http://www.kerneltools.org/ .
+
+Upstream Authors:      Jon Masters <jonathan@jonmasters.org>
+                       Rusty Russell <rusty@rustcorp.com.au>
+                       Adam J. Richter <adam@yggdrasil.com>
+
+Copyright (C) 2001  Rusty Russell.
+Copyright (C) 2002, 2003  Rusty Russell, IBM Corporation.
+
+License: GPL (please see /usr/share/common-licenses/GPL-2).
diff --git a/debian/module-init-tools-udeb.install b/debian/module-init-tools-udeb.install
new file mode 100644 (file)
index 0000000..597c23f
--- /dev/null
@@ -0,0 +1,2 @@
+lsmod /bin/
+insmod depmod modprobe /sbin/
diff --git a/debian/module-init-tools.init b/debian/module-init-tools.init
new file mode 100644 (file)
index 0000000..d7c301a
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/sh -e
+### BEGIN INIT INFO
+# Provides:          module-init-tools
+# Required-Start:    
+# Required-Stop:     
+# Should-Start:      checkroot
+# Should-Stop:
+# Default-Start:     S
+# Default-Stop:
+# Short-Description: Process /etc/modules.
+# Description:       Load the modules listed in /etc/modules.
+### END INIT INFO
+
+# Silently exit if the kernel does not support modules.
+[ -f /proc/modules ] || exit 0
+[ -x /sbin/modprobe  ] || exit 0
+
+[ -f /etc/default/rcS ] && . /etc/default/rcS
+. /lib/lsb/init-functions
+
+PATH="/sbin:/bin"
+
+KVER=$(uname -r)
+KMAJ=${KVER%${KVER#*.*[!.]}}
+KMAJ=${KMAJ%.}
+
+if [ -e /etc/modules-$KVER ]; then
+  MODULES_FILE=/etc/modules-$KVER
+elif [ -e /etc/modules-$KMAJ ]; then
+  MODULES_FILE=/etc/modules-$KMAJ
+else
+  MODULES_FILE=/etc/modules
+fi
+
+load_module() {
+  local module args
+  module="$1"
+  args="$2"
+
+  if [ "$VERBOSE" != no ]; then
+    log_action_msg "Loading kernel module $module"
+    modprobe $module $args || true
+  else
+    modprobe $module $args > /dev/null 2>&1 || true
+  fi
+}
+
+if [ "$VERBOSE" = no ]; then
+  log_action_begin_msg 'Loading kernel modules'
+fi
+
+# Loop over every line in /etc/modules.
+grep '^[^#]' $MODULES_FILE | \
+while read module args; do
+  [ "$module" ] || continue
+  load_module "$module" "$args"
+done
+
+if [ "$VERBOSE" = no ]; then
+  log_action_end_msg 0
+fi
+
+exit 0
+
diff --git a/debian/module-init-tools.install b/debian/module-init-tools.install
new file mode 100644 (file)
index 0000000..ff0c5a1
--- /dev/null
@@ -0,0 +1,2 @@
+lsmod /bin/
+insmod modprobe rmmod depmod modinfo /sbin/
diff --git a/debian/module-init-tools.postinst b/debian/module-init-tools.postinst
new file mode 100644 (file)
index 0000000..2bed980
--- /dev/null
@@ -0,0 +1,86 @@
+#!/bin/sh -e
+
+create_etc_modules() {
+    if [ ! -e /etc/modules ]; then
+       cat <<EOT > /etc/modules
+# /etc/modules: kernel modules to load at boot time.
+#
+# This file contains the names of kernel modules that should be loaded
+# at boot time, one per line. Lines beginning with "#" are ignored.
+# Parameters can be specified after the module name.
+
+EOT
+       chmod 644 /etc/modules
+    fi
+}
+
+undivert_gen() {
+  DEXT=${3:-modutils}
+  dpkg-divert --remove --rename --package module-init-tools \
+    --divert $2/$1.$DEXT $2/$1 > /dev/null
+}
+
+undivert_man() {
+  DSECTION=${2:-8}
+  for locale in '' fr/; do
+    # When a diverted file is removed from a package, old version of dpkg
+    # forget to delete it. See #428650 for the gory details.
+    rm -f /usr/share/man/${locale}man$DSECTION/$1.modutils.$DSECTION.gz
+    dpkg-divert --remove --rename --package module-init-tools --divert \
+      /usr/share/man/${locale}man$DSECTION/$1.modutils.$DSECTION.gz \
+      /usr/share/man/${locale}man$DSECTION/$1.$DSECTION.gz > /dev/null
+  done
+}
+
+big_modutils_cleanup() {
+  undivert_man modules 5
+
+  # try hard to remove any old file left around (see #509575 for details)
+  for cmd in depmod insmod update-modules modinfo; do
+    rm -f /sbin/$cmd.modutils
+    undivert_gen $cmd /sbin
+    undivert_man $cmd
+  done
+  for cmd in kallsyms ksyms; do
+    rm -f /sbin/$cmd.modutils
+    undivert_gen $cmd /sbin
+  done
+  for cmd in lsmod modprobe rmmod; do
+    rm -f /sbin/$cmd.modutils /sbin/$cmd.Lmodutils
+    undivert_gen $cmd /sbin Lmodutils
+    undivert_man $cmd
+  done
+
+  # modutils forgets to delete this file on purge
+  rm -f /etc/rcS.d/S20modutils
+}
+
+upgrade_quirks() {
+  [ "$2" ] || return 0
+
+  dpkg --compare-versions $2 lt 3.3-pre11-4 || return 0
+  # finally remove the diversions of modutils
+  big_modutils_cleanup
+
+  return 0
+}
+
+case "$1" in
+    configure)
+    create_etc_modules
+
+    upgrade_quirks "$@"
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+    echo "$0 called with unknown argument '$1'" >&2
+    exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/module-init-tools.postrm b/debian/module-init-tools.postrm
new file mode 100644 (file)
index 0000000..03849e2
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh -e
+
+remove_etc_files() {
+  rm -f /etc/modules
+}
+
+case "$1" in
+    purge)
+    remove_etc_files
+    ;;
+
+    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+    ;;
+
+    *)
+    echo "$0 called with unknown argument '$1'" >&2
+    exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/module-init-tools.preinst b/debian/module-init-tools.preinst
new file mode 100644 (file)
index 0000000..52fa7ba
--- /dev/null
@@ -0,0 +1,103 @@
+#!/bin/sh -e
+
+undivert_man() {
+  DSECTION=${2:-8}
+  for locale in '' fr/; do
+    dpkg-divert --remove --rename --package module-init-tools --divert \
+      /usr/share/man/${locale}man$DSECTION/$1.modutils.$DSECTION.gz \
+      /usr/share/man/${locale}man$DSECTION/$1.$DSECTION.gz > /dev/null
+  done
+}
+
+rm_conffile_md5() {
+  local file=$1
+  local md5=$2
+  if [ -f $file ] && echo "$md5  $file" | md5sum -c 2> /dev/null; then
+    rm $file
+  fi
+}
+
+rm_conffile() {
+  mv_conffile "$1" "$1.dpkg-bak"
+}
+
+mv_conffile() {
+  local package='module-init-tools'
+  local name="$1"
+  local newname="$2"
+
+  [ -e "$name" ] || return 0
+
+  local md5="$(md5sum $name | sed -e 's/ .*//')"
+  oldmd5="$(dpkg-query -W -f='${Conffiles}' $package | \
+    sed -n -e "\' $name ' { s/ obsolete$//; s/.* //; p }")"
+
+  if [ "$md5" = "$oldmd5" ]; then
+    rm -f "$name"
+  else
+    mv "$name" "$newname"
+  fi
+}
+
+upgrade_quirks() {
+  # $2 is non-empty when installing from the "config-files" state
+  [ "$2" ] || return 0
+
+  if dpkg --compare-versions $2 lt 3.10-3; then
+  if dpkg --compare-versions $2 lt 3.1-pre11-1; then
+  if dpkg --compare-versions $2 lt 3.2-pre9-4; then
+  if dpkg --compare-versions $2 lt 3.1-pre2-1; then
+
+  echo 'Upgrading from packages older than 3.1-pre2-1 is not supported.'
+  echo 'Please purge module-init-tools before installing this package.'
+  exit 1
+
+  fi # lt 3.1-pre2-1
+
+  rm -f /usr/share/man/man8/kallsyms.8.gz /usr/share/man/man8/ksyms.8.gz
+  for cmd in kallsyms ksyms; do
+    undivert_man $cmd
+  done
+
+  fi # lt 3.2-pre9-4
+
+  # remove an obsolete conffile, which was replaced by .../x86_64
+  if [ "$(dpkg --print-architecture)" = amd64 ]; then
+    rm_conffile_md5 /etc/modprobe.d/arch/i386 688ef8c36b20113c46ec631e6c9effd4
+  fi
+
+  fi # lt 3.1-pre11-1
+
+  for file in i386 x86_64 mips s390 parisc sparc powerpc.apus \
+       powerpc.generic powerpc.pmac m68k.amiga m68k.atari m68k.generic; do
+    rm_conffile /etc/modprobe.d/arch/$file
+  done
+  rmdir /etc/modprobe.d/arch/ 2> /dev/null || true
+  if [ -L /etc/modprobe.d/arch-aliases \
+      -a ! -e /etc/modprobe.d/arch-aliases ]; then
+    rm /etc/modprobe.d/arch-aliases
+  fi
+
+  mv_conffile /etc/modprobe.d/aliases /etc/modprobe.d/aliases.conf
+
+  fi # lt 3.10-3
+}
+
+case "$1" in
+    install|upgrade)
+
+    upgrade_quirks "$@"
+    ;;
+
+    abort-upgrade)
+    ;;
+
+    *)
+    echo "$0 called with unknown argument '$1'" >&2
+    exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/patches/blacklist-warn.diff b/debian/patches/blacklist-warn.diff
new file mode 100644 (file)
index 0000000..08222fd
--- /dev/null
@@ -0,0 +1,14 @@
+--- a/modprobe.c
++++ b/modprobe.c
+@@ -558,8 +558,10 @@ static  int
+ find_blacklist(const char *modname, const struct module_blacklist *blacklist)
+ {
+       while (blacklist) {
+-              if (streq(blacklist->modulename, modname))
++              if (streq(blacklist->modulename, modname)) {
++                      warn("Not loading blacklisted module %s\n", modname);
+                       return 1;
++              }
+               blacklist = blacklist->next;
+       }
+       return 0;
diff --git a/debian/patches/document_depmod_m b/debian/patches/document_depmod_m
new file mode 100644 (file)
index 0000000..75d7ee9
--- /dev/null
@@ -0,0 +1,26 @@
+--- a/doc/depmod.sgml
++++ b/doc/depmod.sgml
+@@ -33,6 +33,7 @@
+       <arg><option>-b <replaceable>basedir</replaceable></option></arg>
+       <arg><option>-e</option></arg>
+       <arg><option>-F <replaceable>System.map</replaceable></option></arg>
++      <arg><option>-m</option></arg>
+       <arg><option>-n</option></arg>
+       <arg><option>-v</option></arg>
+       <arg><option><replaceable>version</replaceable></option></arg>
+@@ -165,6 +166,15 @@
+         </listitem>
+       </varlistentry>
+       <varlistentry>
++        <term><option>-m</option> <option>--map</option>
++        </term>
++        <listitem>
++          <para>
++          Enables generation of the obsolete map files.
++        </para>
++        </listitem>
++      </varlistentry>
++      <varlistentry>
+         <term><option>-n</option> <option>--dry-run</option>
+         </term>
+         <listitem>
diff --git a/debian/patches/modprobe_bad_output b/debian/patches/modprobe_bad_output
new file mode 100644 (file)
index 0000000..ea736ec
--- /dev/null
@@ -0,0 +1,21 @@
+--- a/modprobe.c
++++ b/modprobe.c
+@@ -1896,7 +1896,7 @@ int main(int argc, char *argv[])
+       parse_toplevel_config(configname, &conf, dump_config, flags & mit_remove);
+       /* Read module options from kernel command line */
+-      parse_kcmdline(1, &conf.options);
++      parse_kcmdline(dump_config, &conf.options);
+       
+       if (dump_config) {
+               char *aliasfilename, *symfilename;
+@@ -1905,9 +1905,6 @@ int main(int argc, char *argv[])
+               nofail_asprintf(&aliasfilename, "%s/modules.alias", dirname);
+               nofail_asprintf(&symfilename, "%s/modules.symbols", dirname);
+-              parse_toplevel_config(configname, &conf, 1, 0);
+-              /* Read module options from kernel command line */
+-              parse_kcmdline(1, &conf.options);
+               read_aliases(aliasfilename, "", 1, &conf.aliases);
+               read_aliases(symfilename, "", 1, &conf.aliases);
diff --git a/debian/patches/no_maps_by_default b/debian/patches/no_maps_by_default
new file mode 100644 (file)
index 0000000..0d7f8af
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/depmod.c
++++ b/depmod.c
+@@ -60,7 +60,7 @@ struct module_search
+ };
+ static unsigned int skipchars;
+-static unsigned int make_map_files = 1; /* default to on */
++static unsigned int make_map_files = 0; /* default to off */
+ static unsigned int force_map_files = 0; /* default to on */
+ #define SYMBOL_HASH_SIZE 1024
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644 (file)
index 0000000..907367d
--- /dev/null
@@ -0,0 +1,11 @@
+# fixes to be pushed upstream
+document_depmod_m
+
+# features to be pushed upstream
+blacklist-warn.diff
+
+# Debian integration
+
+# modified defaults
+no_maps_by_default
+modprobe_bad_output
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..166c405
--- /dev/null
@@ -0,0 +1,107 @@
+#!/usr/bin/make -f
+SHELL+= -e
+
+distribution = SLP
+
+ifneq ($(distribution),SLP)
+BUILD_UDEB := 1
+endif
+DISABLE_ZLIB := --disable-zlib
+CONFFLAGS := --disable-static-utils --prefix=/
+
+
+QUILT_STAMPFN=.stamp-patched
+include /usr/share/quilt/quilt.make
+
+D := $(CURDIR)/debian/module-init-tools
+
+##############################################################################
+DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+  CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
+else
+  CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
+endif
+
+ifdef BUILD_UDEB
+  BUILD_UDEB_TARGET := .stamp-build-udeb
+else
+  NO_PACKAGE := --no-package=module-init-tools-udeb
+endif
+
+##############################################################################
+all: build
+
+clean: unpatch
+       rm -rf .stamp-* build-*
+       dh_clean
+
+build-deb/config.status: $(QUILT_STAMPFN)
+       rm -f *.[0-9] # XXX workaround for out of tree builds
+       [ -d build-deb ] || mkdir build-deb
+       cd build-deb/ && \
+       ../configure CFLAGS='$(CFLAGS)' \
+               $(DISABLE_ZLIB) $(CONFFLAGS)
+
+build-udeb/config.status: $(QUILT_STAMPFN)
+       [ -d build-udeb ] || mkdir build-udeb
+       cd build-udeb/ && \
+       ../configure CFLAGS='$(CFLAGS) -Os -fomit-frame-pointer' \
+               --disable-zlib $(CONFFLAGS)
+
+build: .stamp-build
+.stamp-build: build-deb/config.status
+       dh_testdir
+       cd build-deb && $(MAKE)
+       touch $@
+
+build: .stamp-build-udeb
+.stamp-build-udeb: build-udeb/config.status
+       dh_testdir
+       cd build-udeb && $(MAKE) lsmod insmod depmod modprobe
+       touch $@
+
+install: .stamp-build $(BUILD_UDEB_TARGET) checkroot
+       dh_testdir
+       dh_clean -k
+
+       dh_installdirs bin/ sbin/ etc/modprobe.d/ lib/modules/
+       dh_install --sourcedir=build-deb/ -p module-init-tools
+       cp extra/modprobe.d/aliases.conf $D/etc/modprobe.d/
+
+ifdef BUILD_UDEB
+       dh_installdirs bin/ sbin/ etc/modprobe.d/ -p module-init-tools-udeb
+       dh_install --sourcedir=build-udeb/ -p module-init-tools-udeb
+       cp extra/modprobe.d/aliases.conf $D-udeb/etc/modprobe.d/
+endif
+
+binary-arch: install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs ChangeLog
+       dh_installdocs NEWS
+ifneq ($(distribution),SLP)
+       dh_installman extra/*.5 build-deb/*.5 build-deb/*.8
+endif
+       dh_installinit --no-start --update-rcd-params="start 20 S ."
+       dh_link bin/lsmod sbin/lsmod
+       dh_strip
+       dh_compress
+       dh_fixperms
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol $(NO_PACKAGE)
+       dh_md5sums
+       dh_builddeb $(NO_PACKAGE)
+
+binary:        binary-arch
+
+get-orig-source:
+       cd $(dir $(firstword $(MAKEFILE_LIST)))../ && \
+       uscan --rename --force-download --destdir $(CURDIR)
+
+checkroot:
+       test root = "`whoami`"
+
+.PHONY: binary binary-arch binary-indep unpack build clean checkroot get-orig-source
diff --git a/debian/watch b/debian/watch
new file mode 100644 (file)
index 0000000..788cad1
--- /dev/null
@@ -0,0 +1,2 @@
+version=3
+http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/module-init-tools-([0-9\.]+(?:-pre[0-9\.]+)?)\.tar\.gz
diff --git a/depcomp b/depcomp
new file mode 100755 (executable)
index 0000000..df8eea7
--- /dev/null
+++ b/depcomp
@@ -0,0 +1,630 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
+# Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  source      Source file read by `PROGRAMS ARGS'.
+  object      Object file output by `PROGRAMS ARGS'.
+  DEPDIR      directory where to store dependencies.
+  depfile     Dependency file to output.
+  tmpdepfile  Temporary file to use when outputing dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+   # This is just like dashmstdout with a different argument.
+   dashmflag=-xM
+   depmode=dashmstdout
+fi
+
+cygpath_u="cygpath -u -f -"
+if test "$depmode" = msvcmsys; then
+   # This is just like msvisualcpp but w/o cygpath translation.
+   # Just convert the backslash-escaped backslashes to single forward
+   # slashes to satisfy depend.m4
+   cygpath_u="sed s,\\\\\\\\,/,g"
+   depmode=msvisualcpp
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am.  Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+  for arg
+  do
+    case $arg in
+    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+    *)  set fnord "$@" "$arg" ;;
+    esac
+    shift # fnord
+    shift # $arg
+  done
+  "$@"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+  tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'.  On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like `#:fec' to the end of the
+    # dependency line.
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> "$depfile"
+    echo >> "$depfile"
+
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  In older versions, this file always lives in the
+  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # start of each line; $object doesn't have directory information.
+  # Version 6 uses the directory in both cases.
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$base.u
+    tmpdepfile3=$dir.libs/$base.u
+    "$@" -Wc,-M
+  else
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$dir$base.u
+    tmpdepfile3=$dir$base.u
+    "$@" -M
+  fi
+  stat=$?
+
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    # Each line is of the form `foo.o: dependent.h'.
+    # Do two passes, one to just change these to
+    # `$object: dependent.h' and one to simply `dependent.h:'.
+    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+    # That's a tab and a space in the [].
+    sed -e 's,^.*\.[a-z]*:[     ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+icc)
+  # Intel's C compiler understands `-MD -MF file'.  However on
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # ICC 7.0 will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+  # ICC 7.1 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using \ :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+    sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp2)
+  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+  # compilers, which have integrated preprocessors.  The correct option
+  # to use with these is +Maked; it writes dependencies to a file named
+  # 'foo.d', which lands next to the object file, wherever that
+  # happens to be.
+  # Much of this is similar to the tru64 case; see comments there.
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir.libs/$base.d
+    "$@" -Wc,+Maked
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    "$@" +Maked
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+     rm -f "$tmpdepfile1" "$tmpdepfile2"
+     exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+    # Add `dependent.h:' lines.
+    sed -ne '2,${
+              s/^ *//
+              s/ \\*$//
+              s/$/:/
+              p
+            }' "$tmpdepfile" >> "$depfile"
+  else
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile" "$tmpdepfile2"
+  ;;
+
+tru64)
+   # The Tru64 compiler uses -MD to generate dependencies as a side
+   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+   # dependencies in `foo.d' instead, so we check for that too.
+   # Subdirectories are respected.
+   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+   test "x$dir" = "x$object" && dir=
+   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+   if test "$libtool" = yes; then
+      # With Tru64 cc, shared objects can also be used to make a
+      # static library.  This mechanism is used in libtool 1.4 series to
+      # handle both shared and static libraries in a single compilation.
+      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+      #
+      # With libtool 1.5 this exception was removed, and libtool now
+      # generates 2 separate objects for the 2 libraries.  These two
+      # compilations output dependencies in $dir.libs/$base.o.d and
+      # in $dir$base.o.d.  We have to check for both files, because
+      # one of the two compilations can be disabled.  We should prefer
+      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+      # automatically cleaned when .libs/ is deleted, while ignoring
+      # the former would cause a distcleancheck panic.
+      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
+      tmpdepfile2=$dir$base.o.d          # libtool 1.5
+      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
+      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1=$dir$base.o.d
+      tmpdepfile2=$dir$base.d
+      tmpdepfile3=$dir$base.d
+      tmpdepfile4=$dir$base.d
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+      exit $stat
+   fi
+
+   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+   do
+     test -f "$tmpdepfile" && break
+   done
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a tab and a space in the [].
+      sed -e 's,^.*\.[a-z]*:[   ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+   else
+      echo "#dummy" > "$depfile"
+   fi
+   rm -f "$tmpdepfile"
+   ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  # Require at least two characters before searching for `:'
+  # in the target name.  This is to cope with DOS-style filenames:
+  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  "$@" $dashmflag |
+    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+  # X makedepend
+  shift
+  cleared=no eat=no
+  for arg
+  do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    if test $eat = yes; then
+      eat=no
+      continue
+    fi
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -arch)
+      eat=yes ;;
+    -*|$object)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix=`echo "$object" | sed 's/^.*\././'`
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E |
+    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+    sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+       set fnord "$@"
+       shift
+       shift
+       ;;
+    *)
+       set fnord "$@" "$arg"
+       shift
+       shift
+       ;;
+    esac
+  done
+  "$@" -E 2>/dev/null |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::     \1 \\:p' >> "$depfile"
+  echo "       " >> "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvcmsys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/depmod.8 b/depmod.8
new file mode 100644 (file)
index 0000000..3458c9a
--- /dev/null
+++ b/depmod.8
@@ -0,0 +1,107 @@
+.\\" auto-generated by docbook2man-spec $Revision: 1.2 $
+.TH "DEPMOD" "8" "2010-03-01" "" ""
+.SH NAME
+depmod \- program to generate modules.dep and map files.
+.SH SYNOPSIS
+.sp
+\fBdepmod\fR [ \fB-b \fIbasedir\fB\fR ]  [ \fB-e\fR ]  [ \fB-F \fISystem.map\fB\fR ]  [ \fB-n\fR ]  [ \fB-v\fR ]  [ \fB\fIversion\fB\fR ]  [ \fB-A\fR ] 
+.sp
+\fBdepmod\fR [ \fB-e\fR ]  [ \fB-F\fISystem.map\fB\fR ]  [ \fB-n\fR ]  [ \fB-v\fR ]  [ \fB\fIversion\fB\fR ]  [ \fB\fIfilename\fB\fR\fI...\fR ] 
+.SH "DESCRIPTION"
+.PP
+Linux kernel modules can provide services (called "symbols") for
+other modules to use (using one of the EXPORT_SYMBOL variants in the
+code). If a second module uses this symbol, that second module clearly
+depends on the first module. These dependencies can get quite complex.
+.PP
+\fBdepmod\fR creates a list of module dependencies
+by reading each module under
+\fI/lib/modules/\fR\fIversion\fR 
+and determining what symbols it exports and what symbols it
+needs. By default, this list is written to
+\fImodules.dep\fR, and a binary hashed version named
+\fImodules.dep.bin\fR, in the same directory. If
+filenames are given on the command line, only those modules are
+examined (which is rarely useful unless all modules are listed).
+\fBdepmod\fR also creates a list of symbols provided
+by modules in the file named \fImodules.symbols\fR
+and its binary hashed version, \fImodules.symbols.bin\fR\&.
+.PP
+If a \fIversion\fR is provided, then that
+kernel version's module directory is used rather than the
+current kernel version (as returned by \fBuname -r\fR).
+.PP
+.PP
+\fBdepmod\fR will also generate various legacy map
+files in the output directory for use by the older hotplug
+infrastructure. These map files are largely deprecated.
+.SH "OPTIONS"
+.TP
+\fB-a --all\fR
+Probe all modules. This option is enabled by default if no
+file names are given in the command-line.
+.TP
+\fB-A --quick\fR
+This option scans to see if any modules are newer than the
+\fImodules.dep\fR file before any work is done:
+if not, it silently exits rather than regenerating the files.
+.TP
+\fB-b \fIbasedir\fB --basedir \fIbasedir\fB\fR
+If your modules are not currently in the (normal)
+directory
+\fI/lib/modules/\fR\fIversion\fR,
+but in a staging area, you can specify a
+\fIbasedir\fR which is prepended to
+the directory name. This
+\fIbasedir\fR is stripped from the
+resulting \fImodules.dep\fR file, so it
+is ready to be moved into the normal location. Use this option
+if you are a distribution vendor who needs to pre-generate the
+meta-data files rather than running depmod again later.
+.TP
+\fB-C --config \fIfile or directory\fB\fR
+This option overrides the default configuration file at
+\fI/etc/depmod.conf\fR (or the 
+\fI/etc/depmod.d/\fR directory if that is not found).
+.TP
+\fB-e --errsyms\fR
+When combined with the \fB-F\fR option, this
+reports any symbols which a module needs which are not
+supplied by other modules or the kernel. Normally, any
+symbols not provided by modules are assumed to be
+provided by the kernel (which should be true in a
+perfect world), but this assumption can break espencially
+when additionally updated third party drivers are not
+correctly installed or were built incorrectly.
+.TP
+\fB-F --filesyms \fISystem.map\fB\fR
+Supplied with the \fISystem.map\fR produced
+when the kernel was built, this allows the
+\fB-e\fR option to report unresolved symbols.
+.TP
+\fB-h --help\fR
+Print the help message and exit.
+.TP
+\fB-n --dry-run\fR
+This sends the resulting modules.dep and the various
+map files to standard output rather than writing them into
+the module directory.
+.TP
+\fB-v --verbose\fR
+In verbose mode, \fBdepmod\fR will print (to stdout)
+all the symbols each module depends on and the module's file name
+which provides that symbol.
+.TP
+\fB-V --version\fR
+Show version of program and exit. See below for caveats when
+run on older kernels.
+.SH "COPYRIGHT"
+.PP
+This manual page originally Copyright 2002, Rusty Russell,
+IBM Corporation. Maintained by Jon Masters and others.
+.SH "SEE ALSO"
+.PP
+\fBdepmod.conf\fR(5),
+\fBdepmod.d\fR(5),
+\fBmodprobe\fR(8),
+\fBmodules.dep\fR(5)
diff --git a/depmod.c b/depmod.c
new file mode 100644 (file)
index 0000000..697477f
--- /dev/null
+++ b/depmod.c
@@ -0,0 +1,1487 @@
+/* New simplified depmod without backwards compat stuff and not
+   requiring ksyms.
+
+   (C) 2010 Jon Masters <jcm@jonmasters.org>, and others.
+   (C) 2002 Rusty Russell IBM Corporation
+ */
+#define _GNU_SOURCE /* asprintf */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <elf.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/utsname.h>
+#include <sys/mman.h>
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+#include "util.h"
+#include "zlibsupport.h"
+#include "depmod.h"
+#include "logging.h"
+#include "index.h"
+#include "elfops.h"
+#include "tables.h"
+#include "config_filter.h"
+
+#include "testing.h"
+
+#ifndef MODULE_DIR
+#define MODULE_DIR "/lib/modules/"
+#endif
+
+#ifndef MODULE_BUILTIN_KEY
+#define MODULE_BUILTIN_KEY "built-in"
+#endif
+
+struct module_overrides
+{
+       /* Next override */
+       struct module_overrides *next;
+
+       /* overridden module */
+       char *modfile;
+};
+
+struct module_search
+{
+       /* Next search */
+       struct module_search *next;
+
+       /* search path */
+       char *search_path;
+       size_t len;
+};
+
+static unsigned int skipchars;
+static unsigned int make_map_files = 1; /* default to on */
+static unsigned int force_map_files = 0; /* default to on */
+
+#define SYMBOL_HASH_SIZE 1024
+struct symbol
+{
+       struct symbol *next;
+       struct module *owner;
+       uint64_t ver;
+       char name[0];
+};
+
+static struct symbol *symbolhash[SYMBOL_HASH_SIZE];
+
+/* This is based on the hash agorithm from gdbm, via tdb */
+static inline unsigned int tdb_hash(const char *name)
+{
+       unsigned value; /* Used to compute the hash value.  */
+       unsigned   i;   /* Used to cycle through random values. */
+
+       /* Set the initial value from the key size. */
+       for (value = 0x238F13AF * strlen(name), i=0; name[i]; i++)
+               value = (value + (((unsigned char *)name)[i] << (i*5 % 24)));
+
+       return (1103515243 * value + 12345);
+}
+
+void add_symbol(const char *name, uint64_t ver, struct module *owner)
+{
+       unsigned int hash;
+       struct symbol *new = NOFAIL(malloc(sizeof *new + strlen(name) + 1));
+
+       new->owner = owner;
+       new->ver = ver;
+       strcpy(new->name, name);
+
+       hash = tdb_hash(name) % SYMBOL_HASH_SIZE;
+       new->next = symbolhash[hash];
+       symbolhash[hash] = new;
+}
+
+static int print_unknown, check_symvers;
+
+struct module *find_symbol(const char *name, uint64_t ver,
+               const char *modname, int weak)
+{
+       struct symbol *s;
+
+       /* For our purposes, .foo matches foo.  PPC64 needs this. */
+       if (name[0] == '.')
+               name++;
+
+       for (s = symbolhash[tdb_hash(name) % SYMBOL_HASH_SIZE]; s; s=s->next) {
+               if (streq(s->name, name))
+                       break;
+       }
+       if (s) {
+               if (ver && s->ver && s->ver != ver && print_unknown && !weak)
+                       warn("%s disagrees about version of symbol %s\n",
+                                       modname, name);
+               return s->owner;
+       }
+
+       if (print_unknown && !weak)
+               warn("%s needs unknown symbol %s\n", modname, name);
+
+       return NULL;
+}
+
+void add_dep(struct module *mod, struct module *depends_on)
+{
+       unsigned int i;
+
+       for (i = 0; i < mod->num_deps; i++)
+               if (mod->deps[i] == depends_on)
+                       return;
+
+       mod->deps = NOFAIL(realloc(mod->deps, sizeof(mod->deps[0])*(mod->num_deps+1)));
+       mod->deps[mod->num_deps++] = depends_on;
+}
+
+static void add_fake_syms(void)
+{
+       /* __this_module is magic inserted by kernel loader. */
+       add_symbol("__this_module", 0, NULL);
+       /* On S390, this is faked up too */
+       add_symbol("_GLOBAL_OFFSET_TABLE_", 0, NULL);
+}
+
+static void load_system_map(const char *filename)
+{
+       FILE *system_map;
+       char line[10240];
+       const char ksymstr[] = "__ksymtab_";
+       const int ksymstr_len = strlen(ksymstr);
+
+       system_map = fopen(filename, "r");
+       if (!system_map)
+               fatal("Could not open '%s': %s\n", filename, strerror(errno));
+
+       /* eg. c0294200 R __ksymtab_devfs_alloc_devnum */
+       while (fgets(line, sizeof(line)-1, system_map)) {
+               char *ptr;
+
+               /* Snip \n */
+               ptr = strchr(line, '\n');
+               if (ptr)
+                       *ptr = '\0';
+
+               ptr = strchr(line, ' ');
+               if (!ptr || !(ptr = strchr(ptr + 1, ' ')))
+                       continue;
+
+               /* Covers gpl-only and normal symbols. */
+               if (strstarts(ptr+1, ksymstr))
+                       add_symbol(ptr+1+ksymstr_len, 0, NULL);
+       }
+
+       fclose(system_map);
+       add_fake_syms();
+}
+
+static void load_module_symvers(const char *filename)
+{
+       FILE *module_symvers;
+       char line[10240];
+
+       module_symvers = fopen(filename, "r");
+       if (!module_symvers)
+               fatal("Could not open '%s': %s\n", filename, strerror(errno));
+
+       /* eg. "0xb352177e\tfind_first_bit\tvmlinux\tEXPORT_SYMBOL" */
+       while (fgets(line, sizeof(line)-1, module_symvers)) {
+               const char *ver, *sym, *where;
+
+               ver = strtok(line, " \t");
+               sym = strtok(NULL, " \t");
+               where = strtok(NULL, " \t");
+               if (!ver || !sym || !where)
+                       continue;
+
+               if (streq(where, "vmlinux"))
+                       add_symbol(sym, strtoull(ver, NULL, 16), NULL);
+       }
+
+       fclose(module_symvers);
+       add_fake_syms();
+}
+
+static struct option options[] = { { "all", 0, NULL, 'a' },
+                                  { "quick", 0, NULL, 'A' },
+                                  { "basedir", 1, NULL, 'b' },
+                                  { "config", 1, NULL, 'C' },
+                                  { "symvers", 1, NULL, 'E' },
+                                  { "filesyms", 1, NULL, 'F' },
+                                  { "errsyms", 0, NULL, 'e' },
+                                  { "unresolved-error", 0, NULL, 'u' },
+                                  { "quiet", 0, NULL, 'q' },
+                                  { "root", 0, NULL, 'r' },
+                                  { "verbose", 0, NULL, 'v' },
+                                  { "show", 0, NULL, 'n' },
+                                  { "dry-run", 0, NULL, 'n' },
+                                  { "help", 0, NULL, 'h' },
+                                  { "version", 0, NULL, 'V' },
+                                  { "warn", 0, NULL, 'w' },
+                                  { "map", 0, NULL, 'm' },
+                                  { NULL, 0, NULL, 0 } };
+
+/* Version number or module name?  Don't assume extension. */
+static int is_version_number(const char *version)
+{
+       unsigned int dummy;
+
+       return (sscanf(version, "%u.%u.%u", &dummy, &dummy, &dummy) == 3);
+}
+
+static int old_module_version(const char *version)
+{
+       /* Expect three part version. */
+       unsigned int major, sub, minor;
+
+       sscanf(version, "%u.%u.%u", &major, &sub, &minor);
+
+       if (major > 2) return 0;
+       if (major < 2) return 1;
+
+       /* 2.x */
+       if (sub > 5) return 0;
+       if (sub < 5) return 1;
+
+       /* 2.5.x */
+       if (minor >= 48) return 0;
+       return 1;
+}
+
+static void print_usage(const char *name)
+{
+       fprintf(stderr,
+       "%s " VERSION " -- part of " PACKAGE "\n"
+       "%s -[aA] [-n -e -v -q -V -r -u -w -m]\n"
+       "      [-b basedirectory] [forced_version]\n"
+       "depmod [-n -e -v -q -r -u -w] [-F kernelsyms] module1.ko module2.ko ...\n"
+       "If no arguments (except options) are given, \"depmod -a\" is assumed\n"
+       "\n"
+       "depmod will output a dependancy list suitable for the modprobe utility.\n"
+       "\n"
+       "\n"
+       "Options:\n"
+       "\t-a, --all            Probe all modules\n"
+       "\t-A, --quick          Only does the work if there's a new module\n"
+       "\t-e, --errsyms        Report not supplied symbols\n"
+       "\t-m, --map            Create the legacy map files\n"
+       "\t-n, --show           Write the dependency file on stdout only\n"
+       "\t-V, --version        Print the release version\n"
+       "\t-v, --verbose        Enable verbose mode\n"
+       "\t-w, --warn           Warn on duplicates\n"
+       "\t-h, --help           Print this usage message\n"
+       "\n"
+       "The following options are useful for people managing distributions:\n"
+       "\t-b basedirectory\n"
+       "\t    --basedir basedirectory    Use an image of a module tree.\n"
+       "\t-F kernelsyms\n"
+       "\t    --filesyms kernelsyms      Use the file instead of the\n"
+       "\t                               current kernel symbols.\n"
+       "\t-E Module.symvers\n"
+       "\t    --symvers Module.symvers   Use Module.symvers file to check\n"
+       "\t                               symbol versions.\n",
+       "depmod", "depmod");
+}
+
+static int ends_in(const char *name, const char *ext)
+{
+       unsigned int namelen, extlen;
+
+       /* Grab lengths */
+       namelen = strlen(name);
+       extlen = strlen(ext);
+
+       if (namelen < extlen) return 0;
+
+       if (streq(name + namelen - extlen, ext))
+               return 1;
+       return 0;
+}
+
+static struct module *grab_module(const char *dirname, const char *filename)
+{
+       struct module *new;
+
+       new = NOFAIL(malloc(sizeof(*new)
+                           + strlen(dirname?:"") + 1 + strlen(filename) + 1));
+       if (dirname)
+               sprintf(new->pathname, "%s/%s", dirname, filename);
+       else
+               strcpy(new->pathname, filename);
+       new->basename = my_basename(new->pathname);
+
+       INIT_LIST_HEAD(&new->dep_list);
+       new->order = INDEX_PRIORITY_MIN;
+
+       new->file = grab_elf_file(new->pathname);
+       if (!new->file) {
+               warn("Can't read module %s: %s\n",
+                    new->pathname, strerror(errno));
+               free(new);
+               return NULL;
+       }
+       return new;
+}
+
+struct module_traverse
+{
+       struct module_traverse *prev;
+       struct module *mod;
+};
+
+static int in_loop(struct module *mod, const struct module_traverse *traverse)
+{
+       const struct module_traverse *i;
+
+       for (i = traverse; i; i = i->prev) {
+               if (i->mod == mod)
+                       return 1;
+       }
+       return 0;
+}
+
+/* Assume we are doing all the modules, so only report each loop once. */
+static void report_loop(const struct module *mod,
+                       const struct module_traverse *traverse)
+{
+       const struct module_traverse *i;
+
+       /* Check that start is least alphabetically.  eg.  a depends
+          on b depends on a will get reported for a, not b.  */
+       for (i = traverse->prev; i->prev; i = i->prev) {
+               if (strcmp(mod->pathname, i->mod->pathname) > 0)
+                       return;
+       }
+
+       /* Is start in the loop?  If not, don't report now. eg. a
+          depends on b which depends on c which depends on b.  Don't
+          report when generating depends for a. */
+       if (mod != i->mod)
+               return;
+
+       warn("Loop detected: %s ", mod->pathname);
+       for (i = traverse->prev; i->prev; i = i->prev)
+               fprintf(stderr, "needs %s ", i->mod->basename);
+       fprintf(stderr, "which needs %s again!\n", i->mod->basename);
+}
+
+/* This is damn slow, but loops actually happen, and we don't want to
+   just exit() and leave the user without any modules. */
+static int has_dep_loop(struct module *module, struct module_traverse *prev)
+{
+       unsigned int i;
+       struct module_traverse traverse = { .prev = prev, .mod = module };
+
+       if (in_loop(module, prev)) {
+               report_loop(module, &traverse);
+               return 1;
+       }
+
+       for (i = 0; i < module->num_deps; i++)
+               if (has_dep_loop(module->deps[i], &traverse))
+                       return 1;
+       return 0;
+}
+
+/* Uniquifies and orders a dependency list. */
+static void order_dep_list(struct module *start, struct module *mod)
+{
+       unsigned int i;
+
+       for (i = 0; i < mod->num_deps; i++) {
+               /* If it was previously depended on, move it to the
+                  tail.  ie. if a needs b and c, and c needs b, we
+                  must order b after c. */
+               list_del(&mod->deps[i]->dep_list);
+               list_add_tail(&mod->deps[i]->dep_list, &start->dep_list);
+               order_dep_list(start, mod->deps[i]);
+       }
+}
+
+static struct module *deleted = NULL;
+
+static void del_module(struct module **modules, struct module *delme)
+{
+       struct module **i;
+
+       /* Find pointer to it. */ 
+       if (modules) {
+               for (i = modules; *i != delme; i = &(*i)->next);
+               
+               *i = delme->next;
+       }
+       
+       /* Save on a list to quiet valgrind.
+          Can't free - other modules may depend on them */
+       delme->next = deleted;
+       deleted = delme;
+}
+
+/* convert to relative path if possible */
+static const char *compress_path(const char *path, const char *basedir)
+{
+       int len = strlen(basedir);
+
+       if (strncmp(path, basedir, len) == 0)
+               path += len + 1;
+       return path;
+}
+
+static int output_deps(struct module *modules,
+                       FILE *out, char *dirname)
+{
+       struct module *i;
+
+       for (i = modules; i; i = i->next) {
+               struct list_head *j, *tmp;
+               order_dep_list(i, i);
+
+               fprintf(out, "%s:", compress_path(i->pathname, dirname));
+               list_for_each_safe(j, tmp, &i->dep_list) {
+                       struct module *dep
+                               = list_entry(j, struct module, dep_list);
+                       fprintf(out, " %s",
+                               compress_path(dep->pathname, dirname));
+                       list_del_init(j);
+               }
+               fprintf(out, "\n");
+       }
+       return 1;
+}
+
+/* warn whenever duplicate module aliases, deps, or symbols are found. */
+int warn_dups = 0;
+
+static int output_deps_bin(struct module *modules,
+                       FILE *out, char *dirname)
+{
+       struct module *i;
+       struct index_node *index;
+       char *line;
+       char *p;
+
+       index = index_create();
+
+       for (i = modules; i; i = i->next) {
+               struct list_head *j, *tmp;
+               char modname[strlen(i->pathname)+1];
+               
+               order_dep_list(i, i);
+               
+               filename2modname(modname, i->pathname);
+               nofail_asprintf(&line, "%s:",
+                               compress_path(i->pathname, dirname));
+               p = line;
+               list_for_each_safe(j, tmp, &i->dep_list) {
+                       struct module *dep
+                               = list_entry(j, struct module, dep_list);
+                       nofail_asprintf(&line, "%s %s",
+                                       p,
+                                       compress_path(dep->pathname, dirname));
+                       free(p);
+                       p = line;
+                       list_del_init(j);
+               }
+               if (index_insert(index, modname, line, i->order) && warn_dups)
+                       warn("duplicate module deps:\n%s\n",line);
+               free(line);
+       }
+       
+       index_write(index, out);
+       index_destroy(index);
+
+       return 1;
+}
+
+
+static int smells_like_module(const char *name)
+{
+       return ends_in(name,".ko") || ends_in(name, ".ko.gz");
+}
+
+typedef struct module *(*do_module_t)(const char *dirname,
+                                     const char *filename,
+                                     struct module *next,
+                                     struct module_search *search,
+                                     struct module_overrides *overrides);
+
+static int is_higher_priority(const char *newpath, const char *oldpath,
+                             struct module_search *search,
+                             struct module_overrides *overrides)
+{
+       struct module_search *tmp;
+       struct module_overrides *ovtmp;
+       int i = 0;
+       int prio_builtin = -1;
+       int prio_new = -1;
+       int prio_old = -1;
+
+/* The names already match, now we check for overrides and directory search
+ * order
+ */
+       for (ovtmp = overrides; ovtmp != NULL; ovtmp = ovtmp->next) {
+               if (streq(ovtmp->modfile, newpath))
+                       return 1;
+               if (streq(ovtmp->modfile, oldpath))
+                       return 0;
+       }
+       for (i = 0, tmp = search; tmp != NULL; tmp = tmp->next, i++) {
+               if (streq(tmp->search_path, MODULE_BUILTIN_KEY))
+                       prio_builtin = i;
+               else if (strncmp(tmp->search_path, newpath, tmp->len) == 0)
+                       prio_new = i;
+               else if (strncmp(tmp->search_path, oldpath, tmp->len) == 0)
+                       prio_old = i;
+       }
+       if (prio_new < 0)
+               prio_new = prio_builtin;
+       if (prio_old < 0)
+               prio_old = prio_builtin;
+
+       return prio_new > prio_old;
+}
+
+
+static struct module *do_module(const char *dirname,
+                                      const char *filename,
+                                      struct module *list,
+                                      struct module_search *search,
+                                      struct module_overrides *overrides)
+{
+       struct module *new, **i;
+
+       new = grab_module(dirname, filename);
+       if (!new)
+               return list;
+
+       /* Check if module is already in the list. */
+       for (i = &list; *i; i = &(*i)->next) {
+
+               if (streq((*i)->basename, filename)) {
+                       char newpath[strlen(dirname) + strlen("/")
+                                     + strlen(filename) + 1];
+
+                       sprintf(newpath, "%s/%s", dirname, filename);
+
+                       if (is_higher_priority(newpath, (*i)->pathname,search,
+                                              overrides)) {
+                               del_module(i, *i);
+                               
+                               new->next = *i;
+                               *i = new;
+                       } else
+                               del_module(NULL, new);
+
+                       return list;
+               }
+       }
+
+       /* Not in the list already. Just prepend. */
+       new->next = list;
+       return new;
+}
+
+static struct module *grab_dir(const char *dirname,
+                              DIR *dir,
+                              struct module *next,
+                              do_module_t do_mod,
+                              struct module_search *search,
+                              struct module_overrides *overrides)
+{
+       struct dirent *dirent;
+
+       while ((dirent = readdir(dir)) != NULL) {
+               if (smells_like_module(dirent->d_name))
+                       next = do_mod(dirname, dirent->d_name, next,
+                                     search, overrides);
+               else if (!streq(dirent->d_name, ".")
+                        && !streq(dirent->d_name, "..")
+                        && !streq(dirent->d_name, "source")
+                        && !streq(dirent->d_name, "build")) {
+
+                       DIR *sub;
+                       char subdir[strlen(dirname) + 1
+                                  + strlen(dirent->d_name) + 1];
+                       sprintf(subdir, "%s/%s", dirname, dirent->d_name);
+                       sub = opendir(subdir);
+                       if (sub) {
+                               next = grab_dir(subdir, sub, next, do_mod,
+                                               search, overrides);
+                               closedir(sub);
+                       }
+               }
+       }
+       return next;
+}
+
+static struct module *grab_basedir(const char *dirname,
+                                  struct module_search *search,
+                                  struct module_overrides *overrides)
+{
+       DIR *dir;
+       struct module *list;
+
+       dir = opendir(dirname);
+       if (!dir) {
+               warn("Couldn't open directory %s: %s\n",
+                    dirname, strerror(errno));
+               return NULL;
+       }
+       list = grab_dir(dirname, dir, NULL, do_module, search, overrides);
+       closedir(dir);
+
+       return list;
+}
+
+static struct module *sort_modules(const char *dirname, struct module *list)
+{
+       struct module *tlist = NULL, **tpos = &tlist;
+       FILE *modorder;
+       int dir_len = strlen(dirname) + 1;
+       char file_name[dir_len + strlen("modules.order") + 1];
+       char line[10240];
+       unsigned int linenum = 0;
+
+       sprintf(file_name, "%s/%s", dirname, "modules.order");
+
+       modorder = fopen(file_name, "r");
+       if (!modorder) {
+               /* Older kernels don't generate modules.order.  Just
+                  return if the file doesn't exist. */
+               if (errno == ENOENT)
+                       return list;
+               fatal("Could not open '%s': %s\n", file_name, strerror(errno));
+       }
+
+       sprintf(line, "%s/", dirname);
+
+       /* move modules listed in modorder file to tlist in order */
+       while (fgets(line, sizeof(line), modorder)) {
+               struct module **pos, *mod;
+               int len = strlen(line);
+
+               linenum++;
+               if (line[len - 1] == '\n')
+                       line[len - 1] = '\0';
+
+               for (pos = &list; (mod = *pos); pos = &(*pos)->next) {
+                       if (streq(line, mod->pathname + dir_len)) {
+                               mod->order = linenum;
+                               *pos = mod->next;
+                               mod->next = NULL;
+                               *tpos = mod;
+                               tpos = &mod->next;
+                               break;
+                       }
+               }
+       }
+
+       /* append the rest */
+       *tpos = list;
+
+       fclose(modorder);
+
+       return tlist;
+}
+
+/* Calculate the dependencies for this module */
+static void calculate_deps(struct module *module)
+{
+       unsigned int i;
+       struct string_table *symnames;
+       struct string_table *symtypes;
+       uint64_t *symvers = NULL;
+       struct elf_file *file;
+
+       module->num_deps = 0;
+       module->deps = NULL;
+       file = module->file;
+
+       symnames = file->ops->load_dep_syms(file, &symtypes,
+                       check_symvers ? &symvers : NULL);
+       if (!symnames || !symtypes)
+               return;
+
+       for (i = 0; i < symnames->cnt; i++) {
+               const char *name;
+               uint64_t ver;
+               struct module *owner;
+               int weak;
+
+               name = symnames->str[i];
+               ver = symvers ? symvers[i] : 0;
+               weak = (*(symtypes->str[i]) == 'W');
+               owner = find_symbol(name, ver, module->pathname, weak);
+               if (owner) {
+                       info("%s needs \"%s\": %s\n",
+                              module->pathname, name,
+                              owner->pathname);
+                       add_dep(module, owner);
+               }
+       }
+
+       free(symnames);
+       free(symtypes);
+       free(symvers);
+}
+
+static struct module *parse_modules(struct module *list)
+{
+       struct module *i;
+       struct elf_file *file;
+       struct string_table *syms;
+       int j;
+
+       for (i = list; i; i = i->next) {
+               uint64_t *symvers = NULL;
+               file = i->file;
+               syms = file->ops->load_symbols(file,
+                               check_symvers ? &symvers : NULL);
+               if (syms) {
+                       for (j = 0; j < syms->cnt; j++)
+                               add_symbol(syms->str[j],
+                                       symvers ? symvers[j] : 0, i);
+                       strtbl_free(syms);
+               }
+               free(symvers);
+               file->ops->fetch_tables(file, &i->tables);
+       }
+       
+       for (i = list; i; i = i->next)
+               calculate_deps(i);
+       
+       /* Strip out modules with dependency loops. */
+ again:
+       for (i = list; i; i = i->next) {
+               if (has_dep_loop(i, NULL)) {
+                       warn("Module %s ignored, due to loop\n",
+                            i->pathname + skipchars);
+                       del_module(&list, i);
+                       goto again;
+               }
+       }
+       
+       return list;
+}
+
+/* Simply dump hash table. */
+static int output_symbols(struct module *unused, FILE *out, char *dirname)
+{
+       unsigned int i;
+
+       fprintf(out, "# Aliases for symbols, used by symbol_request().\n");
+       for (i = 0; i < SYMBOL_HASH_SIZE; i++) {
+               struct symbol *s;
+
+               for (s = symbolhash[i]; s; s = s->next) {
+                       if (s->owner) {
+                               char modname[strlen(s->owner->pathname)+1];
+                               filename2modname(modname, s->owner->pathname);
+                               fprintf(out, "alias symbol:%s %s\n",
+                                       s->name, modname);
+                       }
+               }
+       }
+       return 1;
+}
+
+static int output_symbols_bin(struct module *unused, FILE *out, char *dirname)
+{
+       struct index_node *index;
+       unsigned int i;
+       char *alias;
+       int duplicate;
+
+       index = index_create();
+       
+       for (i = 0; i < SYMBOL_HASH_SIZE; i++) {
+               struct symbol *s;
+
+               for (s = symbolhash[i]; s; s = s->next) {
+                       if (s->owner) {
+                               char modname[strlen(s->owner->pathname)+1];
+                               filename2modname(modname, s->owner->pathname);
+                               nofail_asprintf(&alias, "symbol:%s", s->name);
+                               duplicate = index_insert(index, alias, modname,
+                                                        s->owner->order);
+                               if (duplicate && warn_dups)
+                                       warn("duplicate module syms:\n%s %s\n",
+                                               alias, modname);
+                               free(alias);
+                       }
+               }
+       }
+       
+       index_write(index, out);
+       index_destroy(index);
+
+       return 1;
+}
+
+static int output_builtin_bin(struct module *unused, FILE *out, char *dirname)
+{
+       struct index_node *index;
+       char *textfile, *line;
+       unsigned int linenum;
+       FILE *f;
+
+       nofail_asprintf(&textfile, "%s/modules.builtin", dirname);
+       if (!(f = fopen(textfile, "r"))) {
+               if (errno != ENOENT)
+                       fatal("Could not open '%s': %s\n",
+                                       textfile, strerror(errno));
+               free(textfile);
+               return 0;
+       }
+       free(textfile);
+       index = index_create();
+
+       while ((line = getline_wrapped(f, &linenum)) != NULL) {
+               char *module = line;
+
+               if (!*line || *line == '#') {
+                       free(line);
+                       continue;
+               }
+               filename2modname(module, module);
+               index_insert(index, module, "", 0);
+               free(line);
+       }
+       fclose(f);
+       index_write(index, out);
+       index_destroy(index);
+
+       return 1;
+}
+
+static int output_aliases(struct module *modules, FILE *out, char *dirname)
+{
+       struct module *i;
+       struct elf_file *file;
+       struct string_table *tbl;
+       int j;
+
+       fprintf(out, "# Aliases extracted from modules themselves.\n");
+       for (i = modules; i; i = i->next) {
+               char modname[strlen(i->pathname)+1];
+
+               file = i->file;
+               filename2modname(modname, i->pathname);
+
+               /* Grab from old-style .modalias section. */
+               tbl = file->ops->load_strings(file, ".modalias", NULL);
+               for (j = 0; tbl && j < tbl->cnt; j++)
+                       fprintf(out, "alias %s %s\n", tbl->str[j], modname);
+               strtbl_free(tbl);
+
+               /* Grab from new-style .modinfo section. */
+               tbl = file->ops->load_strings(file, ".modinfo", NULL);
+               for (j = 0; tbl && j < tbl->cnt; j++) {
+                       const char *p = tbl->str[j];
+                       if (strstarts(p, "alias="))
+                               fprintf(out, "alias %s %s\n",
+                                       p + strlen("alias="), modname);
+               }
+               strtbl_free(tbl);
+       }
+       return 1;
+}
+
+static int output_aliases_bin(struct module *modules, FILE *out, char *dirname)
+{
+       struct module *i;
+       struct elf_file *file;
+       struct string_table *tbl;
+       int j;
+       char *alias;
+       struct index_node *index;
+       int duplicate;
+
+       index = index_create();
+       
+       for (i = modules; i; i = i->next) {
+               char modname[strlen(i->pathname)+1];
+
+               file = i->file;
+               filename2modname(modname, i->pathname);
+
+               /* Grab from old-style .modalias section. */
+               tbl = file->ops->load_strings(file, ".modalias", NULL);
+               for (j = 0; tbl && j < tbl->cnt; j++) {
+                       alias = NOFAIL(strdup(tbl->str[j]));
+                       underscores(alias);
+                       duplicate = index_insert(index, alias, modname, i->order);
+                       if (duplicate && warn_dups)
+                               warn("duplicate module alias:\n%s %s\n",
+                                       alias, modname);
+                       free(alias);
+               }
+               strtbl_free(tbl);
+
+               /* Grab from new-style .modinfo section. */
+               tbl = file->ops->load_strings(file, ".modinfo", NULL);
+               for (j = 0; tbl && j < tbl->cnt; j++) {
+                       const char *p = tbl->str[j];
+                       if (strstarts(p, "alias=")) {
+                               alias = NOFAIL(strdup(p + strlen("alias=")));
+                               underscores(alias);
+                               duplicate = index_insert(index, alias, modname, i->order);
+                               if (duplicate && warn_dups)
+                                       warn("duplicate module alias:\n%s %s\n",
+                                               alias, modname);
+                               free(alias);
+                       }
+               }
+               strtbl_free(tbl);
+       }
+       
+       index_write(index, out);
+       index_destroy(index);
+
+       return 1;
+}
+
+static int output_softdeps(struct module *modules, FILE *out, char *dirname)
+{
+       struct module *i;
+       struct elf_file *file;
+       struct string_table *tbl;
+       int j;
+
+       fprintf(out, "# Soft dependencies extracted from modules themselves.\n");
+       fprintf(out, "# Copy, with a .conf extension, to /etc/modprobe.d to use "
+               "it with modprobe.\n");
+       for (i = modules; i; i = i->next) {
+               char modname[strlen(i->pathname)+1];
+
+               file = i->file;
+               filename2modname(modname, i->pathname);
+
+               /* Grab from new-style .modinfo section. */
+               tbl = file->ops->load_strings(file, ".modinfo", NULL);
+               for (j = 0; tbl && j < tbl->cnt; j++) {
+                       const char *p = tbl->str[j];
+                       if (strstarts(p, "softdep="))
+                               fprintf(out, "softdep %s %s\n",
+                                       modname, p + strlen("softdep="));
+               }
+               strtbl_free(tbl);
+       }
+       return 1;
+}
+
+struct depfile {
+       char *name;
+       int (*func)(struct module *, FILE *, char *dirname);
+       int map_file;
+};
+
+static struct depfile depfiles[] = {
+       { "modules.dep", output_deps, 0 }, /* This is what we check for '-A'. */
+       { "modules.dep.bin", output_deps_bin, 0 },
+       { "modules.pcimap", output_pci_table, 1 },
+       { "modules.usbmap", output_usb_table, 1 },
+       { "modules.ccwmap", output_ccw_table, 1 },
+       { "modules.ieee1394map", output_ieee1394_table, 1 },
+       { "modules.isapnpmap", output_isapnp_table, 1 },
+       { "modules.inputmap", output_input_table, 1 },
+       { "modules.ofmap", output_of_table, 1 },
+       { "modules.seriomap", output_serio_table, 1 },
+       { "modules.alias", output_aliases, 0 },
+       { "modules.alias.bin", output_aliases_bin, 0 },
+       { "modules.softdep", output_softdeps, 0 },
+       { "modules.symbols", output_symbols, 0 },
+       { "modules.symbols.bin", output_symbols_bin, 0 },
+       { "modules.builtin.bin", output_builtin_bin, 0 },
+};
+
+/* If we can't figure it out, it's safe to say "true". */
+static int any_modules_newer(const char *dirname, time_t mtime)
+{
+       DIR *dir;
+       struct dirent *dirent;
+
+       dir = opendir(dirname);
+       if (!dir)
+               return 1;
+
+       while ((dirent = readdir(dir)) != NULL) {
+               struct stat st;
+               char file[strlen(dirname) + 1 + strlen(dirent->d_name) + 1];
+
+               if (streq(dirent->d_name, ".") || streq(dirent->d_name, ".."))
+                       continue;
+
+               sprintf(file, "%s/%s", dirname, dirent->d_name);
+               if (lstat(file, &st) != 0)
+                       goto ret_true;
+
+               if (smells_like_module(dirent->d_name)) {
+                       if (st.st_mtime > mtime)
+                               goto ret_true;
+               } else if (S_ISDIR(st.st_mode)) {
+                       if (any_modules_newer(file, mtime))
+                               goto ret_true;
+               }
+       }
+       closedir(dir);
+       return 0;
+
+ret_true:
+       closedir(dir);
+       return 1;
+}
+
+static int depfile_out_of_date(const char *dirname)
+{
+       struct stat st;
+       char depfile[strlen(dirname) + 1 + strlen(depfiles[0].name) + 1];
+
+       sprintf(depfile, "%s/%s", dirname, depfiles[0].name);
+
+       if (stat(depfile, &st) != 0)
+               return 1;
+
+       return any_modules_newer(dirname, st.st_mtime);
+}
+
+static char *strsep_skipspace(char **string, char *delim)
+{
+       if (!*string)
+               return NULL;
+       *string += strspn(*string, delim);
+       return strsep(string, delim);
+}
+
+static struct module_search *add_search(const char *search_path,
+                                       size_t len,
+                                       struct module_search *search)
+{
+
+       struct module_search *new;
+       
+       new = NOFAIL(malloc(sizeof(*new)));
+       new->search_path = NOFAIL(strdup(search_path));
+       new->len = len;
+       new->next = search;
+
+       return new;
+       
+}
+
+static struct module_overrides *add_override(const char *modfile,
+                                            struct module_overrides *overrides)
+{
+
+       struct module_overrides *new;
+       
+       new = NOFAIL(malloc(sizeof(*new)));
+       new->modfile = NOFAIL(strdup(modfile));
+       new->next = overrides;
+
+       return new;
+       
+}
+
+static int parse_config_scan(const char *filename,
+                            const char *basedir,
+                            const char *kernelversion,
+                            struct module_search **search,
+                            struct module_overrides **overrides);
+
+static int parse_config_file(const char *filename,
+                            const char *basedir,
+                            const char *kernelversion,
+                            struct module_search **search,
+                            struct module_overrides **overrides)
+{
+       char *line;
+       unsigned int linenum = 0;
+       FILE *cfile;
+
+       cfile = fopen(filename, "r");
+       if (!cfile) {
+               if (errno != ENOENT)
+                       fatal("could not open '%s', reason: %s\n", filename,
+                             strerror(errno));
+               return 0;
+       }
+
+       while ((line = getline_wrapped(cfile, &linenum)) != NULL) {
+               char *ptr = line;
+               char *cmd, *modname;
+
+               cmd = strsep_skipspace(&ptr, "\t ");
+
+               if (cmd == NULL || cmd[0] == '#' || cmd[0] == '\0') {
+                       free(line);
+                       continue;
+               }
+
+               if (streq(cmd, "search")) {
+                       char *search_path;
+                       
+                       while ((search_path = strsep_skipspace(&ptr, "\t "))) {
+                               char *dirname;
+                               size_t len;
+
+                               if (strcmp(search_path,
+                                               MODULE_BUILTIN_KEY) == 0) {
+                                       *search = add_search(MODULE_BUILTIN_KEY,
+                                                            0, *search);
+                                       continue;
+                               }
+                               nofail_asprintf(&dirname, "%s%s%s/%s", basedir,
+                                       MODULE_DIR, kernelversion, search_path);
+                               len = strlen(dirname);
+                               *search = add_search(dirname, len, *search);
+                               free(dirname);
+                       }
+               } else if (streq(cmd, "override")) {
+                       char *pathname = NULL, *version, *subdir;
+                       modname = strsep_skipspace(&ptr, "\t ");
+                       version = strsep_skipspace(&ptr, "\t ");
+                       subdir = strsep_skipspace(&ptr, "\t ");
+
+                       if (!regex_match(kernelversion, (const char *)version))
+                               continue;
+
+                       nofail_asprintf(&pathname, "%s%s%s/%s/%s.ko", basedir,
+                               MODULE_DIR, kernelversion, subdir, modname);
+
+                       *overrides = add_override(pathname, *overrides);
+                       free(pathname);
+               } else if (streq(cmd, "include")) {
+                       char *newfilename;
+
+                       newfilename = strsep_skipspace(&ptr, "\t ");
+                       if (!newfilename) {
+                               grammar(cmd, filename, linenum);
+                       } else {
+                               warn("\"include %s\" is deprecated, "
+                                    "please use /etc/depmod.d\n", newfilename);
+                               if (strstarts(newfilename, "/etc/depmod.d")) {
+                                       warn("\"include /etc/depmod.d\" is "
+                                            "the default, ignored\n");
+                               } else {
+                                       if (!parse_config_scan(newfilename, basedir,
+                                                              kernelversion,
+                                                              search, overrides))
+                                       warn("Failed to open included"
+                                            " config file %s: %s\n",
+                                            newfilename, strerror(errno));
+                               }
+                       }
+               } else if (streq(cmd, "make_map_files")) {
+                       char *option;
+
+                       option = strsep_skipspace(&ptr, "\t ");
+                       if (!option)
+                               grammar(cmd, filename, linenum);
+                       else {
+                               if (streq(option, "yes"))
+                                       make_map_files = 1;
+                               else if (streq(option, "no"))
+                                       make_map_files = 0;
+                               else
+                                       grammar(cmd, filename, linenum);
+                       }
+                } else
+                        grammar(cmd, filename, linenum);
+
+                free(line);
+        }
+        fclose(cfile);
+        return 1;
+}
+
+static int parse_config_scan(const char *filename,
+                            const char *basedir,
+                            const char *kernelversion,
+                            struct module_search **search,
+                            struct module_overrides **overrides)
+{
+       DIR *dir;
+       int ret = 0;
+
+       dir = opendir(filename);
+       if (dir) {
+               struct file_entry {
+                       struct list_head node;
+                       char name[];
+               };
+               LIST_HEAD(files_list);
+               struct file_entry *fe, *fe_tmp;
+               struct dirent *i;
+
+               /* sort files from directory into list */
+               while ((i = readdir(dir)) != NULL) {
+                       size_t len;
+
+                       if (i->d_name[0] == '.')
+                               continue;
+                       if (!config_filter(i->d_name))
+                               continue;
+
+                       len = strlen(i->d_name);
+                       if (len < 6 || strcmp(&i->d_name[len-5], ".conf") != 0)
+                               warn("All config files need .conf: %s/%s, "
+                                    "it will be ignored in a future release.\n",
+                                    filename, i->d_name);
+                       fe = malloc(sizeof(struct file_entry) + len + 1);
+                       if (fe == NULL)
+                               continue;
+                       strcpy(fe->name, i->d_name);
+                       list_for_each_entry(fe_tmp, &files_list, node)
+                               if (strcmp(fe_tmp->name, fe->name) >= 0)
+                                       break;
+                       list_add_tail(&fe->node, &fe_tmp->node);
+               }
+               closedir(dir);
+
+               /* parse list of files */
+               list_for_each_entry_safe(fe, fe_tmp, &files_list, node) {
+                       char *cfgfile;
+
+                       nofail_asprintf(&cfgfile, "%s/%s", filename, fe->name);
+                       if (!parse_config_file(cfgfile, basedir, kernelversion,
+                                              search, overrides))
+                               warn("Failed to open config file "
+                                    "%s: %s\n", fe->name, strerror(errno));
+                       free(cfgfile);
+                       list_del(&fe->node);
+                       free(fe);
+               }
+
+               ret = 1;
+       } else {
+               if (parse_config_file(filename, basedir, kernelversion, search,
+                                     overrides))
+                       ret = 1;
+       }
+
+       return ret;
+}
+
+static void parse_toplevel_config(const char *filename,
+                                 const char *basedir,
+                                 const char *kernelversion,
+                                 struct module_search **search,
+                                 struct module_overrides **overrides)
+{
+       if (filename) {
+               if (!parse_config_scan(filename, basedir, kernelversion, search,
+                                overrides))
+                       fatal("Failed to open config file %s: %s\n",
+                             filename, strerror(errno));
+               return;
+       }
+
+       /* deprecated config file */
+       if (parse_config_file("/etc/depmod.conf", basedir, kernelversion,
+                             search, overrides) > 0)
+               warn("Deprecated config file /etc/depmod.conf, "
+                     "all config files belong into /etc/depmod.d/.\n");
+
+       /* default config */
+       parse_config_scan("/etc/depmod.d", basedir, kernelversion,
+                         search, overrides);
+}
+
+/* Local to main, but not freed on exit.  Keep valgrind quiet. */
+struct module *list = NULL;
+struct module_search *search = NULL;
+struct module_overrides *overrides = NULL;
+
+int main(int argc, char *argv[])
+{
+       int opt, all = 0, maybe_all = 0, doing_stdout = 0;
+       char *basedir = "", *dirname, *version;
+       char *system_map = NULL, *module_symvers = NULL;
+       int i;
+       const char *config = NULL;
+
+       if (native_endianness() == 0)
+               abort();
+
+       while ((opt = getopt_long(argc, argv, "aAb:C:E:F:euqrvnhVwm", options, NULL))
+              != -1) {
+               switch (opt) {
+               case 'a':
+                       all = 1;
+                       break;
+               case 'A':
+                       maybe_all = 1;
+                       break;
+               case 'b':
+                       basedir = optarg;
+                       skipchars = strlen(basedir);
+                       break;
+               case 'C':
+                       config = optarg;
+                       break;
+               case 'E':
+                       module_symvers = optarg;
+                       check_symvers = 1;
+                       break;
+               case 'F':
+                       system_map = optarg;
+                       break;
+               case 'e':
+                       print_unknown = 1;
+                       break;
+               case 'u':
+               case 'q':
+               case 'r':
+                       break;
+               case 'v':
+                       verbose = 1;
+                       break;
+               case 'n':
+                       doing_stdout = 1;
+                       break;
+               case 'h':
+                       print_usage(argv[0]);
+                       exit(0);
+                       break;
+               case 'V':
+                       printf("%s %s\n", PACKAGE, VERSION);
+                       exit(0);
+               case 'w':
+                       warn_dups = 1;
+                       break;
+               case 'm':
+                       force_map_files = 1;
+                       break;
+               default:
+                       print_usage(argv[0]);
+                       exit(1);
+               }
+       }
+
+       if (module_symvers)
+               load_module_symvers(module_symvers);
+       else if (system_map)
+               load_system_map(system_map);
+       else if (print_unknown) {
+               warn("-e needs -E or -F\n");
+               print_unknown = 0;
+       }
+
+       /* They can specify the version naked on the command line */
+       if (optind < argc && is_version_number(argv[optind])) {
+               version = NOFAIL(strdup(argv[optind]));
+               optind++;
+       } else {
+               struct utsname buf;
+               uname(&buf);
+               version = NOFAIL(strdup(buf.release));
+       }
+
+       /* Check for old version. */
+       if (old_module_version(version)) {
+               fprintf(stderr, "Kernel version %s requires old depmod\n",
+                       version);
+               exit(2);
+       }
+
+       /* Depmod -a by default if no names. */
+       if (optind == argc)
+               all = 1;
+
+       nofail_asprintf(&dirname, "%s%s%s", basedir, MODULE_DIR, version);
+
+       if (maybe_all) {
+               if (!doing_stdout && !depfile_out_of_date(dirname))
+                       exit(0);
+               all = 1;
+       }
+
+       parse_toplevel_config(config, basedir, version, &search, &overrides);
+
+       /* For backward compatibility add "updates" to the head of the search
+        * list here. But only if there was no "search" option specified.
+        */
+       if (!search) {
+               char *dirname;
+               size_t len;
+
+               nofail_asprintf(&dirname, "%s%s%s/updates", basedir,
+                               MODULE_DIR, version);
+               len = strlen(dirname);
+               search = add_search(dirname, len, search);
+       }
+       if (!all) {
+               /* Do command line args. */
+               for (opt = optind; opt < argc; opt++) {
+                       struct module *new;
+
+                       if (argv[opt][0] != '/')
+                               fatal("modules must be specified using absolute paths.\n"
+                                       "\"%s\" is a relative path\n", argv[opt]);
+
+                       new = grab_module(NULL, argv[opt]);
+                       if (!new) {
+                               /* cmd-line specified modules must exist */
+                               fatal("grab_module() failed for module %s\n", argv[opt]);
+                       }
+                       new->next = list;
+                       list = new;
+               }
+       } else {
+               list = grab_basedir(dirname,search,overrides);
+       }
+       list = sort_modules(dirname,list);
+       list = parse_modules(list);
+
+       for (i = 0; i < sizeof(depfiles)/sizeof(depfiles[0]); i++) {
+               FILE *out;
+               int res;
+               struct depfile *d = &depfiles[i];
+               char depname[strlen(dirname) + 1 + strlen(d->name) + 1];
+               char tmpname[strlen(dirname) + 1 + strlen(d->name) +
+                                               strlen(".temp") + 1];
+
+               if (d->map_file && !make_map_files && !force_map_files)
+                       continue;
+
+               sprintf(depname, "%s/%s", dirname, d->name);
+               sprintf(tmpname, "%s/%s.temp", dirname, d->name);
+               if (!doing_stdout) {
+                       out = fopen(tmpname, "w");
+                       if (!out)
+                               fatal("Could not open %s for writing: %s\n",
+                                       tmpname, strerror(errno));
+               } else {
+                       out = stdout;
+                       if (ends_in(depname, ".bin"))
+                               continue;
+               }
+               res = d->func(list, out, dirname);
+               if (doing_stdout)
+                       continue;
+               fclose(out);
+               if (res) {
+                       if (rename(tmpname, depname) < 0)
+                               fatal("Could not rename %s into %s: %s\n",
+                                       tmpname, depname, strerror(errno));
+               } else {
+                       if (unlink(tmpname) < 0)
+                               warn("Could not delete %s: %s\n",
+                                       tmpname, strerror(errno));
+               }
+       }
+
+       free(dirname);
+       free(version);
+       
+       return 0;
+}
diff --git a/depmod.conf.5 b/depmod.conf.5
new file mode 100644 (file)
index 0000000..6594ce0
--- /dev/null
@@ -0,0 +1,58 @@
+.\\" auto-generated by docbook2man-spec $Revision: 1.2 $
+.TH "DEPMOD.CONF" "5" "2010-03-01" "" ""
+.SH NAME
+depmod.conf, depmod.d \- Configuration file/directory for depmod
+.SH "DESCRIPTION"
+.PP
+The order in which modules are processed by the
+\fBdepmod\fR command can be altered on a global or
+per-module basis. This is typically useful in cases where built-in
+kernel modules are complemented by custom built versions of the
+same and the user wishes to affect the priority of processing in
+order to override the module version supplied by the kernel.
+.PP
+The format of \fIdepmod.conf\fR and files under \fIdepmod.d\fR is simple: one
+command per line, with blank lines and lines starting with '#'
+ignored (useful for adding comments). A '\\' at the end of a line
+causes it to continue on the next line, which makes the file a
+bit neater.
+.SH "COMMANDS"
+.TP
+\fBsearch \fIsubdirectory...\fB\fR
+This allows you to specify the order in which /lib/modules
+(or other configured module location) subdirectories will
+be processed by \fBdepmod\fR\&. Directories are
+listed in order, with the highest priority given to the
+first listed directory and the lowest priority given to the last
+directory listed. The special keyword \fBbuilt-in\fR 
+refers to the standard module directories installed by the kernel.
+
+By default, depmod will give a higher priority to 
+a directory with the name \fBupdates\fR
+using this built-in search string: "updates built-in"
+but more complex arrangements are possible and are
+used in several popular distributions.
+.TP
+\fBoverride \fImodulename\fB \fIkernelversion\fB \fImodulesubdirectory\fB\fR
+This command allows you to override which version of a
+specific module will be used when more than one module
+sharing the same name is processed by the
+\fBdepmod\fR command. It is possible to
+specify one kernel or all kernels using the * wildcard.
+\fImodulesubdirectory\fR is the
+name of the subdirectory under /lib/modules (or other
+module location) where the target module is installed.
+
+For example, it is possible to override the priority of
+an updated test module called \fBkmod\fR by
+specifying the following command: "override kmod * extra".
+This will ensure that any matching module name installed
+under the \fBextra\fR subdirectory within
+/lib/modules (or other module location) will take priority
+over any likenamed module already provided by the kernel.
+.SH "COPYRIGHT"
+.PP
+This manual page Copyright 2006-2010, Jon Masters, Red Hat, Inc.
+.SH "SEE ALSO"
+.PP
+\fBdepmod\fR(8)
diff --git a/depmod.h b/depmod.h
new file mode 100644 (file)
index 0000000..7678241
--- /dev/null
+++ b/depmod.h
@@ -0,0 +1,36 @@
+/*
+ * depmod.h - prototypes for the depmod utility
+ */
+
+#ifndef MODINITTOOLS_DEPMOD_H
+#define MODINITTOOLS_DEPMOD_H
+#include "list.h"
+#include "elfops.h"
+
+struct module;
+
+struct module
+{
+       /* Next module in list of all modules */
+       struct module *next;
+
+       /* Dependencies: filled in by ops->calculate_deps() */
+       unsigned int num_deps;
+       struct module **deps;
+
+       /* Set while we are traversing dependencies */
+       struct list_head dep_list;
+
+       /* Line number in modules.order (or INDEX_PRIORITY_MIN) */
+       unsigned int order;
+
+       /* Tables extracted from module by ops->fetch_tables(). */
+       struct module_tables tables;
+
+       struct elf_file *file;
+
+       char *basename; /* points into pathname */
+       char pathname[0];
+};
+
+#endif /* MODINITTOOLS_DEPMOD_H */
diff --git a/doc/depmod.conf.sgml b/doc/depmod.conf.sgml
new file mode 100644 (file)
index 0000000..4bc399b
--- /dev/null
@@ -0,0 +1,132 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+  <!ENTITY debian  "<productname>Debian GNU/Linux</productname>">
+  <!ENTITY docbook "<productname>DocBook</productname>">
+  <!ENTITY sgml    "<abbrev>SGML</abbrev>">
+]>
+
+<!-- Stolen from manual page for docbook-to-man, DocBook source file
+     (C) 1999 W. Borgert debacle@debian.org
+
+     $Id: docbook-to-man.sgml,v 1.8 2002/04/27 15:28:02 debacle Exp $ -->
+
+<refentry>
+  <refentryinfo>
+    <address>
+      <email>jcm@jonmasters.org</email>
+    </address>
+    <author>
+      <firstname>Jon</firstname>
+      <surname>Masters</surname>
+    </author>
+    <date>2010-03-01</date>
+  </refentryinfo>
+  <refmeta>
+    <refentrytitle>depmod.d</refentrytitle>
+    <manvolnum>5</manvolnum>
+    <refentrytitle>depmod.conf</refentrytitle>
+    <manvolnum>5</manvolnum>
+  </refmeta>
+  <refnamediv>
+    <refname>depmod.conf</refname><refname>depmod.d</refname> <refpurpose>Configuration file/directory for depmod</refpurpose>
+  </refnamediv>
+  <refsect1>
+    <title>DESCRIPTION</title>
+
+    <para>The order in which modules are processed by the
+      <command>depmod</command> command can be altered on a global or
+      per-module basis. This is typically useful in cases where built-in
+      kernel modules are complemented by custom built versions of the
+      same and the user wishes to affect the priority of processing in
+      order to override the module version supplied by the kernel.
+    </para>
+    <para>
+      The format of <filename>depmod.conf</filename> and files under <filename>depmod.d</filename> is simple: one
+      command per line, with blank lines and lines starting with '#'
+      ignored (useful for adding comments).  A '\' at the end of a line
+      causes it to continue on the next line, which makes the file a
+      bit neater.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>COMMANDS</title>
+    <variablelist>
+      <varlistentry>
+        <term>search <replaceable>subdirectory...</replaceable>
+        </term>
+       <listitem>
+         <para>
+           This allows you to specify the order in which /lib/modules
+           (or other configured module location) subdirectories will
+           be processed by <command>depmod</command>. Directories are
+           listed in order, with the highest priority given to the
+           first listed directory and the lowest priority given to the last
+           directory listed. The special keyword <command>built-in</command> 
+           refers to the standard module directories installed by the kernel.
+         </para>
+         <para>
+           By default, depmod will give a higher priority to 
+           a directory with the name <command>updates</command>
+           using this built-in search string: "updates built-in"
+           but more complex arrangements are possible and are
+           used in several popular distributions.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>override <replaceable>modulename</replaceable> <replaceable>kernelversion</replaceable> <replaceable>modulesubdirectory</replaceable>
+        </term>
+       <listitem>
+         <para>
+           This command allows you to override which version of a
+           specific module will be used when more than one module
+           sharing the same name is processed by the
+           <command>depmod</command> command. It is possible to
+           specify one kernel or all kernels using the * wildcard.
+           <replaceable>modulesubdirectory</replaceable> is the
+           name of the subdirectory under /lib/modules (or other
+           module location) where the target module is installed.
+         </para>
+         <para>
+           For example, it is possible to override the priority of
+           an updated test module called <command>kmod</command> by
+           specifying the following command: "override kmod * extra".
+           This will ensure that any matching module name installed
+           under the <command>extra</command> subdirectory within
+           /lib/modules (or other module location) will take priority
+           over any likenamed module already provided by the kernel.
+         </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+  <refsect1>
+    <title>COPYRIGHT</title>
+    <para>
+      This manual page Copyright 2006-2010, Jon Masters, Red Hat, Inc.
+    </para>
+  </refsect1>
+    <refsect1>
+    <title>SEE ALSO</title>
+    <para><citerefentry>
+       <refentrytitle>depmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
diff --git a/doc/depmod.sgml b/doc/depmod.sgml
new file mode 100644 (file)
index 0000000..ed39056
--- /dev/null
@@ -0,0 +1,252 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+  <!ENTITY debian  "<productname>Debian GNU/Linux</productname>">
+  <!ENTITY docbook "<productname>DocBook</productname>">
+  <!ENTITY sgml    "<abbrev>SGML</abbrev>">
+]>
+
+<!-- Stolen from manual page for docbook-to-man, DocBook source file
+     (C) 1999 W. Borgert debacle@debian.org
+
+     $Id: docbook-to-man.sgml,v 1.8 2002/04/27 15:28:02 debacle Exp $ -->
+
+<refentry>
+  <refentryinfo>
+    <address>
+      <email>jcm@jonmasters.org</email>
+    </address>
+    <author>
+      <firstname>Jon</firstname>
+      <surname>Masters</surname>
+    </author>
+    <date>2010-03-01</date>
+  </refentryinfo>
+  <refmeta>
+    <refentrytitle>depmod</refentrytitle>
+    <manvolnum>8</manvolnum>
+  </refmeta>
+  <refnamediv>
+    <refname>depmod</refname> <refpurpose>program to generate <filename>modules.dep</filename> and map files.</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>depmod</command>
+      <arg><option>-b <replaceable>basedir</replaceable></option></arg>
+      <arg><option>-e</option></arg>
+      <arg><option>-F <replaceable>System.map</replaceable></option></arg>
+      <arg><option>-n</option></arg>
+      <arg><option>-v</option></arg>
+      <arg><option><replaceable>version</replaceable></option></arg>
+      <arg><option>-A</option></arg>
+    </cmdsynopsis>
+    <cmdsynopsis>
+      <command>depmod</command>
+      <arg><option>-e</option></arg>
+      <arg><option>-F<replaceable>System.map</replaceable></option></arg>
+      <arg><option>-n</option></arg>
+      <arg><option>-v</option></arg>
+      <arg><option><replaceable>version</replaceable></option></arg>
+      <arg rep='repeat'><option><replaceable>filename</replaceable></option></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>DESCRIPTION</title>
+    <para>
+      Linux kernel modules can provide services (called "symbols") for
+      other modules to use (using one of the EXPORT_SYMBOL variants in the
+      code).  If a second module uses this symbol, that second module clearly
+      depends on the first module.  These dependencies can get quite complex.
+    </para>
+    <para>
+      <command>depmod</command> creates a list of module dependencies
+      by reading each module under
+      <filename>/lib/modules/</filename><replaceable>version</replaceable> 
+      and determining what symbols it exports and what symbols it
+      needs.  By default, this list is written to
+      <filename>modules.dep</filename>, and a binary hashed version named
+      <filename>modules.dep.bin</filename>, in the same directory.  If
+      filenames are given on the command line, only those modules are
+      examined (which is rarely useful unless all modules are listed).
+      <command>depmod</command> also creates a list of symbols provided
+      by modules in the file named <filename>modules.symbols</filename>
+      and its binary hashed version, <filename>modules.symbols.bin</filename>.
+    </para>
+    <para>
+      If a <replaceable>version</replaceable> is provided, then that
+      kernel version's module directory is used rather than the
+      current kernel version (as returned by <command>uname -r</command>).
+    </para>
+    <para>
+      
+    <para>
+      <command>depmod</command> will also generate various legacy map
+      files in the output directory for use by the older hotplug
+      infrastructure. These map files are largely deprecated.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>OPTIONS</title>
+    <variablelist>
+      <varlistentry>
+          <term><option>-a</option> <option>--all</option>
+          </term>
+          <listitem>
+            <para>
+              Probe all modules. This option is enabled by default if no
+              file names are given in the command-line.
+            </para>
+          </listitem>
+      </varlistentry>
+      <varlistentry>
+          <term><option>-A</option> <option>--quick</option>
+          </term>
+          <listitem>
+            <para>
+              This option scans to see if any modules are newer than the
+              <filename>modules.dep</filename> file before any work is done:
+              if not, it silently exits rather than regenerating the files.
+            </para>
+          </listitem>
+      </varlistentry>
+      <varlistentry>
+         <term><option>-b <replaceable>basedir</replaceable></option> <option>--basedir <replaceable>basedir</replaceable></option>
+         </term>
+         <listitem>
+           <para>
+             If your modules are not currently in the (normal)
+             directory
+             <filename>/lib/modules/</filename><replaceable>version</replaceable>,
+             but in a staging area, you can specify a
+             <replaceable>basedir</replaceable> which is prepended to
+             the directory name.  This
+             <replaceable>basedir</replaceable> is stripped from the
+             resulting <filename>modules.dep</filename> file, so it
+             is ready to be moved into the normal location. Use this option
+             if you are a distribution vendor who needs to pre-generate the
+             meta-data files rather than running depmod again later.
+           </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-C</option> <option>--config <replaceable>file or directory</replaceable></option>
+        </term>
+        <listitem>
+          <para>
+            This option overrides the default configuration file at
+            <filename>/etc/depmod.conf</filename> (or the 
+            <filename>/etc/depmod.d/</filename> directory if that is not found).
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-e</option> <option>--errsyms</option>
+        </term>
+         <listitem>
+           <para>
+             When combined with the <option>-F</option> option, this
+             reports any symbols which a module needs which are not
+             supplied by other modules or the kernel.  Normally, any
+             symbols not provided by modules are assumed to be
+             provided by the kernel (which should be true in a
+             perfect world), but this assumption can break espencially
+             when additionally updated third party drivers are not
+             correctly installed or were built incorrectly.
+           </para>
+         </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-F</option> <option>--filesyms <replaceable>System.map</replaceable></option>
+        </term>
+        <listitem>
+          <para>
+           Supplied with the <filename>System.map</filename> produced
+           when the kernel was built, this allows the
+           <option>-e</option> option to report unresolved symbols.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-h</option> <option>--help</option>
+        </term>
+        <listitem>
+          <para>
+            Print the help message and exit.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-n</option> <option>--dry-run</option>
+        </term>
+        <listitem>
+          <para>
+           This sends the resulting modules.dep and the various
+           map files to standard output rather than writing them into
+           the module directory.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-v</option> <option>--verbose</option>
+        </term>
+        <listitem>
+          <para>
+           In verbose mode, <command>depmod</command> will print (to stdout)
+            all the symbols each module depends on and the module's file name
+            which provides that symbol.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-V</option> <option>--version</option>
+        </term>
+        <listitem>
+          <para>
+            Show version of program and exit. See below for caveats when
+            run on older kernels.
+          </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+  <refsect1>
+    <title>COPYRIGHT</title>
+
+    <para>
+      This manual page originally Copyright 2002, Rusty Russell,
+      IBM Corporation. Maintained by Jon Masters and others.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>SEE ALSO</title>
+    <para>
+      <citerefentry>
+       <refentrytitle>depmod.conf</refentrytitle><manvolnum>5</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>depmod.d</refentrytitle><manvolnum>5</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>modules.dep</refentrytitle><manvolnum>5</manvolnum>
+      </citerefentry>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
diff --git a/doc/insmod.sgml b/doc/insmod.sgml
new file mode 100644 (file)
index 0000000..ab3a4e8
--- /dev/null
@@ -0,0 +1,94 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+  <!ENTITY debian  "<productname>Debian GNU/Linux</productname>">
+  <!ENTITY docbook "<productname>DocBook</productname>">
+  <!ENTITY sgml    "<abbrev>SGML</abbrev>">
+]>
+
+<!-- Stolen from manual page for docbook-to-man, DocBook source file
+     (C) 1999 W. Borgert debacle@debian.org
+
+     $Id: docbook-to-man.sgml,v 1.8 2002/04/27 15:28:02 debacle Exp $ -->
+
+<refentry>
+  <refentryinfo>
+    <address>
+      <email>jcm@jonmasters.org</email>
+    </address>
+    <author>
+      <firstname>Jon</firstname>
+      <surname>Masters</surname>
+    </author>
+    <date>2010-03-01</date>
+  </refentryinfo>
+  <refmeta>
+    <refentrytitle>insmod</refentrytitle>
+    <manvolnum>8</manvolnum>
+  </refmeta>
+  <refnamediv>
+    <refname>insmod</refname> <refpurpose>simple program to insert a module into the Linux Kernel</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>insmod</command>
+      <arg><replaceable>filename</replaceable></arg>
+      <arg rep='repeat'><replaceable>module options</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>DESCRIPTION</title>
+
+    <para><command>insmod</command> is a trivial program to insert a
+       module into the kernel: if the
+       <replaceable>filename</replaceable> is a hyphen, the module is
+       taken from standard input. Most users will want to use
+       <citerefentry><refentrytitle>modprobe</refentrytitle>
+       <manvolnum>8</manvolnum> </citerefentry> instead, which is
+       more clever and can handle module dependencies.</para>
+
+    <para>Only the most general of error messages are reported: as the
+       work of trying to link the module is now done inside the kernel,
+       the <command>dmesg</command> usually gives more information
+       about errors.</para>
+  </refsect1>
+  <refsect1>
+    <title>COPYRIGHT</title>
+    <para>
+      This manual page originally Copyright 2002, Rusty Russell, IBM
+      Corporation. Maintained by Jon Masters and others.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>SEE ALSO</title>
+
+    <para><citerefentry>
+       <refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>rmmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>lsmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>
+      <citerefentry>
+       <refentrytitle>modinfo</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
diff --git a/doc/lsmod.sgml b/doc/lsmod.sgml
new file mode 100644 (file)
index 0000000..0267451
--- /dev/null
@@ -0,0 +1,83 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+  <!ENTITY debian  "<productname>Debian GNU/Linux</productname>">
+  <!ENTITY docbook "<productname>DocBook</productname>">
+  <!ENTITY sgml    "<abbrev>SGML</abbrev>">
+]>
+
+<!-- Stolen from manual page for docbook-to-man, DocBook source file
+     (C) 1999 W. Borgert debacle@debian.org
+
+     $Id: docbook-to-man.sgml,v 1.8 2002/04/27 15:28:02 debacle Exp $ -->
+
+<refentry>
+  <refentryinfo>
+    <address>
+      <email>jcm@jonmasters.org</email>
+    </address>
+    <author>
+      <firstname>Jon</firstname>
+      <surname>Masters</surname>
+    </author>
+    <date>2010-03-01</date>
+  </refentryinfo>
+  <refmeta>
+    <refentrytitle>lsmod</refentrytitle>
+    <manvolnum>8</manvolnum>
+  </refmeta>
+  <refnamediv>
+    <refname>lsmod</refname> <refpurpose>program to show the status of modules in the Linux Kernel</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>lsmod</command>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>DESCRIPTION</title>
+
+    <para><command>lsmod</command> is a trivial program which nicely
+      formats the contents of the <filename>/proc/modules</filename>,
+      showing what kernel modules are currently loaded.
+    </para>
+
+  </refsect1>
+  <refsect1>
+    <title>COPYRIGHT</title>
+    <para>
+      This manual page originally Copyright 2002, Rusty Russell, IBM
+      Corporation. Maintained by Jon Masters and others.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>SEE ALSO</title>
+
+    <para>
+      <citerefentry>
+       <refentrytitle>insmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>modinfo</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>
+</para>
+  </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
diff --git a/doc/modinfo.sgml b/doc/modinfo.sgml
new file mode 100644 (file)
index 0000000..8c72eef
--- /dev/null
@@ -0,0 +1,169 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+  <!ENTITY debian  "<productname>Debian GNU/Linux</productname>">
+  <!ENTITY docbook "<productname>DocBook</productname>">
+  <!ENTITY sgml    "<abbrev>SGML</abbrev>">
+]>
+
+<!-- Stolen from manual page for docbook-to-man, DocBook source file
+     (C) 1999 W. Borgert debacle@debian.org
+
+     $Id: docbook-to-man.sgml,v 1.8 2002/04/27 15:28:02 debacle Exp $ -->
+
+<refentry>
+  <refentryinfo>
+    <address>
+      <email>jcm@jonmasters.org</email>
+    </address>
+    <author>
+      <firstname>Jon</firstname>
+      <surname>Masters</surname>
+    </author>
+    <date>2010-03-01</date>
+  </refentryinfo>
+  <refmeta>
+    <refentrytitle>modinfo</refentrytitle>
+    <manvolnum>8</manvolnum>
+  </refmeta>
+  <refnamediv>
+    <refname>modinfo</refname> <refpurpose>program to show information about a Linux Kernel module</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>modinfo</command>
+      <arg><option>-0</option></arg>
+      <arg><option>-F <replaceable>field</replaceable></option></arg>
+      <arg><option>-k <replaceable>kernel</replaceable></option></arg>
+      <arg rep='repeat'>modulename|filename</arg>
+    </cmdsynopsis>
+    <cmdsynopsis>
+      <command>modinfo -V</command>
+    </cmdsynopsis>
+    <cmdsynopsis>
+      <command>modinfo -h</command>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>DESCRIPTION</title>
+
+    <para><command>modinfo</command> extracts information from the Linux
+      Kernel modules given on the command line.  If the module name is
+      not a filename, then the
+      <filename>/lib/modules/</filename><replaceable>version</replaceable>
+      directory is searched, as is also done by
+      <citerefentry><refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum></citerefentry> when loading kernel modules.
+    </para>
+
+    <para><command>modinfo</command> by default lists each attribute
+      of the module in form <replaceable>fieldname</replaceable> :
+      <replaceable>value</replaceable>, for easy reading.  The
+      filename is listed the same way (although it's not really an
+      attribute).
+    </para>
+
+    <para>This version of <command>modinfo</command> can understand
+    modules of any Linux Kernel architecture.</para>
+  </refsect1>
+  <refsect1>
+    <title>OPTIONS</title>
+    <variablelist>
+      <varlistentry>
+        <term><option>-V</option> <option>--version</option>
+        </term>
+        <listitem>
+          <para>
+           Print the modinfo version.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-F</option> <option>--field</option>
+        </term>
+        <listitem>
+          <para>
+           Only print this field value, one per line.  This is most
+           useful for scripts.  Field names are case-insenitive.
+           Common fields (which may not be in every module) include
+           <literal>author</literal>, <literal>description</literal>,
+           <literal>license</literal>, <literal>parm</literal>,
+           <literal>depends</literal>, and <literal>alias</literal>.
+           There are often multiple <literal>parm</literal>,
+           <literal>alias</literal> and <literal>depends</literal>
+           fields.  The special field <literal>filename</literal>
+           lists the filename of the module.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-k <replaceable>kernel</replaceable></option>
+        </term>
+        <listitem>
+          <para>
+            Provide information about a kernel other than the running one. This
+            is particularly useful for distributions needing to extract
+            information from a newly installed (but not yet running) set of
+            kernel modules. For example, you wish to find which firmware files
+            are needed by various modules in a new kernel for which you must
+            make an initrd/initramfs image prior to booting.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-0</option> <option>--null</option>
+        </term>
+        <listitem>
+          <para>
+           Use the ASCII zero character to separate field values,
+           instead of a new line.  This is useful for scripts, since
+           a new line can theoretically appear inside a field.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-a</option> <option>-d</option> <option>-l</option> <option>-p</option> <option>-n</option>
+        </term>
+        <listitem>
+          <para>
+           These are shortcuts for <literal>author</literal>,
+           <literal>description</literal>,
+           <literal>license</literal>.  <literal>parm</literal> and
+           <literal>filename</literal> respectively, to ease the
+           transition from the old modutils
+           <command>modinfo</command>.
+         </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+  <refsect1>
+    <title>COPYRIGHT</title>
+    <para>
+      This manual page originally Copyright 2003, Rusty Russell, IBM
+      Corporation. Maintained by Jon Masters and others.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>SEE ALSO</title>
+
+    <para><citerefentry>
+       <refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>
+</para>
+  </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
diff --git a/doc/modprobe.conf.sgml b/doc/modprobe.conf.sgml
new file mode 100644 (file)
index 0000000..a9c3d36
--- /dev/null
@@ -0,0 +1,255 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+  <!ENTITY debian  "<productname>Debian GNU/Linux</productname>">
+  <!ENTITY docbook "<productname>DocBook</productname>">
+  <!ENTITY sgml    "<abbrev>SGML</abbrev>">
+]>
+
+<!-- Stolen from manual page for docbook-to-man, DocBook source file
+     (C) 1999 W. Borgert debacle@debian.org
+
+     $Id: docbook-to-man.sgml,v 1.8 2002/04/27 15:28:02 debacle Exp $ -->
+
+<refentry>
+  <refentryinfo>
+    <address>
+      <email>jcm@jonmasters.org</email>
+    </address>
+    <author>
+      <firstname>Jon</firstname>
+      <surname>Masters</surname>
+    </author>
+    <date>2010-03-09</date>
+  </refentryinfo>
+  <refmeta>
+    <refentrytitle>modprobe.conf</refentrytitle>
+    <manvolnum>5</manvolnum>
+  </refmeta>
+  <refnamediv>
+    <refname>modprobe.d</refname><refname>modprobe.conf</refname> <refpurpose>Configuration directory/file for modprobe</refpurpose>
+  </refnamediv>
+  <refsect1>
+    <title>DESCRIPTION</title>
+
+    <para>Because the <command>modprobe</command> command can add or
+      remove more than one module, due to modules having dependencies,
+      we need a method of specifying what options are to be used with
+      those modules.  All files underneath the 
+      <filename>/etc/modprobe.d</filename> directory which end with the
+      <filename>.conf</filename> extension specify those options as
+      required. (the <filename>/etc/modprobe.conf</filename> file can
+      also be used if it exists, but that will be removed in a future 
+      version).  They can also be used to create convenient aliases: 
+      alternate names for a module, or they can override the normal 
+      <command>modprobe</command> behavior altogether for those with 
+      special requirements (such as inserting more than one module).
+    </para>
+    <para>
+      Note that module and alias names (like other module names) can
+      have - or _ in them: both are interchangable throughout all the
+      module commands as underscore conversion happens automatically.
+    </para>
+    <para>
+      The format of and files under <filename>modprobe.d</filename> and
+      <filename>/etc/modprobe.conf</filename> is simple: one
+      command per line, with blank lines and lines starting with '#'
+      ignored (useful for adding comments).  A '\' at the end of a line
+      causes it to continue on the next line, which makes the file a
+      bit neater.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>COMMANDS</title>
+    <variablelist>
+      <varlistentry>
+        <term>alias <replaceable>wildcard</replaceable> <replaceable>modulename</replaceable>
+        </term>
+       <listitem>
+         <para>
+           This allows you to give alternate names for a module.  For
+           example: "alias my-mod really_long_modulename"
+           means you can use "modprobe my-mod" instead of "modprobe
+           really_long_modulename".  You can also use shell-style
+           wildcards, so "alias my-mod* really_long_modulename"
+           means that "modprobe my-mod-something" has the same
+           effect.  You can't have aliases to other aliases (that
+           way lies madness), but aliases can have options, which
+           will be added to any other options.
+         </para>
+         <para>
+           Note that modules can also contain their own aliases,
+           which you can see using <command>modinfo</command>.  These
+           aliases are used as a last resort (ie. if there is no real
+           module, <command>install</command>,
+           <command>remove</command>, or <command>alias</command>
+           command in the configuration).
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>blacklist <replaceable>modulename</replaceable>
+        </term>
+       <listitem>
+         <para>
+           Modules can contain their own aliases: usually these are
+           aliases describing the devices they support, such as
+           "pci:123...".  These "internal" aliases can be overridden
+           by normal "alias" keywords, but there are cases where two
+           or more modules both support the same devices, or a module
+           invalidly claims to support a devicei that it does not: the
+           <command>blacklist</command> keyword indicates that all of
+           that particular module's internal aliases are to be ignored.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>install <replaceable>modulename</replaceable> <replaceable>command...</replaceable>
+        </term>
+       <listitem>
+         <para>
+           This command instructs <command>modprobe</command> to run your
+           command instead of inserting the module in the kernel as normal.
+           The command can be any shell command: this allows you to do any
+           kind of complex processing you might wish.  For example, if the
+           module "fred" works better with the module "barney"
+           already installed (but it doesn't depend on it, so
+           <command>modprobe</command> won't automatically load it),
+           you could say "install fred /sbin/modprobe barney;
+           /sbin/modprobe --ignore-install fred", which would do what
+           you wanted.  Note the <option>--ignore-install</option>,
+           which stops the second <command>modprobe</command> from
+           running the same <command>install</command> command again.
+           See also <command>remove</command> below.
+         </para>
+         <para>The long term future of this command as a solution to the
+           problem of providing additional module dependencies is not assured
+           and it is intended to replace this command with a warning about
+           its eventual removal or deprecation at some point in a future
+           release. Its use complicates the automated determination of module
+           dependencies by distribution utilities, such as mkinitrd (because
+           these now need to somehow interpret what the
+           <command>install</command> commands might be doing.
+           In a perfect world, modules would provide all dependency
+           information without the use of this command and work is underway
+           to implement soft dependency support within the Linux kernel.
+         </para>
+         <para>
+           If you use the string "$CMDLINE_OPTS" in the command, it
+           will be replaced by any options specified on the modprobe
+           command line.  This can be useful because users expect
+           "modprobe fred opt=1" to pass the "opt=1" arg to the
+           module, even if there's an install command in the
+           configuration file.  So our above example becomes "install
+           fred /sbin/modprobe barney; /sbin/modprobe
+           --ignore-install fred $CMDLINE_OPTS"
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>options <replaceable>modulename</replaceable> <replaceable>option...</replaceable>
+        </term>
+       <listitem>
+         <para>
+           This command allows you to add options to the module
+           <replaceable>modulename</replaceable> (which might be an
+           alias) every time it is inserted into the kernel: whether
+           directly (using <command>modprobe</command> 
+           <replaceable>modulename</replaceable> or because the
+           module being inserted depends on this module.
+         </para>
+         <para>
+           All options are added together: they can come from an
+           <command>option</command> for the module itself, for an
+           alias, and on the command line.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>remove <replaceable>modulename</replaceable> <replaceable>command...</replaceable>
+        </term>
+       <listitem>
+         <para>
+           This is similar to the <command>install</command> command
+           above, except it is invoked when "modprobe -r" is run.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>softdep <replaceable>modulename</replaceable> pre: <replaceable>modules...</replaceable> post: <replaceable>modules...</replaceable>
+        </term>
+       <listitem>
+         <para>
+            The <command>softdep</command> command allows you to specify soft,
+            or optional, module dependencies. <replaceable>modulename</replaceable>
+            can be used without these optional modules installed, but usually with
+            some features missing. For example, a driver for a storage HBA might
+            require another module be loaded in order to use management features.
+         </para>
+         <para>
+            pre-deps and post-deps modules are lists of names and/or aliases of other
+            modules that modprobe will attempt to install (or remove) in order
+            before and after the main module given in the
+            <replaceable>modulename</replaceable> argument.
+         </para>
+         <para>
+            Example: Assume "softdep c pre: a b post: d e" is provided in the
+            configuration. Running "modprobe c" is now equivalent to
+            "modprobe a b c d e" without the softdep.
+            Flags such as --use-blacklist are applied to all the specified
+            modules, while module parameters only apply to module c.
+         </para>
+         <para>
+            Note: if there are <command>install</command> or
+            <command>remove</command> commands with the same
+            <replaceable>modulename</replaceable> argument,
+            <command>softdep</command> takes precedence.
+         </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+  <refsect1>
+    <title>COMPATIBILITY</title>
+    <para>
+      A future version of module-init-tools will come with a strong warning
+      to avoid use of the <command>install</command> as explained above. This
+      will happen once support for soft dependencies in the kernel is complete.
+      That support will complement the existing softdep support within this
+      utility by providing such dependencies directly within the modules.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>COPYRIGHT</title>
+    <para>
+      This manual page originally Copyright 2004, Rusty Russell, IBM
+      Corporation. Maintained by Jon Masters and others.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>SEE ALSO</title>
+
+    <para><citerefentry>
+       <refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>modules.dep</refentrytitle><manvolnum>5</manvolnum>
+      </citerefentry>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
diff --git a/doc/modprobe.d.sgml b/doc/modprobe.d.sgml
new file mode 100644 (file)
index 0000000..a9c3d36
--- /dev/null
@@ -0,0 +1,255 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+  <!ENTITY debian  "<productname>Debian GNU/Linux</productname>">
+  <!ENTITY docbook "<productname>DocBook</productname>">
+  <!ENTITY sgml    "<abbrev>SGML</abbrev>">
+]>
+
+<!-- Stolen from manual page for docbook-to-man, DocBook source file
+     (C) 1999 W. Borgert debacle@debian.org
+
+     $Id: docbook-to-man.sgml,v 1.8 2002/04/27 15:28:02 debacle Exp $ -->
+
+<refentry>
+  <refentryinfo>
+    <address>
+      <email>jcm@jonmasters.org</email>
+    </address>
+    <author>
+      <firstname>Jon</firstname>
+      <surname>Masters</surname>
+    </author>
+    <date>2010-03-09</date>
+  </refentryinfo>
+  <refmeta>
+    <refentrytitle>modprobe.conf</refentrytitle>
+    <manvolnum>5</manvolnum>
+  </refmeta>
+  <refnamediv>
+    <refname>modprobe.d</refname><refname>modprobe.conf</refname> <refpurpose>Configuration directory/file for modprobe</refpurpose>
+  </refnamediv>
+  <refsect1>
+    <title>DESCRIPTION</title>
+
+    <para>Because the <command>modprobe</command> command can add or
+      remove more than one module, due to modules having dependencies,
+      we need a method of specifying what options are to be used with
+      those modules.  All files underneath the 
+      <filename>/etc/modprobe.d</filename> directory which end with the
+      <filename>.conf</filename> extension specify those options as
+      required. (the <filename>/etc/modprobe.conf</filename> file can
+      also be used if it exists, but that will be removed in a future 
+      version).  They can also be used to create convenient aliases: 
+      alternate names for a module, or they can override the normal 
+      <command>modprobe</command> behavior altogether for those with 
+      special requirements (such as inserting more than one module).
+    </para>
+    <para>
+      Note that module and alias names (like other module names) can
+      have - or _ in them: both are interchangable throughout all the
+      module commands as underscore conversion happens automatically.
+    </para>
+    <para>
+      The format of and files under <filename>modprobe.d</filename> and
+      <filename>/etc/modprobe.conf</filename> is simple: one
+      command per line, with blank lines and lines starting with '#'
+      ignored (useful for adding comments).  A '\' at the end of a line
+      causes it to continue on the next line, which makes the file a
+      bit neater.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>COMMANDS</title>
+    <variablelist>
+      <varlistentry>
+        <term>alias <replaceable>wildcard</replaceable> <replaceable>modulename</replaceable>
+        </term>
+       <listitem>
+         <para>
+           This allows you to give alternate names for a module.  For
+           example: "alias my-mod really_long_modulename"
+           means you can use "modprobe my-mod" instead of "modprobe
+           really_long_modulename".  You can also use shell-style
+           wildcards, so "alias my-mod* really_long_modulename"
+           means that "modprobe my-mod-something" has the same
+           effect.  You can't have aliases to other aliases (that
+           way lies madness), but aliases can have options, which
+           will be added to any other options.
+         </para>
+         <para>
+           Note that modules can also contain their own aliases,
+           which you can see using <command>modinfo</command>.  These
+           aliases are used as a last resort (ie. if there is no real
+           module, <command>install</command>,
+           <command>remove</command>, or <command>alias</command>
+           command in the configuration).
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>blacklist <replaceable>modulename</replaceable>
+        </term>
+       <listitem>
+         <para>
+           Modules can contain their own aliases: usually these are
+           aliases describing the devices they support, such as
+           "pci:123...".  These "internal" aliases can be overridden
+           by normal "alias" keywords, but there are cases where two
+           or more modules both support the same devices, or a module
+           invalidly claims to support a devicei that it does not: the
+           <command>blacklist</command> keyword indicates that all of
+           that particular module's internal aliases are to be ignored.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>install <replaceable>modulename</replaceable> <replaceable>command...</replaceable>
+        </term>
+       <listitem>
+         <para>
+           This command instructs <command>modprobe</command> to run your
+           command instead of inserting the module in the kernel as normal.
+           The command can be any shell command: this allows you to do any
+           kind of complex processing you might wish.  For example, if the
+           module "fred" works better with the module "barney"
+           already installed (but it doesn't depend on it, so
+           <command>modprobe</command> won't automatically load it),
+           you could say "install fred /sbin/modprobe barney;
+           /sbin/modprobe --ignore-install fred", which would do what
+           you wanted.  Note the <option>--ignore-install</option>,
+           which stops the second <command>modprobe</command> from
+           running the same <command>install</command> command again.
+           See also <command>remove</command> below.
+         </para>
+         <para>The long term future of this command as a solution to the
+           problem of providing additional module dependencies is not assured
+           and it is intended to replace this command with a warning about
+           its eventual removal or deprecation at some point in a future
+           release. Its use complicates the automated determination of module
+           dependencies by distribution utilities, such as mkinitrd (because
+           these now need to somehow interpret what the
+           <command>install</command> commands might be doing.
+           In a perfect world, modules would provide all dependency
+           information without the use of this command and work is underway
+           to implement soft dependency support within the Linux kernel.
+         </para>
+         <para>
+           If you use the string "$CMDLINE_OPTS" in the command, it
+           will be replaced by any options specified on the modprobe
+           command line.  This can be useful because users expect
+           "modprobe fred opt=1" to pass the "opt=1" arg to the
+           module, even if there's an install command in the
+           configuration file.  So our above example becomes "install
+           fred /sbin/modprobe barney; /sbin/modprobe
+           --ignore-install fred $CMDLINE_OPTS"
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>options <replaceable>modulename</replaceable> <replaceable>option...</replaceable>
+        </term>
+       <listitem>
+         <para>
+           This command allows you to add options to the module
+           <replaceable>modulename</replaceable> (which might be an
+           alias) every time it is inserted into the kernel: whether
+           directly (using <command>modprobe</command> 
+           <replaceable>modulename</replaceable> or because the
+           module being inserted depends on this module.
+         </para>
+         <para>
+           All options are added together: they can come from an
+           <command>option</command> for the module itself, for an
+           alias, and on the command line.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>remove <replaceable>modulename</replaceable> <replaceable>command...</replaceable>
+        </term>
+       <listitem>
+         <para>
+           This is similar to the <command>install</command> command
+           above, except it is invoked when "modprobe -r" is run.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>softdep <replaceable>modulename</replaceable> pre: <replaceable>modules...</replaceable> post: <replaceable>modules...</replaceable>
+        </term>
+       <listitem>
+         <para>
+            The <command>softdep</command> command allows you to specify soft,
+            or optional, module dependencies. <replaceable>modulename</replaceable>
+            can be used without these optional modules installed, but usually with
+            some features missing. For example, a driver for a storage HBA might
+            require another module be loaded in order to use management features.
+         </para>
+         <para>
+            pre-deps and post-deps modules are lists of names and/or aliases of other
+            modules that modprobe will attempt to install (or remove) in order
+            before and after the main module given in the
+            <replaceable>modulename</replaceable> argument.
+         </para>
+         <para>
+            Example: Assume "softdep c pre: a b post: d e" is provided in the
+            configuration. Running "modprobe c" is now equivalent to
+            "modprobe a b c d e" without the softdep.
+            Flags such as --use-blacklist are applied to all the specified
+            modules, while module parameters only apply to module c.
+         </para>
+         <para>
+            Note: if there are <command>install</command> or
+            <command>remove</command> commands with the same
+            <replaceable>modulename</replaceable> argument,
+            <command>softdep</command> takes precedence.
+         </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+  <refsect1>
+    <title>COMPATIBILITY</title>
+    <para>
+      A future version of module-init-tools will come with a strong warning
+      to avoid use of the <command>install</command> as explained above. This
+      will happen once support for soft dependencies in the kernel is complete.
+      That support will complement the existing softdep support within this
+      utility by providing such dependencies directly within the modules.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>COPYRIGHT</title>
+    <para>
+      This manual page originally Copyright 2004, Rusty Russell, IBM
+      Corporation. Maintained by Jon Masters and others.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>SEE ALSO</title>
+
+    <para><citerefentry>
+       <refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>modules.dep</refentrytitle><manvolnum>5</manvolnum>
+      </citerefentry>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
diff --git a/doc/modprobe.sgml b/doc/modprobe.sgml
new file mode 100644 (file)
index 0000000..a4a3b22
--- /dev/null
@@ -0,0 +1,515 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+  <!ENTITY debian  "<productname>Debian GNU/Linux</productname>">
+  <!ENTITY docbook "<productname>DocBook</productname>">
+  <!ENTITY sgml    "<abbrev>SGML</abbrev>">
+]>
+
+<!-- Stolen from manual page for docbook-to-man, DocBook source file
+     (C) 1999 W. Borgert debacle@debian.org
+
+     $Id: docbook-to-man.sgml,v 1.8 2002/04/27 15:28:02 debacle Exp $ -->
+
+<refentry>
+  <refentryinfo>
+    <address>
+      <email>jcm@jonmasters.org</email>
+    </address>
+    <author>
+      <firstname>Jon</firstname>
+      <surname>Masters</surname>
+    </author>
+    <date>2010-03-01</date>
+  </refentryinfo>
+  <refmeta>
+    <refentrytitle>modprobe</refentrytitle>
+    <manvolnum>8</manvolnum>
+  </refmeta>
+  <refnamediv>
+    <refname>modprobe</refname> <refpurpose>program to add and remove modules from the Linux Kernel</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>modprobe</command>
+      <arg><option>-v</option></arg>
+      <arg><option>-V</option></arg>
+      <arg><option>-C <replaceable>config-file</replaceable></option></arg>
+      <arg><option>-n</option></arg>
+      <arg><option>-i</option></arg>
+      <arg><option>-q</option></arg>
+      <arg><option>-b</option></arg>
+      <arg><option>-o</option> <replaceable>modulename</replaceable></arg>
+      <arg><replaceable>modulename</replaceable></arg>
+      <arg rep='repeat'><option><replaceable>module parameters</replaceable></option></arg>
+    </cmdsynopsis>
+    <cmdsynopsis>
+      <command>modprobe</command>
+      <arg>-r</arg>
+      <arg><option>-v</option></arg>
+      <arg><option>-n</option></arg>
+      <arg><option>-i</option></arg>
+      <arg rep='repeat'><option><replaceable>modulename</replaceable></option></arg>
+    </cmdsynopsis>
+    <cmdsynopsis>
+      <command>modprobe</command>
+      <arg>-l</arg>
+      <arg>-t <replaceable>dirname</replaceable></arg>
+      <arg><option><replaceable>wildcard</replaceable></option></arg>
+    </cmdsynopsis>
+    <cmdsynopsis>
+      <command>modprobe</command>
+      <arg>-c</arg>
+    </cmdsynopsis>
+    <cmdsynopsis>
+      <command>modprobe</command>
+      <arg>--dump-modversions</arg> <arg rep='repeat'><replaceable>filename</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>Description</title>
+
+    <para>
+      <command>modprobe</command> intelligently adds or removes a
+      module from the Linux kernel: note that for convenience, there
+      is no difference between _ and - in module names (automatic
+      underscore conversion is performed).
+      <command>modprobe</command> looks in the module directory
+      <filename>/lib/modules/`uname -r`</filename> for all
+      the modules and other files, except for the optional
+      <filename>/etc/modprobe.conf</filename> configuration file and
+      <filename>/etc/modprobe.d</filename> directory
+      (see <citerefentry>
+       <refentrytitle>modprobe.conf</refentrytitle><manvolnum>5</manvolnum>
+      </citerefentry>). <command>modprobe</command> will also use module
+      options specified on the kernel command line in the form of
+      &lt;module&gt;.&lt;option&gt;.
+    </para>
+    <para>
+      Note that unlike in 2.4 series Linux kernels (which are not supported
+      by this tool) this version of <command>modprobe</command> does not
+      do anything to the module itself: the work of resolving symbols
+      and understanding parameters is done inside the kernel.  So
+      module failure is sometimes accompanied by a kernel message: see
+      <citerefentry>
+       <refentrytitle>dmesg</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>.
+    </para>
+    <para>
+      <command>modprobe</command> expects an up-to-date
+      <filename>modules.dep.bin</filename> file (or fallback human
+      readable <filename>modules.dep</filename> file), as generated
+      by the corresponding <command>depmod</command> utility shipped
+      along with <command>modprobe</command> (see
+      <citerefentry><refentrytitle>depmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>).  This file lists what other modules each
+      module needs (if any), and <command>modprobe</command> uses this
+      to add or remove these dependencies automatically.
+    </para>
+    <para>
+      If any arguments are given after the
+      <replaceable>modulename</replaceable>, they are passed to the
+      kernel (in addition to any options listed in the configuration
+      file).
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>OPTIONS</title>
+    <variablelist>
+      <varlistentry>
+        <term><option>-a</option> <option>--all</option>
+        </term>
+        <listitem>
+          <para>Insert all module names on the command line.
+        </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-b</option> <option>--use-blacklist</option>
+        </term>
+        <listitem>
+         <para>
+           This option causes <command>modprobe</command> to apply the
+           <command>blacklist</command> commands in the configuration files
+           (if any) to module names as well.  It is usually used by
+           <citerefentry>
+             <refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum>
+           </citerefentry>.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-C</option> <option>--config</option>
+        </term>
+        <listitem>
+          <para>This option overrides the default configuration directory/file
+               (<filename>/etc/modprobe.d</filename> or 
+               <filename>/etc/modprobe.conf</filename>).
+         </para>
+          <para>
+           This option is passed through <command>install</command>
+           or <command>remove</command> commands to other
+           <command>modprobe</command> commands in the
+           MODPROBE_OPTIONS environment variable.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-c</option> <option>--showconfig</option>
+        </term>
+        <listitem>
+          <para>Dump out the effective configuration from the config directory
+                and exit.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>--dump-modversions</option>
+        </term>
+        <listitem>
+          <para>
+            Print out a list of module versioning information required by a
+            module. This option is commonly used by distributions in order to
+            package up a Linux kernel module using module versioning deps.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-d</option> <option>--dirname</option>
+        </term>
+        <listitem>
+          <para>
+            Directory where modules can be found,
+            <filename>/lib/modules/<replaceable>RELEASE</replaceable></filename>
+            by default.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>--first-time</option>
+        </term>
+        <listitem>
+          <para>
+           Normally, <command>modprobe</command> will succeed (and do
+           nothing) if told to insert a module which is already
+           present or to remove a module which isn't present.  This is
+           ideal for simple scripts; however, more complicated scripts often
+           want to know whether <command>modprobe</command> really
+           did something: this option makes modprobe fail in the
+           case that it actually didn't do anything.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>--force-vermagic</option>
+        </term>
+        <listitem>
+          <para>
+           Every module contains a small string containing important
+           information, such as the kernel and compiler versions.  If
+           a module fails to load and the kernel complains that the
+           "version magic" doesn't match, you can use this option to
+           remove it.  Naturally, this check is there for your
+           protection, so this using option is dangerous unless
+           you know what you're doing.
+        </para>
+        <para>
+           This applies to any modules inserted: both the module (or
+           alias) on the command line and any modules on which it depends.
+        </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>--force-modversion</option>
+        </term>
+        <listitem>
+          <para>
+           When modules are compiled with CONFIG_MODVERSIONS set, a
+           section detailing the versions of every interfaced used
+           by (or supplied by) the module is created.  If a
+           module fails to load and the kernel complains that the
+           module disagrees about a version of some interface, you
+           can use "--force-modversion" to remove the version
+           information altogether.  Naturally, this check is there
+           for your protection, so using this option is dangerous
+           unless you know what you're doing.
+        </para>
+        <para>
+           This applies any modules inserted: both the module (or
+           alias) on the command line and any modules on which it depends.
+        </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-f</option> <option>--force</option>
+        </term>
+        <listitem>
+          <para>
+           Try to strip any versioning information from the module
+           which might otherwise stop it from loading: this is the
+           same as using both <option>--force-vermagic</option> and
+           <option>--force-modversion</option>.  Naturally, these
+           checks are there for your protection, so using this option
+           is dangerous unless you know what you are doing.
+        </para>
+        <para>
+           This applies to any modules inserted: both the module (or
+           alias) on the command line and any modules it on which it depends.
+        </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-i</option> <option>--ignore-install</option> <option>--ignore-remove</option>
+        </term>
+        <listitem>
+          <para>This option causes <command>modprobe</command> to
+               ignore <command>install</command> and
+               <command>remove</command> commands in the
+               configuration file (if any) for the module specified on the
+               command line (any dependent modules are still subject
+               to commands set for them in the configuration file). Both
+               <command>install</command> and <command>remove</command>
+               commands will currently be ignored when this option is used
+               regardless of whether the request was more specifically
+               made with only one or other (and not both) of
+               <option>--ignore-install</option> or
+               <option>--ignore-remove</option>.
+               See <citerefentry>
+<refentrytitle>modprobe.conf</refentrytitle><manvolnum>5</manvolnum>
+</citerefentry>.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-l</option> <option>--list</option>
+        </term>
+        <listitem>
+          <para>List all modules matching the given wildcard (or "*"
+               if no wildcard is given).  This option is provided for
+               backwards compatibility and may go away in future: see
+           <citerefentry>
+             <refentrytitle>find</refentrytitle><manvolnum>1</manvolnum>
+           </citerefentry> and
+           <citerefentry>
+             <refentrytitle>basename</refentrytitle><manvolnum>1</manvolnum>
+           </citerefentry> for a more flexible alternative.
+        </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-n</option> <option>--dry-run</option>
+        <option>--show</option>
+        </term>
+        <listitem>
+          <para>This option does everything but actually insert or
+               delete the modules (or run the install or remove
+               commands).  Combined with <option>-v</option>, it is
+               useful for debugging problems. For historical reasons
+               both <option>--dry-run</option> and <option>--show</option>
+               actually mean the same thing and are interchangeable.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-o</option> <option>--name</option>
+        </term>
+        <listitem>
+          <para>
+           This option tries to rename the module which is being
+           inserted into the kernel.  Some testing modules can
+           usefully be inserted multiple times, but the kernel
+           refuses to have two modules of the same name.  Normally,
+           modules should not require multiple insertions, as that
+           would make them useless if there were no module support.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-q</option> <option>--quiet</option>
+        </term>
+        <listitem>
+          <para>
+           With this flag, <command>modprobe</command> won't print an error
+           message if you try to remove or insert a module it can't find (and
+           isn't an alias or
+           <command>install</command>/<command>remove</command> command).
+           However, it will still return with a non-zero exit status. The
+           kernel uses this to opportunistically probe for modules which might
+           exist using request_module.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-R</option> <option>--resolve-alias</option>
+        </term>
+        <listitem>
+          <para>
+           Print all module names matching an alias. This can be useful
+           for debugging module alias problems.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-r</option> <option>--remove</option>
+        </term>
+        <listitem>
+          <para>
+           This option causes <command>modprobe</command> to remove
+           rather than insert a module.  If the modules it depends on
+           are also unused, <command>modprobe</command> will try to
+           remove them too.  Unlike insertion, more than one module
+           can be specified on the command line (it does not make
+           sense to specify module parameters when removing modules).
+         </para>
+         <para>
+           There is usually no reason to remove modules, but some
+           buggy modules require it.  Your distribution kernel may not
+           have been built to support removal of modules at all.
+         </para>
+        </listitem>
+     </varlistentry>
+     <varlistentry>
+        <term><option>-S</option> <option>--set-version</option>
+        </term>
+        <listitem>
+          <para>
+           Set the kernel version, rather than using
+           <citerefentry><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry> to decide on the kernel version (which dictates where to
+           find the modules).
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>--show-depends</option>
+        </term>
+        <listitem>
+          <para>
+           List the dependencies of a module (or alias), including
+           the module itself.  This produces a (possibly empty) set
+           of module filenames, one per line, each starting with
+           "insmod" and is typically used by distributions to determine
+           which modules to include when generating initrd/initramfs images.
+           <command>Install</commnd> commands which apply are shown prefixed by
+           "install".  It does not run any of the install commands.  Note that
+           <citerefentry><refentrytitle>modinfo</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+           can be used to extract dependencies of a module from the
+           module itself, but knows nothing of aliases or install commands.
+         </para>
+        </listitem>
+     </varlistentry>
+     <varlistentry>
+        <term><option>-s</option> <option>--syslog</option>
+        </term>
+        <listitem>
+          <para>
+           This option causes any error messages to go through the
+           syslog mechanism (as LOG_DAEMON with level LOG_NOTICE)
+           rather than to standard error.  This is also automatically
+           enabled when stderr is unavailable.
+         </para>
+          <para>
+           This option is passed through <command>install</command>
+           or <command>remove</command> commands to other
+           <command>modprobe</command> commands in the
+           MODPROBE_OPTIONS environment variable.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-t</option> <option>--type</option>
+        </term>
+        <listitem>
+          <para>Restrict <option>-l</option> to modules
+               in directories matching the
+               <replaceable>dirname</replaceable> given.  This option
+               is provided for backwards compatibility and may go
+               away in future: see
+           <citerefentry>
+             <refentrytitle>find</refentrytitle><manvolnum>1</manvolnum>
+           </citerefentry>
+           and
+           <citerefentry>
+             <refentrytitle>basename</refentrytitle><manvolnum>1</manvolnum>
+           </citerefentry> for a more flexible alternative.
+        </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-V</option> <option>--version</option>
+        </term>
+        <listitem>
+          <para>Show version of program and exit.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-v</option> <option>--verbose</option>
+        </term>
+        <listitem>
+          <para>
+           Print messages about what the program is doing.  Usually
+           <command>modprobe</command> only prints messages if
+           something goes wrong.
+         </para>
+          <para>
+           This option is passed through <command>install</command>
+           or <command>remove</command> commands to other
+           <command>modprobe</command> commands in the
+           MODPROBE_OPTIONS environment variable.
+         </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+  <refsect1>
+    <title>ENVIRONMENT</title>
+    <para>
+      The MODPROBE_OPTIONS environment variable can also be used to
+      pass arguments to <command>modprobe</command>.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>COPYRIGHT</title>
+    <para>
+      This manual page originally Copyright 2002, Rusty Russell, IBM
+      Corporation. Maintained by Jon Masters and others.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>SEE ALSO</title>
+    <para>
+      <citerefentry>
+       <refentrytitle>modprobe.conf</refentrytitle><manvolnum>5</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>modprobe.d</refentrytitle><manvolnum>5</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>insmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>rmmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>lsmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>modinfo</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
diff --git a/doc/modules.dep.sgml b/doc/modules.dep.sgml
new file mode 100644 (file)
index 0000000..8e804c9
--- /dev/null
@@ -0,0 +1,91 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+  <!ENTITY debian  "<productname>Debian GNU/Linux</productname>">
+  <!ENTITY docbook "<productname>DocBook</productname>">
+  <!ENTITY sgml    "<abbrev>SGML</abbrev>">
+]>
+
+<!-- Stolen from manual page for docbook-to-man, DocBook source file
+     (C) 1999 W. Borgert debacle@debian.org
+
+     $Id: docbook-to-man.sgml,v 1.8 2002/04/27 15:28:02 debacle Exp $ -->
+
+<refentry>
+  <refentryinfo>
+    <address>
+      <email>jcm@jonmasters.org</email>
+    </address>
+    <author>
+      <firstname>Jon</firstname>
+      <surname>Masters</surname>
+    </author>
+    <date>2010-03-01</date>
+  </refentryinfo>
+  <refmeta>
+    <refentrytitle>modules.dep.bin</refentrytitle>
+    <manvolnum>5</manvolnum>
+    <refentrytitle>modules.dep</refentrytitle>
+    <manvolnum>5</manvolnum>
+  </refmeta>
+  <refnamediv>
+    <refname>modules.dep.bin</refname><refname>modules.dep</refname> <refpurpose>Module dependency information</refpurpose>
+  </refnamediv>
+  <refsect1>
+    <title>DESCRIPTION</title>
+
+    <para>
+      The <filename>modules.dep.bin</filename> as generated by
+      module-init-tools <command>depmod</command>, lists the
+      dependencies for every module in the directories under
+      <filename>/lib/modules/</filename><replaceable>version</replaceable>,
+      where <filename>modules.dep.bin</filename> (or the human readable
+      version <filename>modules.dep</filename>) is also located. It is
+      used by utilities such as <command>modprobe</command>. The
+      binary version will be used by default, if it was generated by
+      a compatible version of <command>depmod</commnd>, with fallback
+      to the generic <filename>modules.dep</filename>.
+    </para>
+    <para>
+      These files are not intended for editing or use by any additional
+      utilities as their format is subject to change in the future. You
+      should use the
+      <citerefentry><refentrytitle>modinfo</refentrytitle><manvolnum>8</manvolnum></citerefentry> command to obtain information about modules in a future
+      proof and compatible fashion rather than touching these files.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>COPYRIGHT</title>
+    <para>
+      This manual page originally Copyright 2002, Rusty Russell, IBM
+      Corporation. Maintained by Jon Masters and others.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>SEE ALSO</title>
+
+    <para>
+      <citerefentry>
+       <refentrytitle>depmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
diff --git a/doc/rmmod.sgml b/doc/rmmod.sgml
new file mode 100644 (file)
index 0000000..bd009b7
--- /dev/null
@@ -0,0 +1,159 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+  <!ENTITY debian  "<productname>Debian GNU/Linux</productname>">
+  <!ENTITY docbook "<productname>DocBook</productname>">
+  <!ENTITY sgml    "<abbrev>SGML</abbrev>">
+]>
+
+<!-- Stolen from manual page for docbook-to-man, DocBook source file
+     (C) 1999 W. Borgert debacle@debian.org
+
+     $Id: docbook-to-man.sgml,v 1.8 2002/04/27 15:28:02 debacle Exp $ -->
+
+<refentry>
+  <refentryinfo>
+    <address>
+      <email>jcm@jonmasters.org</email>
+    </address>
+    <author>
+      <firstname>Jon</firstname>
+      <surname>Masters</surname>
+    </author>
+    <date>2010-03-01</date>
+  </refentryinfo>
+  <refmeta>
+    <refentrytitle>rmmod</refentrytitle>
+    <manvolnum>8</manvolnum>
+  </refmeta>
+  <refnamediv>
+    <refname>rmmod</refname> <refpurpose>simple program to remove a module from the Linux Kernel</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>rmmod</command>
+      <arg><option>-f</option></arg>
+      <arg><option>-w</option></arg>
+      <arg><option>-s</option></arg>
+      <arg><option>-v</option></arg>
+      <arg><replaceable>modulename</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>DESCRIPTION</title>
+
+    <para><command>rmmod</command> is a trivial program to remove a
+      module (when module unloading support is provided) from the kernel.
+      Most users will want to use
+      <citerefentry>
+       <refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry> with the <option>-r</option> option instead.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>OPTIONS</title>
+    <variablelist>
+      <varlistentry>
+        <term><option>-v</option> <option>--verbose</option>
+        </term>
+        <listitem>
+          <para>
+           Print messages about what the program is doing.
+           Usually <command>rmmod</command> prints messages
+           only if something goes wrong.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-f</option> <option>--force</option>
+        </term>
+        <listitem>
+          <para>
+           This option can be extremely dangerous: it has no effect unless
+           CONFIG_MODULE_FORCE_UNLOAD was set when the kernel was
+           compiled.  With this option, you can remove modules which are
+           being used, or which are not designed to be removed, or have
+           been marked as unsafe (see <citerefentry>
+       <refentrytitle>lsmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>).
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-w</option> <option>--wait</option>
+        </term>
+        <listitem>
+          <para>
+           Normally, <command>rmmod</command> will refuse to
+           unload modules which are in use.  With this option,
+           <command>rmmod</command> will isolate the module, and
+           wait until the module is no longer used.  Nothing new
+           will be able to use the module, but it's up to you to
+           make sure the current users eventually finish with it.
+           See <citerefentry>
+       <refentrytitle>lsmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>) for information on usage counts.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-s</option> <option>--syslog</option>
+        </term>
+        <listitem>
+          <para>
+           Send errors to syslog instead of standard error.
+         </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-V</option> <option>--version</option>
+        </term>
+        <listitem>
+          <para>
+           Show version of program and exit.
+         </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+  <refsect1>
+    <title>COPYRIGHT</title>
+    <para>
+      This manual page originally Copyright 2002, Rusty Russell, IBM
+      Corporation. Maintained by Jon Masters and others.
+    </para>
+  </refsect1>
+  <refsect1>
+    <title>SEE ALSO</title>
+
+    <para>
+      <citerefentry>
+       <refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>insmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>,
+      <citerefentry>
+       <refentrytitle>lsmod</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>
+      <citerefentry>
+       <refentrytitle>modinfo</refentrytitle><manvolnum>8</manvolnum>
+      </citerefentry>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
diff --git a/elfops.c b/elfops.c
new file mode 100644 (file)
index 0000000..10e80ea
--- /dev/null
+++ b/elfops.c
@@ -0,0 +1,116 @@
+/* The nasty work of reading 32 and 64-bit modules is in here. */
+#include <elf.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include "depmod.h"
+#include "util.h"
+#include "logging.h"
+#include "elfops.h"
+#include "tables.h"
+#include "zlibsupport.h"
+
+#include "testing.h"
+
+/* Symbol types, returned by load_dep_syms */
+static const char *weak_sym = "W";
+static const char *undef_sym = "U";
+
+/* dump_modversions helper */
+static const char *skip_dot(const char *str)
+{
+       /* For our purposes, .foo matches foo.  PPC64 needs this. */
+       if (str && str[0] == '.')
+               return str + 1;
+       return str;
+}
+
+#define ELF32BIT
+#include "elfops_core.c"
+#undef ELF32BIT
+
+#define ELF64BIT
+#include "elfops_core.c"
+#undef ELF64BIT
+
+/*
+ * Check ELF file header.
+ */
+static int elf_ident(void *file, unsigned long fsize, int *conv)
+{
+       /* "\177ELF" <byte> where byte = 001 for 32-bit, 002 for 64 */
+       unsigned char *ident = file;
+
+       if (fsize < EI_CLASS || memcmp(file, ELFMAG, SELFMAG) != 0)
+               return -ENOEXEC;        /* Not an ELF object */
+       if (ident[EI_DATA] == 0 || ident[EI_DATA] > 2)
+               return -EINVAL;         /* Unknown endianness */
+
+       if (conv != NULL)
+               *conv = native_endianness() != ident[EI_DATA];
+       return ident[EI_CLASS];
+}
+
+/*
+ * grab_elf_file - read ELF file into memory
+ * @pathame: file to load
+ *
+ * Returns NULL, and errno set on error.
+ */
+struct elf_file *grab_elf_file(const char *pathname)
+{
+       struct elf_file *file;
+
+       file = malloc(sizeof(*file));
+       if (!file) {
+               errno = ENOMEM;
+               goto fail;
+       }
+       file->pathname = strdup(pathname);
+       if (!file->pathname) {
+               errno = ENOMEM;
+               goto fail_free_file;
+       }
+       file->data = grab_file(pathname, &file->len);
+       if (!file->data)
+               goto fail_free_pathname;
+
+       switch (elf_ident(file->data, file->len, &file->conv)) {
+       case ELFCLASS32:
+               file->ops = &mod_ops32;
+               break;
+       case ELFCLASS64:
+               file->ops = &mod_ops64;
+               break;
+       case -ENOEXEC: /* Not an ELF object */
+       case -EINVAL: /* Unknown endianness */
+       default: /* Unknown word size */
+               errno = ENOEXEC;
+               goto fail;
+       }
+       return file;
+
+fail_free_pathname:
+       free(file->pathname);
+fail_free_file:
+       free(file);
+fail:
+       return NULL;
+}
+
+void release_elf_file(struct elf_file *file)
+{
+       int err = errno;
+
+       if (!file)
+               return;
+
+       release_file(file->data, file->len);
+       free(file->pathname);
+       free(file);
+
+       errno = err;
+}
diff --git a/elfops.h b/elfops.h
new file mode 100644 (file)
index 0000000..266c8cd
--- /dev/null
+++ b/elfops.h
@@ -0,0 +1,84 @@
+#ifndef MODINITTOOLS_MODULEOPS_H
+#define MODINITTOOLS_MODULEOPS_H
+#include <stdio.h>
+#include <stdint.h>
+#include "logging.h"
+
+/* All the icky stuff to do with manipulating 64 and 32-bit modules
+   belongs here. */
+struct modver_info32
+{
+       uint32_t crc;
+       char name[64 - sizeof(uint32_t)];
+};
+
+struct modver_info64
+{
+       uint64_t crc;
+       char name[64 - sizeof(uint64_t)];
+};
+
+struct elf_file
+{
+       char *pathname;
+
+       /* File operations */
+       struct module_ops *ops;
+
+       /* Convert endian? */
+       int conv;
+
+       /* File contents and length. */
+       void *data;
+       unsigned long len;
+};
+
+/* Tables extracted from module by ops->fetch_tables(). */
+struct module_tables
+{
+       unsigned int pci_size;
+       void *pci_table;
+       unsigned int usb_size;
+       void *usb_table;
+       unsigned int ieee1394_size;
+       void *ieee1394_table;
+       unsigned int ccw_size;
+       void *ccw_table;
+       unsigned int pnp_size;
+       void *pnp_table;
+       unsigned int pnp_card_size;
+       unsigned int pnp_card_offset;
+       void *pnp_card_table;
+       unsigned int input_size;
+       void *input_table;
+       unsigned int input_table_size;
+       unsigned int serio_size;
+       void *serio_table;
+       unsigned int of_size;
+       void *of_table;
+};
+
+struct module_ops
+{
+       void *(*load_section)(struct elf_file *module,
+               const char *secname, unsigned long *secsize);
+       struct string_table *(*load_strings)(struct elf_file *module,
+               const char *secname, struct string_table *tbl);
+       struct string_table *(*load_symbols)(struct elf_file *module,
+               uint64_t **versions);
+       struct string_table *(*load_dep_syms)(struct elf_file *module,
+               struct string_table **types, uint64_t **versions);
+       void (*fetch_tables)(struct elf_file *module,
+               struct module_tables *tables);
+       char *(*get_aliases)(struct elf_file *module, unsigned long *size);
+       char *(*get_modinfo)(struct elf_file *module, unsigned long *size);
+       void (*strip_section)(struct elf_file *module, const char *secname);
+       int (*dump_modvers)(struct elf_file *module);
+};
+
+extern struct module_ops mod_ops32, mod_ops64;
+
+struct elf_file *grab_elf_file(const char *pathname);
+void release_elf_file(struct elf_file *file);
+
+#endif /* MODINITTOOLS_MODULEOPS_H */
diff --git a/elfops_core.c b/elfops_core.c
new file mode 100644 (file)
index 0000000..58a7943
--- /dev/null
@@ -0,0 +1,456 @@
+#if defined(ELF32BIT)
+
+#define PERBIT(x) x##32
+#define ElfPERBIT(x) Elf32_##x
+#define ELFPERBIT(x) ELF32_##x
+/* 32-bit unsigned integer */
+#define Elf32_Uint Elf32_Word
+
+#elif defined(ELF64BIT)
+
+#define PERBIT(x) x##64
+#define ElfPERBIT(x) Elf64_##x
+#define ELFPERBIT(x) ELF64_##x
+/* 64-bit unsigned integer */
+#define Elf64_Uint Elf64_Xword
+
+#else
+#  error "Undefined ELF word length"
+#endif
+
+static void *PERBIT(get_section)(struct elf_file *module,
+                                const char *secname,
+                                ElfPERBIT(Shdr) **sechdr,
+                                unsigned long *secsize)
+{
+       void *data = module->data;
+       unsigned long len = module->len;
+       int conv = module->conv;
+
+       ElfPERBIT(Ehdr) *hdr;
+       ElfPERBIT(Shdr) *sechdrs;
+       ElfPERBIT(Off) e_shoff;
+       ElfPERBIT(Half) e_shnum, e_shstrndx;
+       ElfPERBIT(Off) secoffset;
+
+       const char *secnames;
+       unsigned int i;
+
+       *secsize = 0;
+
+       if (len <= 0 || len < sizeof(*hdr))
+               return NULL;
+
+       hdr = data;
+       e_shoff = END(hdr->e_shoff, conv);
+       e_shnum = END(hdr->e_shnum, conv);
+       e_shstrndx = END(hdr->e_shstrndx, conv);
+
+       if (len < e_shoff + e_shnum * sizeof(sechdrs[0]))
+               return NULL;
+
+       sechdrs = data + e_shoff;
+
+       if (len < END(sechdrs[e_shstrndx].sh_offset, conv))
+               return NULL;
+
+       /* Find section by name; return header, pointer and size. */
+       secnames = data + END(sechdrs[e_shstrndx].sh_offset, conv);
+       for (i = 1; i < e_shnum; i++) {
+               if (streq(secnames + END(sechdrs[i].sh_name, conv), secname)) {
+                       *secsize = END(sechdrs[i].sh_size, conv);
+                       secoffset = END(sechdrs[i].sh_offset, conv);
+                       if (sechdr)
+                               *sechdr = sechdrs + i;
+                       if (len < secoffset + *secsize)
+                               return NULL;
+                       return data + secoffset;
+               }
+       }
+       return NULL;
+}
+
+/* Load the given section: NULL on error. */
+static void *PERBIT(load_section)(struct elf_file *module,
+                                 const char *secname,
+                                 unsigned long *secsize)
+{
+       return PERBIT(get_section)(module, secname, NULL, secsize);
+}
+
+static struct string_table *PERBIT(load_strings)(struct elf_file *module,
+                                                const char *secname,
+                                                struct string_table *tbl)
+{
+       unsigned long size;
+       const char *strings;
+
+       strings = PERBIT(load_section)(module, secname, &size);
+       if (strings) {
+               if (strings[size-1] != 0) {
+                       warn("%s may be corrupt; an unterminated string"
+                            " was found at the end of section %s\n",
+                            module->pathname, secname);
+               }
+               /* Skip any zero padding. */
+               while (!strings[0]) {
+                       strings++;
+                       if (size-- <= 1)
+                               return tbl;
+               }
+               for (; strings; strings = next_string(strings, &size))
+                       tbl = NOFAIL(strtbl_add(strings, tbl));
+       }
+       return tbl;
+}
+
+static struct string_table *PERBIT(load_symbols)(struct elf_file *module,
+                                                 uint64_t **versions)
+{
+       struct string_table *symtbl = NULL;
+
+       if (versions) {
+               static const char crc[] = "__crc_";
+               static const int crc_len = sizeof(crc) - 1;
+               unsigned int num_syms, i;
+               unsigned long size;
+               ElfPERBIT(Sym) *syms;
+               char *strings;
+               int conv;
+
+               *versions = NULL;
+               strings = PERBIT(load_section)(module, ".strtab", &size);
+               syms = PERBIT(load_section)(module, ".symtab", &size);
+               if (!strings || !syms)
+                       goto fallback;
+               num_syms = size / sizeof(syms[0]);
+               *versions = NOFAIL(calloc(sizeof(**versions), num_syms));
+
+               conv = module->conv;
+               for (i = 1; i < num_syms; i++) {
+                       const char *name;
+                       name = strings + END(syms[i].st_name, conv);
+                       if (strncmp(name, crc, crc_len) != 0)
+                               continue;
+                       name += crc_len;
+                       symtbl = NOFAIL(strtbl_add(name, symtbl));
+                       (*versions)[symtbl->cnt - 1] = END(syms[i].st_value,
+                                       conv);
+               }
+               if (!symtbl) {
+                       /* Either this module does not export any symbols, or
+                        * it was compiled without CONFIG_MODVERSIONS. If the
+                        * latter, we will print a warning in load_dep_syms,
+                        * so just silently fallback to __ksymtab_strings in
+                        * both cases.
+                        */
+                       free(*versions);
+                       *versions = NULL;
+                       goto fallback;
+               }
+               return symtbl;
+       }
+fallback:
+       return PERBIT(load_strings)(module, "__ksymtab_strings", symtbl);
+}
+
+static char *PERBIT(get_aliases)(struct elf_file *module, unsigned long *size)
+{
+       return PERBIT(load_section)(module, ".modalias", size);
+}
+
+static char *PERBIT(get_modinfo)(struct elf_file *module, unsigned long *size)
+{
+       return PERBIT(load_section)(module, ".modinfo", size);
+}
+
+#ifndef STT_REGISTER
+#define STT_REGISTER    13              /* Global register reserved to app. */
+#endif
+
+static struct string_table *PERBIT(load_dep_syms)(struct elf_file *module,
+                                                 struct string_table **types,
+                                                 uint64_t **versions)
+{
+       unsigned int i, num_syms;
+       unsigned int j, num_symvers, versions_size;
+       unsigned long size;
+       char *strings;
+       ElfPERBIT(Sym) *syms;
+       ElfPERBIT(Ehdr) *hdr;
+       struct PERBIT(modver_info) **symvers;
+       int handle_register_symbols;
+       struct string_table *names;
+       int conv;
+
+       names = NULL;
+       *types = NULL;
+       symvers = NULL;
+       num_symvers = versions_size = 0;
+
+       if (versions) {
+               int ok = 1;
+               *versions = NULL;
+               struct PERBIT(modver_info) *symvers_sec;
+
+               symvers_sec = module->ops->load_section(module, "__versions",
+                               &size);
+               if (!symvers_sec) {
+                       warn("%s is built without modversions",
+                                       module->pathname);
+                       ok = 0;
+               }
+               if (size % sizeof(symvers[0]) != 0) {
+                       warn("invalid __versions section size in %s",
+                                       module->pathname);
+                       ok = 0;
+               }
+               if (ok) {
+                       num_symvers = size / sizeof(symvers_sec[0]);
+                       /* symvers is used to keep track of each visited entry.
+                        * The table also contains the fake struct_module /
+                        * module_layout symbol which we don't want to miss.
+                        */
+                       symvers = NOFAIL(malloc(num_symvers *
+                                               sizeof(symvers[0])));
+                       for (j = 0; j < num_symvers; j++)
+                               symvers[j] = &symvers_sec[j];
+               } else {
+                       versions = NULL;
+               }
+       }
+
+       strings = PERBIT(load_section)(module, ".strtab", &size);
+       syms = PERBIT(load_section)(module, ".symtab", &size);
+       if (!strings || !syms) {
+               warn("Couldn't find symtab and strtab in module %s\n",
+                    module->pathname);
+               goto out;
+       }
+
+       num_syms = size / sizeof(syms[0]);
+       hdr = module->data;
+       conv = module->conv;
+       if (versions) {
+               versions_size = num_syms;
+               *versions = NOFAIL(calloc(sizeof(**versions), versions_size));
+       }
+
+       handle_register_symbols =
+               (END(hdr->e_machine, conv) == EM_SPARC ||
+                END(hdr->e_machine, conv) == EM_SPARCV9);
+
+       for (i = 1; i < num_syms; i++) {
+               if (END(syms[i].st_shndx, conv) == SHN_UNDEF) {
+                       /* Look for symbol */
+                       const char *name;
+                       int weak;
+
+                       name = strings + END(syms[i].st_name, conv);
+
+                       /* Not really undefined: sparc gcc 3.3 creates
+                           U references when you have global asm
+                           variables, to avoid anyone else misusing
+                           them. */
+                       if (handle_register_symbols
+                           && (ELFPERBIT(ST_TYPE)(END(syms[i].st_info, conv))
+                               == STT_REGISTER))
+                               continue;
+
+                       weak = (ELFPERBIT(ST_BIND)(END(syms[i].st_info, conv))
+                               == STB_WEAK);
+                       names = NOFAIL(strtbl_add(name, names));
+                       *types = NOFAIL(strtbl_add(weak ? weak_sym : undef_sym,
+                               *types));
+
+                       if (!versions)
+                               continue;
+                       /* Not optimal, but the number of required symbols
+                        * is usually not huge and this is only called by
+                        * depmod.
+                        */
+                       for (j = 0; j < num_symvers; j++) {
+                               struct PERBIT(modver_info) *info = symvers[j];
+
+                               if (!info)
+                                       continue;
+                               if (streq(name, info->name)) {
+                                       (*versions)[names->cnt - 1] =
+                                               END(info->crc, conv);
+                                       symvers[j] = NULL;
+                                       break;
+                               }
+                       }
+               }
+       }
+       /* add struct_module / module_layout */
+       for (j = 0; j < num_symvers; j++) {
+               struct PERBIT(modver_info) *info = symvers[j];
+
+               if (!info)
+                       continue;
+               if ((names ? names->cnt : 0) >= versions_size) {
+                       versions_size++;
+                       *versions = NOFAIL(realloc(*versions, versions_size));
+               }
+               names = NOFAIL(strtbl_add(info->name, names));
+               *types = NOFAIL(strtbl_add(undef_sym, *types));
+               (*versions)[names->cnt - 1] = END(info->crc, conv);
+       }
+out:
+       free(symvers);
+       return names;
+}
+
+static void *PERBIT(deref_sym)(ElfPERBIT(Ehdr) *hdr,
+                              ElfPERBIT(Shdr) *sechdrs,
+                              ElfPERBIT(Sym) *sym,
+                              unsigned int *secsize,
+                              int conv)
+{
+       /* In BSS?  Happens for empty device tables on
+        * recent GCC versions. */
+       if (END(sechdrs[END(sym->st_shndx, conv)].sh_type,conv) == SHT_NOBITS)
+               return NULL;
+
+       if (secsize)
+               *secsize = END(sym->st_size, conv);
+       return (void *)hdr
+               + END(sechdrs[END(sym->st_shndx, conv)].sh_offset, conv)
+               + END(sym->st_value, conv);
+}
+
+/* FIXME: Check size, unless we end up using aliases anyway --RR */
+static void PERBIT(fetch_tables)(struct elf_file *module,
+                                struct module_tables *tables)
+{
+       unsigned int i;
+       unsigned long size;
+       char *strings;
+       ElfPERBIT(Ehdr) *hdr;
+       ElfPERBIT(Sym) *syms;
+       ElfPERBIT(Shdr) *sechdrs;
+       int conv;
+
+       hdr = module->data;
+       conv = module->conv;
+
+       sechdrs = (void *)hdr + END(hdr->e_shoff, conv);
+       strings = PERBIT(load_section)(module, ".strtab", &size);
+       syms = PERBIT(load_section)(module, ".symtab", &size);
+
+       /* Don't warn again: we already have above */
+       if (!strings || !syms)
+               return;
+
+       memset(tables, 0x00, sizeof(struct module_tables));
+
+       for (i = 0; i < size / sizeof(syms[0]); i++) {
+               char *name = strings + END(syms[i].st_name, conv);
+
+               if (!tables->pci_table && streq(name, "__mod_pci_device_table")) {
+                       tables->pci_size = PERBIT(PCI_DEVICE_SIZE);
+                       tables->pci_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
+                                                             NULL, conv);
+               }
+               else if (!tables->usb_table && streq(name, "__mod_usb_device_table")) {
+                       tables->usb_size = PERBIT(USB_DEVICE_SIZE);
+                       tables->usb_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
+                                                             NULL, conv);
+               }
+               else if (!tables->ccw_table && streq(name, "__mod_ccw_device_table")) {
+                       tables->ccw_size = PERBIT(CCW_DEVICE_SIZE);
+                       tables->ccw_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
+                                                             NULL, conv);
+               }
+               else if (!tables->ieee1394_table && streq(name, "__mod_ieee1394_device_table")) {
+                       tables->ieee1394_size = PERBIT(IEEE1394_DEVICE_SIZE);
+                       tables->ieee1394_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
+                                                                  NULL, conv);
+               }
+               else if (!tables->pnp_table && streq(name, "__mod_pnp_device_table")) {
+                       tables->pnp_size = PERBIT(PNP_DEVICE_SIZE);
+                       tables->pnp_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
+                                                             NULL, conv);
+               }
+               else if (!tables->pnp_card_table && streq(name, "__mod_pnp_card_device_table")) {
+                       tables->pnp_card_size = PERBIT(PNP_CARD_DEVICE_SIZE);
+                       tables->pnp_card_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
+                                                                  NULL, conv);
+                       tables->pnp_card_offset = PERBIT(PNP_CARD_DEVICE_OFFSET);
+               }
+               else if (!tables->input_table && streq(name, "__mod_input_device_table")) {
+                       tables->input_size = PERBIT(INPUT_DEVICE_SIZE);
+                       tables->input_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
+                                                               &tables->input_table_size,
+                                                               conv);
+               }
+               else if (!tables->serio_table && streq(name, "__mod_serio_device_table")) {
+                       tables->serio_size = PERBIT(SERIO_DEVICE_SIZE);
+                       tables->serio_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
+                                                               NULL, conv);
+               }
+               else if (!tables->of_table && streq(name, "__mod_of_device_table")) {
+                       tables->of_size = PERBIT(OF_DEVICE_SIZE);
+                       tables->of_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
+                                                            NULL, conv);
+               }
+       }
+}
+
+/*
+ * strip_section - tell the kernel to ignore the named section
+ */
+static void PERBIT(strip_section)(struct elf_file *module, const char *secname)
+{
+       void *p;
+       ElfPERBIT(Shdr) *sechdr;
+       unsigned long secsize;
+
+       p = PERBIT(get_section)(module, secname, &sechdr, &secsize);
+       if (p) {
+               ElfPERBIT(Uint) mask;
+               mask = ~((ElfPERBIT(Uint))SHF_ALLOC);
+               sechdr->sh_flags &= END(mask, module->conv);
+       }
+}
+
+static int PERBIT(dump_modversions)(struct elf_file *module)
+{
+       unsigned long secsize;
+       struct PERBIT(modver_info) *info;
+       int n = 0;
+
+       info = module->ops->load_section(module, "__versions", &secsize);
+       if (!info)
+               return 0; /* not a kernel module */
+       if (secsize % sizeof(*info) != 0)
+               return -1; /* invalid section size */
+
+       for (n = 0; n < secsize / sizeof(*info); n++) {
+#if defined(ELF32BIT)
+               printf("0x%08lx\t%s\n", (unsigned long)
+#else /* defined(ELF64BIT) */
+               printf("0x%08llx\t%s\n", (unsigned long long)
+#endif
+                       END(info[n].crc, module->conv),
+                       skip_dot(info[n].name));
+       }
+       return n;
+}
+
+struct module_ops PERBIT(mod_ops) = {
+       .load_section   = PERBIT(load_section),
+       .load_strings   = PERBIT(load_strings),
+       .load_symbols   = PERBIT(load_symbols),
+       .load_dep_syms  = PERBIT(load_dep_syms),
+       .fetch_tables   = PERBIT(fetch_tables),
+       .get_aliases    = PERBIT(get_aliases),
+       .get_modinfo    = PERBIT(get_modinfo),
+       .strip_section  = PERBIT(strip_section),
+       .dump_modvers   = PERBIT(dump_modversions),
+};
+
+#undef PERBIT
+#undef ElfPERBIT
+#undef ELFPERBIT
diff --git a/extra/modprobe.d/aliases.conf b/extra/modprobe.d/aliases.conf
new file mode 100644 (file)
index 0000000..10ab609
--- /dev/null
@@ -0,0 +1,167 @@
+# These are the standard aliases for devices and kernel drivers.
+# This file does not need to be modified.
+#
+# No new aliases should be added to this file, please file a bug against
+# the kernel for any aliases which are still not built-in.
+
+# network protocols ##########################################################
+# alias net-pf-1  unix
+# alias net-pf-2  ipv4
+# alias net-pf-3  ax25
+# alias net-pf-4  ipx
+# alias net-pf-5  appletalk
+# alias net-pf-6  netrom
+# 7 BRIDGE
+# alias net-pf-8  atm
+# alias net-pf-9  x25
+# alias net-pf-10 ipv6
+# alias net-pf-11 rose
+# alias net-pf-12 decnet
+# 13 NETBEUI
+# alias net-pf-15 af_key
+# alias net-pf-16 af_netlink
+# alias net-pf-17 af_packet
+# 18 ASH
+# alias net-pf-19 econet
+# alias net-pf-20 atm
+# 22 SNA
+# alias net-pf-23 irda
+# alias net-pf-24 pppoe
+# 25 WANROUTER
+# alias net-pf-26 llc2
+# alias net-pf-31 bluetooth
+# alias net-pf-33 af_rxrpc
+
+alias net-pf-16-proto-1 wire
+alias net-pf-16-proto-3 ip_queue
+# alias net-pf-16-proto-4 inet_diag
+# alias net-pf-16-proto-5 ipt_ULOG
+# alias net-pf-16-proto-6 xfrm_user
+alias net-pf-16-proto-8 scsi_transport_iscsi
+alias net-pf-16-proto-9 audit
+alias net-pf-16-proto-11 cn
+# alias net-pf-16-proto-12 nfnetlink
+alias net-pf-16-proto-13 ip6_queue
+# alias net-pf-16-proto-14 dn_rtmsg
+
+# executables formats ########################################################
+install binfmt-0000 /bin/true
+alias binfmt-204 binfmt_aout
+alias binfmt-263 binfmt_aout
+alias binfmt-264 binfmt_aout
+alias binfmt-267 binfmt_aout
+alias binfmt-387 binfmt_aout
+
+# block devices ##############################################################
+alias block-major-3-*  ide_generic
+alias block-major-22-* ide_generic
+alias block-major-33-* ide_generic
+alias block-major-34-* ide_generic
+alias block-major-37-* ide_tape
+alias block-major-44-* ftl
+alias block-major-46-* pcd
+alias block-major-47-* pf
+alias block-major-56-* ide_generic
+alias block-major-57-* ide_generic
+alias block-major-58-* lvm_mod
+alias block-major-88-* ide_generic
+alias block-major-89-* ide_generic
+alias block-major-90-* ide_generic
+alias block-major-91-* ide_generic
+alias block-major-93-* nftl
+alias block-major-97-* pg
+
+# character devices ##########################################################
+alias char-major-10-1 psmouse
+alias char-major-10-139 openprom
+alias char-major-10-157 applicom
+alias char-major-10-181 toshiba
+alias char-major-10-183 hw_random
+alias char-major-10-187 irnet
+alias char-major-10-189 ussp
+alias char-major-10-250 hci_vhci
+alias char-major-13-0  joydev
+alias char-major-13-1  joydev
+alias char-major-13-2  joydev
+alias char-major-13-3  joydev
+alias char-major-13-32 mousedev
+alias char-major-13-33 mousedev
+alias char-major-13-34 mousedev
+alias char-major-13-35 mousedev
+alias char-major-13-63 mousedev
+alias char-major-13-64 evdev
+alias char-major-13-65 evdev
+alias char-major-13-66 evdev
+alias char-major-13-67 evdev
+alias char-major-19-* cyclades
+alias char-major-20-* cyclades
+alias char-major-22-* pcxx
+alias char-major-23-* pcxx
+alias char-major-27-* ftape
+alias char-major-34-* scc
+alias char-major-35-* tclmidi
+alias char-major-48-* riscom8
+alias char-major-49-* riscom8
+alias char-major-57-* esp
+alias char-major-58-* esp
+alias char-major-63-* kdebug
+alias char-major-67-* coda
+alias char-major-75-* specialix
+alias char-major-76-* specialix
+alias char-major-81-* videodev
+alias char-major-83-* vtx
+alias char-major-89-* i2c_dev
+alias char-major-90-* mtdchar
+alias char-major-96-* pt
+alias char-major-97-* pg
+alias char-major-107-* 3dfx
+alias char-major-109-* lvm_mod
+alias char-major-166-* cdc_acm
+alias char-major-171-0 raw1394
+alias char-major-171-1 video1394
+alias char-major-171-2 dv1394
+alias char-major-171-3 amdtp
+alias char-major-180-* usbcore
+alias char-major-195-* nvidia
+alias char-major-200-* vxspec
+alias char-major-202-* msr
+alias char-major-203-* cpuid
+alias char-major-206-* osst
+alias char-major-208-* ussp
+alias char-major-227-* tub3270
+#alias char-major-240-* usb-serial
+#alias char-major-240-* hsfserial
+#alias char-major-241-* hsfserial
+
+# misc #######################################################################
+#alias bt-proto-0 l2cap
+#alias bt-proto-2 sco
+#alias bt-proto-3 rfcomm
+#alias bt-proto-4 bnep
+#alias bt-proto-5 cmtp
+#alias bt-proto-6 hidp
+alias bt-proto-7 avdtp
+
+alias cipcb0 cipcb
+alias cipcb1 cipcb
+alias cipcb2 cipcb
+alias cipcb3 cipcb
+alias dummy0 dummy
+alias dummy1 dummy
+alias plip0 plip
+alias plip1 plip
+alias slip0 slip
+alias slip1 slip
+alias tunl0 ipip
+alias gre0 ip_gre
+
+alias usbdevfs usbcore
+
+alias nfs4 nfs
+
+# work around other kernel issues ############################################
+# The EHCI driver should be loaded before the ones for low speed controllers
+# or some devices may be confused when they are disconnected and reconnected.
+softdep uhci-hcd pre: ehci-hcd
+softdep ohci-hcd pre: ehci-hcd
+
diff --git a/extra/modules.5 b/extra/modules.5
new file mode 100644 (file)
index 0000000..3dd2397
--- /dev/null
@@ -0,0 +1,14 @@
+.TH MODULES 5 "Version 1.2" "Debian GNU/Linux"
+.SH NAME
+/etc/modules - kernel modules to load at boot time
+.SH DESCRIPTION
+.PP
+The
+.B /etc/modules
+file contains the names of kernel modules that are to be loaded at boot
+time, one per line. Arguments can be given in the same line as the module
+name. Lines beginning with a '#' are ignored. 
+.SH "SEE ALSO"
+.BR depmod (8)
+.BR modprobe (8)
+.BR modprobe.conf (5)
diff --git a/extra/modules.fr.5 b/extra/modules.fr.5
new file mode 100644 (file)
index 0000000..00c87ad
--- /dev/null
@@ -0,0 +1,19 @@
+.\"Traduction Lundi 14 octobre 2002 par Antoine Gémis
+.\"(agemis@netuup.com)
+.TH MODULES 5 "Version 1.1" "Debian GNU/Linux"
+.SH NOM
+/etc/modules - modules du noyau Ã  charger au démarrage
+.SH DESCRIPTION
+.PP
+Le fichier
+.B /etc/modules
+contient la liste des modules du noyau Ã  charger au démarrage, un module par
+ligne. Une ligne peut inclure, après le nom du module, des paramètres Ã  lui
+passer. Sur une ligne, tout ce qui suit Â«\ #\ Â» sera considéré comme commentaire
+et ignoré. 
+.SH "VOIR AUSSI"
+.BR depmod (8)
+.BR modprobe (8)
+.BR modprobe.conf (5)
+.SH TRADUCTION
+Antoine Gémis <agemis@netuup.com>.
diff --git a/generate-modprobe.conf b/generate-modprobe.conf
new file mode 100755 (executable)
index 0000000..7d0d895
--- /dev/null
@@ -0,0 +1,281 @@
+#! /bin/sh -e
+
+# Naive shell script to translate modules.conf + defaults to modprobe.conf
+# Normal caveats apply, as with any machine translation.
+usage() {
+       cat <<-EOF
+               Usage: $0 [--assume-kernel=n.n.n] [--stdin] [modprobe.conf]
+                  Converts your current modules setup to modprobe.conf.
+                  Don't trust it too much.
+                Version 0.1
+       EOF
+       exit ${1:-1}
+}
+
+KV=$(uname -r)
+STDIN=
+while [ -n "$1" ] ; do
+       case $1 in
+       --assume-kernel)   KV=$2; shift;;
+       --assume-kernel=*) KV=${1#*=};;
+       --stdin)           STDIN=1;;
+       -h|--help)         usage 0;;
+       *)                 break;;
+       esac
+       shift
+done
+
+# Set up output if specified.
+if [ $# -eq 1 ] ; then
+       exec > $1
+else
+       usage 1
+fi
+
+MODPROBECONF=`mktemp /tmp/modprobe.XXXXXX || tempfile || echo /tmp/modprobe.$$`
+trap "rm -f $MODPROBECONF" 0
+
+modprobe_abort()
+{
+    echo Failed to to run modprobe.  Giving up. 1>&2
+    exit 1
+}
+
+if [ x"$TESTING_MODPROBE_CONF" != x ]; then
+    cp $TESTING_MODPROBE_CONF $MODPROBECONF
+elif [ "$STDIN" = "1" ]; then
+    cat > $MODPROBECONF
+elif [ -x /sbin/modprobe.old ]; then
+    # In sbin.
+    /sbin/modprobe.old -c > $MODPROBECONF || modprobe_abort
+elif modprobe.old -c >/dev/null 2>&1; then
+    # Somewhere in path.
+    modprobe.old -c > $MODPROBECONF || modprobe_abort
+elif /sbin/modprobe -V 2>/dev/null | grep -q 'modprobe version'; then
+    # Running /sbin/modprobe gives old version.
+    /sbin/modprobe -c > $MODPROBECONF || modprobe_abort
+elif modprobe -V 2>/dev/null | grep -q 'modprobe version'; then
+    # Running modprobe gives old version.
+    modprobe -c > $MODPROBECONF || modprobe_abort
+else
+    echo Cannot find old version of modprobe.  Giving up. 2>&1
+    exit 1
+fi
+
+# Resolve (possibly recursive) alias: args filename alias
+resolve_alias()
+{
+    RA_RESOLVE=`grep "^alias[  ][      ]*$2[   ]" -- $1 | awk '{ print $3 }'`
+    if [ x"$RA_RESOLVE" = x ]; then
+       echo $2
+       return
+    fi
+    # Recurse.
+    (resolve_alias $1 "$RA_RESOLVE")
+}
+
+# Parse alias: args filename modulename aliasto.
+parse_alias()
+{
+    PA_ALIAS=`resolve_alias $1 $3`
+    NAME=`echo $2|sed -e 's/\(block\|char\)-major-\([0-9]\+\)$/\1-major-\2-*/'`
+
+    echo "alias $NAME $PA_ALIAS"
+}
+
+# Parse options: args modulename aliasto.
+parse_options()
+{
+    # Second arg can be null if grab_noninstall options returns empty.
+    [ x"$2" = x ] || echo "options $1 $2"
+}
+
+# Separate out the modprobe options from the module options
+grab_install_options()
+{
+    GRAB_OPTS=""
+    GRAB_NEXT=0
+    for grab_i; do
+       case "$grab_i" in
+       -o) GRAB_OPTS="$GRAB_OPTS -o"; GRAB_NEXT=1;;
+       -*) echo Warning: Ignoring unknown alias option "$grab_i" >&2;;
+       *)
+           [ $GRAB_NEXT = 0 ] || GRAB_OPTS="$GRAB_OPTS $grab_i"
+           GRAB_NEXT=0
+           ;;
+       esac
+    done
+    echo "$GRAB_OPTS"
+}
+
+grab_noninstall_options()
+{
+    GRAB_OPTS=""
+    GRAB_NEXT=0
+    for grab_i; do
+       case "$grab_i" in
+       -o) GRAB_NEXT=1;;
+       -*) ;;
+       *)
+           [ $GRAB_NEXT = 1 ] || GRAB_OPTS="$GRAB_OPTS $grab_i"
+           GRAB_NEXT=0
+           ;;
+       esac
+    done
+    echo "$GRAB_OPTS"
+}
+
+# Produce a multiple install/remove commands. Args: list, command, separator.
+multi()
+{
+    mp_res=""
+    for mp_arg in $1; do
+       if [ x"$mp_res" = x ]; then mp_res="/sbin/$2 $mp_arg";
+       else mp_res="$mp_res${3}/sbin/$2 $mp_arg";
+       fi
+    done
+    echo "$mp_res"
+}
+
+# Install and remove commands frequently refer to insmod and rmmod.
+# Use "modprobe --ignore-install " and "modprobe -r --ignore-remove" since 
+# our versions of rmmod and insmod are deliberately stupid.
+convert_command()
+{
+    echo "$@" | sed -e 's,insmod,/sbin/modprobe --ignore-install,' -e 's,rmmod,/sbin/modprobe -r --ignore-remove,'
+}
+
+while read ADD NAME MODULE REST; do
+    # Ignore a spurious add, otherwise move them down.
+    if [ x"$ADD" = x"add" ]; then :; else
+       REST="`echo $MODULE $REST | sed 's/ *$//'`"
+       MODULE="$NAME"
+       NAME="$ADD";
+    fi
+    #echo "NAME=$NAME MODULE=$MODULE REST=$REST" >&2
+
+    # MODNAME is the converted name for use in variables.
+    MODNAME=`echo $MODULE | tr -c A-Za-z_0-9 _`
+    case "$NAME" in
+    '#'*) : ;; # Comment 
+    '') : ;;   # Blank line
+
+    keep) # Do nothing.
+       ;;
+
+    alias)
+       if [ x"$REST" = xoff ] || [ x"$REST" = xnull ]; then
+           INSTALL_COMMANDS="$INSTALL_COMMANDS $MODULE"
+           eval install_$MODNAME=\"/bin/true\"
+       else
+           parse_alias $MODPROBECONF "$MODULE" $REST
+       fi
+       ;;
+
+    options) 
+       # Options used to be able to contain extra args to insmod
+       # (eg. -o foo).  Not any more.
+       case " $REST" in
+       *' '-[-a-z]*)
+           parse_options $MODULE `grab_noninstall_options $REST`
+           INSTALL_OPTIONS=`grab_install_options $REST`
+           INSTALL_COMMANDS="$INSTALL_COMMANDS $MODULE"
+           eval install_$MODNAME=\"/sbin/modprobe $INSTALL_OPTIONS --ignore-install `resolve_alias $MODPROBECONF $MODULE`\"
+           ;;
+       *)
+           parse_options $MODULE "$REST"
+           ;;
+       esac
+       ;;
+
+    above)
+       # Pull in these modules after me.
+       INSTALL_COMMANDS="$INSTALL_COMMANDS $MODULE"
+       eval post_install_$MODNAME=\"`multi "$REST" 'modprobe' '; '`\; /bin/true\"
+       REMOVE_COMMANDS="$REMOVE_COMMANDS $MODULE"
+       eval pre_remove_$MODNAME=\"`multi "$REST" 'modprobe -r' '; '`\"
+       ;;
+    below)
+       # Pull in these modules before me.
+       INSTALL_COMMANDS="$INSTALL_COMMANDS $MODULE"
+       eval pre_install_$MODNAME=\"`multi "$REST" 'modprobe' '; '`\"
+       REMOVE_COMMANDS="$REMOVE_COMMANDS $MODULE"
+       eval post_remove_$MODNAME=\"`multi "$REST" 'modprobe -r' '; '`\; /bin/true\"
+       ;;
+    probe) 
+       INSTALL_COMMANDS="$INSTALL_COMMANDS $MODULE"
+       eval install_$MODNAME=\"`multi "$REST" 'modprobe' ' || '`\"
+       ;;
+    probeall)
+       # Not quite correct.  If they all fail, we should fail.
+       INSTALL_COMMANDS="$INSTALL_COMMANDS $MODULE"
+       eval install_$MODNAME=\"`multi "$REST" 'modprobe' '; '`\; /bin/true\"
+       ;;
+    post-install)
+       INSTALL_COMMANDS="$INSTALL_COMMANDS $MODULE"
+       eval post_install_$MODNAME=\"`convert_command "$REST"`\"
+       ;;
+    pre-install)
+       INSTALL_COMMANDS="$INSTALL_COMMANDS $MODULE"
+       eval pre_install_$MODNAME=\"`convert_command "$REST"`\"
+       ;;
+    install)
+       INSTALL_COMMANDS="$INSTALL_COMMANDS $MODULE"
+       eval install_$MODNAME=\"`convert_command "$REST"`\"
+       ;;
+    post-remove)
+       REMOVE_COMMANDS="$REMOVE_COMMANDS $MODULE"
+       eval post_remove_$MODNAME=\"`convert_command "$REST"`\"
+       ;;
+    pre-remove)
+       REMOVE_COMMANDS="$REMOVE_COMMANDS $MODULE"
+       eval pre_remove_$MODNAME=\"`convert_command "$REST"`\"
+       ;;
+    remove)
+       REMOVE_COMMANDS="$REMOVE_COMMANDS $MODULE"
+       eval remove_$MODNAME=\"`convert_command "$REST"`\"
+       ;;
+    include)
+       # Recurse.
+       ($0 $MODULE)
+       ;;
+    # Ignore default lines which are not required any more.
+    "path[boot]=/lib/modules/boot"|"path[toplevel]=/lib/modules/$KV"|"path[toplevel]=/lib/modules/2.4"|"path[kernel]=/lib/modules/kernel"|"path[fs]=/lib/modules/fs"|"path[net]=/lib/modules/net"|"path[scsi]=/lib/modules/scsi"|"path[block]=/lib/modules/block"|"path[cdrom]=/lib/modules/cdrom"|"path[ipv4]=/lib/modules/ipv4"|"path[ipv6]=/lib/modules/ipv6"|"path[sound]=/lib/modules/sound"|"path[fc4]=/lib/modules/fc4"|"path[video]=/lib/modules/video"|"path[misc]=/lib/modules/misc"|"path[pcmcia]=/lib/modules/pcmcia"|"path[atm]=/lib/modules/atm"|"path[usb]=/lib/modules/usb"|"path[ide]=/lib/modules/ide"|"path[ieee1394]=/lib/modules/ieee1394"|"path[mtd]=/lib/modules/mtd"|"generic_stringfile=/lib/modules/$KV/modules.generic_string"|"pcimapfile=/lib/modules/$KV/modules.pcimap"|"isapnpmapfile=/lib/modules/$KV/modules.isapnpmap"|"usbmapfile=/lib/modules/$KV/modules.usbmap"|"parportmapfile=/lib/modules/$KV/modules.parportmap"|"ieee1394mapfile=/lib/modules/$KV/modules.ieee1394map"|"pnpbiosmapfile=/lib/modules/$KV/modules.pnpbiosmap"|"depfile=/lib/modules/$KV/modules.dep"|"persistdir=/var/lib/modules/persist")
+       ;;
+
+    # Ignore prune lines unless they end in .o or .ko, which would
+    # have an effect.
+    prune)
+       case "$MODULE" in
+       *.ko|*.o)
+           echo "Warning: not translating $NAME $MODULE $REST" >&2
+           ;;
+       esac
+       ;;
+    *)
+       echo "Warning: not translating $NAME $MODULE $REST" >&2
+       ;;
+    esac
+done < $MODPROBECONF
+
+for mod in `echo $INSTALL_COMMANDS | tr ' ' '\n' | sort -u`; do
+    # MODNAME is the converted name for use in variables.
+    MODNAME=`echo $mod | tr -c A-Za-z_0-9 _`
+    eval PREINSTALL=\"\$pre_install_$MODNAME\"
+    eval POSTINSTALL=\"\$post_install_$MODNAME\"
+    eval INSTALL=\"\$\{install_$MODNAME:-/sbin/modprobe --first-time --ignore-install $mod}\"
+    if [ -n "$PREINSTALL" ]; then PREINSTALL="{ $PREINSTALL; } ; "; fi
+    if [ -n "$POSTINSTALL" ]; then POSTINSTALL="&& { $POSTINSTALL; }"; fi
+    echo install $mod $PREINSTALL $INSTALL $POSTINSTALL
+done
+
+for mod in `echo $REMOVE_COMMANDS | tr ' ' '\n' | sort -u`; do
+    # MODNAME is the converted name for use in variables.
+    MODNAME=`echo $mod | tr -c A-Za-z_0-9 _`
+    eval PREREMOVE=\"\$pre_remove_$MODNAME\"
+    eval POSTREMOVE=\"\$post_remove_$MODNAME\"
+    eval REMOVE=\"\$\{remove_$MODNAME:-/sbin/modprobe -r --first-time --ignore-remove $mod}\"
+    if [ -n "$PREREMOVE" ]; then PREREMOVE="{ $PREREMOVE; } ; "; fi
+    if [ -n "$POSTREMOVE" ]; then POSTREMOVE="&& { $POSTREMOVE; }"; fi
+    echo remove $mod $PREREMOVE $REMOVE $POSTREMOVE
+done
diff --git a/index.c b/index.c
new file mode 100644 (file)
index 0000000..a97ba1d
--- /dev/null
+++ b/index.c
@@ -0,0 +1,807 @@
+/* index.c: module index file shared functions for modprobe and depmod
+    Copyright (C) 2008  Alan Jenkins <alan-jenkins@tuffmail.co.uk>.
+
+    These programs are free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with these programs.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <arpa/inet.h> /* htonl */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <fnmatch.h>
+
+#include "util.h"
+#include "logging.h"
+#include "index.h"
+
+#include "testing.h"
+
+/*
+ * Index abstract data type (used only by depmod)
+ */
+
+struct index_node *index_create()
+{
+       struct index_node *node;
+
+       node = NOFAIL(calloc(sizeof(struct index_node), 1));
+       node->prefix = NOFAIL(strdup(""));
+       node->first = INDEX_CHILDMAX;
+       
+       return node;
+}
+
+void index_values_free(struct index_value *values)
+{
+       while (values) {
+               struct index_value *value = values;
+
+               values = value->next;
+               free(value);
+       }
+}
+
+void index_destroy(struct index_node *node)
+{
+       int c;
+       
+       for (c = node->first; c <= node->last; c++) {
+               struct index_node *child = node->children[c];
+               
+               if (child)
+                       index_destroy(child);
+       }
+       index_values_free(node->values);
+       free(node->prefix);
+       free(node);
+}
+
+static void index__checkstring(const char *str)
+{
+       int i;
+       
+       for (i = 0; str[i]; i++) {
+               int ch = str[i];
+               
+               if (ch >= INDEX_CHILDMAX)
+                       fatal("Module index: bad character '%c'=0x%x - only 7-bit ASCII is supported:"
+                             "\n%s\n", (char) ch, (int) ch, str);
+       }
+}
+
+static int add_value(struct index_value **values,
+                    const char *value, unsigned int priority)
+{
+       struct index_value *v;
+       int duplicate = 0;
+       int len;
+
+       /* report the presence of duplicate values */
+       for (v = *values; v; v = v->next) {
+               if (streq(v->value, value))
+                       duplicate = 1;
+       }
+
+       /* find position to insert value */
+       while (*values && (*values)->priority < priority)
+               values = &(*values)->next;
+
+       len = strlen(value);
+       v = NOFAIL(calloc(sizeof(struct index_value) + len + 1, 1));
+       v->next = *values;
+       v->priority = priority;
+       memcpy(v->value, value, len + 1);
+       *values = v;
+
+       return duplicate;
+}
+
+int index_insert(struct index_node *node, const char *key,
+                const char *value, unsigned int priority)
+{
+       int i = 0; /* index within str */
+       int ch;
+       
+       index__checkstring(key);
+       index__checkstring(value);
+       
+       while(1) {
+               int j; /* index within node->prefix */
+       
+               /* Ensure node->prefix is a prefix of &str[i].
+                  If it is not already, then we must split node. */
+               for (j = 0; node->prefix[j]; j++) {
+                       ch = node->prefix[j];
+               
+                       if (ch != key[i+j]) {
+                               char *prefix = node->prefix;
+                               struct index_node *n;
+                               
+                               /* New child is copy of node with prefix[j+1..N] */
+                               n = NOFAIL(calloc(sizeof(struct index_node), 1));
+                               memcpy(n, node, sizeof(struct index_node));
+                               n->prefix = NOFAIL(strdup(&prefix[j+1]));
+                               
+                               /* Parent has prefix[0..j], child at prefix[j] */
+                               memset(node, 0, sizeof(struct index_node));
+                               prefix[j] = '\0';
+                               node->prefix = prefix;
+                               node->first = ch;
+                               node->last = ch;
+                               node->children[ch] = n;
+                               
+                               break;
+                       }
+               }
+               /* j is now length of node->prefix */
+               i += j;
+       
+               ch = key[i];
+               if(ch == '\0')
+                       return add_value(&node->values, value, priority);
+               
+               if (!node->children[ch]) {
+                       struct index_node *child;
+               
+                       if (ch < node->first)
+                               node->first = ch;
+                       if (ch > node->last)
+                               node->last = ch;
+                       node->children[ch] = NOFAIL(calloc(sizeof(struct index_node), 1));
+                       
+                       child = node->children[ch];
+                       child->prefix = NOFAIL(strdup(&key[i+1]));
+                       child->first = INDEX_CHILDMAX;
+                       add_value(&child->values, value, priority);
+
+                       return 0;
+               }
+               
+               /* Descend into child node and continue */
+               node = node->children[ch];
+               i++;
+       }
+}
+
+static int index__haschildren(const struct index_node *node)
+{
+       return node->first < INDEX_CHILDMAX;
+}
+
+/* Recursive post-order traversal
+
+   Pre-order would make for better read-side buffering / readahead / caching.
+   (post-order means you go backwards in the file as you descend the tree).
+   However, index reading is already fast enough.
+   Pre-order is simpler for writing, and depmod is already slow.
+ */
+static uint32_t index_write__node(const struct index_node *node, FILE *out)
+{
+       uint32_t *child_offs = NULL;
+       int child_count = 0;
+       long offset;
+       
+       if (!node)
+               return 0;
+       
+       /* Write children and save their offsets */
+       if (index__haschildren(node)) {
+               const struct index_node *child;
+               int i;
+               
+               child_count = node->last - node->first + 1;
+               child_offs = NOFAIL(malloc(child_count * sizeof(uint32_t)));
+               
+               for (i = 0; i < child_count; i++) {
+                       child = node->children[node->first + i];
+                       child_offs[i] = htonl(index_write__node(child, out));
+               }
+       }
+               
+       /* Now write this node */
+       offset = ftell(out);
+       
+       if (node->prefix[0]) {
+               fputs(node->prefix, out);
+               fputc('\0', out);
+               offset |= INDEX_NODE_PREFIX;
+       }
+               
+       if (child_count) {
+               fputc(node->first, out);
+               fputc(node->last, out);
+               fwrite(child_offs, sizeof(uint32_t), child_count, out);
+               free(child_offs);
+               offset |= INDEX_NODE_CHILDS;
+       }
+       
+       if (node->values) {
+               const struct index_value *v;
+               unsigned int value_count;
+               uint32_t u;
+
+               value_count = 0;
+               for (v = node->values; v != NULL; v = v->next)
+                       value_count++;
+               u = htonl(value_count);
+               fwrite(&u, sizeof(u), 1, out);
+
+               for (v = node->values; v != NULL; v = v->next) {
+                       u = htonl(v->priority);
+                       fwrite(&u, sizeof(u), 1, out);
+                       fputs(v->value, out);
+                       fputc('\0', out);
+               }
+               offset |= INDEX_NODE_VALUES;
+       }
+       
+       return offset;
+}
+
+void index_write(const struct index_node *node, FILE *out)
+{
+       long initial_offset, final_offset;
+       uint32_t u;
+       
+       u = htonl(INDEX_MAGIC);
+       fwrite(&u, sizeof(u), 1, out);
+       u = htonl(INDEX_VERSION);
+       fwrite(&u, sizeof(u), 1, out);
+       
+       /* Second word is reserved for the offset of the root node */
+       initial_offset = ftell(out);
+       u = 0;
+       fwrite(&u, sizeof(uint32_t), 1, out);
+       
+       /* Dump trie */
+       u = htonl(index_write__node(node, out));
+       
+       /* Update first word */
+       final_offset = ftell(out);
+       fseek(out, initial_offset, SEEK_SET);
+       fwrite(&u, sizeof(uint32_t), 1, out);
+       fseek(out, final_offset, SEEK_SET);
+}
+
+
+
+static void read_error()
+{
+       fatal("Module index: unexpected error: %s\n"
+                       "Try re-running depmod\n", errno ? strerror(errno) : "EOF");
+}
+
+static int read_char(FILE *in)
+{
+       int ch;
+
+       errno = 0;
+       ch = getc_unlocked(in);
+       if (ch == EOF)
+               read_error();
+       return ch;
+}
+
+static uint32_t read_long(FILE *in)
+{
+       uint32_t l;
+
+       errno = 0;
+       if (fread(&l, sizeof(uint32_t), 1, in) <= 0)
+               read_error();
+       return ntohl(l);
+}
+
+/*
+ * Buffer abstract data type
+ *
+ * Used internally to store the current path during tree traversal.
+ * They help build wildcard key strings to pass to fnmatch(),
+ * as well as building values of matching keys.
+ */
+
+struct buffer {
+       char *bytes;
+       unsigned size;
+       unsigned used;
+};
+
+static void buf__realloc(struct buffer *buf, unsigned size)
+{
+       if (size > buf->size) {
+               buf->bytes = NOFAIL(realloc(buf->bytes, size));
+               buf->size = size;
+       }
+}
+
+static struct buffer *buf_create()
+{
+       struct buffer *buf;
+        
+       buf = NOFAIL(calloc(sizeof(struct buffer), 1));
+       buf__realloc(buf, 256);
+       return buf;
+}
+
+static void buf_destroy(struct buffer *buf)
+{
+       free(buf->bytes);
+       free(buf);
+}
+
+/* Destroy buffer and return a copy as a C string */
+static char *buf_detach(struct buffer *buf)
+{
+       char *bytes;
+
+       bytes = NOFAIL(realloc(buf->bytes, buf->used + 1));
+       bytes[buf->used] = '\0';
+
+       free(buf);
+       return bytes;
+}
+
+/* Return a C string owned by the buffer
+   (invalidated if the buffer is changed).
+ */
+static const char *buf_str(struct buffer *buf)
+{
+       buf__realloc(buf, buf->used + 1);
+       buf->bytes[buf->used] = '\0';
+       return buf->bytes;
+}
+
+static int buf_fwrite(struct buffer *buf, FILE *out)
+{
+       return fwrite(buf->bytes, 1, buf->used, out);
+}
+
+static void buf_pushchar(struct buffer *buf, char ch)
+{
+       buf__realloc(buf, buf->used + 1);
+       buf->bytes[buf->used] = ch;
+       buf->used++;
+}
+
+static unsigned buf_pushchars(struct buffer *buf, const char *str)
+{
+       unsigned i = 0;
+       int ch;
+
+       while ((ch = str[i])) {
+               buf_pushchar(buf, ch);
+               i++;
+       }
+       return i;
+}
+
+/* like buf_pushchars(), but the string comes from a file */
+static unsigned buf_freadchars(struct buffer *buf, FILE *in)
+{
+       unsigned i = 0;
+       int ch;
+
+       while ((ch = read_char(in))) {
+               buf_pushchar(buf, ch);
+               i++;
+       }
+
+       return i;
+}
+
+static void buf_popchar(struct buffer *buf)
+{
+       buf->used--;
+}
+
+static void buf_popchars(struct buffer *buf, unsigned n)
+{
+       buf->used -= n;
+}
+
+static void buf_clear(struct buffer *buf)
+{
+       buf->used = 0;
+}
+
+/*
+ * Index file searching (used only by modprobe)
+ */
+
+struct index_node_f {
+       FILE *file;
+       char *prefix;           /* path compression */
+       struct index_value *values;
+       unsigned char first;    /* range of child nodes */
+       unsigned char last;
+       uint32_t children[0];
+};
+
+static struct index_node_f *index_read(FILE *in, uint32_t offset)
+{
+       struct index_node_f *node;
+       char *prefix;
+       int i, child_count = 0;
+
+       if ((offset & INDEX_NODE_MASK) == 0)
+               return NULL;
+
+       fseek(in, offset & INDEX_NODE_MASK, SEEK_SET);
+       
+       if (offset & INDEX_NODE_PREFIX) {
+               struct buffer *buf = buf_create();
+               buf_freadchars(buf, in);
+               prefix = buf_detach(buf);
+       } else
+               prefix = NOFAIL(strdup(""));
+               
+       if (offset & INDEX_NODE_CHILDS) {
+               char first = read_char(in);
+               char last = read_char(in);
+               child_count = last - first + 1;
+               
+               node = NOFAIL(malloc(sizeof(struct index_node_f) +
+                                    sizeof(uint32_t) * child_count));
+               
+               node->first = first;
+               node->last = last;
+
+               for (i = 0; i < child_count; i++)
+                       node->children[i] = read_long(in);
+       } else {
+               node = NOFAIL(malloc(sizeof(struct index_node_f)));
+               node->first = INDEX_CHILDMAX;
+               node->last = 0;
+       }
+       
+       node->values = NULL;
+       if (offset & INDEX_NODE_VALUES) {
+               int value_count;
+               struct buffer *buf = buf_create();
+               const char *value;
+               unsigned int priority;
+
+               value_count = read_long(in);
+
+               while (value_count--) {
+                       priority = read_long(in);
+                       buf_freadchars(buf, in);
+                       value = buf_str(buf);
+                       add_value(&node->values, value, priority);
+                       buf_clear(buf);
+               }
+               buf_destroy(buf);
+       }
+
+       node->prefix = prefix;
+       node->file = in;
+       return node;
+}
+
+static void index_close(struct index_node_f *node)
+{
+       free(node->prefix);
+       index_values_free(node->values);
+       free(node);
+}
+
+struct index_file {
+       FILE *file;
+       uint32_t root_offset;
+};
+
+/* Failures are silent; modprobe will fall back to text files */
+struct index_file *index_file_open(const char *filename)
+{
+       FILE *file;
+       uint32_t magic, version;
+       struct index_file *new;
+
+       file = fopen(filename, "r");
+       if (!file)
+               return NULL;
+       errno = EINVAL;
+
+       magic = read_long(file);
+       if (magic != INDEX_MAGIC)
+               return NULL;
+
+       version = read_long(file);
+       if (version >> 16 != INDEX_VERSION_MAJOR)
+               return NULL;
+
+       new = NOFAIL(malloc(sizeof(struct index_file)));
+       new->file = file;
+       new->root_offset = read_long(new->file);
+
+       errno = 0;
+       return new;
+}
+
+void index_file_close(struct index_file *index)
+{
+       fclose(index->file);
+       free(index);
+}
+
+
+static struct index_node_f *index_readroot(struct index_file *in)
+{
+       return index_read(in->file, in->root_offset);
+}
+
+static struct index_node_f *index_readchild(const struct index_node_f *parent,
+                                           int ch)
+{
+       if (parent->first <= ch && ch <= parent->last)
+               return index_read(parent->file,
+                                      parent->children[ch - parent->first]);
+       else
+               return NULL;
+}
+
+/*
+ * Dump all strings as lines in a plain text file.
+ */
+
+static void index_dump_node(struct index_node_f *node,
+                           struct buffer *buf,
+                           FILE *out,
+                           const char *prefix)
+{
+       struct index_value *v;
+       int ch, pushed;
+       
+       pushed = buf_pushchars(buf, node->prefix);
+       
+       for (v = node->values; v != NULL; v = v->next) {
+               fputs(prefix, out);
+               buf_fwrite(buf, out);
+               fputc(' ', out);
+               fputs(v->value, out);
+               fputc('\n', out);
+       }
+       
+       for (ch = node->first; ch <= node->last; ch++) {
+               struct index_node_f *child = index_readchild(node, ch);
+               
+               if (!child)
+                       continue;
+                       
+               buf_pushchar(buf, ch);
+               index_dump_node(child, buf, out, prefix);
+               buf_popchar(buf);
+       }
+       
+       buf_popchars(buf, pushed);
+       index_close(node);
+}
+
+void index_dump(struct index_file *in, FILE *out, const char *prefix)
+{
+       struct index_node_f *root;
+       struct buffer *buf;
+       
+       buf = buf_create();
+       root = index_readroot(in);
+       index_dump_node(root, buf, out, prefix);
+       buf_destroy(buf);
+}
+
+/*
+ * Search the index for a key
+ *
+ * Returns the value of the first match
+ *
+ * The recursive functions free their node argument (using index_close).
+ */
+
+char *index_search(struct index_file *in, const char *key);
+static char *index_search__node(struct index_node_f *node, const char *key, int i);
+
+char *index_search(struct index_file *in, const char *key)
+{
+       struct index_node_f *root;
+       char *value;
+       
+       root = index_readroot(in);
+       value = index_search__node(root, key, 0);
+       
+       return value;
+}
+
+static char *index_search__node(struct index_node_f *node, const char *key, int i)
+{
+       char *value;
+       struct index_node_f *child;
+       int ch;
+       int j;
+
+       while(node) {
+               for (j = 0; node->prefix[j]; j++) {
+                       ch = node->prefix[j];
+                       
+                       if (ch != key[i+j]) {
+                               index_close(node);
+                               return NULL;
+                       }
+               }
+               i += j;
+               
+               if (key[i] == '\0') {
+                       if (node->values) {
+                               value = strdup(node->values[0].value);
+                               index_close(node);
+                               return value;
+                       } else {
+                               return NULL;
+                       }
+               }
+               
+               child = index_readchild(node, key[i]);
+               index_close(node);
+               node = child;
+               i++;
+       }
+       
+       return NULL;
+}
+
+/*
+ * Search the index for a key.  The index may contain wildcards.
+ *
+ * Returns a list of all the values of matching keys.
+ */
+
+/* Level 1: interface function */
+struct index_value *index_searchwild(struct index_file *in, const char *key);
+
+/* Level 2: descend the tree (until we hit a wildcard) */
+static void index_searchwild__node(struct index_node_f *node,
+                                  struct buffer *buf,
+                                  const char *key, int i,
+                                  struct index_value **out);
+
+/* Level 3: traverse a sub-keyspace which starts with a wildcard,
+            looking for matches.
+*/
+static void index_searchwild__all(struct index_node_f *node, int j,
+                                 struct buffer *buf,
+                                 const char *subkey,
+                                 struct index_value **out);
+
+/* Level 4: add all the values from a matching node */
+static void index_searchwild__allvalues(struct index_node_f *node,
+                                       struct index_value **out);
+
+
+struct index_value *index_searchwild(struct index_file *in, const char *key)
+{
+       struct index_node_f *root = index_readroot(in);
+       struct buffer *buf = buf_create();
+       struct index_value *out = NULL;
+       
+       index_searchwild__node(root, buf, key, 0, &out);
+       buf_destroy(buf);
+       return out;
+}
+
+static void index_searchwild__node(struct index_node_f *node,
+                                  struct buffer *buf,
+                                  const char *key, int i,
+                                  struct index_value **out)
+{
+       struct index_node_f *child;
+       int j;
+       int ch;
+
+       while(node) {
+               for (j = 0; node->prefix[j]; j++) {
+                       ch = node->prefix[j];
+                       
+                       if (ch == '*' || ch == '?' || ch == '[') {
+                               index_searchwild__all(node, j, buf,
+                                                     &key[i+j], out);
+                               return;
+                       }
+                       
+                       if (ch != key[i+j]) {
+                               index_close(node);
+                               return;
+                       }
+               }
+               i += j;
+               
+               child = index_readchild(node, '*');
+               if (child) {
+                       buf_pushchar(buf, '*');
+                       index_searchwild__all(child, 0, buf, &key[i], out);
+                       buf_popchar(buf);
+               }
+               
+               child = index_readchild(node, '?');
+               if (child) {
+                       buf_pushchar(buf, '?');
+                       index_searchwild__all(child, 0, buf, &key[i], out);
+                       buf_popchar(buf);
+               }
+               
+               child = index_readchild(node, '[');
+               if (child) {
+                       buf_pushchar(buf, '[');
+                       index_searchwild__all(child, 0, buf, &key[i], out);
+                       buf_popchar(buf);
+               }
+               
+               if (key[i] == '\0') {
+                       index_searchwild__allvalues(node, out);
+
+                       return;
+               }
+               
+               child = index_readchild(node, key[i]);
+               index_close(node);
+               node = child;
+               i++;
+       }
+}
+
+static void index_searchwild__all(struct index_node_f *node, int j,
+                                 struct buffer *buf,
+                                 const char *subkey,
+                                 struct index_value **out)
+{
+       int pushed = 0;
+       int ch;
+       
+       while (node->prefix[j]) {
+               ch = node->prefix[j];
+               
+               buf_pushchar(buf, ch);
+               pushed++;
+               j++;
+       }
+
+       for (ch = node->first; ch <= node->last; ch++) {
+               struct index_node_f *child = index_readchild(node, ch);
+               
+               if (!child)
+                       continue;
+                       
+               buf_pushchar(buf, ch);
+               index_searchwild__all(child, 0, buf, subkey, out);
+               buf_popchar(buf);
+       }
+       
+       if (node->values) {
+               if (fnmatch(buf_str(buf), subkey, 0) == 0)
+                       index_searchwild__allvalues(node, out);
+       } else {
+               index_close(node);
+       }
+       
+       buf_popchars(buf, pushed);
+}
+
+static void index_searchwild__allvalues(struct index_node_f *node,
+                                       struct index_value **out)
+{
+       struct index_value *v;
+       
+       for (v = node->values; v != NULL; v = v->next)
+               add_value(out, v->value, v->priority);
+
+       index_close(node);
+}
diff --git a/index.h b/index.h
new file mode 100644 (file)
index 0000000..d8aced5
--- /dev/null
+++ b/index.h
@@ -0,0 +1,185 @@
+
+/* index.c: module index file shared functions for modprobe and depmod
+    Copyright (C) 2008  Alan Jenkins <alan-jenkins@tuffmail.co.uk>.
+
+    These programs are free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with these programs.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef MODINITTOOLS_INDEX_H
+#define MODINITTOOLS_INDEX_H
+
+#include <stdint.h>
+
+/* Integers are stored as 32 bit unsigned in "network" order, i.e. MSB first.
+   All files start with a magic number.
+
+   Magic spells "BOOTFAST". Second one used on newer versioned binary files.
+ */
+/* #define INDEX_MAGIC_OLD 0xB007FA57 */
+#define INDEX_MAGIC 0xB007F457
+
+/* We use a version string to keep track of changes to the binary format
+ * This is stored in the form: INDEX_MAJOR (hi) INDEX_MINOR (lo) just in
+ * case we ever decide to have minor changes that are not incompatible.
+ */
+
+#define INDEX_VERSION_MAJOR 0x0002
+#define INDEX_VERSION_MINOR 0x0001
+#define INDEX_VERSION ((INDEX_VERSION_MAJOR<<16)|INDEX_VERSION_MINOR)
+
+/* The index file maps keys to values. Both keys and values are ASCII strings.
+   Each key can have multiple values. Values are sorted by an integer priority.
+
+   The reader also implements a wildcard search (including range expressions)
+   where the keys in the index are treated as patterns.
+   This feature is required for module aliases.
+*/
+
+/* Implementation is based on a radix tree, or "trie".
+   Each arc from parent to child is labelled with a character.
+   Each path from the root represents a string.
+
+   == Example strings ==
+
+   ask
+   ate
+   on
+   once
+   one
+
+   == Key ==
+    + Normal node
+    * Marked node, representing a key and it's values.
+
+   +
+   |-a-+-s-+-k-*
+   |   |
+   |   `-t-+-e-*
+   |
+   `-o-+-n-*-c-+-e-*
+           |
+           `-e-*
+
+   Naive implementations tend to be very space inefficient; child pointers
+   are stored in arrays indexed by character, but most child pointers are null.
+
+   Our implementation uses a scheme described by Wikipedia as a Patrica trie,
+
+       "easiest to understand as a space-optimized trie where
+        each node with only one child is merged with its child"
+
+   +
+   |-a-+-sk-*
+   |   |
+   |   `-te-*
+   |
+   `-on-*-ce-*
+        |
+        `-e-*
+
+   We still use arrays of child pointers indexed by a single character;
+   the remaining characters of the label are stored as a "prefix" in the child.
+
+   The paper describing the original Patrica trie works on individiual bits -
+   each node has a maximum of two children, which increases space efficiency.
+   However for this application it is simpler to use the ASCII character set.
+   Since the index file is read-only, it can be compressed by omitting null
+   child pointers at the start and end of arrays.
+*/
+
+#define INDEX_PRIORITY_MIN UINT32_MAX
+
+struct index_value {
+       struct index_value *next;
+       unsigned int priority;
+       char value[0];
+};
+
+/* In-memory index (depmod only) */
+
+#define INDEX_CHILDMAX 128
+struct index_node {
+       char *prefix;           /* path compression */
+       struct index_value *values;
+       unsigned char first;    /* range of child nodes */
+       unsigned char last;
+       struct index_node *children[INDEX_CHILDMAX]; /* indexed by character */
+};
+
+/* Disk format:
+
+   uint32_t magic = INDEX_MAGIC;
+   uint32_t version = INDEX_VERSION;
+   uint32_t root_offset;
+
+   (node_offset & INDEX_NODE_MASK) specifies the file offset of nodes:
+
+        char[] prefix; // nul terminated
+
+        char first;
+        char last;
+        uint32_t children[last - first + 1];
+
+        uint32_t value_count;
+        struct {
+            uint32_t priority;
+            char[] value; // nul terminated
+        } values[value_count];
+
+   (node_offset & INDEX_NODE_FLAGS) indicates which fields are present.
+   Empty prefixes are ommitted, leaf nodes omit the three child-related fields.
+
+   This could be optimised further by adding a sparse child format
+   (indicated using a new flag).
+ */
+
+/* Format of node offsets within index file */
+enum node_offset {
+       INDEX_NODE_FLAGS    = 0xF0000000, /* Flags in high nibble */
+       INDEX_NODE_PREFIX   = 0x80000000,
+       INDEX_NODE_VALUES = 0x40000000,
+       INDEX_NODE_CHILDS   = 0x20000000,
+
+       INDEX_NODE_MASK     = 0x0FFFFFFF, /* Offset value */
+};
+
+struct index_file;
+
+struct index_node *index_create(void);
+void index_destroy(struct index_node *node);
+int index_insert(struct index_node *node, const char *key,
+                const char *value, unsigned int priority);
+void index_write(const struct index_node *node, FILE *out);
+
+struct index_file *index_file_open(const char *filename);
+void index_file_close(struct index_file *index);
+
+/* Dump all strings in index as lines in a plain text file
+   (prefix is prepended to each line)
+*/
+void index_dump(struct index_file *in, FILE *out, const char *prefix);
+
+/* Return value for first matching key.
+   Keys must be exactly equal to match - i.e. there are no wildcard patterns
+*/
+char *index_search(struct index_file *index, const char *key);
+
+/* Return values for all matching keys.
+   The keys in the index are treated as wildcard patterns using fnmatch()
+*/
+struct index_value *index_searchwild(struct index_file *index, const char *key);
+
+void index_values_free(struct index_value *values);
+
+#endif /* MODINITTOOLS_INDEX_H */
diff --git a/insmod.8 b/insmod.8
new file mode 100644 (file)
index 0000000..55d18ed
--- /dev/null
+++ b/insmod.8
@@ -0,0 +1,30 @@
+.\\" auto-generated by docbook2man-spec $Revision: 1.2 $
+.TH "INSMOD" "8" "2010-03-01" "" ""
+.SH NAME
+insmod \- simple program to insert a module into the Linux Kernel
+.SH SYNOPSIS
+.sp
+\fBinsmod\fR [ \fB\fIfilename\fB\fR ]  [ \fB\fImodule options\fB\fR\fI...\fR ] 
+.SH "DESCRIPTION"
+.PP
+\fBinsmod\fR is a trivial program to insert a
+module into the kernel: if the
+\fIfilename\fR is a hyphen, the module is
+taken from standard input. Most users will want to use
+\fBmodprobe\fR(8) instead, which is
+more clever and can handle module dependencies.
+.PP
+Only the most general of error messages are reported: as the
+work of trying to link the module is now done inside the kernel,
+the \fBdmesg\fR usually gives more information
+about errors.
+.SH "COPYRIGHT"
+.PP
+This manual page originally Copyright 2002, Rusty Russell, IBM
+Corporation. Maintained by Jon Masters and others.
+.SH "SEE ALSO"
+.PP
+\fBmodprobe\fR(8),
+\fBrmmod\fR(8),
+\fBlsmod\fR(8)
+\fBmodinfo\fR(8)
diff --git a/insmod.c b/insmod.c
new file mode 100644 (file)
index 0000000..de4f68b
--- /dev/null
+++ b/insmod.c
@@ -0,0 +1,169 @@
+/* insmod.c: insert a module into the kernel.
+    Copyright (C) 2001  Rusty Russell.
+    Copyright (C) 2002  Rusty Russell, IBM Corporation.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+#include <asm/unistd.h>
+
+#include "util.h"
+#include "testing.h"
+
+extern long init_module(void *, unsigned long, const char *);
+
+static void print_usage(const char *progname)
+{
+       fprintf(stderr, "Usage: %s filename [args]\n", progname);
+       exit(1);
+}
+
+/* We use error numbers in a loose translation... */
+static const char *moderror(int err)
+{
+       switch (err) {
+       case ENOEXEC:
+               return "Invalid module format";
+       case ENOENT:
+               return "Unknown symbol in module";
+       case ESRCH:
+               return "Module has wrong symbol version";
+       case EINVAL:
+               return "Invalid parameters";
+       default:
+               return strerror(err);
+       }
+}
+
+static void *grab_file(const char *filename, unsigned long *size)
+{
+       unsigned int max = 16384;
+       int ret, fd, err_save;
+       void *buffer;
+
+       if (streq(filename, "-"))
+               fd = dup(STDIN_FILENO);
+       else
+               fd = open(filename, O_RDONLY, 0);
+
+       if (fd < 0)
+               return NULL;
+
+       buffer = malloc(max);
+       if (!buffer)
+               goto out_error;
+
+       *size = 0;
+       while ((ret = read(fd, buffer + *size, max - *size)) > 0) {
+               *size += ret;
+               if (*size == max) {
+                       void *p;
+
+                       p = realloc(buffer, max *= 2);
+                       if (!p)
+                               goto out_error;
+                       buffer = p;
+               }
+       }
+       if (ret < 0)
+               goto out_error;
+
+       close(fd);
+       return buffer;
+
+out_error:
+       err_save = errno;
+       free(buffer);
+       close(fd);
+       errno = err_save;
+       return NULL;
+}
+
+int main(int argc, char *argv[])
+{
+       unsigned int i;
+       long int ret;
+       unsigned long len;
+       void *file;
+       char *filename, *options = strdup("");
+       char *p, *progname = argv[0];
+
+       if (!options) {
+               fprintf(stderr,
+                       "insmod: can't allocate memory: %s\n",
+                       strerror(errno));
+               exit(1);
+       }
+
+       p = my_basename(argv[0]);
+
+       if (argv[1] && (streq(argv[1], "--version") || streq(argv[1], "-V"))) {
+               puts(PACKAGE " version " VERSION);
+               exit(0);
+       }
+
+       /* Ignore old options, for backwards compat. */
+       while (argv[1] && (streq(argv[1], "-p")
+                          || streq(argv[1], "-s")
+                          || streq(argv[1], "-f"))) {
+               argv++;
+               argc--;
+       }
+
+       filename = argv[1];
+       if (!filename)
+               print_usage(progname);
+
+       /* Rest is options */
+       for (i = 2; i < argc; i++) {
+               options = realloc(options,
+                                 strlen(options) + 1 + strlen(argv[i]) + 1);
+               if (!options) {
+                       fprintf(stderr,
+                               "insmod: can't allocate memory: %s\n",
+                               strerror(errno));
+                       exit(1);
+               }
+               strcat(options, argv[i]);
+               strcat(options, " ");
+       }
+
+       file = grab_file(filename, &len);
+       if (!file) {
+               fprintf(stderr, "insmod: can't read '%s': %s\n",
+                       filename, strerror(errno));
+               exit(1);
+       }
+
+       ret = init_module(file, len, options);
+       if (ret != 0) {
+               fprintf(stderr, "insmod: error inserting '%s': %li %s\n",
+                       filename, ret, moderror(errno));
+       }
+       free(file);
+
+       if (ret != 0)
+               exit(1);
+       exit(0);
+}
diff --git a/install-sh b/install-sh
new file mode 100755 (executable)
index 0000000..6781b98
--- /dev/null
@@ -0,0 +1,520 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2009-04-28.21; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" ""       $nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+  doit_exec=exec
+else
+  doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+     --help     display this help and exit.
+     --version  display version info and exit.
+
+  -c            (ignored)
+  -C            install only if different (preserve the last data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -s            $stripprog installed files.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+  case $1 in
+    -c) ;;
+
+    -C) copy_on_change=true;;
+
+    -d) dir_arg=true;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+       shift;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) mode=$2
+       case $mode in
+         *' '* | *'    '* | *'
+'*       | *'*'* | *'?'* | *'['*)
+           echo "$0: invalid mode: $mode" >&2
+           exit 1;;
+       esac
+       shift;;
+
+    -o) chowncmd="$chownprog $2"
+       shift;;
+
+    -s) stripcmd=$stripprog;;
+
+    -t) dst_arg=$2
+       shift;;
+
+    -T) no_target_directory=true;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    --)        shift
+       break;;
+
+    -*)        echo "$0: invalid option: $1" >&2
+       exit 1;;
+
+    *)  break;;
+  esac
+  shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+  # When -d is used, all remaining arguments are directories to create.
+  # When -t is used, the destination is already specified.
+  # Otherwise, the last argument is the destination.  Remove it from $@.
+  for arg
+  do
+    if test -n "$dst_arg"; then
+      # $@ is not empty: it contains at least $arg.
+      set fnord "$@" "$dst_arg"
+      shift # fnord
+    fi
+    shift # arg
+    dst_arg=$arg
+  done
+fi
+
+if test $# -eq 0; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+if test -z "$dir_arg"; then
+  trap '(exit $?); exit' 1 2 13 15
+
+  # Set umask so as not to create temps with too-generous modes.
+  # However, 'strip' requires both read and write access to temps.
+  case $mode in
+    # Optimize common cases.
+    *644) cp_umask=133;;
+    *755) cp_umask=22;;
+
+    *[0-7])
+      if test -z "$stripcmd"; then
+       u_plus_rw=
+      else
+       u_plus_rw='% 200'
+      fi
+      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+    *)
+      if test -z "$stripcmd"; then
+       u_plus_rw=
+      else
+       u_plus_rw=,u+rw
+      fi
+      cp_umask=$mode$u_plus_rw;;
+  esac
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    dstdir=$dst
+    test -d "$dstdir"
+    dstdir_status=$?
+  else
+
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dst_arg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+
+    dst=$dst_arg
+    # Protect names starting with `-'.
+    case $dst in
+      -*) dst=./$dst;;
+    esac
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+       echo "$0: $dst_arg: Is a directory" >&2
+       exit 1
+      fi
+      dstdir=$dst
+      dst=$dstdir/`basename "$src"`
+      dstdir_status=0
+    else
+      # Prefer dirname, but fall back on a substitute if dirname fails.
+      dstdir=`
+       (dirname "$dst") 2>/dev/null ||
+       expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+            X"$dst" : 'X\(//\)[^/]' \| \
+            X"$dst" : 'X\(//\)$' \| \
+            X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+       echo X"$dst" |
+           sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\/\)[^/].*/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\/\)$/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\).*/{
+                  s//\1/
+                  q
+                }
+                s/.*/./; q'
+      `
+
+      test -d "$dstdir"
+      dstdir_status=$?
+    fi
+  fi
+
+  obsolete_mkdir_used=false
+
+  if test $dstdir_status != 0; then
+    case $posix_mkdir in
+      '')
+       # Create intermediate dirs using mode 755 as modified by the umask.
+       # This is like FreeBSD 'install' as of 1997-10-28.
+       umask=`umask`
+       case $stripcmd.$umask in
+         # Optimize common cases.
+         *[2367][2367]) mkdir_umask=$umask;;
+         .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+         *[0-7])
+           mkdir_umask=`expr $umask + 22 \
+             - $umask % 100 % 40 + $umask % 20 \
+             - $umask % 10 % 4 + $umask % 2
+           `;;
+         *) mkdir_umask=$umask,go-w;;
+       esac
+
+       # With -d, create the new directory with the user-specified mode.
+       # Otherwise, rely on $mkdir_umask.
+       if test -n "$dir_arg"; then
+         mkdir_mode=-m$mode
+       else
+         mkdir_mode=
+       fi
+
+       posix_mkdir=false
+       case $umask in
+         *[123567][0-7][0-7])
+           # POSIX mkdir -p sets u+wx bits regardless of umask, which
+           # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+           ;;
+         *)
+           tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+           trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+           if (umask $mkdir_umask &&
+               exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+           then
+             if test -z "$dir_arg" || {
+                  # Check for POSIX incompatibilities with -m.
+                  # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+                  # other-writeable bit of parent directory when it shouldn't.
+                  # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+                  ls_ld_tmpdir=`ls -ld "$tmpdir"`
+                  case $ls_ld_tmpdir in
+                    d????-?r-*) different_mode=700;;
+                    d????-?--*) different_mode=755;;
+                    *) false;;
+                  esac &&
+                  $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+                    ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+                    test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+                  }
+                }
+             then posix_mkdir=:
+             fi
+             rmdir "$tmpdir/d" "$tmpdir"
+           else
+             # Remove any dirs left behind by ancient mkdir implementations.
+             rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+           fi
+           trap '' 0;;
+       esac;;
+    esac
+
+    if
+      $posix_mkdir && (
+       umask $mkdir_umask &&
+       $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+      )
+    then :
+    else
+
+      # The umask is ridiculous, or mkdir does not conform to POSIX,
+      # or it failed possibly due to a race condition.  Create the
+      # directory the slow way, step by step, checking for races as we go.
+
+      case $dstdir in
+       /*) prefix='/';;
+       -*) prefix='./';;
+       *)  prefix='';;
+      esac
+
+      eval "$initialize_posix_glob"
+
+      oIFS=$IFS
+      IFS=/
+      $posix_glob set -f
+      set fnord $dstdir
+      shift
+      $posix_glob set +f
+      IFS=$oIFS
+
+      prefixes=
+
+      for d
+      do
+       test -z "$d" && continue
+
+       prefix=$prefix$d
+       if test -d "$prefix"; then
+         prefixes=
+       else
+         if $posix_mkdir; then
+           (umask=$mkdir_umask &&
+            $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+           # Don't fail if two instances are running concurrently.
+           test -d "$prefix" || exit 1
+         else
+           case $prefix in
+             *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+             *) qprefix=$prefix;;
+           esac
+           prefixes="$prefixes '$qprefix'"
+         fi
+       fi
+       prefix=$prefix/
+      done
+
+      if test -n "$prefixes"; then
+       # Don't fail if two instances are running concurrently.
+       (umask $mkdir_umask &&
+        eval "\$doit_exec \$mkdirprog $prefixes") ||
+         test -d "$dstdir" || exit 1
+       obsolete_mkdir_used=true
+      fi
+    fi
+  fi
+
+  if test -n "$dir_arg"; then
+    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+  else
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+    # Copy the file name to the temp name.
+    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"    2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       $posix_glob set +f &&
+
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+       # Now remove or move aside any old file at destination location.
+       # We try this two ways since rm can't unlink itself on some
+       # systems and the destination file might be busy for other
+       # reasons.  In this case, the final cleanup might fail but the new
+       # file should still install successfully.
+       {
+         test ! -f "$dst" ||
+         $doit $rmcmd -f "$dst" 2>/dev/null ||
+         { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+           { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+         } ||
+         { echo "$0: cannot unlink or rename $dst" >&2
+           (exit 1); exit 1
+         }
+       } &&
+
+       # Now rename the file to the real destination.
+       $doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
+
+    trap '' 0
+  fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/install-with-care b/install-with-care
new file mode 100755 (executable)
index 0000000..eb699cf
--- /dev/null
@@ -0,0 +1,30 @@
+#! /bin/sh
+
+echo install-with-care "$@"
+
+# Final arg is dest.
+eval DEST=\$$#
+
+case $(echo $DEST | tr -s / /) in
+    /sbin/insmod.static) ;;# This didn't exist before, OK.
+    /sbin/insmod|/sbin/lsmod|/sbin/modprobe|/sbin/rmmod|/sbin/depmod)
+       if [ -f $DEST ] && [ -f $DEST.old ]; then
+           echo Refusing to install $DEST, remove $DEST.old first. >&2
+           echo Note: $DEST requires kernel version 2.5.48 or above.
+           if [ $DEST = /sbin/modprobe ]; then
+cat << EOF >&2
+
+Note: generate-modprobe.conf requires /sbin/modprobe.old.
+(i.e. if you need to run it, do so before removing modprobe.old).
+
+EOF
+           fi
+           exit 1
+       fi
+       ;;
+    /bin/lsmod) # If we're installing into /bin, make /sbin/lsmod link.
+       ln -sf ../bin/lsmod /sbin/lsmod
+       ;;
+esac
+
+exec install "$@"
diff --git a/list.h b/list.h
new file mode 100644 (file)
index 0000000..95ca43c
--- /dev/null
+++ b/list.h
@@ -0,0 +1,251 @@
+/* Stolen from Linux Kernel Source's list.h -- GPL. */
+#ifndef _MODINITTOOLS_LIST_H
+#define _MODINITTOOLS_LIST_H
+
+#undef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ *
+ * @ptr:       the pointer to the member.
+ * @type:      the type of the container struct this is embedded in.
+ * @member:    the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({                     \
+        const typeof( ((type *)0)->member ) *__mptr = (ptr);   \
+        (type *)( (char *)__mptr - offsetof(type,member) );})
+
+/*
+ * Simple doubly linked list implementation.
+ *
+ * Some of the internal functions ("__xxx") are useful when
+ * manipulating whole lists rather than single entries, as
+ * sometimes we already know the next/prev entries and we can
+ * generate better code by using them directly rather than
+ * using the generic single-entry routines.
+ */
+
+struct list_head {
+       struct list_head *next, *prev;
+};
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) \
+       struct list_head name = LIST_HEAD_INIT(name)
+
+#define INIT_LIST_HEAD(ptr) do { \
+       (ptr)->next = (ptr); (ptr)->prev = (ptr); \
+} while (0)
+
+/*
+ * Insert a new entry between two known consecutive entries. 
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_add(struct list_head *new,
+                             struct list_head *prev,
+                             struct list_head *next)
+{
+       next->prev = new;
+       new->next = next;
+       new->prev = prev;
+       prev->next = new;
+}
+
+/**
+ * list_add - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ */
+static inline void list_add(struct list_head *new, struct list_head *head)
+{
+       __list_add(new, head, head->next);
+}
+
+/**
+ * list_add_tail - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static inline void list_add_tail(struct list_head *new, struct list_head *head)
+{
+       __list_add(new, head->prev, head);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_del(struct list_head * prev, struct list_head * next)
+{
+       next->prev = prev;
+       prev->next = next;
+}
+
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty on entry does not return true after this, the entry is
+ * in an undefined state.
+ */
+static inline void list_del(struct list_head *entry)
+{
+       __list_del(entry->prev, entry->next);
+}
+
+/**
+ * list_del_init - deletes entry from list and reinitialize it.
+ * @entry: the element to delete from the list.
+ */
+static inline void list_del_init(struct list_head *entry)
+{
+       __list_del(entry->prev, entry->next);
+       INIT_LIST_HEAD(entry); 
+}
+
+/**
+ * list_move - delete from one list and add as another's head
+ * @list: the entry to move
+ * @head: the head that will precede our entry
+ */
+static inline void list_move(struct list_head *list, struct list_head *head)
+{
+        __list_del(list->prev, list->next);
+        list_add(list, head);
+}
+
+/**
+ * list_move_tail - delete from one list and add as another's tail
+ * @list: the entry to move
+ * @head: the head that will follow our entry
+ */
+static inline void list_move_tail(struct list_head *list,
+                                 struct list_head *head)
+{
+        __list_del(list->prev, list->next);
+        list_add_tail(list, head);
+}
+
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static inline int list_empty(struct list_head *head)
+{
+       return head->next == head;
+}
+
+static inline void __list_splice(struct list_head *list,
+                                struct list_head *head)
+{
+       struct list_head *first = list->next;
+       struct list_head *last = list->prev;
+       struct list_head *at = head->next;
+
+       first->prev = head;
+       head->next = first;
+
+       last->next = at;
+       at->prev = last;
+}
+
+/**
+ * list_splice - join two lists
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ */
+static inline void list_splice(struct list_head *list, struct list_head *head)
+{
+       if (!list_empty(list))
+               __list_splice(list, head);
+}
+
+/**
+ * list_splice_init - join two lists and reinitialise the emptied list.
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ *
+ * The list at @list is reinitialised
+ */
+static inline void list_splice_init(struct list_head *list,
+                                   struct list_head *head)
+{
+       if (!list_empty(list)) {
+               __list_splice(list, head);
+               INIT_LIST_HEAD(list);
+       }
+}
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr:       the &struct list_head pointer.
+ * @type:      the type of the struct this is embedded in.
+ * @member:    the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+       container_of(ptr, type, member)
+
+/**
+ * list_for_each       -       iterate over a list
+ * @pos:       the &struct list_head to use as a loop counter.
+ * @head:      the head for your list.
+ */
+#define list_for_each(pos, head) \
+       for (pos = (head)->next; pos != (head); pos = pos->next)
+
+/**
+ * list_for_each_prev  -       iterate over a list backwards
+ * @pos:       the &struct list_head to use as a loop counter.
+ * @head:      the head for your list.
+ */
+#define list_for_each_prev(pos, head) \
+       for (pos = (head)->prev; pos != (head); pos = pos->prev)
+               
+/**
+ * list_for_each_safe  -       iterate over a list safe against removal of list entry
+ * @pos:       the &struct list_head to use as a loop counter.
+ * @n:         another &struct list_head to use as temporary storage
+ * @head:      the head for your list.
+ */
+#define list_for_each_safe(pos, n, head) \
+       for (pos = (head)->next, n = pos->next; pos != (head); \
+               pos = n, n = pos->next)
+
+/**
+ * list_for_each_entry -       iterate over list of given type
+ * @pos:       the type * to use as a loop counter.
+ * @head:      the head for your list.
+ * @member:    the name of the list_struct within the struct.
+ */
+#define list_for_each_entry(pos, head, member)                         \
+       for (pos = list_entry((head)->next, typeof(*pos), member);      \
+            &pos->member != (head);                                    \
+            pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos:       the type * to use as a loop cursor.
+ * @n:         another type * to use as temporary storage
+ * @head:      the head for your list.
+ * @member:    the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_safe(pos, n, head, member)                 \
+       for (pos = list_entry((head)->next, typeof(*pos), member),      \
+               n = list_entry(pos->member.next, typeof(*pos), member); \
+            &pos->member != (head);                                    \
+            pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+#endif
diff --git a/logging.c b/logging.c
new file mode 100644 (file)
index 0000000..4330269
--- /dev/null
+++ b/logging.c
@@ -0,0 +1,79 @@
+#define _GNU_SOURCE /* asprintf */
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <syslog.h>
+
+#include "logging.h"
+
+/* Do we use syslog for messages or stderr? */
+int logging = 0;
+
+/* Do we want to silently drop all warnings? */
+int quiet = 0;
+
+/* Do we want informative messages as well as errors? */
+int verbose = 0;
+
+void message(const char *prefix, const char *fmt, va_list *arglist)
+{
+       int ret;
+       char *buf, *buf2;
+
+       ret = vasprintf(&buf, fmt, *arglist);
+       if (ret >= 0)
+               ret = asprintf(&buf2, "%s%s", prefix, buf);
+
+       if (ret < 0)
+               buf2 = "FATAL: Out of memory.\n";
+
+       if (logging)
+               syslog(LOG_NOTICE, "%s", buf2);
+       else
+               fprintf(stderr, "%s", buf2);
+
+       if (ret < 0)
+               exit(1);
+
+       free(buf2);
+       free(buf);
+}
+
+void warn(const char *fmt, ...)
+{
+       va_list arglist;
+       va_start(arglist, fmt);
+       if (!quiet)
+               message("WARNING: ", fmt, &arglist);
+       va_end(arglist);
+}
+
+void error(const char *fmt, ...)
+{
+       va_list arglist;
+       va_start(arglist, fmt);
+       message("ERROR: ", fmt, &arglist);
+       va_end(arglist);
+}
+
+void fatal(const char *fmt, ...)
+{
+       va_list arglist;
+       va_start(arglist, fmt);
+       message("FATAL: ", fmt, &arglist);
+       va_end(arglist);
+       exit(1);
+}
+
+/* If we don't flush, then child processes print before we do */
+void info(const char *fmt, ...)
+{
+       va_list arglist;
+       va_start(arglist, fmt);
+       if (verbose) {
+               vfprintf(stdout, fmt, arglist);
+               fflush(stdout);
+       }
+       va_end(arglist);
+}
diff --git a/logging.h b/logging.h
new file mode 100644 (file)
index 0000000..fb11df0
--- /dev/null
+++ b/logging.h
@@ -0,0 +1,49 @@
+#ifndef MODINITTOOLS_LOGGING_H
+#define MODINITTOOLS_LOGGING_H
+
+/* Do we use syslog for messages or stderr? */
+extern int logging;
+
+/* Do we want to silently drop all warnings? */
+extern int quiet;
+
+/* Do we want informative messages as well as errors? */
+extern int verbose;
+
+#ifdef __GNUC__
+#define _printf __attribute__((format(printf, 1, 2)))
+#else
+#define _printf
+#endif
+
+extern void _printf fatal(const char *fmt, ...);
+extern void _printf error(const char *fmt, ...);
+extern void _printf warn(const char *fmt, ...);
+extern void _printf info(const char *fmt, ...);
+
+typedef void _printf (*errfn_t)(const char *fmt, ...);
+
+static inline void grammar(const char *cmd,
+                          const char *filename, unsigned int line)
+{
+       warn("%s line %u: ignoring bad line starting with '%s'\n",
+            filename, line, cmd);
+}
+
+#define NOFAIL(ptr)  do_nofail((ptr), __FILE__, __LINE__, #ptr)
+
+#define nofail_asprintf(ptr, ...)                              \
+       do { if (asprintf((ptr), __VA_ARGS__) < 0)              \
+               do_nofail(NULL, __FILE__, __LINE__, #ptr);      \
+       } while(0)
+
+static inline void *do_nofail(void *ptr, const char *file, int line, const char *expr)
+{
+       if (!ptr) {
+               fatal("Memory allocation failure %s line %d: %s.\n",
+                     file, line, expr);
+       }
+       return ptr;
+}
+
+#endif /* MODINITTOOLS_LOGGING_H */
diff --git a/lsmod.8 b/lsmod.8
new file mode 100644 (file)
index 0000000..bd6a313
--- /dev/null
+++ b/lsmod.8
@@ -0,0 +1,21 @@
+.\\" auto-generated by docbook2man-spec $Revision: 1.2 $
+.TH "LSMOD" "8" "2010-03-01" "" ""
+.SH NAME
+lsmod \- program to show the status of modules in the Linux Kernel
+.SH SYNOPSIS
+.sp
+\fBlsmod\fR
+.SH "DESCRIPTION"
+.PP
+\fBlsmod\fR is a trivial program which nicely
+formats the contents of the \fI/proc/modules\fR,
+showing what kernel modules are currently loaded.
+.SH "COPYRIGHT"
+.PP
+This manual page originally Copyright 2002, Rusty Russell, IBM
+Corporation. Maintained by Jon Masters and others.
+.SH "SEE ALSO"
+.PP
+\fBinsmod\fR(8),
+\fBmodprobe\fR(8),
+\fBmodinfo\fR(8)
diff --git a/lsmod.c b/lsmod.c
new file mode 100644 (file)
index 0000000..1fd2ec4
--- /dev/null
+++ b/lsmod.c
@@ -0,0 +1,83 @@
+/* lsmod.c: list the status of kernel modules.
+    Copyright (C) 2002  Rusty Russell, IBM Corporation.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <ctype.h>
+#include <asm/unistd.h>
+
+#include "testing.h"
+
+static void print_usage(const char *progname)
+{
+       fprintf(stderr, "Usage: %s\n", progname);
+       exit(1);
+}
+
+int main(int argc, char *argv[])
+{
+       char line[4096];
+       FILE *file;
+
+       if (argc != 1)
+               print_usage("lsmod");
+
+       file = fopen("/proc/modules", "r");
+       if (!file) {
+               perror("Opening /proc/modules");
+               exit(1);
+       }
+
+       printf("Module                  Size  Used by\n");
+       while (fgets(line, sizeof(line), file)) {
+               char *tok;
+
+               tok = strtok(line, " \t");
+               printf("%-19s", tok);
+               tok = strtok(NULL, " \t\n");
+               printf(" %8s", tok);
+               tok = strtok(NULL, " \t\n");
+               /* Null if no module unloading support. */
+               if (tok) {
+                       printf("  %s", tok);
+                       tok = strtok(NULL, "\n");
+                       if (!tok)
+                               tok = "";
+                       /* New-style has commas, or -.  If so,
+                          truncate (other fields might follow). */
+                       else if (strchr(tok, ',')) {
+                               tok = strtok(tok, "\t ");
+                               /* Strip trailing comma. */
+                               if (tok[strlen(tok)-1] == ',')
+                                       tok[strlen(tok)-1] = '\0';
+                       } else if (tok[0] == '-'
+                                  && (tok[1] == '\0' || isspace(tok[1])))
+                               tok = "";
+                       printf(" %s", tok);
+               }
+               printf("\n");
+       }
+       fclose(file);
+       exit(0);
+}
diff --git a/m4/ax_configure_args.m4 b/m4/ax_configure_args.m4
new file mode 100644 (file)
index 0000000..2099cf9
--- /dev/null
@@ -0,0 +1,72 @@
+# ===========================================================================
+#           http://autoconf-archive.cryp.to/ax_configure_args.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CONFIGURE_ARGS
+#
+# DESCRIPTION
+#
+#   Helper macro for AX_ENABLE_BUILDDIR.
+#
+#   The traditional way of starting a subdir-configure is running the script
+#   with ${1+"$@"} but since autoconf 2.60 this is broken. Instead we have
+#   to rely on eval'ing $ac_configure_args however some old autoconf
+#   versions do not provide that. To ensure maximum portability of autoconf
+#   extension macros this helper can be AC_REQUIRE'd so that
+#   $ac_configure_args will alsways be present.
+#
+#   Sadly, the traditional "exec $SHELL" of the enable_builddir macros is
+#   spoiled now and must be replaced by "eval + exit $?".
+#
+#   Example:
+#
+#      AC_DEFUN([AX_ENABLE_SUBDIR],[dnl
+#        AC_REQUIRE([AX_CONFIGURE_ARGS])dnl
+#        eval $SHELL $ac_configure_args || exit $?
+#        ...])
+#
+# LAST MODIFICATION
+#
+#   2008-04-12
+#
+# COPYLEFT
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Macro Archive. When you make and
+#   distribute a modified version of the Autoconf Macro, you may extend this
+#   special exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AX_CONFIGURE_ARGS],[
+   # [$]@ is unsable in 2.60+ but earlier autoconf had no ac_configure_args
+   if test "${ac_configure_args+set}" != "set" ; then
+      ac_configure_args=
+      for ac_arg in ${1+"[$]@"}; do
+         ac_configure_args="$ac_configure_args '$ac_arg'"
+      done
+   fi
+])
diff --git a/m4/ax_enable_builddir.m4 b/m4/ax_enable_builddir.m4
new file mode 100644 (file)
index 0000000..4273a53
--- /dev/null
@@ -0,0 +1,302 @@
+# ===========================================================================
+#           http://autoconf-archive.cryp.to/ax_enable_builddir.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_ENABLE_BUILDDIR [(dirstring-or-command [,Makefile.mk [,-all]])]
+#
+# DESCRIPTION
+#
+#   If the current configure was run within the srcdir then we move all
+#   configure-files into a subdir and let the configure steps continue
+#   there. We provide an option --disable-builddir to suppress the move into
+#   a separate builddir.
+#
+#   Defaults:
+#
+#     $1 = $host (overridden with $HOST)
+#     $2 = Makefile.mk
+#     $3 = -all
+#
+#   This macro must be called before AM_INIT_AUTOMAKE. It creates a default
+#   toplevel srcdir Makefile from the information found in the created
+#   toplevel builddir Makefile. It just copies the variables and
+#   rule-targets, each extended with a default rule-execution that recurses
+#   into the build directory of the current "HOST". You can override the
+#   auto-dection through `config.guess` and build-time of course, as in
+#
+#     make HOST=i386-mingw-cross
+#
+#   which can of course set at configure time as well using
+#
+#     configure --host=i386-mingw-cross
+#
+#   After the default has been created, additional rules can be appended
+#   that will not just recurse into the subdirectories and only ever exist
+#   in the srcdir toplevel makefile - these parts are read from the $2 =
+#   Makefile.mk file
+#
+#   The automatic rules are usually scanning the toplevel Makefile for lines
+#   like '#### $host |$builddir' to recognize the place where to recurse
+#   into. Usually, the last one is the only one used. However, almost all
+#   targets have an additional "*-all" rule which makes the script to
+#   recurse into _all_ variants of the current HOST (!!) setting. The "-all"
+#   suffix can be overriden for the macro as well.
+#
+#   a special rule is only given for things like "dist" that will copy the
+#   tarball from the builddir to the sourcedir (or $(PUB)) for reason of
+#   convenience.
+#
+# LAST MODIFICATION
+#
+#   2009-03-09
+#
+# COPYLEFT
+#
+#   Copyright (c) 2009 Guido U. Draheim <guidod@gmx.de>
+#   Copyright (c) 2009 Alan Jenkins <alan-jenkins@tuffmail.co.uk>
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Macro Archive. When you make and
+#   distribute a modified version of the Autoconf Macro, you may extend this
+#   special exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AX_ENABLE_BUILDDIR],[
+AC_REQUIRE([AC_CANONICAL_HOST])[]dnl
+AC_REQUIRE([AX_CONFIGURE_ARGS])[]dnl
+AC_REQUIRE([AM_AUX_DIR_EXPAND])[]dnl
+AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl
+AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl
+AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl
+AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl
+SUB="."
+AC_ARG_ENABLE([builddir], AC_HELP_STRING(
+  [--disable-builddir],[disable automatic build in subdir of sources])
+  ,[SUB="$enableval"], [SUB="auto"])
+if test ".$ac_srcdir_defaulted" != ".no" ; then
+if test ".$srcdir" = ".." ; then
+  if test -f config.status ; then
+    AC_MSG_NOTICE(toplevel srcdir already configured... skipping subdir build)
+  else
+    test ".$SUB" = "."  && SUB="."
+    test ".$SUB" = ".no"  && SUB="."
+    test ".$TARGET" = "." && TARGET="$target"
+    test ".$SUB" = ".auto" && SUB="m4_ifval([$1], [$1],[$TARGET])"
+    if test ".$SUB" != ".." ; then    # we know where to go and
+      AS_MKDIR_P([$SUB])
+      echo __.$SUB.__ > $SUB/conftest.tmp
+      cd $SUB
+      if grep __.$SUB.__ conftest.tmp >/dev/null 2>/dev/null ; then
+        rm conftest.tmp
+        AC_MSG_RESULT([continue configure in default builddir "./$SUB"])
+      else
+        AC_MSG_ERROR([could not change to default builddir "./$SUB"])
+      fi
+      srcdir=`echo "$SUB" |
+              sed -e 's,^\./,,;s,[[^/]]$,&/,;s,[[^/]]*/,../,g;s,[[/]]$,,;'`
+      # going to restart from subdirectory location
+      test -f $srcdir/config.log   && mv $srcdir/config.log   .
+      test -f $srcdir/confdefs.h   && mv $srcdir/confdefs.h   .
+      test -f $srcdir/conftest.log && mv $srcdir/conftest.log .
+      test -f $srcdir/$cache_file  && mv $srcdir/$cache_file  .
+      AC_MSG_RESULT(....exec $SHELL $srcdir/[$]0 "--srcdir=$srcdir" "--enable-builddir=$SUB" ${1+"[$]@"})
+      case "[$]0" in # restart
+       [/\\]*) eval $SHELL "'[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;;
+       *) eval $SHELL "'$srcdir/[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;;
+      esac ; exit $?
+    fi
+  fi
+fi fi
+test ".$SUB" = ".auto" && SUB="."
+dnl ac_path_prog uses "set dummy" to override $@ which would defeat the "exec"
+AC_PATH_PROG(SED,gsed sed, sed)
+AUX="$am_aux_dir"
+AS_VAR_POPDEF([SED])dnl
+AS_VAR_POPDEF([AUX])dnl
+AS_VAR_POPDEF([SUB])dnl
+AC_CONFIG_COMMANDS([buildir],[dnl .............. config.status ..............
+AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl
+AS_VAR_PUSHDEF([TOP],[top_srcdir])dnl
+AS_VAR_PUSHDEF([SRC],[ac_top_srcdir])dnl
+AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl
+AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl
+pushdef([END],[Makefile.mk])dnl
+pushdef([_ALL],[ifelse([$3],,[-all],[$3])])dnl
+  SRC="$ax_enable_builddir_srcdir"
+  if test ".$SUB" = ".." ; then
+    if test -f "$TOP/Makefile" ; then
+      AC_MSG_NOTICE([skipping TOP/Makefile - left untouched])
+    else
+      AC_MSG_NOTICE([skipping TOP/Makefile - not created])
+    fi
+  else
+    if test -f "$SRC/Makefile" ; then
+      a=`grep "^VERSION " "$SRC/Makefile"` ; b=`grep "^VERSION " Makefile`
+      test "$a" != "$b" && rm "$SRC/Makefile"
+    fi
+    if test -f "$SRC/Makefile" ; then
+       echo "$SRC/Makefile : $SRC/Makefile.in" > $tmp/conftemp.mk
+       echo "  []@ echo 'REMOVED,,,' >\$[]@" >> $tmp/conftemp.mk
+      eval "${MAKE-make} -f $tmp/conftemp.mk 2>/dev/null >/dev/null"
+      if grep '^REMOVED,,,' "$SRC/Makefile" >/dev/null
+      then rm $SRC/Makefile ; fi
+      cp $tmp/conftemp.mk $SRC/makefiles.mk~      ## DEBUGGING
+    fi
+    if test ! -f "$SRC/Makefile" ; then
+      AC_MSG_NOTICE([create TOP/Makefile guessed from local Makefile])
+      x='`' ; cat >$tmp/conftemp.sed <<_EOF
+/^\$/n
+x
+/^\$/bS
+x
+/\\\\\$/{H;d;}
+{H;s/.*//;x;}
+bM
+:S
+x
+/\\\\\$/{h;d;}
+{h;s/.*//;x;}
+:M
+s/\\(\\n\\)    /\\1 /g
+/^     /d
+/^[[   ]]*[[\\#]]/d
+/^VPATH *=/d
+s/^srcdir *=.*/srcdir = ./
+s/^top_srcdir *=.*/top_srcdir = ./
+/[[:=]]/!d
+/^\\./d
+dnl Now handle rules (i.e. lines containing ":" but not " = ").
+/ = /b
+/ .= /b
+/:/!b
+s/:.*/:/
+s/ /  /g
+s/ \\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/ \\1 \\1[]_ALL\\2/g
+s/^\\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/\\1 \\1[]_ALL\\2/
+s/  / /g
+/^all all[]_ALL[[ :]]/i\\
+all-configured : all[]_ALL
+dnl dist-all exists... and would make for dist-all-all
+s/ [[a-zA-Z0-9-]]*[]_ALL [[a-zA-Z0-9-]]*[]_ALL[]_ALL//g
+/[]_ALL[]_ALL/d
+a\\
+       @ HOST="\$(HOST)\" \\\\\\
+       ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\
+       ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+       ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
+       ; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" = "0" ; then : \\\\\\
+       ; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\
+       ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
+       ; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\
+       ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done
+dnl special rule add-on: "dist" copies the tarball to $(PUB). (source tree)
+/dist[]_ALL *:/a\\
+       @ HOST="\$(HOST)\" \\\\\\
+       ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\
+       ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+       ; found=$x echo \$\$BUILD | wc -w $x \\\\\\
+       ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\
+       ; if test "\$\$found" = "0" ; then : \\\\\\
+       ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\
+       ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\
+       ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done
+dnl special rule add-on: "dist-foo" copies all the archives to $(PUB). (source tree)
+/dist-[[a-zA-Z0-9]]*[]_ALL *:/a\\
+       @ HOST="\$(HOST)\" \\\\\\
+       ; test ".\$\$HOST" = "." && HOST=$x sh ./config.guess $x \\\\\\
+       ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+       ; found=$x echo \$\$BUILD | wc -w $x \\\\\\
+       ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).*" \\\\\\
+       ; if test "\$\$found" = "0" ; then : \\\\\\
+       ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\
+       ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).* \\\\\\
+       ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done
+dnl special rule add-on: "distclean" removes all local builddirs completely
+/distclean[]_ALL *:/a\\
+       @ HOST="\$(HOST)\" \\\\\\
+       ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\
+       ; BUILD=$x grep "^#### .*|" Makefile | sed -e 's/.*|//' $x \\\\\\
+       ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
+       ; echo "MAKE \$\$HOST : \$\$n * \$\@ (all local builds)" \\\\\\
+       ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
+       ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; echo "# rm -r \$\$i"; done ; echo "# (sleep 3)" ; sleep 3 \\\\\\
+       ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; echo "\$\$i" | grep "^/" > /dev/null && continue \\\\\\
+       ; echo "\$\$i" | grep "^../" > /dev/null && continue \\\\\\
+       ; echo "rm -r \$\$i"; (rm -r "\$\$i") ; done ; rm Makefile
+_EOF
+      cp "$tmp/conftemp.sed" "$SRC/makefile.sed~"            ## DEBUGGING
+      $SED -f $tmp/conftemp.sed Makefile >$SRC/Makefile
+      if test -f "$SRC/m4_ifval([$2],[$2],[END])" ; then
+        AC_MSG_NOTICE([extend TOP/Makefile with TOP/m4_ifval([$2],[$2],[END])])
+        cat $SRC/END >>$SRC/Makefile
+      fi ; xxxx="####"
+      echo "$xxxx CONFIGURATIONS FOR TOPLEVEL MAKEFILE: " >>$SRC/Makefile
+      # sanity check
+      if grep '^; echo "MAKE ' $SRC/Makefile >/dev/null ; then
+        AC_MSG_NOTICE([buggy sed found - it deletes tab in "a" text parts])
+        $SED -e '/^@ HOST=/s/^/        /' -e '/^; /s/^/        /' $SRC/Makefile \
+          >$SRC/Makefile~
+        (test -s $SRC/Makefile~ && mv $SRC/Makefile~ $SRC/Makefile) 2>/dev/null
+      fi
+    else
+      xxxx="\\#\\#\\#\\#"
+      # echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed
+      echo "s!^$xxxx [[^|]]* | *$SUB *\$!$xxxx ...... $SUB!" >$tmp/conftemp.sed
+      $SED -f "$tmp/conftemp.sed" "$SRC/Makefile" >$tmp/mkfile.tmp
+        cp "$tmp/conftemp.sed" "$SRC/makefiles.sed~"         ## DEBUGGING
+        cp "$tmp/mkfile.tmp"   "$SRC/makefiles.out~"         ## DEBUGGING
+      if cmp -s "$SRC/Makefile" "$tmp/mkfile.tmp" 2>/dev/null ; then
+        AC_MSG_NOTICE([keeping TOP/Makefile from earlier configure])
+        rm "$tmp/mkfile.tmp"
+      else
+        AC_MSG_NOTICE([reusing TOP/Makefile from earlier configure])
+        mv "$tmp/mkfile.tmp" "$SRC/Makefile"
+      fi
+    fi
+    AC_MSG_NOTICE([build in $SUB (HOST=$ax_enable_builddir_host)])
+    xxxx="####"
+    echo "$xxxx" "$ax_enable_builddir_host" "|$SUB" >>$SRC/Makefile
+  fi
+popdef([END])dnl
+AS_VAR_POPDEF([SED])dnl
+AS_VAR_POPDEF([AUX])dnl
+AS_VAR_POPDEF([SRC])dnl
+AS_VAR_POPDEF([TOP])dnl
+AS_VAR_POPDEF([SUB])dnl
+],[dnl
+ax_enable_builddir_srcdir="$srcdir"                    # $srcdir
+ax_enable_builddir_host="$HOST"                        # $HOST / $host
+ax_enable_builddir_version="$VERSION"                  # $VERSION
+ax_enable_builddir_package="$PACKAGE"                  # $PACKAGE
+ax_enable_builddir_auxdir="$ax_enable_builddir_auxdir" # $AUX
+ax_enable_builddir_sed="$ax_enable_builddir_sed"       # $SED
+ax_enable_builddir="$ax_enable_builddir"               # $SUB
+])dnl
+])
diff --git a/missing b/missing
new file mode 100755 (executable)
index 0000000..28055d2
--- /dev/null
+++ b/missing
@@ -0,0 +1,376 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
+# 2008, 2009 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case $1 in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  # Exit code 63 means version mismatch.  This often happens
+  # when the user try to use an ancient version of a tool on
+  # a file that requires a minimum version.  In this case we
+  # we should proceed has if the program had been absent, or
+  # if --run hadn't been passed.
+  if test $? = 63; then
+    run=:
+    msg="probably too old"
+  fi
+  ;;
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  autom4te     touch the output file, or create a stub one
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
+\`g' are ignored when checking the name.
+
+Send bug reports to <bug-automake@gnu.org>."
+    exit $?
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+esac
+
+# normalize program name to check for.
+program=`echo "$1" | sed '
+  s/^gnu-//; t
+  s/^gnu//; t
+  s/^g//; t'`
+
+# Now exit if we have it, but it failed.  Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).  This is about non-GNU programs, so use $1 not
+# $program.
+case $1 in
+  lex*|yacc*)
+    # Not GNU programs, they don't have --version.
+    ;;
+
+  tar*)
+    if test -n "$run"; then
+       echo 1>&2 "ERROR: \`tar' requires --run"
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       exit 1
+    fi
+    ;;
+
+  *)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       # Could not run --version or --help.  This is probably someone
+       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # $TOOL exists and not knowing $TOOL uses missing.
+       exit 1
+    fi
+    ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $program in
+  aclocal*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`${configure_ac}'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case $f in
+      *:*) touch_files="$touch_files "`echo "$f" |
+                                      sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+          sed 's/\.am$/.in/' |
+          while read f; do touch "$f"; done
+    ;;
+
+  autom4te*)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo "#! /bin/sh"
+       echo "# Created by GNU Automake missing as a replacement of"
+       echo "#  $ $@"
+       echo "exit 0"
+       chmod +x $file
+       exit 1
+    fi
+    ;;
+
+  bison*|yacc*)
+    echo 1>&2 "\
+WARNING: \`$1' $msg.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if test $# -ne 1; then
+        eval LASTARG="\${$#}"
+       case $LASTARG in
+       *.y)
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+           if test -f "$SRCFILE"; then
+                cp "$SRCFILE" y.tab.c
+           fi
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+           if test -f "$SRCFILE"; then
+                cp "$SRCFILE" y.tab.h
+           fi
+         ;;
+       esac
+    fi
+    if test ! -f y.tab.h; then
+       echo >y.tab.h
+    fi
+    if test ! -f y.tab.c; then
+       echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex*|flex*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if test $# -ne 1; then
+        eval LASTARG="\${$#}"
+       case $LASTARG in
+       *.l)
+           SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+           if test -f "$SRCFILE"; then
+                cp "$SRCFILE" lex.yy.c
+           fi
+         ;;
+       esac
+    fi
+    if test ! -f lex.yy.c; then
+       echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+        you modified a dependency of a manual page.  You may need the
+        \`Help2man' package in order for those modifications to take
+        effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo ".ab help2man is required to generate this page"
+       exit $?
+    fi
+    ;;
+
+  makeinfo*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    # The file to touch is that specified with -o ...
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -z "$file"; then
+      # ... or it is the one specified with @setfilename ...
+      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '
+       /^@setfilename/{
+         s/.* \([^ ]*\) *$/\1/
+         p
+         q
+       }' $infile`
+      # ... or it is derived from the source name (dir/f.texi becomes f.info)
+      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+    fi
+    # If the file does not exist, the user really needs makeinfo;
+    # let's fail without touching anything.
+    test -f $file || exit 1
+    touch $file
+    ;;
+
+  tar*)
+    shift
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+       case $firstarg in
+       *o*)
+           firstarg=`echo "$firstarg" | sed s/o//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+       case $firstarg in
+       *h*)
+           firstarg=`echo "$firstarg" | sed s/h//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequisites for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/modindex.c b/modindex.c
new file mode 100644 (file)
index 0000000..da397d0
--- /dev/null
@@ -0,0 +1,165 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <getopt.h>
+#include <errno.h>
+#include <string.h>
+
+#include "util.h"
+#include "logging.h"
+#include "index.h"
+
+static void write_index(const char *filename)
+{
+       struct index_node *index;
+       char *line, *pos;
+       FILE *cfile;
+       unsigned int linenum = 0;
+       
+       cfile = fopen(filename, "w");
+       if (!cfile)
+               fatal("Could not open %s for writing: %s\n",
+                     filename, strerror(errno));
+       
+       index = index_create();
+       
+       while((line = getline_wrapped(stdin, &linenum))) {
+               pos = strchr(line, ' ');
+               *pos++ = '\0';
+               index_insert(index, line, pos, linenum);
+               free(line);
+       }
+       
+       index_write(index, cfile);
+       index_destroy(index);
+       fclose(cfile);
+}
+
+static struct index_file *open_index(const char *filename)
+{
+       struct index_file *index;
+
+       index = index_file_open(filename);
+       if (!index) {
+               if (errno == EINVAL)
+                       fatal("%s has wrong magic or version number", filename);
+
+               fatal("Could not open %s for reading: %s\n",
+                     filename, strerror(errno));
+       }
+
+       return index;
+}
+
+static void dump_index(const char *filename)
+{
+       struct index_file *index = open_index(filename);
+
+       index_dump(index, stdout, "");
+
+       index_file_close(index);
+}
+
+static void search_index(const char *filename, char *key)
+{
+       struct index_file *index = open_index(filename);
+       char *value;
+
+       value = index_search(index, key);
+       if (value)
+               printf("Found value:\n%s\n", value);
+       else
+               printf("Not found.\n");
+       
+       free(value);
+       index_file_close(index);
+}
+
+static void searchwild_index(const char *filename, char *key)
+{
+       struct index_file *index = open_index(filename);
+       struct index_value *values, *v;
+
+       values = index_searchwild(index, key);
+       if (values)
+               printf("Found value(s):\n");
+       else
+               printf("Not found.\n"); 
+
+       for (v = values; v; v = v->next)
+               printf("%s\n", v->value);
+
+       index_values_free(values);
+       index_file_close(index);
+}
+
+static void print_usage(const char *progname)
+{
+       fprintf(stderr,
+               "Usage: %s [MODE] [FILE] ...\n"
+               " -o, --output <outfile>\n"
+               " -d, --dump <infile>\n"
+               " -s, --search <key> <infile>\n"
+               " -w, --searchwild <key> <infile>\n"
+               ,progname);
+       exit(1);
+}
+
+static struct option options[] = {
+       { "output", 0, NULL, 'o' },
+       { "dump", 0, NULL, 'd' },
+       { "search", 1, NULL, 's' },
+       { "searchwild", 1, NULL, 'w' },
+};
+
+int main(int argc, char *argv[])
+{
+       int opt;
+       char mode = 0;
+       char *filename = NULL;
+       char *key = NULL;
+       
+       while ((opt = getopt_long(argc, argv, "ods:w:", options, NULL))
+                      != -1) {
+               switch (opt) {
+                       case 'o':
+                               mode = 'o';
+                               break;
+                       case 'd':
+                               mode = 'd';
+                               break;
+                       case 's':
+                               mode = 's';
+                               key = optarg;
+                               break;
+                       case 'w':
+                               mode = 'w';
+                               key = optarg;
+                               break;
+                       default:
+                               print_usage(argv[0]);
+               }
+       }
+       if (!mode)
+               print_usage(argv[0]);
+       
+       if (optind >= argc)
+               print_usage(argv[0]);
+       filename = argv[optind];
+       
+       switch(mode) {
+               case 'o':
+                       write_index(filename);
+                       break;
+               case 'd':
+                       dump_index(filename);
+                       break;
+               case 's':
+                       search_index(filename, key);
+                       break;
+               case 'w':
+                       searchwild_index(filename, key);
+                       break;
+       }
+       
+       return 0;
+}
diff --git a/modinfo.8 b/modinfo.8
new file mode 100644 (file)
index 0000000..12856d1
--- /dev/null
+++ b/modinfo.8
@@ -0,0 +1,72 @@
+.\\" auto-generated by docbook2man-spec $Revision: 1.2 $
+.TH "MODINFO" "8" "2010-03-01" "" ""
+.SH NAME
+modinfo \- program to show information about a Linux Kernel module
+.SH SYNOPSIS
+.sp
+\fBmodinfo\fR [ \fB-0\fR ]  [ \fB-F \fIfield\fB\fR ]  [ \fB-k \fIkernel\fB\fR ]  [ \fBmodulename|filename\fR\fI...\fR ] 
+.sp
+\fBmodinfo -V\fR
+.sp
+\fBmodinfo -h\fR
+.SH "DESCRIPTION"
+.PP
+\fBmodinfo\fR extracts information from the Linux
+Kernel modules given on the command line. If the module name is
+not a filename, then the
+\fI/lib/modules/\fR\fIversion\fR
+directory is searched, as is also done by
+\fBmodprobe\fR(8) when loading kernel modules.
+.PP
+\fBmodinfo\fR by default lists each attribute
+of the module in form \fIfieldname\fR :
+\fIvalue\fR, for easy reading. The
+filename is listed the same way (although it's not really an
+attribute).
+.PP
+This version of \fBmodinfo\fR can understand
+modules of any Linux Kernel architecture.
+.SH "OPTIONS"
+.TP
+\fB-V --version\fR
+Print the modinfo version.
+.TP
+\fB-F --field\fR
+Only print this field value, one per line. This is most
+useful for scripts. Field names are case-insenitive.
+Common fields (which may not be in every module) include
+author, description,
+license, parm,
+depends, and alias\&.
+There are often multiple parm,
+alias and depends
+fields. The special field filename
+lists the filename of the module.
+.TP
+\fB-k \fIkernel\fB\fR
+Provide information about a kernel other than the running one. This
+is particularly useful for distributions needing to extract
+information from a newly installed (but not yet running) set of
+kernel modules. For example, you wish to find which firmware files
+are needed by various modules in a new kernel for which you must
+make an initrd/initramfs image prior to booting.
+.TP
+\fB-0 --null\fR
+Use the ASCII zero character to separate field values,
+instead of a new line. This is useful for scripts, since
+a new line can theoretically appear inside a field.
+.TP
+\fB-a -d -l -p -n\fR
+These are shortcuts for author,
+description,
+license\&. parm and
+filename respectively, to ease the
+transition from the old modutils
+\fBmodinfo\fR\&.
+.SH "COPYRIGHT"
+.PP
+This manual page originally Copyright 2003, Rusty Russell, IBM
+Corporation. Maintained by Jon Masters and others.
+.SH "SEE ALSO"
+.PP
+\fBmodprobe\fR(8)
diff --git a/modinfo.c b/modinfo.c
new file mode 100644 (file)
index 0000000..90e9ad3
--- /dev/null
+++ b/modinfo.c
@@ -0,0 +1,323 @@
+/* Extract module info: useful for both the curious and for scripts. */
+#define _GNU_SOURCE /* asprintf rocks */
+#include <elf.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/utsname.h>
+#include <sys/mman.h>
+
+#include "util.h"
+#include "logging.h"
+#include "elfops.h"
+#include "zlibsupport.h"
+#include "testing.h"
+
+#ifndef MODULE_DIR
+#define MODULE_DIR "/lib/modules"
+#endif
+
+struct param
+{
+       struct param *next;
+       const char *name;       /* Terminated by a colon */
+       const char *param;
+       const char *type;
+};
+
+static struct param *add_param(const char *name, struct param **list)
+{
+       struct param *i;
+       unsigned int namelen = strcspn(name, ":") + 1;
+
+       for (i = *list; i; i = i->next)
+               if (strncmp(i->name, name, namelen) == 0)
+                       return i;
+       i = NOFAIL(malloc(sizeof(*i) + namelen+1));
+       strncpy((char *)(i + 1), name, namelen);
+       ((char *)(i + 1))[namelen] = '\0';
+       i->name = (char *)(i + 1);
+       i->param = NULL;
+       i->type = NULL;
+       i->next = *list;
+       *list = i;
+       return i;
+}
+
+static void print_tag(const char *tag, struct string_table *tags,
+                     const char *filename, char sep)
+{
+       int j;
+       unsigned int taglen = strlen(tag);
+
+       if (streq(tag, "filename")) {
+               printf("%s%c", filename, sep);
+               return;
+       }
+
+       for (j = 0; j < tags->cnt; j++) {
+               const char *info = tags->str[j];
+               if (strncmp(info, tag, taglen) == 0 && info[taglen] == '=')
+                       printf("%s%c", info + taglen + 1, sep);
+       }
+}
+
+static void print_all(struct string_table *tags,
+                     const char *filename, char sep)
+{
+       int j;
+       struct param *i, *params = NULL;
+
+       printf("%-16s%s%c", "filename:", filename, sep);
+       for (j = 0; j < tags->cnt; j++) {
+               const char *info = tags->str[j];
+               char *eq, *colon;
+
+               /* We expect this in parm and parmtype. */
+               colon = strchr(info, ':');
+
+               /* We store these for handling at the end */
+               if (strstarts(info, "parm=") && colon) {
+                       i = add_param(info + strlen("parm="), &params);
+                       i->param = colon + 1;
+                       continue;
+               }
+               if (strstarts(info, "parmtype=") && colon) {
+                       i = add_param(info + strlen("parmtype="), &params);
+                       i->type = colon + 1;
+                       continue;
+               }
+
+               if (!sep) {
+                       printf("%s%c", info, sep);
+                       continue;
+               }
+
+               eq = strchr(info, '=');
+               /* Warn if no '=' maybe? */
+               if (eq) {
+                       char tag[eq - info + 2];
+                       strncpy(tag, info, eq - info);
+                       tag[eq-info] = ':';
+                       tag[eq-info+1] = '\0';
+                       printf("%-16s%s%c", tag, eq+1, sep);
+               }
+       }
+
+       /* Now show parameters. */
+       for (i = params; i; i = i->next) {
+               if (!i->param)
+                       printf("%-16s%s%s%c", "parm:", i->name, i->type, sep);
+               else if (i->type)
+                       printf("%-16s%s%s (%s)%c",
+                              "parm:", i->name, i->param, i->type, sep);
+               else 
+                       printf("%-16s%s%s%c", "parm:", i->name, i->param, sep);
+       }
+}
+
+static struct option options[] =
+{
+       {"author", 0, 0, 'a'},
+       {"description", 0, 0, 'd'},
+       {"license", 0, 0, 'l'},
+       {"parameters", 0, 0, 'p'},
+       {"filename", 0, 0, 'n'},
+       {"version", 0, 0, 'V'},
+       {"help", 0, 0, 'h'},
+       {"null", 0, 0, '0'},
+       {"field", 1, 0, 'F'},
+       {0, 0, 0, 0}
+};
+
+/* - and _ are equivalent, and expect suffix. */
+static int name_matches(const char *line, const char *end, const char *modname)
+{
+       unsigned int i;
+       char *p;
+
+       /* Ignore comment lines */
+       if (line[strspn(line, "\t ")] == '#')
+               return 0;
+
+       /* Find last / before colon. */
+       p = memchr(line, ':', end - line);
+       if (!p)
+               return 0;
+       while (p > line) {
+               if (*p == '/') {
+                       p++;
+                       break;
+               }
+               p--;
+       }
+
+       for (i = 0; modname[i]; i++) {
+               /* Module names can't have colons. */
+               if (modname[i] == ':')
+                       continue;
+               if (modname[i] == p[i])
+                       continue;
+               if (modname[i] == '_' && p[i] == '-')
+                       continue;
+               if (modname[i] == '-' && p[i] == '_')
+                       continue;
+               return 0;
+       }
+       /* Must match all the way to the extension */
+       return (p[i] == '.');
+}
+
+static char *next_line(char *p, const char *end)
+{
+       char *eol;
+
+       eol = memchr(p, '\n', end - p);
+       if (eol)
+               return eol + 1;
+       return (char *)end + 1;
+}
+
+static struct elf_file *grab_module(const char *name,
+                                   const char *kernel,
+                                   const char *basedir)
+{
+       char *data;
+       unsigned long size;
+       struct utsname buf;
+       char *depname, *p, *moddir;
+       struct elf_file *module;
+
+       if (strchr(name, '.') || strchr(name, '/')) {
+               module = grab_elf_file(name);
+               if (!module)
+                       error("modinfo: could not open %s: %s\n",
+                               name, strerror(errno));
+               return module;
+       }
+
+       if (!kernel) {
+               uname(&buf);
+               kernel = buf.release;
+       }
+       if (strlen(basedir))
+               nofail_asprintf(&moddir, "%s/%s/%s", basedir, MODULE_DIR, kernel);
+       else
+               nofail_asprintf(&moddir, "%s/%s", MODULE_DIR, kernel);
+
+       /* Search for it in modules.dep. */
+       nofail_asprintf(&depname, "%s/%s", moddir, "modules.dep");
+       data = grab_file(depname, &size);
+       if (!data) {
+               error("modinfo: could not open %s\n", depname);
+               free(depname);
+               return NULL;
+       }
+       free(depname);
+
+       for (p = data; p < data + size; p = next_line(p, data + size)) {
+               if (name_matches(p, data + size, name)) {
+                       int namelen = strcspn(p, ":");
+                       const char *dir;
+                       char *filename;
+
+                       if ('/' == p[0])
+                               dir = basedir; /* old style deps - abs. path */
+                       else
+                               dir = moddir; /* new style - relative path */
+
+                       if (strlen(dir)) {
+                               nofail_asprintf(&filename, "%s/%s", dir, p);
+                               filename[namelen + strlen(dir) + 1] = '\0';
+                       } else {
+                               filename = strndup(p, namelen);
+                       }
+                       release_file(data, size);
+                       module = grab_elf_file(filename);
+                       if (!module)
+                               error("modinfo: could not open %s: %s\n",
+                                        filename, strerror(errno));
+                       free(filename);
+                       return module;
+               }
+       }
+       release_file(data, size);
+       error("modinfo: could not find module %s\n", name);
+       return NULL;
+}
+
+static void usage(const char *name)
+{
+       fprintf(stderr, "Usage: %s [-0][-F field][-k kernelversion][-b basedir]  module...\n"
+               " Prints out the information about one or more module(s).\n"
+               " If a fieldname is given, just print out that field (or nothing if not found).\n"
+               " Otherwise, print all information out in a readable form\n"
+               " If -0 is given, separate with nul, not newline.\n"
+               " If -b is given, use an image of the module tree.\n",
+               name);
+}
+
+int main(int argc, char *argv[])
+{
+       const char *field = NULL;
+       const char *kernel = NULL;
+       char sep = '\n';
+       int opt, ret = 0;
+       char *basedir = "";
+
+       logging = 0; /* send messages to stderr */
+
+       if (native_endianness() == 0)
+               abort();
+
+       while ((opt = getopt_long(argc,argv,"adlpVhn0F:k:b:",options,NULL)) >= 0){
+               switch (opt) {
+               case 'a': field = "author"; break;
+               case 'd': field = "description"; break;
+               case 'l': field = "license"; break;
+               case 'p': field = "parm"; break;
+               case 'n': field = "filename"; break;
+               case 'V': printf(PACKAGE " version " VERSION "\n"); exit(0);
+               case 'F': field = optarg; break;
+               case '0': sep = '\0'; break;
+               case 'k': kernel = optarg; break;
+               case 'b': basedir = optarg; break;
+               case 'h': usage(argv[0]); exit(0); break;
+               default:
+                       usage(argv[0]); exit(1);
+               }
+       }
+       if (argc < optind + 1) {
+               usage(argv[0]);
+               exit(1);
+       }
+
+       for (opt = optind; opt < argc; opt++) {
+               struct string_table *tags;
+               struct elf_file *mod;
+
+               mod = grab_module(argv[opt], kernel, basedir);
+               if (!mod) {
+                       ret = 1;
+                       continue;
+               }
+               tags = mod->ops->load_strings(mod, ".modinfo", NULL);
+               if (!tags) {
+                       release_elf_file(mod);
+                       continue;
+               }
+               if (field)
+                       print_tag(field, tags, mod->pathname, sep);
+               else
+                       print_all(tags, mod->pathname, sep);
+               strtbl_free(tags);
+               release_elf_file(mod);
+       }
+       return ret;
+}
diff --git a/modprobe.8 b/modprobe.8
new file mode 100644 (file)
index 0000000..9acfd60
--- /dev/null
@@ -0,0 +1,260 @@
+.\\" auto-generated by docbook2man-spec $Revision: 1.2 $
+.TH "MODPROBE" "8" "2010-03-01" "" ""
+.SH NAME
+modprobe \- program to add and remove modules from the Linux Kernel
+.SH SYNOPSIS
+.sp
+\fBmodprobe\fR [ \fB-v\fR ]  [ \fB-V\fR ]  [ \fB-C \fIconfig-file\fB\fR ]  [ \fB-n\fR ]  [ \fB-i\fR ]  [ \fB-q\fR ]  [ \fB-b\fR ]  [ \fB-o \fImodulename\fB\fR ]  [ \fB\fImodulename\fB\fR ]  [ \fB\fImodule parameters\fB\fR\fI...\fR ] 
+.sp
+\fBmodprobe\fR [ \fB-r\fR ]  [ \fB-v\fR ]  [ \fB-n\fR ]  [ \fB-i\fR ]  [ \fB\fImodulename\fB\fR\fI...\fR ] 
+.sp
+\fBmodprobe\fR [ \fB-l\fR ]  [ \fB-t \fIdirname\fB\fR ]  [ \fB\fIwildcard\fB\fR ] 
+.sp
+\fBmodprobe\fR [ \fB-c\fR ] 
+.sp
+\fBmodprobe\fR [ \fB--dump-modversions\fR ]  [ \fB\fIfilename\fB\fR\fI...\fR ] 
+.SH "DESCRIPTION"
+.PP
+\fBmodprobe\fR intelligently adds or removes a
+module from the Linux kernel: note that for convenience, there
+is no difference between _ and - in module names (automatic
+underscore conversion is performed).
+\fBmodprobe\fR looks in the module directory
+\fI/lib/modules/`uname -r`\fR for all
+the modules and other files, except for the optional
+\fI/etc/modprobe.conf\fR configuration file and
+\fI/etc/modprobe.d\fR directory
+(see \fBmodprobe.conf\fR(5)). \fBmodprobe\fR will also use module
+options specified on the kernel command line in the form of
+<module>\&.<option>\&.
+.PP
+Note that unlike in 2.4 series Linux kernels (which are not supported
+by this tool) this version of \fBmodprobe\fR does not
+do anything to the module itself: the work of resolving symbols
+and understanding parameters is done inside the kernel. So
+module failure is sometimes accompanied by a kernel message: see
+\fBdmesg\fR(8)\&.
+.PP
+\fBmodprobe\fR expects an up-to-date
+\fImodules.dep.bin\fR file (or fallback human
+readable \fImodules.dep\fR file), as generated
+by the corresponding \fBdepmod\fR utility shipped
+along with \fBmodprobe\fR (see
+\fBdepmod\fR(8)). This file lists what other modules each
+module needs (if any), and \fBmodprobe\fR uses this
+to add or remove these dependencies automatically.
+.PP
+If any arguments are given after the
+\fImodulename\fR, they are passed to the
+kernel (in addition to any options listed in the configuration
+file).
+.SH "OPTIONS"
+.TP
+\fB-a --all\fR
+Insert all module names on the command line.
+.TP
+\fB-b --use-blacklist\fR
+This option causes \fBmodprobe\fR to apply the
+\fBblacklist\fR commands in the configuration files
+(if any) to module names as well. It is usually used by
+\fBudev\fR(7)\&.
+.TP
+\fB-C --config\fR
+This option overrides the default configuration directory/file
+(\fI/etc/modprobe.d\fR or 
+\fI/etc/modprobe.conf\fR).
+
+This option is passed through \fBinstall\fR
+or \fBremove\fR commands to other
+\fBmodprobe\fR commands in the
+MODPROBE_OPTIONS environment variable.
+.TP
+\fB-c --showconfig\fR
+Dump out the effective configuration from the config directory
+and exit.
+.TP
+\fB--dump-modversions\fR
+Print out a list of module versioning information required by a
+module. This option is commonly used by distributions in order to
+package up a Linux kernel module using module versioning deps.
+.TP
+\fB-d --dirname\fR
+Directory where modules can be found,
+\fI/lib/modules/RELEASE\fR
+by default.
+.TP
+\fB--first-time\fR
+Normally, \fBmodprobe\fR will succeed (and do
+nothing) if told to insert a module which is already
+present or to remove a module which isn't present. This is
+ideal for simple scripts; however, more complicated scripts often
+want to know whether \fBmodprobe\fR really
+did something: this option makes modprobe fail in the
+case that it actually didn't do anything.
+.TP
+\fB--force-vermagic\fR
+Every module contains a small string containing important
+information, such as the kernel and compiler versions. If
+a module fails to load and the kernel complains that the
+"version magic" doesn't match, you can use this option to
+remove it. Naturally, this check is there for your
+protection, so this using option is dangerous unless
+you know what you're doing.
+
+This applies to any modules inserted: both the module (or
+alias) on the command line and any modules on which it depends.
+.TP
+\fB--force-modversion\fR
+When modules are compiled with CONFIG_MODVERSIONS set, a
+section detailing the versions of every interfaced used
+by (or supplied by) the module is created. If a
+module fails to load and the kernel complains that the
+module disagrees about a version of some interface, you
+can use "--force-modversion" to remove the version
+information altogether. Naturally, this check is there
+for your protection, so using this option is dangerous
+unless you know what you're doing.
+
+This applies any modules inserted: both the module (or
+alias) on the command line and any modules on which it depends.
+.TP
+\fB-f --force\fR
+Try to strip any versioning information from the module
+which might otherwise stop it from loading: this is the
+same as using both \fB--force-vermagic\fR and
+\fB--force-modversion\fR\&. Naturally, these
+checks are there for your protection, so using this option
+is dangerous unless you know what you are doing.
+
+This applies to any modules inserted: both the module (or
+alias) on the command line and any modules it on which it depends.
+.TP
+\fB-i --ignore-install --ignore-remove\fR
+This option causes \fBmodprobe\fR to
+ignore \fBinstall\fR and
+\fBremove\fR commands in the
+configuration file (if any) for the module specified on the
+command line (any dependent modules are still subject
+to commands set for them in the configuration file). Both
+\fBinstall\fR and \fBremove\fR
+commands will currently be ignored when this option is used
+regardless of whether the request was more specifically
+made with only one or other (and not both) of
+\fB--ignore-install\fR or
+\fB--ignore-remove\fR\&.
+See \fBmodprobe.conf\fR(5)\&.
+.TP
+\fB-l --list\fR
+List all modules matching the given wildcard (or "*"
+if no wildcard is given). This option is provided for
+backwards compatibility and may go away in future: see
+\fBfind\fR(1) and
+\fBbasename\fR(1) for a more flexible alternative.
+.TP
+\fB-n --dry-run\fR
+This option does everything but actually insert or
+delete the modules (or run the install or remove
+commands). Combined with \fB-v\fR, it is
+useful for debugging problems. For historical reasons
+both \fB--dry-run\fR and \fB--show\fR
+actually mean the same thing and are interchangeable.
+.TP
+\fB-o --name\fR
+This option tries to rename the module which is being
+inserted into the kernel. Some testing modules can
+usefully be inserted multiple times, but the kernel
+refuses to have two modules of the same name. Normally,
+modules should not require multiple insertions, as that
+would make them useless if there were no module support.
+.TP
+\fB-q --quiet\fR
+With this flag, \fBmodprobe\fR won't print an error
+message if you try to remove or insert a module it can't find (and
+isn't an alias or
+\fBinstall\fR/\fBremove\fR command).
+However, it will still return with a non-zero exit status. The
+kernel uses this to opportunistically probe for modules which might
+exist using request_module.
+.TP
+\fB-R --resolve-alias\fR
+Print all module names matching an alias. This can be useful
+for debugging module alias problems.
+.TP
+\fB-r --remove\fR
+This option causes \fBmodprobe\fR to remove
+rather than insert a module. If the modules it depends on
+are also unused, \fBmodprobe\fR will try to
+remove them too. Unlike insertion, more than one module
+can be specified on the command line (it does not make
+sense to specify module parameters when removing modules).
+
+There is usually no reason to remove modules, but some
+buggy modules require it. Your distribution kernel may not
+have been built to support removal of modules at all.
+.TP
+\fB-S --set-version\fR
+Set the kernel version, rather than using
+\fBuname\fR(2) to decide on the kernel version (which dictates where to
+find the modules).
+.TP
+\fB--show-depends\fR
+List the dependencies of a module (or alias), including
+the module itself. This produces a (possibly empty) set
+of module filenames, one per line, each starting with
+"insmod" and is typically used by distributions to determine
+which modules to include when generating initrd/initramfs images.
+\fBInstall commands which apply are shown prefixed by
+"install". It does not run any of the install commands. Note that
+modinfo(8)
+can be used to extract dependencies of a module from the
+module itself, but knows nothing of aliases or install commands.
+\fR.TP
+\fB-s --syslog\fR
+This option causes any error messages to go through the
+syslog mechanism (as LOG_DAEMON with level LOG_NOTICE)
+rather than to standard error. This is also automatically
+enabled when stderr is unavailable.
+
+This option is passed through \fBinstall\fR
+or \fBremove\fR commands to other
+\fBmodprobe\fR commands in the
+MODPROBE_OPTIONS environment variable.
+.TP
+\fB-t --type\fR
+Restrict \fB-l\fR to modules
+in directories matching the
+\fIdirname\fR given. This option
+is provided for backwards compatibility and may go
+away in future: see
+\fBfind\fR(1)
+and
+\fBbasename\fR(1) for a more flexible alternative.
+.TP
+\fB-V --version\fR
+Show version of program and exit.
+.TP
+\fB-v --verbose\fR
+Print messages about what the program is doing. Usually
+\fBmodprobe\fR only prints messages if
+something goes wrong.
+
+This option is passed through \fBinstall\fR
+or \fBremove\fR commands to other
+\fBmodprobe\fR commands in the
+MODPROBE_OPTIONS environment variable.
+.SH "ENVIRONMENT"
+.PP
+The MODPROBE_OPTIONS environment variable can also be used to
+pass arguments to \fBmodprobe\fR\&.
+.SH "COPYRIGHT"
+.PP
+This manual page originally Copyright 2002, Rusty Russell, IBM
+Corporation. Maintained by Jon Masters and others.
+.SH "SEE ALSO"
+.PP
+\fBmodprobe.conf\fR(5),
+\fBmodprobe.d\fR(5),
+\fBinsmod\fR(8),
+\fBrmmod\fR(8),
+\fBlsmod\fR(8),
+\fBmodinfo\fR(8)
diff --git a/modprobe.c b/modprobe.c
new file mode 100644 (file)
index 0000000..d16151a
--- /dev/null
@@ -0,0 +1,1943 @@
+/* modprobe.c: add or remove a module from the kernel, intelligently.
+    Copyright (C) 2001  Rusty Russell.
+    Copyright (C) 2002, 2003  Rusty Russell, IBM Corporation.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+#define _GNU_SOURCE /* asprintf */
+
+#include <sys/utsname.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <limits.h>
+#include <elf.h>
+#include <getopt.h>
+#include <fnmatch.h>
+#include <asm/unistd.h>
+#include <sys/wait.h>
+#include <syslog.h>
+
+#include "util.h"
+#include "elfops.h"
+#include "zlibsupport.h"
+#include "logging.h"
+#include "index.h"
+#include "list.h"
+#include "config_filter.h"
+
+#include "testing.h"
+
+int use_binary_indexes = 1; /* default to enabled. */
+
+/* Limit do_softdep/do_modprobe recursion.
+ * This is a simple way to handle dependency loops
+ * caused by poorly written softdep commands.
+ */
+static int recursion_depth = 0;
+const int MAX_RECURSION = 50; /* Arbitrary choice */
+
+extern long init_module(void *, unsigned long, const char *);
+extern long delete_module(const char *, unsigned int);
+
+struct module {
+       struct list_head list;
+       char *modname;
+       char filename[0];
+};
+
+typedef enum
+{
+       mit_remove = 1,
+       mit_dry_run = 2,
+       mit_first_time = 4,
+       mit_use_blacklist = 8,
+       mit_ignore_commands = 16,
+       mit_ignore_loaded = 32,
+       mit_quiet_inuse = 64,
+       mit_strip_vermagic = 128,
+       mit_strip_modversion = 256,
+       mit_resolve_alias = 512
+
+} modprobe_flags_t;
+
+#ifndef MODULE_DIR
+#define MODULE_DIR "/lib/modules"
+#endif
+
+static void print_usage(const char *progname)
+{
+       fprintf(stderr,
+               "Usage: %s [-v] [-V] [-C config-file] [-d <dirname> ] [-n] [-i] [-q] [-b] [-o <modname>] [ --dump-modversions ] <modname> [parameters...]\n"
+               "%s -r [-n] [-i] [-v] <modulename> ...\n"
+               "%s -l -t <dirname> [ -a <modulename> ...]\n",
+               progname, progname, progname);
+       exit(1);
+}
+
+static struct module *find_module(const char *filename, struct list_head *list)
+{
+       struct module *i;
+
+       list_for_each_entry(i, list, list) {
+               if (streq(i->filename, filename))
+                       return i;
+       }
+       return NULL;
+}
+
+static void add_module(char *filename, int namelen, struct list_head *list)
+{
+       struct module *mod;
+
+       /* If it's a duplicate: move it to the end, so it gets
+          inserted where it is *first* required. */
+       mod = find_module(filename, list);
+       if (mod)
+               list_del(&mod->list);
+       else {
+               /* No match.  Create a new module. */
+               mod = NOFAIL(malloc(sizeof(struct module) + namelen + 1));
+               memcpy(mod->filename, filename, namelen);
+               mod->filename[namelen] = '\0';
+               mod->modname = NOFAIL(malloc(namelen + 1));
+               filename2modname(mod->modname, mod->filename);
+       }
+
+       list_add_tail(&mod->list, list);
+}
+
+static void free_module(struct module *mod)
+{
+       free(mod->modname);
+       free(mod);
+}
+
+/* Compare len chars of a to b, with _ and - equivalent. */
+static int modname_equal(const char *a, const char *b, unsigned int len)
+{
+       unsigned int i;
+
+       if (strlen(b) != len)
+               return 0;
+
+       for (i = 0; i < len; i++) {
+               if ((a[i] == '_' || a[i] == '-')
+                   && (b[i] == '_' || b[i] == '-'))
+                       continue;
+               if (a[i] != b[i])
+                       return 0;
+       }
+       return 1;
+}
+
+/* Fills in list of modules if this is the line we want. */
+static int add_modules_dep_line(char *line,
+                               const char *name,
+                               struct list_head *list,
+                               const char *dirname)
+{
+       char *ptr;
+       int len;
+       char *modname, *fullpath;
+
+       /* Ignore lines without : or which start with a # */
+       ptr = strchr(line, ':');
+       if (ptr == NULL || line[strspn(line, "\t ")] == '#')
+               return 0;
+
+       /* Is this the module we are looking for? */
+       *ptr = '\0';
+       modname = my_basename(line);
+
+       len = strlen(modname);
+       if (strchr(modname, '.'))
+               len = strchr(modname, '.') - modname;
+       if (!modname_equal(modname, name, len))
+               return 0;
+
+       /* Create the list. */
+       if ('/' == line[0]) {   /* old style deps - absolute path specified */
+               add_module(line, ptr - line, list);
+       } else {
+               nofail_asprintf(&fullpath, "%s/%s", dirname, line);
+               add_module(fullpath, strlen(dirname)+1+(ptr - line), list);
+               free(fullpath);
+       }
+
+       ptr++;
+       for(;;) {
+               char *dep_start;
+               ptr += strspn(ptr, " \t");
+               if (*ptr == '\0')
+                       break;
+               dep_start = ptr;
+               ptr += strcspn(ptr, " \t");
+               if ('/' == dep_start[0]) {      /* old style deps */
+                       add_module(dep_start, ptr - dep_start, list);
+               } else {
+                       nofail_asprintf(&fullpath, "%s/%s", dirname, dep_start);
+                       add_module(fullpath,
+                                  strlen(dirname)+1+(ptr - dep_start), list);
+                       free(fullpath);
+               }
+       }
+       return 1;
+}
+
+static int read_depends_file(const char *dirname,
+                            const char *start_name,
+                            struct list_head *list)
+{
+       char *modules_dep_name;
+       char *line;
+       struct index_file *modules_dep;
+
+       nofail_asprintf(&modules_dep_name, "%s/%s", dirname, "modules.dep.bin");
+       modules_dep = index_file_open(modules_dep_name);
+       if (!modules_dep) {
+               free(modules_dep_name);
+               return 0;
+       }
+
+       line = index_search(modules_dep, start_name);
+       if (line) {
+               /* Value is standard dependency line format */
+               if (!add_modules_dep_line(line, start_name, list, dirname))
+                       fatal("Module index is inconsistent\n");
+               free(line);
+       }
+
+       index_file_close(modules_dep);
+       free(modules_dep_name);
+       
+       return 1;
+}
+
+static void read_depends(const char *dirname,
+                        const char *start_name,
+                        struct list_head *list)
+{
+       char *modules_dep_name;
+       char *line;
+       FILE *modules_dep;
+       int done = 0;
+
+       if (use_binary_indexes)
+               if (read_depends_file(dirname, start_name, list))
+                       return;
+
+       nofail_asprintf(&modules_dep_name, "%s/%s", dirname, "modules.dep");
+       modules_dep = fopen(modules_dep_name, "r");
+       if (!modules_dep)
+               fatal("Could not load %s: %s\n",
+                     modules_dep_name, strerror(errno));
+
+       /* Stop at first line, as we can have duplicates (eg. symlinks
+           from boot/ */
+       while (!done && (line = getline_wrapped(modules_dep, NULL)) != NULL) {
+               done = add_modules_dep_line(line, start_name, list, dirname);
+               free(line);
+       }
+       fclose(modules_dep);
+       free(modules_dep_name);
+}
+
+/* We use error numbers in a loose translation... */
+static const char *insert_moderror(int err)
+{
+       switch (err) {
+       case ENOEXEC:
+               return "Invalid module format";
+       case ENOENT:
+               return "Unknown symbol in module, or unknown parameter (see dmesg)";
+       case ENOSYS:
+               return "Kernel does not have module support";
+       default:
+               return strerror(err);
+       }
+}
+
+static const char *remove_moderror(int err)
+{
+       switch (err) {
+       case ENOENT:
+               return "No such module";
+       case ENOSYS:
+               return "Kernel does not have module unloading support";
+       default:
+               return strerror(err);
+       }
+}
+
+static void replace_modname(struct elf_file *module,
+                           void *mem, unsigned long len,
+                           const char *oldname, const char *newname)
+{
+       char *p;
+
+       /* 64 - sizeof(unsigned long) - 1 */
+       if (strlen(newname) > 55)
+               fatal("New name %s is too long\n", newname);
+
+       /* Find where it is in the module structure.  Don't assume layout! */
+       for (p = mem; p < (char *)mem + len - strlen(oldname); p++) {
+               if (memcmp(p, oldname, strlen(oldname)) == 0) {
+                       strcpy(p, newname);
+                       return;
+               }
+       }
+
+       warn("Could not find old name in %s to replace!\n", module->pathname);
+}
+
+static void rename_module(struct elf_file *module,
+                         const char *oldname,
+                         const char *newname)
+{
+       void *modstruct;
+       unsigned long len;
+
+       /* Old-style */
+       modstruct = module->ops->load_section(module,
+               ".gnu.linkonce.this_module", &len);
+       /* New-style */
+       if (!modstruct)
+               modstruct = module->ops->load_section(module, "__module", &len);
+       if (!modstruct)
+               warn("Could not find module name to change in %s\n",
+                    module->pathname);
+       else
+               replace_modname(module, modstruct, len, oldname, newname);
+}
+
+static void clear_magic(struct elf_file *module)
+{
+       struct string_table *tbl;
+       int j;
+
+       /* Old-style: __vermagic section */
+       module->ops->strip_section(module, "__vermagic");
+
+       /* New-style: in .modinfo section */
+       tbl = module->ops->load_strings(module, ".modinfo", NULL);
+       for (j = 0; tbl && j < tbl->cnt; j++) {
+               const char *p = tbl->str[j];
+               if (strstarts(p, "vermagic=")) {
+                       memset((char *)p, 0, strlen(p));
+                       return;
+               }
+       }
+}
+
+struct module_options
+{
+       struct module_options *next;
+       char *modulename;
+       char *options;
+};
+
+struct module_command
+{
+       struct module_command *next;
+       char *modulename;
+       char *command;
+};
+
+struct module_alias
+{
+       struct module_alias *next;
+       char *aliasname;
+       char *module;
+};
+
+struct module_blacklist
+{
+       struct module_blacklist *next;
+       char *modulename;
+};
+
+struct module_softdep
+{
+       struct module_softdep *next;
+       char *buf;
+       /* The modname and string tables point to buf. */
+       char *modname;
+       struct string_table *pre;
+       struct string_table *post;
+};
+
+struct modprobe_conf
+{
+       struct module_options *options;
+       struct module_command *commands;
+       struct module_alias *aliases;
+       struct module_blacklist *blacklist;
+       struct module_softdep *softdeps;
+};
+
+/* Link in a new option line from the config file. */
+static struct module_options *
+add_options(const char *modname,
+           const char *option,
+           struct module_options *options)
+{
+       struct module_options *new;
+       char *tab; 
+
+       new = NOFAIL(malloc(sizeof(*new)));
+       new->modulename = NOFAIL(strdup(modname));
+       new->options = NOFAIL(strdup(option));
+       /* We can handle tabs, kernel can't. */
+       for (tab = strchr(new->options, '\t'); tab; tab = strchr(tab, '\t'))
+               *tab = ' ';
+       new->next = options;
+       return new;
+}
+
+/* Link in a new install line from the config file. */
+static struct module_command *
+add_command(const char *modname,
+              const char *command,
+              struct module_command *commands)
+{
+       struct module_command *new;
+
+       new = NOFAIL(malloc(sizeof(*new)));
+       new->modulename = NOFAIL(strdup(modname));
+       new->command = NOFAIL(strdup(command));
+       new->next = commands;
+       return new;
+}
+
+/* Link in a new alias line from the config file. */
+static struct module_alias *
+add_alias(const char *aliasname, const char *modname, struct module_alias *aliases)
+{
+       struct module_alias *new;
+
+       new = NOFAIL(malloc(sizeof(*new)));
+       new->aliasname = NOFAIL(strdup(aliasname));
+       new->module = NOFAIL(strdup(modname));
+       new->next = aliases;
+       return new;
+}
+
+
+/* Return a list of matching aliases */
+static struct module_alias *
+find_aliases(const struct module_alias *aliases,
+            const char *name)
+{
+       struct module_alias *result = NULL;
+       while (aliases) {
+               char *aliasname = aliases->aliasname;
+               char *modname = aliases->module;
+               if (fnmatch(aliasname, name, 0) == 0)
+                       result = add_alias(aliasname, modname, result);
+               aliases = aliases->next;
+       }
+       return result;
+}
+
+static void free_aliases(struct module_alias *alias_list)
+{
+       while (alias_list) {
+               struct module_alias *alias;
+
+               alias = alias_list;
+               alias_list = alias_list->next;
+
+               free(alias->aliasname);
+               free(alias->module);
+               free(alias);
+       }
+}
+
+/* Link in a new blacklist line from the config file. */
+static struct module_blacklist *
+add_blacklist(const char *modname, struct module_blacklist *blacklist)
+{
+       struct module_blacklist *new;
+
+       new = NOFAIL(malloc(sizeof(*new)));
+       new->modulename = NOFAIL(strdup(modname));
+       new->next = blacklist;
+       return new;
+}
+
+/* Find blacklist commands if any. */
+static int
+find_blacklist(const char *modname, const struct module_blacklist *blacklist)
+{
+       while (blacklist) {
+               if (streq(blacklist->modulename, modname))
+                       return 1;
+               blacklist = blacklist->next;
+       }
+       return 0;
+}
+
+/* delete backlisted elems from a list of aliases */
+static void
+apply_blacklist(struct module_alias **aliases,
+               const struct module_blacklist *blacklist)
+{
+       struct module_alias *result = NULL;
+       struct module_alias *alias = *aliases;
+       while (alias) {
+               char *modname = alias->module;
+               if (!find_blacklist(modname, blacklist))
+                       result = add_alias(alias->aliasname, modname, result);
+               alias = alias->next;
+       }
+       free_aliases(*aliases);
+       *aliases = result;
+}
+
+/* Find install commands if any. */
+static const char *find_command(const char *modname,
+                               const struct module_command *commands)
+{
+       while (commands) {
+               if (fnmatch(commands->modulename, modname, 0) == 0)
+                       return commands->command;
+               commands = commands->next;
+       }
+       return NULL;
+}
+
+/* Find soft dependencies, if any. */
+static const struct module_softdep *
+find_softdep(const char *modname, const struct module_softdep *softdeps)
+{
+       while (softdeps) {
+               if (fnmatch(softdeps->modname, modname, 0) == 0)
+                       return softdeps;
+               softdeps = softdeps->next;
+       }
+       return NULL;
+}
+
+static char *append_option(char *options, const char *newoption)
+{
+       options = NOFAIL(realloc(options, strlen(options) + 1
+                                + strlen(newoption) + 1));
+       if (strlen(options)) strcat(options, " ");
+       strcat(options, newoption);
+       return options;
+}
+
+static char *prepend_option(char *options, const char *newoption)
+{
+       size_t l1, l2;
+       l1 = strlen(options);
+       l2 = strlen(newoption);
+       /* the resulting string will look like
+        * newoption + ' ' + options + '\0' */
+       if (l1) {
+               options = NOFAIL(realloc(options, l2 + 1 + l1 + 1));
+               memmove(options + l2 + 1, options, l1 + 1);
+               options[l2] = ' ';
+               memcpy(options, newoption, l2);
+       } else {
+               options = NOFAIL(realloc(options, l2 + 1));
+               memcpy(options, newoption, l2);
+               options[l2] = '\0';
+       }
+       return options;
+}
+
+/* Add to options */
+static char *add_extra_options(const char *modname,
+                              const char *optstring,
+                              const struct module_options *options)
+{
+       char *opts = NOFAIL(strdup(optstring));
+
+       while (options) {
+               if (streq(options->modulename, modname))
+                       opts = prepend_option(opts, options->options);
+               options = options->next;
+       }
+       return opts;
+}
+
+/* Is module in /proc/modules?  If so, fill in usecount if not NULL.
+   0 means no, 1 means yes, -1 means unknown.
+ */
+static int module_in_procfs(const char *modname, unsigned int *usecount)
+{
+       FILE *proc_modules;
+       char *line;
+
+again:
+       /* Might not be mounted yet.  Don't fail. */
+       proc_modules = fopen("/proc/modules", "r");
+       if (!proc_modules)
+               return -1;
+
+       while ((line = getline_wrapped(proc_modules, NULL)) != NULL) {
+               char *entry = strtok(line, " \n");
+
+               if (entry && streq(entry, modname)) {
+                       /* If it exists, usecount is the third entry. */
+                       if (!strtok(NULL, " \n"))
+                               goto out;
+
+                       if (!(entry = strtok(NULL, " \n"))) /* usecount */
+                               goto out;
+                       else
+                               if (usecount)
+                                       *usecount = atoi(entry);
+
+                       /* Followed by - then status. */
+                       if (strtok(NULL, " \n")
+                           && (entry = strtok(NULL, " \n")) != NULL) {
+                               /* No locking, we might hit cases
+                                * where module is in flux.  Spin. */
+                               if (streq(entry, "Loading")
+                                   || streq(entry, "Unloading")) {
+                                       usleep(100000);
+                                       free(line);
+                                       fclose(proc_modules);
+                                       goto again;
+                               }
+                       }
+
+               out:
+                       free(line);
+                       fclose(proc_modules);
+                       return 1;
+               }
+               free(line);
+       }
+       fclose(proc_modules);
+       return 0;
+}
+
+/* Read sysfs attribute into a buffer.
+ * returns: 1 = ok, 0 = attribute missing,
+ * -1 = file error (or empty file, but we don't care).
+ */
+static int read_attribute(const char *filename, char *buf, size_t buflen)
+{
+       FILE *file;
+       char *s;
+
+       file = fopen(filename, "r");
+       if (file == NULL)
+               return (errno == ENOENT) ? 0 : -1;
+       s = fgets(buf, buflen, file);
+       fclose(file);
+
+       return (s == NULL) ? -1 : 1;
+}
+
+/* is this a built-in module?
+ * 0: no, 1: yes, -1: don't know
+ */
+static int module_builtin(const char *dirname, const char *modname)
+{
+       struct index_file *index;
+       char *filename, *value;
+
+       nofail_asprintf(&filename, "%s/modules.builtin.bin", dirname);
+       index = index_file_open(filename);
+       free(filename);
+       if (!index)
+               return -1;
+       value = index_search(index, modname);
+       free(value);
+       return value ? 1 : 0;
+}
+
+/* Is module in /sys/module?  If so, fill in usecount if not NULL.
+   0 means no, 1 means yes, -1 means unknown.
+ */
+static int module_in_sysfs(const char *modname, unsigned int *usecount)
+{
+       int ret;
+       char *name;
+       struct stat finfo;
+
+       const int ATTR_LEN = 16;
+       char attr[ATTR_LEN];
+
+       /* Check sysfs is mounted */
+       if (stat("/sys/module", &finfo) < 0)
+               return -1;
+
+       /* Find module. */
+       nofail_asprintf(&name, "/sys/module/%s", modname);
+       ret = stat(name, &finfo);
+       free(name);
+       if (ret < 0)
+               return (errno == ENOENT) ? 0 : -1; /* Not found or unknown. */
+
+       nofail_asprintf(&name, "/sys/module/%s/initstate", modname);
+       ret = read_attribute(name, attr, ATTR_LEN);
+       if (ret == 0) {
+               free(name);
+               nofail_asprintf(&name, "/sys/module/%s", modname);
+               if (stat(name, &finfo) < 0) {
+                       /* module was removed before we could read initstate */
+                       ret = 0;
+               } else {
+                       /* initstate not available (2.6.19 or earlier) */
+                       ret = -1;
+               }
+               free(name);
+               return ret;
+       }
+
+       /* Wait for the existing module to either go live or disappear. */
+       while (ret == 1 && !streq(attr, "live\n")) {
+               usleep(100000);
+               ret = read_attribute(name, attr, ATTR_LEN);
+       }
+       free(name);
+
+       if (ret != 1)
+               return ret;
+
+       /* Get reference count, if it exists. */
+       if (usecount != NULL) {
+               nofail_asprintf(&name, "/sys/module/%s/refcnt", modname);
+               ret = read_attribute(name, attr, ATTR_LEN);
+               free(name);
+               if (ret == 1)
+                       *usecount = atoi(attr);
+       }
+
+       return 1;
+}
+
+/* Is module loaded?  If so, fill in usecount if not NULL. 
+   0 means no, 1 means yes, -1 means unknown.
+ */
+static int module_in_kernel(const char *modname, unsigned int *usecount)
+{
+       int result;
+
+       result = module_in_sysfs(modname, usecount);
+       if (result != -1)
+               return result;
+
+       /* /sys/module/%s/initstate is only available since 2.6.20,
+          fallback to /proc/modules to get module state on earlier kernels. */
+       return module_in_procfs(modname, usecount);
+}
+
+void dump_modversions(const char *filename, errfn_t error)
+{
+       struct elf_file *module;
+
+       module = grab_elf_file(filename);
+       if (!module) {
+               error("%s: %s\n", filename, strerror(errno));
+               return;
+       }
+       if (module->ops->dump_modvers(module) < 0)
+               error("Wrong section size in '%s'\n", filename);
+       release_elf_file(module);
+}
+
+/* Does path contain directory(s) subpath? */
+static int type_matches(const char *path, const char *subpath)
+{
+       char *subpath_with_slashes;
+       int ret;
+
+       nofail_asprintf(&subpath_with_slashes, "/%s/", subpath);
+
+       ret = (strstr(path, subpath_with_slashes) != NULL);
+       free(subpath_with_slashes);
+       return ret;
+}
+
+
+static int do_wildcard(const char *dirname,
+                      const char *type,
+                      const char *wildcard)
+{
+       char *modules_dep_name;
+       char *line, *wcard;
+       FILE *modules_dep;
+
+       /* Canonicalize wildcard */
+       wcard = strdup(wildcard);
+       underscores(wcard);
+
+       nofail_asprintf(&modules_dep_name, "%s/%s", dirname, "modules.dep");
+       modules_dep = fopen(modules_dep_name, "r");
+       if (!modules_dep)
+               fatal("Could not load %s: %s\n",
+                     modules_dep_name, strerror(errno));
+
+       while ((line = getline_wrapped(modules_dep, NULL)) != NULL) {
+               char *ptr;
+
+               /* Ignore lines without : or which start with a # */
+               ptr = strchr(line, ':');
+               if (ptr == NULL || line[strspn(line, "\t ")] == '#')
+                       goto next;
+               *ptr = '\0';
+
+               /* "type" must match complete directory component(s). */
+               if (!type || type_matches(line, type)) {
+                       char modname[strlen(line)+1];
+
+                       filename2modname(modname, line);
+                       if (fnmatch(wcard, modname, 0) == 0)
+                               printf("%s\n", line);
+               }
+       next:
+               free(line);
+       }
+
+       free(modules_dep_name);
+       free(wcard);
+       return 0;
+}
+
+static char *strsep_skipspace(char **string, char *delim)
+{
+       if (!*string)
+               return NULL;
+       *string += strspn(*string, delim);
+       return strsep(string, delim);
+}
+
+static int parse_config_scan(const char *filename,
+                            struct modprobe_conf *conf,
+                            int dump_only,
+                            int removing);
+
+static int parse_config_file(const char *filename,
+                           struct modprobe_conf *conf,
+                           int dump_only,
+                           int removing)
+{
+       char *line;
+       unsigned int linenum = 0;
+       FILE *cfile;
+
+       struct module_options **options = &conf->options;
+       struct module_command **commands = &conf->commands;
+       struct module_alias **aliases = &conf->aliases;
+       struct module_blacklist **blacklist = &conf->blacklist;
+
+       cfile = fopen(filename, "r");
+       if (!cfile)
+               return 0;
+
+       while ((line = getline_wrapped(cfile, &linenum)) != NULL) {
+               char *ptr = line;
+               char *cmd, *modname;
+
+               if (dump_only)
+                       printf("%s\n", line);
+
+               cmd = strsep_skipspace(&ptr, "\t ");
+               if (cmd == NULL || cmd[0] == '#' || cmd[0] == '\0') {
+                       free(line);
+                       continue;
+               }
+
+               if (streq(cmd, "alias")) {
+                       char *wildcard = strsep_skipspace(&ptr, "\t ");
+                       char *realname = strsep_skipspace(&ptr, "\t ");
+                       if (!wildcard || !realname)
+                               goto syntax_error;
+                       *aliases = add_alias(underscores(wildcard),
+                                            underscores(realname),
+                                            *aliases);
+               } else if (streq(cmd, "include")) {
+                       struct modprobe_conf newconf = *conf;
+                       newconf.aliases = NULL;
+                       char *newfilename;
+                       newfilename = strsep_skipspace(&ptr, "\t ");
+                       if (!newfilename)
+                               goto syntax_error;
+
+                       warn("\"include %s\" is deprecated, "
+                            "please use /etc/modprobe.d\n", newfilename);
+                       if (strstarts(newfilename, "/etc/modprobe.d")) {
+                               warn("\"include /etc/modprobe.d\" is "
+                                    "the default, ignored\n");
+                       } else {
+                               if (!parse_config_scan(newfilename,
+                                                      &newconf, dump_only,
+                                                      removing))
+                                       warn("Failed to open included"
+                                             " config file %s: %s\n",
+                                             newfilename, strerror(errno));
+                       }
+                       /* Files included override aliases,
+                          etc that was already set ... */
+                       if (newconf.aliases)
+                               *aliases = newconf.aliases;
+
+               } else if (streq(cmd, "options")) {
+                       modname = strsep_skipspace(&ptr, "\t ");
+                       if (!modname || !ptr)
+                               goto syntax_error;
+
+                       ptr += strspn(ptr, "\t ");
+                       *options = add_options(underscores(modname),
+                                              ptr, *options);
+
+               } else if (streq(cmd, "install")) {
+                       modname = strsep_skipspace(&ptr, "\t ");
+                       if (!modname || !ptr)
+                               goto syntax_error;
+                       if (!removing) {
+                               ptr += strspn(ptr, "\t ");
+                               *commands = add_command(underscores(modname),
+                                                       ptr, *commands);
+                       }
+               } else if (streq(cmd, "blacklist")) {
+                       modname = strsep_skipspace(&ptr, "\t ");
+                       if (!modname)
+                               goto syntax_error;
+                       if (!removing) {
+                               *blacklist = add_blacklist(underscores(modname),
+                                                       *blacklist);
+                       }
+               } else if (streq(cmd, "remove")) {
+                       modname = strsep_skipspace(&ptr, "\t ");
+                       if (!modname || !ptr)
+                               goto syntax_error;
+                       if (removing) {
+                               ptr += strspn(ptr, "\t ");
+                               *commands = add_command(underscores(modname),
+                                                       ptr, *commands);
+                       }
+               } else if (streq(cmd, "softdep")) {
+                       char *tk;
+                       int pre = 0, post = 0;
+                       struct string_table *pre_modnames = NULL;
+                       struct string_table *post_modnames = NULL;
+                       struct module_softdep *new;
+
+                       modname = underscores(strsep_skipspace(&ptr, "\t "));
+                       if (!modname || !ptr)
+                               goto syntax_error;
+                       while ((tk = strsep_skipspace(&ptr, "\t ")) != NULL) {
+                               if (streq(tk, "pre:")) {
+                                       pre = 1; post = 0;
+                               } else if (streq(tk, "post:")) {
+                                       pre = 0; post = 1;
+                               } else if (pre) {
+                                       pre_modnames = NOFAIL(
+                                               strtbl_add(tk, pre_modnames));
+                               } else if (post) {
+                                       post_modnames = NOFAIL(
+                                               strtbl_add(tk, post_modnames));
+                               } else {
+                                       strtbl_free(pre_modnames);
+                                       strtbl_free(post_modnames);
+                                       goto syntax_error;
+                               }
+                       }
+                       new = NOFAIL(malloc(sizeof(*new)));
+                       new->buf = line;
+                       new->modname = modname;
+                       new->pre = pre_modnames;
+                       new->post = post_modnames;
+                       new->next = conf->softdeps;
+                       conf->softdeps = new;
+
+                       line = NULL; /* Don't free() this line. */
+
+               } else if (streq(cmd, "config")) {
+                       char *tmp = strsep_skipspace(&ptr, "\t ");
+
+                       if (!tmp)
+                               goto syntax_error;
+                       if (streq(tmp, "binary_indexes")) {
+                               tmp = strsep_skipspace(&ptr, "\t ");
+                               if (streq(tmp, "yes"))
+                                       use_binary_indexes = 1;
+                               if (streq(tmp, "no"))
+                                       use_binary_indexes = 0;
+                       }
+               } else {
+syntax_error:
+                       grammar(cmd, filename, linenum);
+               }
+
+               free(line);
+       }
+       fclose(cfile);
+       return 1;
+}
+
+/* Read binary index file containing aliases only */
+static int read_aliases_file(const char *filename,
+                            const char *name,
+                            int dump_only,
+                            struct module_alias **aliases)
+{
+       struct index_value *realnames;
+       struct index_value *realname;
+       char *binfile;
+       struct index_file *index;
+
+       nofail_asprintf(&binfile, "%s.bin", filename);
+       index = index_file_open(binfile);
+       if (!index) {
+               free(binfile);
+               return 0;
+       }
+
+       if (dump_only) {
+               index_dump(index, stdout, "alias ");
+               free(binfile);
+               index_file_close(index);
+               return 1;
+       }
+
+       realnames = index_searchwild(index, name);
+       for (realname = realnames; realname; realname = realname->next)
+               *aliases = add_alias("*", realname->value, *aliases);
+       index_values_free(realnames);
+
+       free(binfile);
+       index_file_close(index);
+       return 1;
+}
+
+/* fallback to plain-text aliases file if necessary */
+static int read_aliases(const char *filename,
+                       const char *name,
+                       int dump_only,
+                       struct module_alias **aliases)
+{
+       char *line;
+       unsigned int linenum = 0;
+       FILE *cfile;
+
+       if (use_binary_indexes)
+               if (read_aliases_file(filename, name, dump_only, aliases))
+                       return 1;
+
+       cfile = fopen(filename, "r");
+       if (!cfile)
+               return 0;
+
+       while ((line = getline_wrapped(cfile, &linenum)) != NULL) {
+               char *ptr = line;
+               char *cmd;
+
+               if (dump_only)
+                       printf("%s\n", line);
+
+               cmd = strsep_skipspace(&ptr, "\t ");
+               if (cmd == NULL || cmd[0] == '#' || cmd[0] == '\0') {
+                       free(line);
+                       continue;
+               }
+
+               if (streq(cmd, "alias")) {
+                       char *wildcard = strsep_skipspace(&ptr, "\t ");
+                       char *realname = strsep_skipspace(&ptr, "\t ");
+                       if (!wildcard || !realname)
+                               goto syntax_error;
+                       if (fnmatch(underscores(wildcard),name,0) == 0)
+                               *aliases = add_alias(wildcard,
+                                                    underscores(realname),
+                                                    *aliases);
+               } else {
+syntax_error:
+                       grammar(cmd, filename, linenum);
+               }
+
+               free(line);
+       }
+       fclose(cfile);
+       return 1;
+}
+
+static int parse_config_scan(const char *filename,
+                            struct modprobe_conf *conf,
+                            int dump_only,
+                            int removing)
+{
+       DIR *dir;
+       int ret = 0;
+
+       dir = opendir(filename);
+       if (dir) {
+               struct file_entry {
+                       struct list_head node;
+                       char name[];
+               };
+               LIST_HEAD(files_list);
+               struct file_entry *fe, *fe_tmp;
+               struct dirent *i;
+
+               /* sort files from directory into list */
+               while ((i = readdir(dir)) != NULL) {
+                       size_t len;
+
+                       if (i->d_name[0] == '.')
+                               continue;
+                       if (!config_filter(i->d_name))
+                               continue;
+
+                       len = strlen(i->d_name);
+                       if (len < 6 ||
+                           (strcmp(&i->d_name[len-5], ".conf") != 0 &&
+                            strcmp(&i->d_name[len-6], ".alias") != 0))
+                               warn("All config files need .conf: %s/%s, "
+                                    "it will be ignored in a future release.\n",
+                                    filename, i->d_name);
+                       fe = malloc(sizeof(struct file_entry) + len + 1);
+                       if (fe == NULL)
+                               continue;
+                       strcpy(fe->name, i->d_name);
+                       list_for_each_entry(fe_tmp, &files_list, node)
+                               if (strcmp(fe_tmp->name, fe->name) >= 0)
+                                       break;
+                       list_add_tail(&fe->node, &fe_tmp->node);
+               }
+               closedir(dir);
+
+               /* parse list of files */
+               list_for_each_entry_safe(fe, fe_tmp, &files_list, node) {
+                       char *cfgfile;
+
+                       nofail_asprintf(&cfgfile, "%s/%s", filename, fe->name);
+                       if (!parse_config_file(cfgfile, conf,
+                                              dump_only, removing))
+                               warn("Failed to open config file "
+                                    "%s: %s\n", fe->name, strerror(errno));
+                       free(cfgfile);
+                       list_del(&fe->node);
+                       free(fe);
+               }
+
+               ret = 1;
+       } else {
+               if (parse_config_file(filename, conf, dump_only, removing))
+                       ret = 1;
+       }
+       return ret;
+}
+
+static void parse_toplevel_config(const char *filename,
+                                 struct modprobe_conf *conf,
+                                 int dump_only,
+                                 int removing)
+{
+       if (filename) {
+               if (!parse_config_scan(filename, conf, dump_only, removing))
+                       fatal("Failed to open config file %s: %s\n",
+                             filename, strerror(errno));
+               return;
+       }
+
+       /* deprecated config file */
+       if (parse_config_file("/etc/modprobe.conf", conf,
+                             dump_only, removing) > 0)
+               warn("Deprecated config file /etc/modprobe.conf, "
+                     "all config files belong into /etc/modprobe.d/.\n");
+
+       /* default config */
+       parse_config_scan("/etc/modprobe.d", conf, dump_only, removing);
+}
+
+/* Read possible module arguments from the kernel command line. */
+static int parse_kcmdline(int dump_only, struct module_options **options)
+{
+       char *line;
+       unsigned int linenum = 0;
+       FILE *kcmdline;
+
+       kcmdline = fopen("/proc/cmdline", "r");
+       if (!kcmdline)
+               return 0;
+
+       while ((line = getline_wrapped(kcmdline, &linenum)) != NULL) {
+               char *ptr = line;
+               char *arg;
+
+               while ((arg = strsep_skipspace(&ptr, "\t ")) != NULL) {
+                       char *sep, *modname, *opt;
+
+                       sep = strchr(arg, '.');
+                       if (sep) {
+                               if (!strchr(sep, '='))
+                                       continue;
+                               modname = arg;
+                               *sep = '\0';
+                               opt = ++sep;
+
+                               if (dump_only)
+                                       printf("options %s %s\n", modname, opt);
+
+                               *options = add_options(underscores(modname),
+                                                      opt, *options);
+                       }
+               }
+
+               free(line);
+       }
+       fclose(kcmdline);
+       return 1;
+}
+
+static void add_to_env_var(const char *option)
+{
+       const char *oldenv;
+
+       if ((oldenv = getenv("MODPROBE_OPTIONS")) != NULL) {
+               char *newenv;
+               nofail_asprintf(&newenv, "%s %s", oldenv, option);
+               setenv("MODPROBE_OPTIONS", newenv, 1);
+               free(newenv);
+       } else
+               setenv("MODPROBE_OPTIONS", option, 1);
+}
+
+/* Prepend options from environment. */
+static char **merge_args(char *args, char *argv[], int *argc)
+{
+       char *arg, *argstring;
+       char **newargs = NULL;
+       unsigned int i, num_env = 0;
+
+       if (!args)
+               return argv;
+
+       argstring = NOFAIL(strdup(args));
+       for (arg = strtok(argstring, " "); arg; arg = strtok(NULL, " ")) {
+               num_env++;
+               newargs = NOFAIL(realloc(newargs,
+                                        sizeof(newargs[0])
+                                        * (num_env + *argc + 1)));
+               newargs[num_env] = arg;
+       }
+
+       if (!newargs)
+               return argv;
+
+       /* Append commandline args */
+       newargs[0] = argv[0];
+       for (i = 1; i <= *argc; i++)
+               newargs[num_env+i] = argv[i];
+
+       *argc += num_env;
+       return newargs;
+}
+
+static char *gather_options(char *argv[])
+{
+       char *optstring = NOFAIL(strdup(""));
+
+       /* Rest is module options */
+       while (*argv) {
+               /* Quote value if it contains spaces. */
+               unsigned int eq = strcspn(*argv, "=");
+
+               if (strchr(*argv+eq, ' ') && !strchr(*argv, '"')) {
+                       char quoted[strlen(*argv) + 3];
+                       (*argv)[eq] = '\0';
+                       sprintf(quoted, "%s=\"%s\"", *argv, *argv+eq+1);
+                       optstring = append_option(optstring, quoted);
+               } else
+                       optstring = append_option(optstring, *argv);
+               argv++;
+       }
+       return optstring;
+}
+
+/* Do an install/remove command: replace $CMDLINE_OPTS if it's specified. */
+static void do_command(const char *modname,
+                      const char *command,
+                      int dry_run,
+                      errfn_t error,
+                      const char *type,
+                      const char *cmdline_opts)
+{
+       int ret;
+       char *p, *replaced_cmd = NOFAIL(strdup(command));
+
+       while ((p = strstr(replaced_cmd, "$CMDLINE_OPTS")) != NULL) {
+               char *new;
+               nofail_asprintf(&new, "%.*s%s%s",
+                        (int)(p - replaced_cmd), replaced_cmd, cmdline_opts,
+                        p + strlen("$CMDLINE_OPTS"));
+               free(replaced_cmd);
+               replaced_cmd = new;
+       }
+
+       info("%s %s\n", type, replaced_cmd);
+       if (dry_run)
+               goto out;
+
+       setenv("MODPROBE_MODULE", modname, 1);
+       ret = system(replaced_cmd);
+       if (ret == -1 || WEXITSTATUS(ret))
+               error("Error running %s command for %s\n", type, modname);
+
+out:
+       free(replaced_cmd);
+}
+
+/* Forward declaration */
+int do_modprobe(const char *modname,
+               const char *newname,
+               const char *cmdline_opts,
+               const struct modprobe_conf *conf,
+               const char *dirname,
+               errfn_t error,
+               modprobe_flags_t flags);
+
+static void do_softdep(const struct module_softdep *softdep,
+                      const char *cmdline_opts,
+                      const struct modprobe_conf *conf,
+                      const char *dirname,
+                      errfn_t error,
+                      modprobe_flags_t flags)
+{
+       struct string_table *pre_modnames, *post_modnames;
+       int i, j;
+
+       if (++recursion_depth >= MAX_RECURSION)
+               fatal("modprobe: softdep dependency loop encountered %s %s\n",
+                       (flags & mit_remove) ? "removing" : "inserting",
+                       softdep->modname);
+
+       if (flags & mit_remove) {
+               /* Reverse module order if removing. */
+               pre_modnames = softdep->post;
+               post_modnames = softdep->pre;
+       } else {
+               pre_modnames = softdep->pre;
+               post_modnames = softdep->post;
+       }
+
+       /* Modprobe pre_modnames */
+
+       for (i = 0; pre_modnames && i < pre_modnames->cnt; i++) {
+               /* Reverse module order if removing. */
+               j = (flags & mit_remove) ? pre_modnames->cnt-1 - i : i;
+
+               do_modprobe(pre_modnames->str[j], NULL, "",
+                       conf, dirname, warn, flags);
+       }
+
+       /* Modprobe main module, passing cmdline_opts, ignoring softdep */
+
+       do_modprobe(softdep->modname, NULL, cmdline_opts,
+               conf, dirname, warn, flags | mit_ignore_commands);
+
+       /* Modprobe post_modnames */
+
+       for (i = 0; post_modnames && i < post_modnames->cnt; i++) {
+               /* Reverse module order if removing. */
+               j = (flags & mit_remove) ? post_modnames->cnt-1 - i : i;
+
+               do_modprobe(post_modnames->str[j], NULL, "", conf,
+                       dirname, warn, flags);
+       }
+}
+
+/* Actually do the insert. */
+static int insmod(struct list_head *list,
+                  const char *optstring,
+                  const char *newname,
+                  const char *cmdline_opts,
+                  const struct modprobe_conf *conf,
+                  const char *dirname,
+                  errfn_t error,
+                  modprobe_flags_t flags)
+{
+       int ret;
+       struct elf_file *module;
+       const struct module_softdep *softdep;
+       const char *command;
+       struct module *mod = list_entry(list->next, struct module, list);
+       int rc = 0;
+       int already_loaded;
+       char *opts = NULL;
+
+       /* Take us off the list. */
+       list_del(&mod->list);
+
+       /* Do things we (or parent) depend on first. */
+       if (!list_empty(list)) {
+               modprobe_flags_t f = flags;
+               f &= ~mit_first_time;
+               f &= ~mit_ignore_commands;
+               if ((rc = insmod(list, "", NULL,
+                      "", conf, dirname, warn, f)) != 0)
+               {
+                       error("Error inserting %s (%s): %s\n",
+                               mod->modname, mod->filename,
+                               insert_moderror(errno));
+                       goto out;
+               }
+       }
+
+       /* Don't do ANYTHING if already in kernel. */
+       already_loaded = module_in_kernel(newname ?: mod->modname, NULL);
+
+       if (!(flags & mit_ignore_loaded) && already_loaded == 1) {
+               if (flags & mit_first_time)
+                       error("Module %s already in kernel.\n",
+                             newname ?: mod->modname);
+               goto out;
+       }
+
+       softdep = find_softdep(mod->modname, conf->softdeps);
+       if (softdep && !(flags & mit_ignore_commands)) {
+               do_softdep(softdep, cmdline_opts, conf, dirname, 
+                          error, flags & (mit_remove | mit_dry_run));
+               goto out;
+       }
+
+       command = find_command(mod->modname, conf->commands);
+       if (command && !(flags & mit_ignore_commands)) {
+               if (already_loaded == -1) {
+                       warn("/sys/module/ not present or too old,"
+                               " and /proc/modules does not exist.\n");
+                       warn("Ignoring install commands for %s"
+                               " in case it is already loaded.\n",
+                               newname ?: mod->modname);
+               } else {
+                       do_command(mod->modname, command, flags & mit_dry_run,
+                                  error, "install", cmdline_opts);
+                       goto out;
+               }
+       }
+
+       module = grab_elf_file(mod->filename);
+       if (!module) {
+               error("Could not read '%s': %s\n", mod->filename,
+                       (errno == ENOEXEC) ? "Invalid module format" :
+                               strerror(errno));
+               goto out;
+       }
+       if (newname)
+               rename_module(module, mod->modname, newname);
+       if (flags & mit_strip_modversion)
+               module->ops->strip_section(module, "__versions");
+       if (flags & mit_strip_vermagic)
+               clear_magic(module);
+
+       /* Config file might have given more options */
+       opts = add_extra_options(mod->modname, optstring, conf->options);
+
+       info("insmod %s %s\n", mod->filename, opts);
+
+       if (flags & mit_dry_run)
+               goto out_elf_file;
+
+       ret = init_module(module->data, module->len, opts);
+       if (ret != 0) {
+               if (errno == EEXIST) {
+                       if (flags & mit_first_time)
+                               error("Module %s already in kernel.\n",
+                                     newname ?: mod->modname);
+                       goto out_elf_file;
+               }
+               /* don't warn noisely if we're loading multiple aliases. */
+               /* one of the aliases may try to use hardware we don't have. */
+               if ((error != warn) || (verbose))
+                       error("Error inserting %s (%s): %s\n",
+                             mod->modname, mod->filename,
+                             insert_moderror(errno));
+               rc = 1;
+       }
+ out_elf_file:
+       release_elf_file(module);
+       free(opts);
+ out:
+       free_module(mod);
+       return rc;
+}
+
+/* Do recursive removal. */
+static void rmmod(struct list_head *list,
+                 const char *name,
+                 const char *cmdline_opts,
+                 const struct modprobe_conf *conf,
+                 const char *dirname,
+                 errfn_t error,
+                 modprobe_flags_t flags)
+{
+       const struct module_softdep *softdep;
+       const char *command;
+       unsigned int usecount = 0;
+       struct module *mod = list_entry(list->next, struct module, list);
+       int exists;
+
+       /* Take first one off the list. */
+       list_del(&mod->list);
+
+       if (!name)
+               name = mod->modname;
+
+       /* Don't do ANYTHING if not loaded. */
+       exists = module_in_kernel(name, &usecount);
+       if (exists == 0)
+               goto nonexistent_module;
+
+       /* Even if renamed, find commands/softdeps to orig. name. */
+
+       softdep = find_softdep(mod->modname, conf->softdeps);
+       if (softdep && !(flags & mit_ignore_commands)) {
+               do_softdep(softdep, cmdline_opts, conf, dirname,
+                          error, flags & (mit_remove | mit_dry_run));
+               goto remove_rest;
+       }
+
+       command = find_command(mod->modname, conf->commands);
+       if (command && !(flags & mit_ignore_commands)) {
+               if (exists == -1) {
+                       warn("/sys/module/ not present or too old,"
+                               " and /proc/modules does not exist.\n");
+                       warn("Ignoring remove commands for %s"
+                               " in case it is not loaded.\n",
+                               mod->modname);
+               } else {
+                       do_command(mod->modname, command, flags & mit_dry_run,
+                                  error, "remove", cmdline_opts);
+                       goto remove_rest;
+               }
+       }
+
+       if (usecount != 0) {
+               if (!(flags & mit_quiet_inuse))
+                       error("Module %s is in use.\n", name);
+               goto remove_rest;
+       }
+
+       info("rmmod %s\n", mod->filename);
+
+       if (flags & mit_dry_run)
+               goto remove_rest;
+
+       if (delete_module(name, O_EXCL) != 0) {
+               if (errno == ENOENT)
+                       goto nonexistent_module;
+               error("Error removing %s (%s): %s\n",
+                     name, mod->filename,
+                     remove_moderror(errno));
+       }
+
+ remove_rest:
+       /* Now do things we depend. */
+       if (!list_empty(list)) {
+               flags &= ~mit_first_time;
+               flags &= ~mit_ignore_commands;
+               flags |= mit_quiet_inuse;
+
+               rmmod(list, NULL, "", conf, dirname, warn, flags);
+       }
+       free_module(mod);
+       return;
+
+nonexistent_module:
+       if (flags & mit_first_time)
+               fatal("Module %s is not in kernel.\n", mod->modname);
+       goto remove_rest;
+}
+
+static int handle_module(const char *modname,
+                         struct list_head *todo_list,
+                         const char *newname,
+                         const char *options,
+                         const char *cmdline_opts,
+                         const struct modprobe_conf *conf,
+                         const char *dirname,
+                         errfn_t error,
+                         modprobe_flags_t flags)
+{
+       if (list_empty(todo_list)) {
+               const struct module_softdep *softdep;
+               const char *command;
+
+               /* The dependencies have to be real modules, but
+                  handle case where the first is completely bogus. */
+
+               softdep = find_softdep(modname, conf->softdeps);
+               if (softdep && !(flags & mit_ignore_commands)) {
+                       do_softdep(softdep, cmdline_opts, conf, dirname,
+                                  error, flags & (mit_remove | mit_dry_run));
+                       return 0;
+               }
+
+               command = find_command(modname, conf->commands);
+               if (command && !(flags & mit_ignore_commands)) {
+                       do_command(modname, command, flags & mit_dry_run, error,
+                                  (flags & mit_remove) ? "remove":"install", cmdline_opts);
+                       return 0;
+               }
+
+               if (!quiet)
+                       error("Module %s not found.\n", modname);
+               return 1;
+       }
+
+       if (flags & mit_remove)
+               rmmod(todo_list, newname, cmdline_opts,
+                     conf, dirname, error, flags);
+       else
+               insmod(todo_list, options, newname,
+                      cmdline_opts, conf, dirname, error, flags);
+
+       return 0;
+}
+
+int handle_builtin_module(const char *modname,
+                          errfn_t error,
+                          modprobe_flags_t flags)
+{
+       if (flags & mit_remove) {
+               error("Module %s is builtin\n", modname);
+               return 1;
+       } else if (flags & mit_first_time) {
+               error("Module %s already in kernel (builtin).\n", modname);
+               return 1;
+       } else if (flags & mit_ignore_loaded) {
+               /* --show-depends given */
+               info("builtin %s\n", modname);
+       }
+       return 0;
+}
+
+int do_modprobe(const char *modulename,
+               const char *newname,
+               const char *cmdline_opts,
+               const struct modprobe_conf *conf,
+               const char *dirname,
+               errfn_t error,
+               modprobe_flags_t flags)
+{
+       char *modname;
+       struct module_alias *matching_aliases;
+       LIST_HEAD(list);
+       int failed = 0;
+
+       /* Convert name we are looking for */
+       modname = underscores(NOFAIL(strdup(modulename)));
+
+       matching_aliases = find_aliases(conf->aliases, modname);
+
+       /* No luck?  Try symbol names, if starts with symbol:. */
+       if (!matching_aliases && strstarts(modname, "symbol:")) {
+               char *symfilename;
+
+               nofail_asprintf(&symfilename, "%s/modules.symbols", dirname);
+               read_aliases(symfilename, modname, 0, &matching_aliases);
+               free(symfilename);
+       }
+       if (!matching_aliases) {
+               if(!strchr(modname, ':'))
+                       read_depends(dirname, modname, &list);
+
+               /* We only use canned aliases as last resort. */
+               if (list_empty(&list)
+                   && !find_softdep(modname, conf->softdeps)
+                   && !find_command(modname, conf->commands))
+               {
+                       char *aliasfilename;
+
+                       nofail_asprintf(&aliasfilename, "%s/modules.alias",
+                                       dirname);
+                       read_aliases(aliasfilename, modname, 0,
+                                    &matching_aliases);
+                       free(aliasfilename);
+                       /* builtin module? */
+                       if (!matching_aliases && module_builtin(dirname, modname) > 0) {
+                               failed |= handle_builtin_module(modname, error,
+                                                               flags);
+                               goto out;
+                       }
+               }
+       }
+
+       apply_blacklist(&matching_aliases, conf->blacklist);
+       if(flags & mit_resolve_alias) {
+               struct module_alias *aliases = matching_aliases;
+
+               for(; aliases; aliases=aliases->next)
+                       printf("%s\n", aliases->module);
+               goto out;
+       }
+       if (matching_aliases) {
+               errfn_t err = error;
+               struct module_alias *aliases = matching_aliases;
+
+               /* More than one alias?  Don't bail out on failure. */
+               if (aliases->next)
+                       err = warn;
+               while (aliases) {
+                       /* Add the options for this alias. */
+                       char *opts;
+                       opts = add_extra_options(modname,
+                                                cmdline_opts, conf->options);
+
+                       read_depends(dirname, aliases->module, &list);
+                       failed |= handle_module(aliases->module,
+                               &list, newname, opts, cmdline_opts,
+                               conf, dirname, err, flags);
+
+                       aliases = aliases->next;
+                       free(opts);
+                       INIT_LIST_HEAD(&list);
+               }
+       } else {
+               if (flags & mit_use_blacklist
+                   && find_blacklist(modname, conf->blacklist))
+                       goto out;
+
+               failed |= handle_module(modname, &list, newname, cmdline_opts,
+                       cmdline_opts, conf, dirname, error, flags);
+       }
+
+out:
+       free(modname);
+       free_aliases(matching_aliases);
+       return failed;
+}
+
+static struct option options[] = { { "version", 0, NULL, 'V' },
+                                  { "verbose", 0, NULL, 'v' },
+                                  { "quiet", 0, NULL, 'q' },
+                                  { "syslog", 0, NULL, 's' },
+                                  { "show", 0, NULL, 'n' },
+                                  { "dry-run", 0, NULL, 'n' },
+                                  { "show-depends", 0, NULL, 'D' },
+                                  { "resolve-alias", 0, NULL, 'R' },
+                                  { "dirname", 1, NULL, 'd' },
+                                  { "set-version", 1, NULL, 'S' },
+                                  { "config", 1, NULL, 'C' },
+                                  { "name", 1, NULL, 'o' },
+                                  { "remove", 0, NULL, 'r' },
+                                  { "showconfig", 0, NULL, 'c' },
+                                  { "list", 0, NULL, 'l' },
+                                  { "type", 1, NULL, 't' },
+                                  { "all", 0, NULL, 'a' },
+                                  { "ignore-install", 0, NULL, 'i' },
+                                  { "ignore-remove", 0, NULL, 'i' },
+                                  { "use-blacklist", 0, NULL, 'b' },
+                                  { "force", 0, NULL, 'f' },
+                                  { "force-vermagic", 0, NULL, 1 },
+                                  { "force-modversion", 0, NULL, 2 },
+                                  { "first-time", 0, NULL, 3 },
+                                  { "dump-modversions", 0, NULL, 4 },
+                                  { NULL, 0, NULL, 0 } };
+
+int main(int argc, char *argv[])
+{
+       struct utsname buf;
+       struct stat statbuf;
+       int opt;
+       int dump_config = 0;
+       int list_only = 0;
+       int all = 0;
+       int dump_modver = 0;
+       unsigned int i, num_modules;
+       char *type = NULL;
+       const char *configname = NULL;
+       char *basedir = "";
+       char *cmdline_opts = NULL;
+       char *newname = NULL;
+       char *dirname;
+       errfn_t error = fatal;
+       int failed = 0;
+       modprobe_flags_t flags = 0;
+       struct modprobe_conf conf = {};
+
+       recursion_depth = 0;
+
+       /* Prepend options from environment. */
+       argv = merge_args(getenv("MODPROBE_OPTIONS"), argv, &argc);
+
+       uname(&buf);
+       while ((opt = getopt_long(argc, argv, "Vvqsnd:S:C:DRo:rclt:aibf", options, NULL)) != -1){
+               switch (opt) {
+               case 'V':
+                       puts(PACKAGE " version " VERSION);
+                       exit(0);
+               case 'v':
+                       add_to_env_var("-v");
+                       verbose = 1;
+                       break;
+               case 'q':
+                       quiet = 1;
+                       add_to_env_var("-q");
+                       break;
+               case 's':
+                       add_to_env_var("-s");
+                       logging = 1;
+                       break;
+               case 'n':
+                       flags |= mit_dry_run;
+                       break;
+               case 'd':
+                       basedir = optarg;
+                       break;
+               case 'S':
+                       strncpy(buf.release, optarg, sizeof(buf.release));
+                       buf.release[sizeof(buf.release)-1] = '\0';
+                       break;
+               case 'C':
+                       configname = optarg;
+                       add_to_env_var("-C");
+                       add_to_env_var(configname);
+                       break;
+               case 'D':
+                       flags |= mit_dry_run;
+                       flags |= mit_ignore_loaded;
+                       verbose = 1;
+                       break;
+               case 'R':
+                       flags |= mit_resolve_alias;
+                       break;
+               case 'o':
+                       newname = optarg;
+                       break;
+               case 'r':
+                       flags |= mit_remove;
+                       break;
+               case 'c':
+                       dump_config = 1;
+                       break;
+               case 'l':
+                       list_only = 1;
+                       break;
+               case 't':
+                       type = optarg;
+                       break;
+               case 'a':
+                       all = 1;
+                       error = warn;
+                       break;
+               case 'i':
+                       flags |= mit_ignore_commands;
+                       break;
+               case 'b':
+                       flags |= mit_use_blacklist;
+                       break;
+               case 'f':
+                       flags |= mit_strip_vermagic;
+                       flags |= mit_strip_modversion;
+                       break;
+               case 1:
+                       flags |= mit_strip_vermagic;
+                       break;
+               case 2:
+                       flags |= mit_strip_modversion;
+                       break;
+               case 3:
+                       flags |= mit_first_time;
+                       break;
+               case 4:
+                       dump_modver = 1;
+                       break;
+               default:
+                       print_usage(argv[0]);
+               }
+       }
+
+       /* If stderr not open, go to syslog */
+       if (logging || fstat(STDERR_FILENO, &statbuf) != 0) {
+               openlog("modprobe", LOG_CONS, LOG_DAEMON);
+               logging = 1;
+       }
+
+       if (argc < optind + 1 && !dump_config && !list_only)
+               print_usage(argv[0]);
+
+       nofail_asprintf(&dirname, "%s%s/%s", basedir, MODULE_DIR, buf.release);
+
+       /* Old-style -t xxx wildcard?  Only with -l. */
+       if (list_only) {
+               if (optind+1 < argc)
+                       fatal("Can't have multiple wildcards\n");
+               /* fprintf(stderr, "man find\n"); return 1; */
+               failed = do_wildcard(dirname, type, argv[optind]?:"*");
+               goto out;
+       }
+       if (type)
+               fatal("-t only supported with -l");
+
+       /* Read aliases, options etc. */
+       parse_toplevel_config(configname, &conf, dump_config, flags & mit_remove);
+
+       /* Read module options from kernel command line */
+       parse_kcmdline(1, &conf.options);
+       
+       if (dump_config) {
+               char *aliasfilename, *symfilename;
+               struct modprobe_conf conf = {};
+
+               nofail_asprintf(&aliasfilename, "%s/modules.alias", dirname);
+               nofail_asprintf(&symfilename, "%s/modules.symbols", dirname);
+
+               parse_toplevel_config(configname, &conf, 1, 0);
+               /* Read module options from kernel command line */
+               parse_kcmdline(1, &conf.options);
+               read_aliases(aliasfilename, "", 1, &conf.aliases);
+               read_aliases(symfilename, "", 1, &conf.aliases);
+
+               goto out;
+       }
+
+       if ((flags & mit_remove) || all) {
+               num_modules = argc - optind;
+               cmdline_opts = NOFAIL(strdup(""));
+       } else {
+               num_modules = 1;
+               cmdline_opts = gather_options(argv+optind+1);
+       }
+
+       /* num_modules is always 1 except for -r or -a. */
+       for (i = 0; i < num_modules; i++) {
+               char *modname = argv[optind + i];
+
+               if (dump_modver)
+                       dump_modversions(modname, error);
+               else
+                       failed |= do_modprobe(modname, newname, cmdline_opts,
+                               &conf, dirname, error, flags);
+
+       }
+
+out:
+       if (logging)
+               closelog();
+       free(dirname);
+       free(cmdline_opts);
+       /* Don't bother to free conf */
+
+       exit(failed);
+}
diff --git a/modprobe.conf.5 b/modprobe.conf.5
new file mode 100644 (file)
index 0000000..8aafbb5
--- /dev/null
@@ -0,0 +1,148 @@
+.\\" auto-generated by docbook2man-spec $Revision: 1.2 $
+.TH "MODPROBE.CONF" "5" "2010-03-09" "" ""
+.SH NAME
+modprobe.d, modprobe.conf \- Configuration directory/file for modprobe
+.SH "DESCRIPTION"
+.PP
+Because the \fBmodprobe\fR command can add or
+remove more than one module, due to modules having dependencies,
+we need a method of specifying what options are to be used with
+those modules. All files underneath the 
+\fI/etc/modprobe.d\fR directory which end with the
+\fI\&.conf\fR extension specify those options as
+required. (the \fI/etc/modprobe.conf\fR file can
+also be used if it exists, but that will be removed in a future 
+version). They can also be used to create convenient aliases: 
+alternate names for a module, or they can override the normal 
+\fBmodprobe\fR behavior altogether for those with 
+special requirements (such as inserting more than one module).
+.PP
+Note that module and alias names (like other module names) can
+have - or _ in them: both are interchangable throughout all the
+module commands as underscore conversion happens automatically.
+.PP
+The format of and files under \fImodprobe.d\fR and
+\fI/etc/modprobe.conf\fR is simple: one
+command per line, with blank lines and lines starting with '#'
+ignored (useful for adding comments). A '\\' at the end of a line
+causes it to continue on the next line, which makes the file a
+bit neater.
+.SH "COMMANDS"
+.TP
+\fBalias \fIwildcard\fB \fImodulename\fB\fR
+This allows you to give alternate names for a module. For
+example: "alias my-mod really_long_modulename"
+means you can use "modprobe my-mod" instead of "modprobe
+really_long_modulename". You can also use shell-style
+wildcards, so "alias my-mod* really_long_modulename"
+means that "modprobe my-mod-something" has the same
+effect. You can't have aliases to other aliases (that
+way lies madness), but aliases can have options, which
+will be added to any other options.
+
+Note that modules can also contain their own aliases,
+which you can see using \fBmodinfo\fR\&. These
+aliases are used as a last resort (ie. if there is no real
+module, \fBinstall\fR,
+\fBremove\fR, or \fBalias\fR
+command in the configuration).
+.TP
+\fBblacklist \fImodulename\fB\fR
+Modules can contain their own aliases: usually these are
+aliases describing the devices they support, such as
+"pci:123...". These "internal" aliases can be overridden
+by normal "alias" keywords, but there are cases where two
+or more modules both support the same devices, or a module
+invalidly claims to support a devicei that it does not: the
+\fBblacklist\fR keyword indicates that all of
+that particular module's internal aliases are to be ignored.
+.TP
+\fBinstall \fImodulename\fB \fIcommand...\fB\fR
+This command instructs \fBmodprobe\fR to run your
+command instead of inserting the module in the kernel as normal.
+The command can be any shell command: this allows you to do any
+kind of complex processing you might wish. For example, if the
+module "fred" works better with the module "barney"
+already installed (but it doesn't depend on it, so
+\fBmodprobe\fR won't automatically load it),
+you could say "install fred /sbin/modprobe barney;
+/sbin/modprobe --ignore-install fred", which would do what
+you wanted. Note the \fB--ignore-install\fR,
+which stops the second \fBmodprobe\fR from
+running the same \fBinstall\fR command again.
+See also \fBremove\fR below.
+
+The long term future of this command as a solution to the
+problem of providing additional module dependencies is not assured
+and it is intended to replace this command with a warning about
+its eventual removal or deprecation at some point in a future
+release. Its use complicates the automated determination of module
+dependencies by distribution utilities, such as mkinitrd (because
+these now need to somehow interpret what the
+\fBinstall\fR commands might be doing.
+In a perfect world, modules would provide all dependency
+information without the use of this command and work is underway
+to implement soft dependency support within the Linux kernel.
+
+If you use the string "$CMDLINE_OPTS" in the command, it
+will be replaced by any options specified on the modprobe
+command line. This can be useful because users expect
+"modprobe fred opt=1" to pass the "opt=1" arg to the
+module, even if there's an install command in the
+configuration file. So our above example becomes "install
+fred /sbin/modprobe barney; /sbin/modprobe
+--ignore-install fred $CMDLINE_OPTS"
+.TP
+\fBoptions \fImodulename\fB \fIoption...\fB\fR
+This command allows you to add options to the module
+\fImodulename\fR (which might be an
+alias) every time it is inserted into the kernel: whether
+directly (using \fBmodprobe\fR 
+\fImodulename\fR or because the
+module being inserted depends on this module.
+
+All options are added together: they can come from an
+\fBoption\fR for the module itself, for an
+alias, and on the command line.
+.TP
+\fBremove \fImodulename\fB \fIcommand...\fB\fR
+This is similar to the \fBinstall\fR command
+above, except it is invoked when "modprobe -r" is run.
+.TP
+\fBsoftdep \fImodulename\fB pre: \fImodules...\fB post: \fImodules...\fB\fR
+The \fBsoftdep\fR command allows you to specify soft,
+or optional, module dependencies. \fImodulename\fR
+can be used without these optional modules installed, but usually with
+some features missing. For example, a driver for a storage HBA might
+require another module be loaded in order to use management features.
+
+pre-deps and post-deps modules are lists of names and/or aliases of other
+modules that modprobe will attempt to install (or remove) in order
+before and after the main module given in the
+\fImodulename\fR argument.
+
+Example: Assume "softdep c pre: a b post: d e" is provided in the
+configuration. Running "modprobe c" is now equivalent to
+"modprobe a b c d e" without the softdep.
+Flags such as --use-blacklist are applied to all the specified
+modules, while module parameters only apply to module c.
+
+Note: if there are \fBinstall\fR or
+\fBremove\fR commands with the same
+\fImodulename\fR argument,
+\fBsoftdep\fR takes precedence.
+.SH "COMPATIBILITY"
+.PP
+A future version of module-init-tools will come with a strong warning
+to avoid use of the \fBinstall\fR as explained above. This
+will happen once support for soft dependencies in the kernel is complete.
+That support will complement the existing softdep support within this
+utility by providing such dependencies directly within the modules.
+.SH "COPYRIGHT"
+.PP
+This manual page originally Copyright 2004, Rusty Russell, IBM
+Corporation. Maintained by Jon Masters and others.
+.SH "SEE ALSO"
+.PP
+\fBmodprobe\fR(8),
+\fBmodules.dep\fR(5)
diff --git a/modprobe.d.5 b/modprobe.d.5
new file mode 100644 (file)
index 0000000..d0ed026
--- /dev/null
@@ -0,0 +1 @@
+.so modprobe.conf.5
diff --git a/modules.dep.5 b/modules.dep.5
new file mode 100644 (file)
index 0000000..6c5ffaa
--- /dev/null
@@ -0,0 +1,30 @@
+.\\" auto-generated by docbook2man-spec $Revision: 1.2 $
+.TH "MODULES.DEP" "5" "2010-03-01" "" ""
+.SH NAME
+modules.dep.bin, modules.dep \- Module dependency information
+.SH "DESCRIPTION"
+.PP
+The \fImodules.dep.bin\fR as generated by
+module-init-tools \fBdepmod\fR, lists the
+dependencies for every module in the directories under
+\fI/lib/modules/\fR\fIversion\fR,
+where \fImodules.dep.bin\fR (or the human readable
+version \fImodules.dep\fR) is also located. It is
+used by utilities such as \fBmodprobe\fR\&. The
+binary version will be used by default, if it was generated by
+a compatible version of \fBdepmod, with fallback
+to the generic \fImodules.dep\fB\&.
+\fR.PP
+These files are not intended for editing or use by any additional
+utilities as their format is subject to change in the future. You
+should use the
+\fBmodinfo\fR(8) command to obtain information about modules in a future
+proof and compatible fashion rather than touching these files.
+.SH "COPYRIGHT"
+.PP
+This manual page originally Copyright 2002, Rusty Russell, IBM
+Corporation. Maintained by Jon Masters and others.
+.SH "SEE ALSO"
+.PP
+\fBdepmod\fR(8),
+\fBmodprobe\fR(8)
diff --git a/rmmod.8 b/rmmod.8
new file mode 100644 (file)
index 0000000..6942a0d
--- /dev/null
+++ b/rmmod.8
@@ -0,0 +1,51 @@
+.\\" auto-generated by docbook2man-spec $Revision: 1.2 $
+.TH "RMMOD" "8" "2010-03-01" "" ""
+.SH NAME
+rmmod \- simple program to remove a module from the Linux Kernel
+.SH SYNOPSIS
+.sp
+\fBrmmod\fR [ \fB-f\fR ]  [ \fB-w\fR ]  [ \fB-s\fR ]  [ \fB-v\fR ]  [ \fB\fImodulename\fB\fR ] 
+.SH "DESCRIPTION"
+.PP
+\fBrmmod\fR is a trivial program to remove a
+module (when module unloading support is provided) from the kernel.
+Most users will want to use
+\fBmodprobe\fR(8) with the \fB-r\fR option instead.
+.SH "OPTIONS"
+.TP
+\fB-v --verbose\fR
+Print messages about what the program is doing.
+Usually \fBrmmod\fR prints messages
+only if something goes wrong.
+.TP
+\fB-f --force\fR
+This option can be extremely dangerous: it has no effect unless
+CONFIG_MODULE_FORCE_UNLOAD was set when the kernel was
+compiled. With this option, you can remove modules which are
+being used, or which are not designed to be removed, or have
+been marked as unsafe (see \fBlsmod\fR(8)).
+.TP
+\fB-w --wait\fR
+Normally, \fBrmmod\fR will refuse to
+unload modules which are in use. With this option,
+\fBrmmod\fR will isolate the module, and
+wait until the module is no longer used. Nothing new
+will be able to use the module, but it's up to you to
+make sure the current users eventually finish with it.
+See \fBlsmod\fR(8)) for information on usage counts.
+.TP
+\fB-s --syslog\fR
+Send errors to syslog instead of standard error.
+.TP
+\fB-V --version\fR
+Show version of program and exit.
+.SH "COPYRIGHT"
+.PP
+This manual page originally Copyright 2002, Rusty Russell, IBM
+Corporation. Maintained by Jon Masters and others.
+.SH "SEE ALSO"
+.PP
+\fBmodprobe\fR(8),
+\fBinsmod\fR(8),
+\fBlsmod\fR(8)
+\fBmodinfo\fR(8)
diff --git a/rmmod.c b/rmmod.c
new file mode 100644 (file)
index 0000000..f317ed9
--- /dev/null
+++ b/rmmod.c
@@ -0,0 +1,211 @@
+/* rmmod.c: remove a module from the kernel.
+    Copyright (C) 2001  Rusty Russell.
+    Copyright (C) 2002  Rusty Russell, IBM Corporation.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <asm/unistd.h>
+#include <stdarg.h>
+#include <getopt.h>
+#include <syslog.h>
+
+#include "util.h"
+#include "logging.h"
+#include "testing.h"
+
+extern long delete_module(const char *, unsigned int);
+
+static char *next_field(const char *line)
+{
+       const char *rest;
+
+       rest = line + strcspn(line, " ");
+       rest += strspn(rest, " ");
+       return (char *)rest;
+}
+
+/* Report that the module is in use. */
+static void mod_in_use(const char *modname, char *usedby)
+{
+       /* New /proc/modules uses a single "-" to mean "nothing".  Old
+           one just puts nothing there. */
+       if (usedby[0] == '-' || streq(usedby, "")) {
+               error("Module %s is in use\n", modname);
+               return;
+       }
+
+       /* New /proc/modules *always* prints commas (even if only one) */
+       if (strchr(usedby, ','))
+               /* Blatt over trailing comma for neatness */
+               usedby[strcspn(usedby, " \n")-1] = '\0';
+       else {
+               /* Older /proc/modules just put them as
+                   space-separated names.  Blatt over trailing \n */
+               usedby[strlen(usedby)-1] = '\0';
+       }
+
+       error("Module %s is in use by %s\n", modname, usedby);
+}
+
+/* If we can check usage without entering kernel, do so. */
+static int check_usage(const char *modname)
+{
+       FILE *module_list;
+       char line[10240], name[64];
+       unsigned long size, refs;
+       int scanned;
+
+       module_list = fopen("/proc/modules", "r");
+       if (!module_list) {
+               if (errno == ENOENT) /* /proc may not be mounted. */
+                       return 0;
+               fatal("can't open /proc/modules: %s\n", strerror(errno));
+       }
+       while (fgets(line, sizeof(line)-1, module_list) != NULL) {
+               if (strchr(line, '\n') == NULL) {
+                       fatal("V. v. long line broke rmmod.\n");
+                       exit(1);
+               }
+
+               scanned = sscanf(line, "%s %lu %lu", name, &size, &refs);
+               if (strcmp(name, modname) != 0)
+                       continue;
+
+               if (scanned < 2)
+                       fatal("Unknown format in /proc/modules: %s\n", line);
+
+               if (scanned == 2)
+                       fatal("Kernel does not have unload support.\n");
+
+               /* Hand it fields 3 onwards. */
+               if (refs != 0)
+                       mod_in_use(modname,
+                                  next_field(next_field(next_field(line))));
+               goto out;
+       }
+       error("Module %s does not exist in /proc/modules\n", modname);
+       refs = 1;
+ out:
+       fclose(module_list);
+       return (refs == 0) ? 0 : -EINVAL;
+}
+
+static int rmmod(const char *path, int flags)
+{
+       long ret;
+       char name[strlen(path) + 1];
+
+       filename2modname(name, path);
+
+       if ((flags & O_NONBLOCK) && !(flags & O_TRUNC)) {
+               if (check_usage(name) != 0)
+                       return 1;
+       }
+
+       info("rmmod %s, wait=%s%s\n", name,
+            (flags & O_NONBLOCK) ? "no" : "yes",
+            (flags & O_TRUNC) ? " force" : "");
+
+       ret = delete_module(name, flags);
+       if (ret != 0)
+               error("Removing '%s': %s\n", name, strerror(errno));
+       return ret;
+}
+
+static struct option options[] = { { "all", 0, NULL, 'a' },
+                                  { "force", 0, NULL, 'f' },
+                                  { "help", 0, NULL, 'h' },
+                                  { "syslog", 0, NULL, 's' },
+                                  { "verbose", 0, NULL, 'v' },
+                                  { "version", 0, NULL, 'V' },
+                                  { "wait", 0, NULL, 'w' },
+                                  { NULL, 0, NULL, 0 } };
+
+static void print_usage(const char *progname)
+{
+       fprintf(stderr,
+               "Usage: %s [-fhswvV] modulename ...\n"
+               // " -a (or --all) to remove all modules (no names needed)\n"
+               " -f (or --force) forces a module unload, and may crash your\n"
+               "    machine.  This requires the Forced Module Removal option\n"
+               "    when the kernel was compiled.\n"
+               " -h (or --help) prints this help text\n"
+               " -s (or --syslog) says use syslog, not stderr\n"
+               " -v (or --verbose) enables more messages\n"
+               " -V (or --version) prints the version code\n"
+               " -w (or --wait) begins a module removal even if it is used\n"
+               "    and will stop new users from accessing the module (so it\n"
+               "    should eventually fall to zero).\n"
+               , progname);
+       exit(1);
+}
+
+int main(int argc, char *argv[])
+{
+       /* O_EXCL so kernels can spot old rmmod versions */
+       unsigned int flags = O_NONBLOCK|O_EXCL;
+       int i, opt, all = 0;
+       int ret, err;
+
+       while ((opt = getopt_long(argc, argv,
+                       "afh?swvV", options, NULL)) != EOF) {
+               switch (opt) {
+               case 'a':       // --all
+                       all = 1;
+                       break;
+               case 'f':       // --force
+                       flags |= O_TRUNC;
+                       break;
+               case 's':       // --syslog
+                       openlog("rmmod", LOG_CONS, LOG_DAEMON);
+                       logging = 1;
+                       break;
+               case 'w':       // --wait
+                       flags &= ~O_NONBLOCK;
+                       break;
+               case 'v':       // --verbose
+                       verbose++;
+                       break;
+               case 'V':       // --version
+                       puts(PACKAGE " version " VERSION);
+                       return 0;
+
+               default:
+                       print_usage(argv[0]);
+               }
+       }
+       if (!argv[optind]) {
+               fprintf(stderr, "no module names given\n");
+               print_usage(argv[0]);
+       }
+
+       err = 0;
+       /* remove each specified module */
+       for (i = optind; i < argc; i++) {
+               ret = rmmod(argv[i], flags);
+               if (ret != 0)
+                       err = 1;
+       }
+
+       if (logging)
+               closelog();
+       exit(err);
+}
diff --git a/stress_modules.sh b/stress_modules.sh
new file mode 100755 (executable)
index 0000000..37c1b57
--- /dev/null
@@ -0,0 +1,42 @@
+#! /bin/sh
+
+MODULE_DIR=/lib/modules/`uname -r`/kernel
+
+case "$1" in
+    mount-unmount)
+       trap "umount $3; rm -f $2; rmdir $3" 0
+       mkdir $3
+       dd bs=1204k count=20 if=/dev/zero of=$2
+       mke2fs -F $2
+       tune2fs -c 0 $2
+       modprobe loop
+       while true; do mount -o loop $2 $3; umount $3; sleep 1; done
+       ;;
+    bang-one)
+       trap "rmmod $2" 0
+       while true; do modprobe $2; rmmod $2; done
+       ;;
+    bang-all)
+       while true; do
+           # Randomize order
+           find $MODULE_DIR -name '*.ko' | ( while read mod; do echo $RANDOM $mod; done ) | sort -n |
+               while read junk modname; do
+                   if [ $RANDOM -gt $RANDOM ]; then
+                       rmmod `basename $modname .ko`
+                   else
+                       modprobe `basename $modname .ko`
+                   fi
+               done
+       done
+       ;;
+    "")
+       $0 mount-unmount testfs.$$ /tmp/$$ &
+       $0 bang-one ext2 &
+       $0 bang-all &
+       exit 0
+       ;;
+    *)
+       echo Unknown arg "$1"
+       exit 1
+       ;;
+esac
diff --git a/tables.c b/tables.c
new file mode 100644 (file)
index 0000000..c862920
--- /dev/null
+++ b/tables.c
@@ -0,0 +1,571 @@
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "depmod.h"
+#include "tables.h"
+#include "util.h"
+
+/* Turn /lib/modules/2.5.49/kernel/foo.ko(.gz) => foo */
+static void make_shortname(char *dest, const char *src)
+{
+       char *ext;
+       const char *bname;
+
+       bname = my_basename(src);
+       strcpy(dest, bname);
+       ext = strchr(dest, '.');
+       if (ext)
+               *ext = '\0';
+}
+
+/* We set driver_data to zero */
+static void output_pci_entry(struct pci_device_id *pci, char *name, FILE *out,
+                            int conv)
+{
+       fprintf(out,
+               "%-20s 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x0\n",
+               name,
+               END(pci->vendor, conv),
+               END(pci->device, conv),
+               END(pci->subvendor, conv),
+               END(pci->subdevice, conv),
+               END(pci->class, conv),
+               END(pci->class_mask, conv));
+}
+
+int output_pci_table(struct module *modules, FILE *out, char *dirname)
+{
+       struct module *i;
+
+       fprintf(out, "# pci module         vendor     device     subvendor"
+               "  subdevice  class      class_mask driver_data\n");
+
+       for (i = modules; i; i = i->next) {
+               struct pci_device_id *e;
+               char shortname[strlen(i->pathname) + 1];
+               struct module_tables *t = &i->tables;
+
+               if (!t->pci_table)
+                       continue;
+
+               make_shortname(shortname, i->pathname);
+               for (e = t->pci_table; e->vendor; e = (void *)e + t->pci_size)
+                       output_pci_entry(e, shortname, out, i->file->conv);
+       }
+       return 1;
+}
+
+/* We set driver_info to zero */
+static void output_usb_entry(struct usb_device_id *usb, char *name, FILE *out,
+                            int conv)
+{
+       fprintf(out, "%-20s 0x%04x      0x%04x   0x%04x    0x%04x"
+               "       0x%04x       0x%02x         0x%02x"
+               "            0x%02x            0x%02x"
+               "            0x%02x               0x%02x"
+               "               0x0\n",
+               name,
+               END(usb->match_flags, conv),
+               END(usb->idVendor, conv),
+               END(usb->idProduct, conv),
+               END(usb->bcdDevice_lo, conv),
+               END(usb->bcdDevice_hi, conv),
+               END(usb->bDeviceClass, conv),
+               END(usb->bDeviceSubClass, conv),
+               END(usb->bDeviceProtocol, conv),
+               END(usb->bInterfaceClass, conv),
+               END(usb->bInterfaceSubClass, conv),
+               END(usb->bInterfaceProtocol, conv));
+}
+
+int output_usb_table(struct module *modules, FILE *out, char *dirname)
+{
+       struct module *i;
+
+       fprintf(out, "# usb module         ");
+       /* Requires all users to be on kernel 2.4.0 or later */
+       fprintf(out, "match_flags ");
+       fprintf(out, "idVendor idProduct bcdDevice_lo bcdDevice_hi"
+               " bDeviceClass bDeviceSubClass bDeviceProtocol"
+               " bInterfaceClass bInterfaceSubClass"
+               " bInterfaceProtocol driver_info\n");
+
+       for (i = modules; i; i = i->next) {
+               struct usb_device_id *e;
+               char shortname[strlen(i->pathname) + 1];
+               struct module_tables *t = &i->tables;
+
+               if (!t->usb_table)
+                       continue;
+
+               make_shortname(shortname, i->pathname);
+               for (e = t->usb_table;
+                    e->idVendor || e->bDeviceClass || e->bInterfaceClass;
+                    e = (void *)e + t->usb_size)
+                       output_usb_entry(e, shortname, out, i->file->conv);
+       }
+       return 1;
+}
+
+static void output_ieee1394_entry(struct ieee1394_device_id *fw, char *name,
+                                 FILE *out, int conv)
+{
+       fprintf(out, "%-20s 0x%08x  0x%06x  0x%06x 0x%06x     0x%06x\n",
+               name,
+               END(fw->match_flags, conv),
+               END(fw->vendor_id, conv),
+               END(fw->model_id, conv),
+               END(fw->specifier_id, conv),
+               END(fw->version, conv));
+}
+
+int output_ieee1394_table(struct module *modules, FILE *out, char *dirname)
+{
+       struct module *i;
+
+       fprintf(out, "# ieee1394 module    ");
+       fprintf(out, "match_flags vendor_id model_id specifier_id version\n");
+
+       for (i = modules; i; i = i->next) {
+               struct ieee1394_device_id *fw;
+               char shortname[strlen(i->pathname) + 1];
+               struct module_tables *t = &i->tables;
+
+               if (!t->ieee1394_table)
+                       continue;
+
+               make_shortname(shortname, i->pathname);
+               for (fw = t->ieee1394_table; fw->match_flags;
+                    fw = (void *) fw + t->ieee1394_size)
+                       output_ieee1394_entry(fw, shortname, out, i->file->conv);
+       }
+       return 1;
+}
+
+
+/* We set driver_data to zero */
+static void output_ccw_entry(struct ccw_device_id *ccw, char *name, FILE *out,
+                            int conv)
+{
+       fprintf(out, "%-20s 0x%04x      0x%04x  0x%02x      0x%04x  0x%02x\n",
+               name, END(ccw->match_flags, conv),
+               END(ccw->cu_type, conv),  END(ccw->cu_model, conv),
+               END(ccw->dev_type, conv), END(ccw->dev_model, conv));
+}
+
+int output_ccw_table(struct module *modules, FILE *out, char *dirname)
+{
+       struct module *i;
+
+       fprintf(out, "# ccw module         ");
+       fprintf(out, "match_flags cu_type cu_model dev_type dev_model\n");
+
+       for (i = modules; i; i = i->next) {
+               struct ccw_device_id *e;
+               char shortname[strlen(i->pathname) + 1];
+               struct module_tables *t = &i->tables;
+
+               if (!t->ccw_table)
+                       continue;
+
+               make_shortname(shortname, i->pathname);
+               for (e = t->ccw_table;
+                    e->cu_type || e->cu_model || e->dev_type || e->dev_model;
+                    e = (void *) e + t->ccw_size)
+                       output_ccw_entry(e, shortname, out, i->file->conv);
+       }
+       return 1;
+}
+
+#define ISAPNP_VENDOR(a,b,c)   (((((a)-'A'+1)&0x3f)<<2)|\
+                               ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
+                               ((((c)-'A'+1)&0x1f)<<8))
+#define ISAPNP_DEVICE(x)       ((((x)&0xf000)>>8)|\
+                                (((x)&0x0f00)>>8)|\
+                                (((x)&0x00f0)<<8)|\
+                                (((x)&0x000f)<<8))
+
+static void put_isapnp_id(FILE *out, const char *id)
+{
+       unsigned short vendor, device;
+
+       vendor = ISAPNP_VENDOR(id[0], id[1], id[2]);
+       device = (unsigned short)strtol(&id[3], NULL, 16);
+       device = ISAPNP_DEVICE(device);
+       fprintf(out, " 0x%04x     0x%04x    ", vendor, device);
+}
+
+int output_isapnp_table(struct module *modules, FILE *out, char *dirname)
+{
+       struct module *i;
+
+       fprintf(out, "# isapnp module      ");
+       fprintf(out, "cardvendor carddevice driver_data vendor     function   ...\n");
+
+       for (i = modules; i; i = i->next) {
+               char shortname[strlen(i->pathname) + 1];
+               struct module_tables *t = &i->tables;
+
+               if (t->pnp_table) {
+                       struct pnp_device_id *id;
+                       make_shortname(shortname, i->pathname);
+                       for (id = t->pnp_table;
+                            id->id[0];
+                            id = (void *)id + t->pnp_size) {
+                               fprintf(out, "%-20s", shortname);
+                               fprintf(out, " 0xffff     0xffff    ");
+                               fprintf(out, " 0x00000000 "); /* driver_data */
+                               put_isapnp_id(out, id->id);
+                               fprintf(out, "\n");
+                       }
+               }
+               if (t->pnp_card_table) {
+                       void *id;
+                       make_shortname(shortname, i->pathname);
+                       for (id = t->pnp_card_table;
+                            ((char *)id)[0];
+                            id += t->pnp_card_size) {
+                               int idx;
+                               struct pnp_card_devid *devid
+                                       = id + t->pnp_card_offset;
+
+                               fprintf(out, "%-20s", shortname);
+                               put_isapnp_id(out, id);
+                               fprintf(out, " 0x00000000 "); /* driver_data */
+                               for (idx = 0; idx < 8; idx++) {
+                                       if (!devid->devid[idx][0])
+                                               break;
+                                       put_isapnp_id(out, devid->devid[idx]);
+                               }
+                               fprintf(out, "\n");
+                       }
+               }
+       }
+       return 1;
+}
+
+#define MATCH_bustype   1
+#define MATCH_vendor    2
+#define MATCH_product   4
+#define MATCH_version   8
+
+#define MATCH_evbit     0x010
+#define MATCH_keybit    0x020
+#define MATCH_relbit    0x040
+#define MATCH_absbit    0x080
+#define MATCH_mscbit    0x100
+#define MATCH_ledbit    0x200
+#define MATCH_sndbit    0x400
+#define MATCH_ffbit     0x800
+#define MATCH_swbit     0x1000
+
+#define MATCH(x) (END(input->match_flags, conv) & MATCH_ ## x)
+#define PRINT_SCALAR(n) fprintf(out, "  0x%lx", MATCH(n) ? END(input->n, conv) : 0l)
+#define PRINT_ARRAY64(n) do {                                              \
+       fprintf(out, "  ");                                                 \
+       if (MATCH(n))                                                       \
+               output_input_bits_64(out, input->n, sizeof(input->n), conv); \
+       else                                                                \
+               fprintf(out, "%d", 0);                                      \
+       } while (0)
+
+#define PRINT_ARRAY32(n) do {                                              \
+       fprintf(out, "  ");                                                 \
+       if (MATCH(n))                                                       \
+               output_input_bits_32(out, input->n, sizeof(input->n), conv); \
+       else                                                                \
+               fprintf(out, "%d", 0);                                      \
+       } while (0)
+
+static void output_input_bits_32(FILE *out, unsigned int *bits, int size,
+                                int conv)
+{
+       int i, j;
+
+       size /= sizeof(*bits);
+       for (i = size - 1; i >= 0; i--)
+                if (END(bits[i], conv))
+                        break;
+       if (i < 0)
+               i = 0;
+       fprintf(out, "%x", END(bits[i], conv));
+       for (j = i - 1; j >= 0; j--)
+               fprintf(out, ":%x", END(bits[j], conv));
+}
+
+static void output_input_bits_64(FILE *out, unsigned long long *bits, int size,
+                                int conv)
+{
+       int i, j;
+
+       size /= sizeof(*bits);
+       for (i = size - 1; i >= 0; i--)
+                if (END(bits[i], conv))
+                        break;
+       if (i < 0)
+               i = 0;
+       fprintf(out, "%llx", END(bits[i], conv));
+       for (j = i - 1; j >= 0; j--)
+               fprintf(out, ":%llx", END(bits[j], conv));
+}
+
+/* Formats are too different to */
+static int output_input_entry_32(struct input_device_id_32 *input,
+                                char *name, FILE *out, int conv)
+{
+       if (!input->match_flags && !input->driver_info)
+               return 1;
+
+       fprintf(out, "%-20s0x%x", name, END(input->match_flags, conv));
+
+       PRINT_SCALAR(bustype);
+       PRINT_SCALAR(vendor);
+       PRINT_SCALAR(product);
+       PRINT_SCALAR(version);
+
+       PRINT_ARRAY32(evbit);
+       PRINT_ARRAY32(keybit);
+       PRINT_ARRAY32(relbit);
+       PRINT_ARRAY32(absbit);
+       PRINT_ARRAY32(mscbit);
+       PRINT_ARRAY32(ledbit);
+       PRINT_ARRAY32(sndbit);
+       PRINT_ARRAY32(ffbit);
+       PRINT_ARRAY32(swbit);
+
+       fprintf(out, "  0x%x\n", END(input->driver_info, conv));
+       return 0;
+}
+
+static int output_input_entry_32_old(struct input_device_id_old_32 *input,
+                                    char *name, FILE *out, int conv)
+{
+       if (!input->match_flags && !input->driver_info)
+               return 1;
+
+       fprintf(out, "%-20s0x%x", name, END(input->match_flags, conv));
+
+       PRINT_SCALAR(bustype);
+       PRINT_SCALAR(vendor);
+       PRINT_SCALAR(product);
+       PRINT_SCALAR(version);
+
+       PRINT_ARRAY32(evbit);
+       PRINT_ARRAY32(keybit);
+       PRINT_ARRAY32(relbit);
+       PRINT_ARRAY32(absbit);
+       PRINT_ARRAY32(mscbit);
+       PRINT_ARRAY32(ledbit);
+       PRINT_ARRAY32(sndbit);
+       PRINT_ARRAY32(ffbit);
+
+       fprintf(out, "  0x%x\n", END(input->driver_info, conv));
+       return 0;
+}
+
+static int output_input_entry_64(struct input_device_id_64 *input,
+                                char *name, FILE *out, int conv)
+{
+       if (!input->match_flags && !input->driver_info)
+               return 1;
+
+       fprintf(out, "%-20s0x%llx", name, END(input->match_flags, conv));
+
+       PRINT_SCALAR(bustype);
+       PRINT_SCALAR(vendor);
+       PRINT_SCALAR(product);
+       PRINT_SCALAR(version);
+
+       PRINT_ARRAY64(evbit);
+       PRINT_ARRAY64(keybit);
+       PRINT_ARRAY64(relbit);
+       PRINT_ARRAY64(absbit);
+       PRINT_ARRAY64(mscbit);
+       PRINT_ARRAY64(ledbit);
+       PRINT_ARRAY64(sndbit);
+       PRINT_ARRAY64(ffbit);
+       PRINT_ARRAY64(swbit);
+
+       fprintf(out, "  0x%llx\n", END(input->driver_info, conv));
+       return 0;
+}
+
+static int output_input_entry_64_old(struct input_device_id_old_64 *input,
+                                    char *name, FILE *out, int conv)
+{
+       if (!input->match_flags && !input->driver_info)
+               return 1;
+
+       fprintf(out, "%-20s0x%llx", name, END(input->match_flags, conv));
+
+       PRINT_SCALAR(bustype);
+       PRINT_SCALAR(vendor);
+       PRINT_SCALAR(product);
+       PRINT_SCALAR(version);
+
+       PRINT_ARRAY64(evbit);
+       PRINT_ARRAY64(keybit);
+       PRINT_ARRAY64(relbit);
+       PRINT_ARRAY64(absbit);
+       PRINT_ARRAY64(mscbit);
+       PRINT_ARRAY64(ledbit);
+       PRINT_ARRAY64(sndbit);
+       PRINT_ARRAY64(ffbit);
+
+       fprintf(out, "  0x%llx\n", END(input->driver_info, conv));
+       return 0;
+}
+
+int output_input_table(struct module *modules, FILE *out, char *dirname)
+{
+       struct module *i;
+
+       fprintf(out, "# module         matchBits");
+       fprintf(out, " bustype vendor product version evBits keyBits relBits");
+       fprintf(out, " absBits mscBits ledBits sndBits ffBits [swBits] driver_info\n");
+
+       for (i = modules; i; i = i->next) {
+               void *p;
+               char shortname[strlen(i->pathname) + 1];
+               int done = 0;
+               struct module_tables *t = &i->tables;
+               int conv = i->file->conv;
+
+               if (!t->input_table)
+                       continue;
+
+               make_shortname(shortname, i->pathname);
+               /* Guess what size it really is, based on size of
+                * whole table.  Table changed in 2.6.14.  This is a hack. */
+               if (t->input_size == sizeof(struct input_device_id_old_64)) {
+                       if ((t->input_table_size % t->input_size) != 0) {
+                               t->input_size
+                                       = sizeof(struct input_device_id_64);
+                       }
+               } else {
+                       if ((t->input_table_size % t->input_size) != 0) {
+                               t->input_size
+                                       = sizeof(struct input_device_id_32);
+                       }
+               }
+
+               for (p = t->input_table; !done; p += t->input_size) {
+                       switch (t->input_size) {
+                       case sizeof(struct input_device_id_old_64):
+                               done = output_input_entry_64_old(p,
+                                                                shortname,
+                                                                out, conv);
+                               break;
+                       case sizeof(struct input_device_id_64):
+                               done = output_input_entry_64(p, shortname,
+                                                            out, conv);
+                               break;
+                       case sizeof(struct input_device_id_old_32):
+                               done = output_input_entry_32_old(p,
+                                                                shortname,
+                                                                out, conv);
+                               break;
+                       case sizeof(struct input_device_id_32):
+                               done = output_input_entry_32(p, shortname,
+                                                            out, conv);
+                               break;
+                       }
+               }                               
+       }
+       return 1;
+}
+
+static void output_serio_entry(struct serio_device_id *serio, char *name, FILE *out)
+{
+       fprintf(out,
+               "%-20s 0x%02x 0x%02x  0x%02x 0x%02x\n",
+               name,
+               serio->type,
+               serio->extra,
+               serio->id,
+               serio->proto);
+}
+
+
+int output_serio_table(struct module *modules, FILE *out, char *dirname)
+{
+       struct module *i;
+
+       fprintf(out, "# serio module       type extra id   proto\n");
+
+       for (i = modules; i; i = i->next) {
+               struct serio_device_id *e;
+               char shortname[strlen(i->pathname) + 1];
+               struct module_tables *t = &i->tables;
+
+               if (!t->serio_table)
+                       continue;
+
+               make_shortname(shortname, i->pathname);
+               for (e = t->serio_table; e->type || e->proto; e = (void *)e + t->serio_size)
+                       output_serio_entry(e, shortname, out);
+       }
+       return 1;
+}
+
+
+static void
+strip_whitespace (char *str, char chr)
+{
+       int i;
+       if (!str)
+               return;
+       for (i = strlen (str); i >= 0; --i)
+               if (isspace (*str))
+                       *str = chr;
+}
+
+/* We set driver_data to zero */
+static void output_of_entry(struct of_device_id *dev, char *name, FILE *out)
+{
+       char *ofname = NULL, *type = NULL, *compatible = NULL;
+       if (dev->name[0]) {
+               ofname = strdup (dev->name);
+               strip_whitespace (ofname, '_');
+       }
+
+       if (dev->type[0]) {
+               type = strdup (dev->type);
+               strip_whitespace (type, '_');
+       }
+
+       if (dev->compatible[0]) {
+               compatible = strdup (dev->compatible);
+               strip_whitespace (compatible, '_');
+       }
+
+        fprintf (out, "%-20s %-20s %-20s %s\n",
+                name, ofname ? ofname : "*", type ? type : "*",
+                compatible ? compatible : "*");
+       
+       free(ofname);
+       free(type);
+       free(compatible);
+}
+
+int output_of_table(struct module *modules, FILE *out, char *dirname)
+{
+       struct module *i;
+
+        fprintf (out, "# of module          name                 type                 compatible\n");                                 
+       for (i = modules; i; i = i->next) {
+               struct of_device_id *e;
+               char shortname[strlen(i->pathname) + 1];
+               struct module_tables *t = &i->tables;
+
+               if (!t->of_table)
+                       continue;
+
+               make_shortname(shortname, i->pathname);
+               for (e = t->of_table; e->name[0]|e->type[0]|e->compatible[0];
+                     e = (void *)e + t->of_size)
+                       output_of_entry(e, shortname, out);
+       }
+       return 1;
+}
diff --git a/tables.h b/tables.h
new file mode 100644 (file)
index 0000000..920e8df
--- /dev/null
+++ b/tables.h
@@ -0,0 +1,187 @@
+#ifndef MODINITTOOLS_TABLES_H
+#define MODINITTOOLS_TABLES_H
+#include <stddef.h>
+
+/* Taken from the 2.5.49 kernel, with the kernel specific fields removed */
+struct pci_device_id {
+       unsigned int vendor, device;            /* Vendor and device ID or PCI_ANY_ID */
+       unsigned int subvendor, subdevice;      /* Subsystem ID's or PCI_ANY_ID */
+       unsigned int class, class_mask;         /* (class,subclass,prog-if) triplet */
+};
+#define PCI_DEVICE_SIZE32 (6 * 4 + 4)
+#define PCI_DEVICE_SIZE64 (6 * 4 + 8)
+
+struct usb_device_id {
+       /* which fields to match against? */
+       unsigned short  match_flags;
+
+       /* Used for product specific matches; range is inclusive */
+       unsigned short  idVendor;
+       unsigned short  idProduct;
+       unsigned short  bcdDevice_lo;
+       unsigned short  bcdDevice_hi;
+
+       /* Used for device class matches */
+       unsigned char   bDeviceClass;
+       unsigned char   bDeviceSubClass;
+       unsigned char   bDeviceProtocol;
+
+       /* Used for interface class matches */
+       unsigned char   bInterfaceClass;
+       unsigned char   bInterfaceSubClass;
+       unsigned char   bInterfaceProtocol;
+
+};
+#define USB_DEVICE_SIZE32 (5 * 2 + 6 * 1 + 4)
+#define USB_DEVICE_SIZE64 (5 * 2 + 6 * 1 + 8)
+
+struct ieee1394_device_id {
+       unsigned int match_flags;
+       unsigned int vendor_id;
+       unsigned int model_id;
+       unsigned int specifier_id;
+       unsigned int version;
+};
+#define IEEE1394_DEVICE_SIZE32 (5 * 4 + 4)
+#define IEEE1394_DEVICE_SIZE64 (5 * 4 + 4 /*padding*/ + 8)
+
+struct ccw_device_id {
+       unsigned short match_flags;     /* which fields to match against */
+
+       unsigned short cu_type;         /* control unit type     */
+       unsigned short dev_type;        /* device type           */
+       unsigned char  cu_model;        /* control unit model    */
+       unsigned char  dev_model;       /* device model          */
+};
+#define CCW_DEVICE_SIZE32 (3 * 2 + 2 * 1 + 4)
+#define CCW_DEVICE_SIZE64 (3 * 2 + 2 * 1 + 8)
+
+struct pnp_device_id {
+       char id[8];
+};
+#define PNP_DEVICE_SIZE32 (8 + 4)
+#define PNP_DEVICE_SIZE64 (8 + 8)
+
+struct pnp_card_devid
+{
+       char devid[8][8];
+};
+struct pnp_card_device_id_32 {
+       char id[8];
+       char driver_data[4];
+       char devid[8][8];
+};
+struct pnp_card_device_id_64 {
+       char id[8];
+       char driver_data[8];
+       char devid[8][8];
+};
+#define PNP_CARD_DEVICE_SIZE32 (sizeof(struct pnp_card_device_id_32))
+#define PNP_CARD_DEVICE_SIZE64 (sizeof(struct pnp_card_device_id_64))
+#define PNP_CARD_DEVICE_OFFSET32 (offsetof(struct pnp_card_device_id_32, devid))
+#define PNP_CARD_DEVICE_OFFSET64 (offsetof(struct pnp_card_device_id_64, devid))
+struct input_device_id_old_64 {
+       unsigned long long match_flags;
+       unsigned short bustype;
+       unsigned short vendor;
+       unsigned short product;
+       unsigned short version;
+       unsigned long long evbit[1];
+       unsigned long long keybit[8]; /* 512 bits */
+       unsigned long long relbit[1];
+       unsigned long long absbit[1]; /* 64 bits */
+       unsigned long long mscbit[1];
+       unsigned long long ledbit[1];
+       unsigned long long sndbit[1];
+       unsigned long long ffbit[2]; /* 128 bits */
+       unsigned long long driver_info;
+};
+
+struct input_device_id_old_32 {
+       unsigned int match_flags;
+       unsigned short bustype;
+       unsigned short vendor;
+       unsigned short product;
+       unsigned short version;
+       unsigned int evbit[1];
+       unsigned int keybit[16]; /* 512 bits */
+       unsigned int relbit[1];
+       unsigned int absbit[2]; /* 64 bits */
+       unsigned int mscbit[1];
+       unsigned int ledbit[1];
+       unsigned int sndbit[1];
+       unsigned int ffbit[4]; /* 128 bits */
+       unsigned int driver_info;
+};
+
+/* Whee... structure changed in 2.6.14 and broke module-init-tools. */
+struct input_device_id_64 {
+       unsigned long long match_flags;
+       unsigned short bustype;
+       unsigned short vendor;
+       unsigned short product;
+       unsigned short version;
+       unsigned long long evbit[1];
+       unsigned long long keybit[8]; /* 512 bits */
+       unsigned long long relbit[1];
+       unsigned long long absbit[1]; /* 64 bits */
+       unsigned long long mscbit[1];
+       unsigned long long ledbit[1];
+       unsigned long long sndbit[1];
+       unsigned long long ffbit[2]; /* 128 bits */
+       unsigned long long swbit[1];
+       unsigned long long driver_info;
+};
+
+struct input_device_id_32 {
+       unsigned int match_flags;
+       unsigned short bustype;
+       unsigned short vendor;
+       unsigned short product;
+       unsigned short version;
+       unsigned int evbit[1];
+       unsigned int keybit[16]; /* 512 bits */
+       unsigned int relbit[1];
+       unsigned int absbit[2]; /* 64 bits */
+       unsigned int mscbit[1];
+       unsigned int ledbit[1];
+       unsigned int sndbit[1];
+       unsigned int ffbit[4]; /* 128 bits */
+       unsigned int swbit[1];
+       unsigned int driver_info;
+};
+
+/* These are the old sizes. */
+#define INPUT_DEVICE_SIZE32 (4 + 4 * 2 + 4 + 16 * 4 + 4 + 2 * 4 + 4 + 4 + 4 + 4 * 4 + 4)
+#define INPUT_DEVICE_SIZE64 (8 + 4 * 2 + 8 + 8 * 8 + 8 + 8 + 8 + 8 + 8 + 2 * 8 + 8)
+
+struct serio_device_id {
+       unsigned char type;
+       unsigned char extra;
+       unsigned char id;
+       unsigned char proto;
+};
+#define SERIO_DEVICE_SIZE32 (4 * 1)
+#define SERIO_DEVICE_SIZE64 (4 * 1 + 4)
+
+struct of_device_id {
+       char name[32];
+       char type[32];
+       char compatible[128];
+};
+
+#define OF_DEVICE_SIZE32 (32 * 2 + 128 + 4)
+#define OF_DEVICE_SIZE64 (32 * 2 + 128 + 8)
+
+/* Functions provided by tables.c */
+struct module;
+int output_usb_table(struct module *modules, FILE *out, char *dirname);
+int output_ieee1394_table(struct module *modules, FILE *out, char *dirname);
+int output_pci_table(struct module *modules, FILE *out, char *dirname);
+int output_ccw_table(struct module *modules, FILE *out, char *dirname);
+int output_isapnp_table(struct module *modules, FILE *out, char *dirname);
+int output_input_table(struct module *modules, FILE *out, char *dirname);
+int output_serio_table(struct module *modules, FILE *out, char *dirname);
+int output_of_table(struct module *modules, FILE *out, char *dirname);
+
+#endif /* MODINITTOOLS_TABLES_H */
diff --git a/testing.h b/testing.h
new file mode 100644 (file)
index 0000000..1fe234a
--- /dev/null
+++ b/testing.h
@@ -0,0 +1,251 @@
+#ifndef _TESTING_H
+#define _TESTING_H
+
+/* Testing code. */
+#ifdef JUST_TESTING
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <sys/utsname.h>
+#include <asm/unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <time.h>
+
+/* We don't use all of these. */
+static int modtest_uname(struct utsname *buf) __attribute__((unused));
+static long modtest_create_module(const char *name, size_t size)
+__attribute__((unused));
+static void *modtest_fopen(const char *path, const char *mode)
+__attribute__((unused));
+static int modtest_open(const char *path, int flags, mode_t mode)
+__attribute__((unused));
+static int modtest_stat(const char *file_name, struct stat *buf)
+__attribute__((unused));
+static int modtest_lstat(const char *file_name, struct stat *buf)
+__attribute__((unused));
+static DIR *modtest_opendir(const char *name) __attribute__((unused));
+static int modtest_system(const char *string) __attribute__((unused));
+static int modtest_rename(const char *oldpath, const char *newpath)
+__attribute__((unused));
+static long modtest_init_module(void *map, unsigned long size,
+                               const char *optstring) __attribute__((unused));
+static long modtest_delete_module(const char *modname, unsigned int flags)
+__attribute__((unused));
+
+static int modtest_readlink(const char *path, char *buf, size_t bufsiz)
+__attribute__((unused));
+
+static int modtest_uname(struct utsname *buf)
+{
+       char *release = NULL;
+
+       strcpy(buf->sysname, "Linux");
+       strcpy(buf->nodename, "fakenodename");
+       if ((release = getenv("MODTEST_UNAME")))
+               strcpy(buf->release, release);
+       else {
+               printf("MODTEST_OVERRIDE_ROOT used but MODTEST_UNAME not set.\n");
+               exit(1);
+       }
+       strcpy(buf->version, "Fakeversion");
+       strcpy(buf->machine, "fakemachine");
+       return 0;
+}
+
+static long modtest_create_module(const char *name, size_t size)
+{
+       if (getenv("MODTEST_DO_CREATE_MODULE"))
+               return 0;
+       errno = ENOSYS;
+       return -1;
+}
+
+static const struct timespec modtest_delay = {
+       .tv_sec = 0,
+       .tv_nsec = 500 * 1000 * 1000
+};
+
+static long modtest_init_module(void *map, unsigned long size,
+                               const char *optstring)
+{
+
+       if (getenv("MODPROBE_WAIT")) {
+               int fd;
+               const char *file = getenv("MODPROBE_WAIT");
+
+               printf("Looping on %s\n", file);
+               fflush(stdout);
+               while ((fd = open(file, O_RDONLY)) < 0)
+                       nanosleep(&modtest_delay, NULL);
+               close(fd);
+               printf("Removing %s\n", file);
+               unlink(file);
+       }
+       if (getenv("MODTEST_DUMP_INIT")) {
+               while (size) {
+                       int ret;
+                       ret = write(2, map, size);
+                       if (ret < 0) exit(1);
+                       size -= ret;
+                       map += ret;
+               }
+       } else          
+               printf("INIT_MODULE: %lu %s\n", size, optstring);
+       
+       return 0;
+}
+
+static long modtest_delete_module(const char *modname, unsigned int flags)
+{
+       char flagnames[100];
+
+       if (getenv("MODPROBE_WAIT")) {
+               int fd;
+               const char *file = getenv("MODPROBE_WAIT");
+
+               printf("Looping on %s\n", file);
+               fflush(stdout);
+               while ((fd = open(file, O_RDONLY)) < 0)
+                       nanosleep(&modtest_delay, NULL);
+               close(fd);
+               printf("Removing %s\n", file);
+               fflush(stdout);
+               unlink(file);
+       }
+       flagnames[0] = '\0';
+       if (flags & O_EXCL)
+               strcat(flagnames, "EXCL ");
+       if (flags & O_TRUNC)
+               strcat(flagnames, "TRUNC ");
+       if (flags & O_NONBLOCK)
+               strcat(flagnames, "NONBLOCK ");
+       if (flags & ~(O_EXCL|O_TRUNC|O_NONBLOCK))
+               strcat(flagnames, "UNKNOWN ");
+
+       printf("DELETE_MODULE: %s %s\n", modname, flagnames);
+       return 0;
+}
+
+/* Add prefix to absolute paths; relative paths are left unchanged */
+static const char *modtest_mapname(const char *path, char *buf, size_t buflen)
+{
+       char *root; 
+
+       if (path[0] != '/')
+               return path;
+
+       root = getenv("MODTEST_OVERRIDE_ROOT");
+       if (!root)
+               return path;
+
+       snprintf(buf, buflen, "%s%s", root, path);
+       return buf;
+}
+
+static void *modtest_fopen(const char *path, const char *mode)
+{
+       char path_buf[PATH_MAX];
+
+       path = modtest_mapname(path, path_buf, sizeof(path_buf));
+       return fopen(path, mode);
+}
+
+static int modtest_open(const char *path, int flags, mode_t mode)
+{
+       char path_buf[PATH_MAX];
+
+       path = modtest_mapname(path, path_buf, sizeof(path_buf));
+       return open(path, flags, mode);
+}
+
+static int modtest_stat(const char *path, struct stat *buf)
+{
+       char path_buf[PATH_MAX];
+
+       path = modtest_mapname(path, path_buf, sizeof(path_buf));
+       return stat(path, buf);
+}
+
+static int modtest_lstat(const char *path, struct stat *buf)
+{
+       char path_buf[PATH_MAX];
+
+       path = modtest_mapname(path, path_buf, sizeof(path_buf));
+       return lstat(path, buf);
+}
+
+static DIR *modtest_opendir(const char *path)
+{
+       char path_buf[PATH_MAX];
+
+       path = modtest_mapname(path, path_buf, sizeof(path_buf));
+       return opendir(path);
+}
+
+static int modtest_system(const char *string)
+{
+       if (getenv("MODTEST_DO_SYSTEM"))
+               return system(string);
+       printf("SYSTEM: %s\n", string);
+       return 0;
+}
+
+static int modtest_rename(const char *oldpath, const char *newpath)
+{
+       char oldpath_buf[PATH_MAX];
+       char newpath_buf[PATH_MAX];
+
+       oldpath = modtest_mapname(oldpath, oldpath_buf, sizeof(oldpath_buf));
+       newpath = modtest_mapname(newpath, newpath_buf, sizeof(newpath_buf));
+       return rename(oldpath, newpath);
+}
+
+static int modtest_readlink(const char *path, char *buf, size_t bufsiz)
+{
+       char path_buf[PATH_MAX];
+
+       path = modtest_mapname(path, path_buf, sizeof(path_buf));
+       return readlink(path, buf, bufsiz);
+}
+
+#ifdef CONFIG_USE_ZLIB
+#include <zlib.h>
+static gzFile *modtest_gzopen(const char *path, const char *mode)
+__attribute__((unused));
+
+static gzFile *modtest_gzopen(const char *path, const char *mode)
+{
+       char path_buf[PATH_MAX];
+
+       path = modtest_mapname(path, path_buf, sizeof(path_buf));
+       return gzopen(path, mode);
+}
+#endif
+
+/* create_module call */
+#undef create_module
+#define create_module modtest_create_module
+
+#define uname modtest_uname
+#define delete_module modtest_delete_module
+#define init_module modtest_init_module
+#define open modtest_open
+#define fopen modtest_fopen
+#define stat(name, ptr) modtest_stat(name, ptr)
+#define lstat(name, ptr) modtest_lstat(name, ptr)
+#define opendir modtest_opendir
+#define system modtest_system
+#define rename modtest_rename
+#define readlink modtest_readlink
+#define gzopen modtest_gzopen
+
+#endif /* JUST_TESTING */
+#endif /* _TESTING_H */
+
diff --git a/tests/data/32-be/alias/alias-32.ko b/tests/data/32-be/alias/alias-32.ko
new file mode 100644 (file)
index 0000000..26f0a7f
Binary files /dev/null and b/tests/data/32-be/alias/alias-32.ko differ
diff --git a/tests/data/32-be/complex/complex_a-32.ko b/tests/data/32-be/complex/complex_a-32.ko
new file mode 100644 (file)
index 0000000..ef47ab3
Binary files /dev/null and b/tests/data/32-be/complex/complex_a-32.ko differ
diff --git a/tests/data/32-be/complex/complex_b-32.ko b/tests/data/32-be/complex/complex_b-32.ko
new file mode 100644 (file)
index 0000000..034a9d3
Binary files /dev/null and b/tests/data/32-be/complex/complex_b-32.ko differ
diff --git a/tests/data/32-be/complex/complex_c-32.ko b/tests/data/32-be/complex/complex_c-32.ko
new file mode 100644 (file)
index 0000000..9c25564
Binary files /dev/null and b/tests/data/32-be/complex/complex_c-32.ko differ
diff --git a/tests/data/32-be/complex/complex_d-32.ko b/tests/data/32-be/complex/complex_d-32.ko
new file mode 100644 (file)
index 0000000..05ad08b
Binary files /dev/null and b/tests/data/32-be/complex/complex_d-32.ko differ
diff --git a/tests/data/32-be/complex/complex_e-32.ko b/tests/data/32-be/complex/complex_e-32.ko
new file mode 100644 (file)
index 0000000..12bec14
Binary files /dev/null and b/tests/data/32-be/complex/complex_e-32.ko differ
diff --git a/tests/data/32-be/loop/loop1-32.ko b/tests/data/32-be/loop/loop1-32.ko
new file mode 100644 (file)
index 0000000..e47ab4e
Binary files /dev/null and b/tests/data/32-be/loop/loop1-32.ko differ
diff --git a/tests/data/32-be/loop/loop2-32.ko b/tests/data/32-be/loop/loop2-32.ko
new file mode 100644 (file)
index 0000000..a9b29ca
Binary files /dev/null and b/tests/data/32-be/loop/loop2-32.ko differ
diff --git a/tests/data/32-be/loop/loop_dep-32.ko b/tests/data/32-be/loop/loop_dep-32.ko
new file mode 100644 (file)
index 0000000..3ef61af
Binary files /dev/null and b/tests/data/32-be/loop/loop_dep-32.ko differ
diff --git a/tests/data/32-be/map/ccw_map-32.ko b/tests/data/32-be/map/ccw_map-32.ko
new file mode 100644 (file)
index 0000000..c8809e4
Binary files /dev/null and b/tests/data/32-be/map/ccw_map-32.ko differ
diff --git a/tests/data/32-be/map/ieee1394_map-32.ko b/tests/data/32-be/map/ieee1394_map-32.ko
new file mode 100644 (file)
index 0000000..3f86ffd
Binary files /dev/null and b/tests/data/32-be/map/ieee1394_map-32.ko differ
diff --git a/tests/data/32-be/map/input_map-32.ko b/tests/data/32-be/map/input_map-32.ko
new file mode 100644 (file)
index 0000000..06455e1
Binary files /dev/null and b/tests/data/32-be/map/input_map-32.ko differ
diff --git a/tests/data/32-be/map/input_map_new-32.ko b/tests/data/32-be/map/input_map_new-32.ko
new file mode 100644 (file)
index 0000000..d3c8686
Binary files /dev/null and b/tests/data/32-be/map/input_map_new-32.ko differ
diff --git a/tests/data/32-be/map/of_map-32.ko b/tests/data/32-be/map/of_map-32.ko
new file mode 100644 (file)
index 0000000..6ef83ee
Binary files /dev/null and b/tests/data/32-be/map/of_map-32.ko differ
diff --git a/tests/data/32-be/map/pci_map-32.ko b/tests/data/32-be/map/pci_map-32.ko
new file mode 100644 (file)
index 0000000..cedf0f6
Binary files /dev/null and b/tests/data/32-be/map/pci_map-32.ko differ
diff --git a/tests/data/32-be/map/pnp_map-32.ko b/tests/data/32-be/map/pnp_map-32.ko
new file mode 100644 (file)
index 0000000..8a32965
Binary files /dev/null and b/tests/data/32-be/map/pnp_map-32.ko differ
diff --git a/tests/data/32-be/map/usb_map-32.ko b/tests/data/32-be/map/usb_map-32.ko
new file mode 100644 (file)
index 0000000..95e1181
Binary files /dev/null and b/tests/data/32-be/map/usb_map-32.ko differ
diff --git a/tests/data/32-be/modinfo/modinfo-32.ko b/tests/data/32-be/modinfo/modinfo-32.ko
new file mode 100644 (file)
index 0000000..fc10519
Binary files /dev/null and b/tests/data/32-be/modinfo/modinfo-32.ko differ
diff --git a/tests/data/32-be/normal/export_dep-32.ko b/tests/data/32-be/normal/export_dep-32.ko
new file mode 100644 (file)
index 0000000..9af4079
Binary files /dev/null and b/tests/data/32-be/normal/export_dep-32.ko differ
diff --git a/tests/data/32-be/normal/export_nodep-32.ko b/tests/data/32-be/normal/export_nodep-32.ko
new file mode 100644 (file)
index 0000000..de24b0e
Binary files /dev/null and b/tests/data/32-be/normal/export_nodep-32.ko differ
diff --git a/tests/data/32-be/normal/noexport_dep-32.ko b/tests/data/32-be/normal/noexport_dep-32.ko
new file mode 100644 (file)
index 0000000..e2f0d5f
Binary files /dev/null and b/tests/data/32-be/normal/noexport_dep-32.ko differ
diff --git a/tests/data/32-be/normal/noexport_doubledep-32.ko b/tests/data/32-be/normal/noexport_doubledep-32.ko
new file mode 100644 (file)
index 0000000..a6076cc
Binary files /dev/null and b/tests/data/32-be/normal/noexport_doubledep-32.ko differ
diff --git a/tests/data/32-be/normal/noexport_nodep-32.ko b/tests/data/32-be/normal/noexport_nodep-32.ko
new file mode 100644 (file)
index 0000000..6a98e4e
Binary files /dev/null and b/tests/data/32-be/normal/noexport_nodep-32.ko differ
diff --git a/tests/data/32-be/rename/rename-new-32.ko b/tests/data/32-be/rename/rename-new-32.ko
new file mode 100644 (file)
index 0000000..ebdc82e
Binary files /dev/null and b/tests/data/32-be/rename/rename-new-32.ko differ
diff --git a/tests/data/32-be/rename/rename-old-32.ko b/tests/data/32-be/rename/rename-old-32.ko
new file mode 100644 (file)
index 0000000..4cc1093
Binary files /dev/null and b/tests/data/32-be/rename/rename-old-32.ko differ
diff --git a/tests/data/32-be/rename/rename-version-32.ko b/tests/data/32-be/rename/rename-version-32.ko
new file mode 100644 (file)
index 0000000..3e47731
Binary files /dev/null and b/tests/data/32-be/rename/rename-version-32.ko differ
diff --git a/tests/data/32-be/unknown/unknown-32.ko b/tests/data/32-be/unknown/unknown-32.ko
new file mode 100644 (file)
index 0000000..76d2025
Binary files /dev/null and b/tests/data/32-be/unknown/unknown-32.ko differ
diff --git a/tests/data/32-le/alias/alias-32.ko b/tests/data/32-le/alias/alias-32.ko
new file mode 100644 (file)
index 0000000..58efdf3
Binary files /dev/null and b/tests/data/32-le/alias/alias-32.ko differ
diff --git a/tests/data/32-le/complex/complex_a-32.ko b/tests/data/32-le/complex/complex_a-32.ko
new file mode 100644 (file)
index 0000000..89de851
Binary files /dev/null and b/tests/data/32-le/complex/complex_a-32.ko differ
diff --git a/tests/data/32-le/complex/complex_b-32.ko b/tests/data/32-le/complex/complex_b-32.ko
new file mode 100644 (file)
index 0000000..bdb997b
Binary files /dev/null and b/tests/data/32-le/complex/complex_b-32.ko differ
diff --git a/tests/data/32-le/complex/complex_c-32.ko b/tests/data/32-le/complex/complex_c-32.ko
new file mode 100644 (file)
index 0000000..680b3fb
Binary files /dev/null and b/tests/data/32-le/complex/complex_c-32.ko differ
diff --git a/tests/data/32-le/complex/complex_d-32.ko b/tests/data/32-le/complex/complex_d-32.ko
new file mode 100644 (file)
index 0000000..103d470
Binary files /dev/null and b/tests/data/32-le/complex/complex_d-32.ko differ
diff --git a/tests/data/32-le/complex/complex_e-32.ko b/tests/data/32-le/complex/complex_e-32.ko
new file mode 100644 (file)
index 0000000..1346158
Binary files /dev/null and b/tests/data/32-le/complex/complex_e-32.ko differ
diff --git a/tests/data/32-le/loop/loop1-32.ko b/tests/data/32-le/loop/loop1-32.ko
new file mode 100644 (file)
index 0000000..d18f112
Binary files /dev/null and b/tests/data/32-le/loop/loop1-32.ko differ
diff --git a/tests/data/32-le/loop/loop2-32.ko b/tests/data/32-le/loop/loop2-32.ko
new file mode 100644 (file)
index 0000000..0ab863d
Binary files /dev/null and b/tests/data/32-le/loop/loop2-32.ko differ
diff --git a/tests/data/32-le/loop/loop_dep-32.ko b/tests/data/32-le/loop/loop_dep-32.ko
new file mode 100644 (file)
index 0000000..d6f71e2
Binary files /dev/null and b/tests/data/32-le/loop/loop_dep-32.ko differ
diff --git a/tests/data/32-le/map/ccw_map-32.ko b/tests/data/32-le/map/ccw_map-32.ko
new file mode 100644 (file)
index 0000000..bfed69a
Binary files /dev/null and b/tests/data/32-le/map/ccw_map-32.ko differ
diff --git a/tests/data/32-le/map/ieee1394_map-32.ko b/tests/data/32-le/map/ieee1394_map-32.ko
new file mode 100644 (file)
index 0000000..65d8455
Binary files /dev/null and b/tests/data/32-le/map/ieee1394_map-32.ko differ
diff --git a/tests/data/32-le/map/input_map-32.ko b/tests/data/32-le/map/input_map-32.ko
new file mode 100644 (file)
index 0000000..ddc8356
Binary files /dev/null and b/tests/data/32-le/map/input_map-32.ko differ
diff --git a/tests/data/32-le/map/input_map_new-32.ko b/tests/data/32-le/map/input_map_new-32.ko
new file mode 100644 (file)
index 0000000..05406b3
Binary files /dev/null and b/tests/data/32-le/map/input_map_new-32.ko differ
diff --git a/tests/data/32-le/map/of_map-32.ko b/tests/data/32-le/map/of_map-32.ko
new file mode 100644 (file)
index 0000000..697aa7c
Binary files /dev/null and b/tests/data/32-le/map/of_map-32.ko differ
diff --git a/tests/data/32-le/map/pci_map-32.ko b/tests/data/32-le/map/pci_map-32.ko
new file mode 100644 (file)
index 0000000..33e8331
Binary files /dev/null and b/tests/data/32-le/map/pci_map-32.ko differ
diff --git a/tests/data/32-le/map/pnp_map-32.ko b/tests/data/32-le/map/pnp_map-32.ko
new file mode 100644 (file)
index 0000000..8e56148
Binary files /dev/null and b/tests/data/32-le/map/pnp_map-32.ko differ
diff --git a/tests/data/32-le/map/usb_map-32.ko b/tests/data/32-le/map/usb_map-32.ko
new file mode 100644 (file)
index 0000000..85eb85e
Binary files /dev/null and b/tests/data/32-le/map/usb_map-32.ko differ
diff --git a/tests/data/32-le/modinfo/modinfo-32.ko b/tests/data/32-le/modinfo/modinfo-32.ko
new file mode 100644 (file)
index 0000000..87c4f1f
Binary files /dev/null and b/tests/data/32-le/modinfo/modinfo-32.ko differ
diff --git a/tests/data/32-le/normal/export_dep-32.ko b/tests/data/32-le/normal/export_dep-32.ko
new file mode 100644 (file)
index 0000000..f4fd81f
Binary files /dev/null and b/tests/data/32-le/normal/export_dep-32.ko differ
diff --git a/tests/data/32-le/normal/export_nodep-32.ko b/tests/data/32-le/normal/export_nodep-32.ko
new file mode 100644 (file)
index 0000000..9c5f8c2
Binary files /dev/null and b/tests/data/32-le/normal/export_nodep-32.ko differ
diff --git a/tests/data/32-le/normal/noexport_dep-32.ko b/tests/data/32-le/normal/noexport_dep-32.ko
new file mode 100644 (file)
index 0000000..399666c
Binary files /dev/null and b/tests/data/32-le/normal/noexport_dep-32.ko differ
diff --git a/tests/data/32-le/normal/noexport_doubledep-32.ko b/tests/data/32-le/normal/noexport_doubledep-32.ko
new file mode 100644 (file)
index 0000000..0c8dad0
Binary files /dev/null and b/tests/data/32-le/normal/noexport_doubledep-32.ko differ
diff --git a/tests/data/32-le/normal/noexport_nodep-32.ko b/tests/data/32-le/normal/noexport_nodep-32.ko
new file mode 100644 (file)
index 0000000..054aea3
Binary files /dev/null and b/tests/data/32-le/normal/noexport_nodep-32.ko differ
diff --git a/tests/data/32-le/rename/rename-new-32.ko b/tests/data/32-le/rename/rename-new-32.ko
new file mode 100644 (file)
index 0000000..2e6ca3e
Binary files /dev/null and b/tests/data/32-le/rename/rename-new-32.ko differ
diff --git a/tests/data/32-le/rename/rename-old-32.ko b/tests/data/32-le/rename/rename-old-32.ko
new file mode 100644 (file)
index 0000000..71e720d
Binary files /dev/null and b/tests/data/32-le/rename/rename-old-32.ko differ
diff --git a/tests/data/32-le/rename/rename-version-32.ko b/tests/data/32-le/rename/rename-version-32.ko
new file mode 100644 (file)
index 0000000..5e1f7d5
Binary files /dev/null and b/tests/data/32-le/rename/rename-version-32.ko differ
diff --git a/tests/data/32-le/unknown/unknown-32.ko b/tests/data/32-le/unknown/unknown-32.ko
new file mode 100644 (file)
index 0000000..8118c5a
Binary files /dev/null and b/tests/data/32-le/unknown/unknown-32.ko differ
diff --git a/tests/data/64-be/alias/alias-64.ko b/tests/data/64-be/alias/alias-64.ko
new file mode 100644 (file)
index 0000000..0e91d7b
Binary files /dev/null and b/tests/data/64-be/alias/alias-64.ko differ
diff --git a/tests/data/64-be/complex/complex_a-64.ko b/tests/data/64-be/complex/complex_a-64.ko
new file mode 100644 (file)
index 0000000..7193226
Binary files /dev/null and b/tests/data/64-be/complex/complex_a-64.ko differ
diff --git a/tests/data/64-be/complex/complex_b-64.ko b/tests/data/64-be/complex/complex_b-64.ko
new file mode 100644 (file)
index 0000000..ffd9661
Binary files /dev/null and b/tests/data/64-be/complex/complex_b-64.ko differ
diff --git a/tests/data/64-be/complex/complex_c-64.ko b/tests/data/64-be/complex/complex_c-64.ko
new file mode 100644 (file)
index 0000000..76043a4
Binary files /dev/null and b/tests/data/64-be/complex/complex_c-64.ko differ
diff --git a/tests/data/64-be/complex/complex_d-64.ko b/tests/data/64-be/complex/complex_d-64.ko
new file mode 100644 (file)
index 0000000..d277ab5
Binary files /dev/null and b/tests/data/64-be/complex/complex_d-64.ko differ
diff --git a/tests/data/64-be/complex/complex_e-64.ko b/tests/data/64-be/complex/complex_e-64.ko
new file mode 100644 (file)
index 0000000..5afbea4
Binary files /dev/null and b/tests/data/64-be/complex/complex_e-64.ko differ
diff --git a/tests/data/64-be/loop/loop1-64.ko b/tests/data/64-be/loop/loop1-64.ko
new file mode 100644 (file)
index 0000000..3316ae6
Binary files /dev/null and b/tests/data/64-be/loop/loop1-64.ko differ
diff --git a/tests/data/64-be/loop/loop2-64.ko b/tests/data/64-be/loop/loop2-64.ko
new file mode 100644 (file)
index 0000000..e6fb6ef
Binary files /dev/null and b/tests/data/64-be/loop/loop2-64.ko differ
diff --git a/tests/data/64-be/loop/loop_dep-64.ko b/tests/data/64-be/loop/loop_dep-64.ko
new file mode 100644 (file)
index 0000000..5470d07
Binary files /dev/null and b/tests/data/64-be/loop/loop_dep-64.ko differ
diff --git a/tests/data/64-be/map/ccw_map-64.ko b/tests/data/64-be/map/ccw_map-64.ko
new file mode 100644 (file)
index 0000000..4329f1e
Binary files /dev/null and b/tests/data/64-be/map/ccw_map-64.ko differ
diff --git a/tests/data/64-be/map/ieee1394_map-64.ko b/tests/data/64-be/map/ieee1394_map-64.ko
new file mode 100644 (file)
index 0000000..8318515
Binary files /dev/null and b/tests/data/64-be/map/ieee1394_map-64.ko differ
diff --git a/tests/data/64-be/map/input_map-64.ko b/tests/data/64-be/map/input_map-64.ko
new file mode 100644 (file)
index 0000000..1a0d28e
Binary files /dev/null and b/tests/data/64-be/map/input_map-64.ko differ
diff --git a/tests/data/64-be/map/input_map_new-64.ko b/tests/data/64-be/map/input_map_new-64.ko
new file mode 100644 (file)
index 0000000..6539967
Binary files /dev/null and b/tests/data/64-be/map/input_map_new-64.ko differ
diff --git a/tests/data/64-be/map/of_map-64.ko b/tests/data/64-be/map/of_map-64.ko
new file mode 100644 (file)
index 0000000..80151f4
Binary files /dev/null and b/tests/data/64-be/map/of_map-64.ko differ
diff --git a/tests/data/64-be/map/pci_map-64.ko b/tests/data/64-be/map/pci_map-64.ko
new file mode 100644 (file)
index 0000000..381db15
Binary files /dev/null and b/tests/data/64-be/map/pci_map-64.ko differ
diff --git a/tests/data/64-be/map/pnp_map-64.ko b/tests/data/64-be/map/pnp_map-64.ko
new file mode 100644 (file)
index 0000000..1853417
Binary files /dev/null and b/tests/data/64-be/map/pnp_map-64.ko differ
diff --git a/tests/data/64-be/map/usb_map-64.ko b/tests/data/64-be/map/usb_map-64.ko
new file mode 100644 (file)
index 0000000..ee79f65
Binary files /dev/null and b/tests/data/64-be/map/usb_map-64.ko differ
diff --git a/tests/data/64-be/modinfo/modinfo-64.ko b/tests/data/64-be/modinfo/modinfo-64.ko
new file mode 100644 (file)
index 0000000..47df892
Binary files /dev/null and b/tests/data/64-be/modinfo/modinfo-64.ko differ
diff --git a/tests/data/64-be/normal/export_dep-64.ko b/tests/data/64-be/normal/export_dep-64.ko
new file mode 100644 (file)
index 0000000..ea804be
Binary files /dev/null and b/tests/data/64-be/normal/export_dep-64.ko differ
diff --git a/tests/data/64-be/normal/export_nodep-64.ko b/tests/data/64-be/normal/export_nodep-64.ko
new file mode 100644 (file)
index 0000000..8b0188f
Binary files /dev/null and b/tests/data/64-be/normal/export_nodep-64.ko differ
diff --git a/tests/data/64-be/normal/noexport_dep-64.ko b/tests/data/64-be/normal/noexport_dep-64.ko
new file mode 100644 (file)
index 0000000..dda931a
Binary files /dev/null and b/tests/data/64-be/normal/noexport_dep-64.ko differ
diff --git a/tests/data/64-be/normal/noexport_doubledep-64.ko b/tests/data/64-be/normal/noexport_doubledep-64.ko
new file mode 100644 (file)
index 0000000..298accd
Binary files /dev/null and b/tests/data/64-be/normal/noexport_doubledep-64.ko differ
diff --git a/tests/data/64-be/normal/noexport_nodep-64.ko b/tests/data/64-be/normal/noexport_nodep-64.ko
new file mode 100644 (file)
index 0000000..26d26ab
Binary files /dev/null and b/tests/data/64-be/normal/noexport_nodep-64.ko differ
diff --git a/tests/data/64-be/rename/rename-new-64.ko b/tests/data/64-be/rename/rename-new-64.ko
new file mode 100644 (file)
index 0000000..1d50dec
Binary files /dev/null and b/tests/data/64-be/rename/rename-new-64.ko differ
diff --git a/tests/data/64-be/rename/rename-old-64.ko b/tests/data/64-be/rename/rename-old-64.ko
new file mode 100644 (file)
index 0000000..8193902
Binary files /dev/null and b/tests/data/64-be/rename/rename-old-64.ko differ
diff --git a/tests/data/64-be/rename/rename-version-64.ko b/tests/data/64-be/rename/rename-version-64.ko
new file mode 100644 (file)
index 0000000..7e374d9
Binary files /dev/null and b/tests/data/64-be/rename/rename-version-64.ko differ
diff --git a/tests/data/64-be/unknown/unknown-64.ko b/tests/data/64-be/unknown/unknown-64.ko
new file mode 100644 (file)
index 0000000..8c7444f
Binary files /dev/null and b/tests/data/64-be/unknown/unknown-64.ko differ
diff --git a/tests/data/64-le/alias/alias-64.ko b/tests/data/64-le/alias/alias-64.ko
new file mode 100644 (file)
index 0000000..46bb055
Binary files /dev/null and b/tests/data/64-le/alias/alias-64.ko differ
diff --git a/tests/data/64-le/complex/complex_a-64.ko b/tests/data/64-le/complex/complex_a-64.ko
new file mode 100644 (file)
index 0000000..d91d4db
Binary files /dev/null and b/tests/data/64-le/complex/complex_a-64.ko differ
diff --git a/tests/data/64-le/complex/complex_b-64.ko b/tests/data/64-le/complex/complex_b-64.ko
new file mode 100644 (file)
index 0000000..bf0185d
Binary files /dev/null and b/tests/data/64-le/complex/complex_b-64.ko differ
diff --git a/tests/data/64-le/complex/complex_c-64.ko b/tests/data/64-le/complex/complex_c-64.ko
new file mode 100644 (file)
index 0000000..5c9e847
Binary files /dev/null and b/tests/data/64-le/complex/complex_c-64.ko differ
diff --git a/tests/data/64-le/complex/complex_d-64.ko b/tests/data/64-le/complex/complex_d-64.ko
new file mode 100644 (file)
index 0000000..5505232
Binary files /dev/null and b/tests/data/64-le/complex/complex_d-64.ko differ
diff --git a/tests/data/64-le/complex/complex_e-64.ko b/tests/data/64-le/complex/complex_e-64.ko
new file mode 100644 (file)
index 0000000..7a8be7e
Binary files /dev/null and b/tests/data/64-le/complex/complex_e-64.ko differ
diff --git a/tests/data/64-le/loop/loop1-64.ko b/tests/data/64-le/loop/loop1-64.ko
new file mode 100644 (file)
index 0000000..0b00a81
Binary files /dev/null and b/tests/data/64-le/loop/loop1-64.ko differ
diff --git a/tests/data/64-le/loop/loop2-64.ko b/tests/data/64-le/loop/loop2-64.ko
new file mode 100644 (file)
index 0000000..de60503
Binary files /dev/null and b/tests/data/64-le/loop/loop2-64.ko differ
diff --git a/tests/data/64-le/loop/loop_dep-64.ko b/tests/data/64-le/loop/loop_dep-64.ko
new file mode 100644 (file)
index 0000000..1079a79
Binary files /dev/null and b/tests/data/64-le/loop/loop_dep-64.ko differ
diff --git a/tests/data/64-le/map/ccw_map-64.ko b/tests/data/64-le/map/ccw_map-64.ko
new file mode 100644 (file)
index 0000000..87dc094
Binary files /dev/null and b/tests/data/64-le/map/ccw_map-64.ko differ
diff --git a/tests/data/64-le/map/ieee1394_map-64.ko b/tests/data/64-le/map/ieee1394_map-64.ko
new file mode 100644 (file)
index 0000000..e1722e1
Binary files /dev/null and b/tests/data/64-le/map/ieee1394_map-64.ko differ
diff --git a/tests/data/64-le/map/input_map-64.ko b/tests/data/64-le/map/input_map-64.ko
new file mode 100644 (file)
index 0000000..6961f8f
Binary files /dev/null and b/tests/data/64-le/map/input_map-64.ko differ
diff --git a/tests/data/64-le/map/input_map_new-64.ko b/tests/data/64-le/map/input_map_new-64.ko
new file mode 100644 (file)
index 0000000..5bd75e6
Binary files /dev/null and b/tests/data/64-le/map/input_map_new-64.ko differ
diff --git a/tests/data/64-le/map/of_map-64.ko b/tests/data/64-le/map/of_map-64.ko
new file mode 100644 (file)
index 0000000..4bbcbff
Binary files /dev/null and b/tests/data/64-le/map/of_map-64.ko differ
diff --git a/tests/data/64-le/map/pci_map-64.ko b/tests/data/64-le/map/pci_map-64.ko
new file mode 100644 (file)
index 0000000..e0c1083
Binary files /dev/null and b/tests/data/64-le/map/pci_map-64.ko differ
diff --git a/tests/data/64-le/map/pnp_map-64.ko b/tests/data/64-le/map/pnp_map-64.ko
new file mode 100644 (file)
index 0000000..7873916
Binary files /dev/null and b/tests/data/64-le/map/pnp_map-64.ko differ
diff --git a/tests/data/64-le/map/usb_map-64.ko b/tests/data/64-le/map/usb_map-64.ko
new file mode 100644 (file)
index 0000000..f7d5344
Binary files /dev/null and b/tests/data/64-le/map/usb_map-64.ko differ
diff --git a/tests/data/64-le/modinfo/modinfo-64.ko b/tests/data/64-le/modinfo/modinfo-64.ko
new file mode 100644 (file)
index 0000000..6b2cf3f
Binary files /dev/null and b/tests/data/64-le/modinfo/modinfo-64.ko differ
diff --git a/tests/data/64-le/normal/export_dep-64.ko b/tests/data/64-le/normal/export_dep-64.ko
new file mode 100644 (file)
index 0000000..9c77678
Binary files /dev/null and b/tests/data/64-le/normal/export_dep-64.ko differ
diff --git a/tests/data/64-le/normal/export_nodep-64.ko b/tests/data/64-le/normal/export_nodep-64.ko
new file mode 100644 (file)
index 0000000..fcc0e36
Binary files /dev/null and b/tests/data/64-le/normal/export_nodep-64.ko differ
diff --git a/tests/data/64-le/normal/noexport_dep-64.ko b/tests/data/64-le/normal/noexport_dep-64.ko
new file mode 100644 (file)
index 0000000..276d915
Binary files /dev/null and b/tests/data/64-le/normal/noexport_dep-64.ko differ
diff --git a/tests/data/64-le/normal/noexport_doubledep-64.ko b/tests/data/64-le/normal/noexport_doubledep-64.ko
new file mode 100644 (file)
index 0000000..b855db6
Binary files /dev/null and b/tests/data/64-le/normal/noexport_doubledep-64.ko differ
diff --git a/tests/data/64-le/normal/noexport_nodep-64.ko b/tests/data/64-le/normal/noexport_nodep-64.ko
new file mode 100644 (file)
index 0000000..0834844
Binary files /dev/null and b/tests/data/64-le/normal/noexport_nodep-64.ko differ
diff --git a/tests/data/64-le/rename/rename-new-64.ko b/tests/data/64-le/rename/rename-new-64.ko
new file mode 100644 (file)
index 0000000..c95fdb4
Binary files /dev/null and b/tests/data/64-le/rename/rename-new-64.ko differ
diff --git a/tests/data/64-le/rename/rename-old-64.ko b/tests/data/64-le/rename/rename-old-64.ko
new file mode 100644 (file)
index 0000000..67b1d91
Binary files /dev/null and b/tests/data/64-le/rename/rename-old-64.ko differ
diff --git a/tests/data/64-le/rename/rename-version-64.ko b/tests/data/64-le/rename/rename-version-64.ko
new file mode 100644 (file)
index 0000000..9e8c853
Binary files /dev/null and b/tests/data/64-le/rename/rename-version-64.ko differ
diff --git a/tests/data/64-le/unknown/unknown-64.ko b/tests/data/64-le/unknown/unknown-64.ko
new file mode 100644 (file)
index 0000000..8b50445
Binary files /dev/null and b/tests/data/64-le/unknown/unknown-64.ko differ
diff --git a/tests/data/Makefile b/tests/data/Makefile
new file mode 100644 (file)
index 0000000..ffa19f6
--- /dev/null
@@ -0,0 +1,75 @@
+# Makefile to rebuild the test modules for a given bits-endianess combination
+USAGE := make BITS=32|64 END=be|le [CC=..] [CFLAGS=...]
+
+CC := gcc
+CFLAGS := -Wall -DBITS_PER_LONG=$(BITS)
+
+targets :=                                                   \
+       alias/alias.ko                                       \
+       complex/complex_a.ko                                 \
+       complex/complex_b.ko                                 \
+       complex/complex_c.ko                                 \
+       complex/complex_d.ko                                 \
+       complex/complex_e.ko                                 \
+       loop/loop1.ko                                        \
+       loop/loop2.ko                                        \
+       loop/loop_dep.ko                                     \
+       map/ccw_map.ko                                       \
+       map/ieee1394_map.ko                                  \
+       map/input_map.ko                                     \
+       map/input_map_new.ko                                 \
+       map/of_map.ko                                        \
+       map/pci_map.ko                                       \
+       map/pnp_map.ko                                       \
+       map/usb_map.ko                                       \
+       modinfo/modinfo.ko                                   \
+       normal/export_dep.ko                                 \
+       normal/export_nodep.ko                               \
+       normal/noexport_dep.ko                               \
+       normal/noexport_doubledep.ko                         \
+       normal/noexport_nodep.ko                             \
+       rename/rename-new.ko                                 \
+       rename/rename-old.ko                                 \
+       rename/rename-version.ko                             \
+       unknown/unknown.ko
+
+all: check_vars build
+
+check_vars:
+       @case "$(BITS)-$(END)" in                            \
+       32-le | 32-be | 64-le | 64-be) ;;                    \
+       *)                                                   \
+               echo "Usage: $(USAGE)" >&2;                  \
+               exit 1;;                                     \
+       esac
+
+build: $(patsubst %.ko, $(BITS)-$(END)/%-$(BITS).ko, $(targets))
+
+%.ko: %.o
+       mv $^ $@
+
+# FIXME - ugly
+$(BITS)-$(END)/map/%-$(BITS).o                               \
+$(BITS)-$(END)/modinfo/%-$(BITS).o                           \
+$(BITS)-$(END)/rename/%-$(BITS).o                            \
+$(BITS)-$(END)/normal/%-$(BITS).o                            \
+$(BITS)-$(END)/unknown/%-$(BITS).o                           \
+$(BITS)-$(END)/complex/%-$(BITS).o                           \
+$(BITS)-$(END)/alias/%-$(BITS).o                             \
+$(BITS)-$(END)/loop/%-$(BITS).o                              \
+$(BITS)-$(END)/normal/%-$(BITS).o                            \
+: src/%.c
+       mkdir -p $(dir $@)
+       $(CC) $(CFLAGS) -o $@ -c $^
+       @case "$(END)" in                                    \
+       le)     end2=LSB;;                                   \
+       be)     end2=MSB;;                                   \
+       esac;                                                \
+       desc=`file -b $@`;                                   \
+       case "$$desc" in                                     \
+       *\ $(BITS)-bit\ $$end2\ *) ;;                        \
+       *) echo "$@ does not look like a $(BITS)-$(END) object:" >&2; \
+          echo "$$desc" >&2 ;                               \
+          exit 1;;                                          \
+       esac
+
diff --git a/tests/data/src/alias.c b/tests/data/src/alias.c
new file mode 100644 (file)
index 0000000..cf297be
--- /dev/null
@@ -0,0 +1,10 @@
+/* Simple module with aliases. */
+/* For userspace: you can also call me... */
+#define ___module_cat(a,b) a ## b
+#define __module_cat(a,b) ___module_cat(a,b)
+#define MODULE_ALIAS(alias)                                    \
+       static const char __module_cat(__alias_,__LINE__)[]     \
+               __attribute__((section(".modalias"))) = alias
+
+MODULE_ALIAS("alias1");
+MODULE_ALIAS("alias2");
diff --git a/tests/data/src/ccw_map.c b/tests/data/src/ccw_map.c
new file mode 100644 (file)
index 0000000..04562eb
--- /dev/null
@@ -0,0 +1,48 @@
+/* Simple file with a CCW map in it. */
+#define __stringify_1(x)       #x
+#define __stringify(x)         __stringify_1(x)
+
+#define MODULE_GENERIC_TABLE(gtype,name)                       \
+static const unsigned long __module_##gtype##_size             \
+  __attribute__ ((unused)) = sizeof(struct gtype##_id);                \
+static const struct gtype##_id * __module_##gtype##_table      \
+  __attribute__ ((unused)) = name;                             \
+extern const struct gtype##_id __mod_##gtype##_table           \
+  __attribute__ ((unused, alias(__stringify(name))))
+
+#define MODULE_DEVICE_TABLE(type,name)         \
+  MODULE_GENERIC_TABLE(type##_device,name)
+
+struct ccw_device_id {
+       unsigned short  match_flags;    /* which fields to match against */
+
+       unsigned short  cu_type;        /* control unit type     */
+       unsigned short  dev_type;       /* device type           */
+       unsigned char   cu_model;       /* control unit model    */
+       unsigned char   dev_model;      /* device model          */
+
+       unsigned long driver_info;
+};
+
+enum match_flag {
+       CCW_DEVICE_ID_MATCH_CU_TYPE      = 0x01,
+       CCW_DEVICE_ID_MATCH_CU_MODEL     = 0x02,
+       CCW_DEVICE_ID_MATCH_DEVICE_TYPE  = 0x04,
+       CCW_DEVICE_ID_MATCH_DEVICE_MODEL = 0x08,
+};
+
+static struct ccw_device_id ccw_ids[] = {
+       { CCW_DEVICE_ID_MATCH_CU_TYPE |
+         CCW_DEVICE_ID_MATCH_CU_MODEL |
+         CCW_DEVICE_ID_MATCH_DEVICE_TYPE |
+         CCW_DEVICE_ID_MATCH_DEVICE_MODEL,
+         1, 2, 3, 4, 0xdeadbeef },
+       { CCW_DEVICE_ID_MATCH_CU_TYPE |
+         CCW_DEVICE_ID_MATCH_CU_MODEL |
+         CCW_DEVICE_ID_MATCH_DEVICE_TYPE |
+         CCW_DEVICE_ID_MATCH_DEVICE_MODEL,
+         11, 12, 13, 14, 0xdeadbee5 },
+       { /* end of list */ }
+};
+
+MODULE_DEVICE_TABLE(ccw, ccw_ids);
diff --git a/tests/data/src/complex_a.c b/tests/data/src/complex_a.c
new file mode 100644 (file)
index 0000000..c23a313
--- /dev/null
@@ -0,0 +1,10 @@
+/* A depends on B, C and D.  B depends on E.  C depends on B and E.  D
+   depends on B. */
+extern int b, c, d;
+
+static void foo(void)
+{
+       b = c = d = 0;
+}
+
+
diff --git a/tests/data/src/complex_b.c b/tests/data/src/complex_b.c
new file mode 100644 (file)
index 0000000..a2691a9
--- /dev/null
@@ -0,0 +1,15 @@
+/* A depends on B, C and D.  B depends on E.  C depends on B and E.  D
+   depends on B. */
+#include "module.h"
+
+int b;
+extern int e;
+
+static void foo(void)
+{
+       b = e = 0;
+}
+
+
+EXPORT_SYMBOL(b);
+
diff --git a/tests/data/src/complex_c.c b/tests/data/src/complex_c.c
new file mode 100644 (file)
index 0000000..abe4bea
--- /dev/null
@@ -0,0 +1,15 @@
+/* A depends on B, C and D.  B depends on E.  C depends on B and E.  D
+   depends on B. */
+#include "module.h"
+
+int c;
+extern int b, e;
+
+static void foo(void)
+{
+       c = b = e = 0;
+}
+
+
+EXPORT_SYMBOL(c);
+
diff --git a/tests/data/src/complex_d.c b/tests/data/src/complex_d.c
new file mode 100644 (file)
index 0000000..decb422
--- /dev/null
@@ -0,0 +1,14 @@
+/* A depends on B, C and D.  B depends on E.  C depends on B and E.  D
+   depends on B. */
+#include "module.h"
+
+int d;
+extern int b;
+
+static void foo(void)
+{
+       d = b;
+}
+
+EXPORT_SYMBOL(d);
+
diff --git a/tests/data/src/complex_e.c b/tests/data/src/complex_e.c
new file mode 100644 (file)
index 0000000..1815c7d
--- /dev/null
@@ -0,0 +1,8 @@
+/* A depends on B, C and D.  B depends on E.  C depends on B and E.  D
+   depends on B. */
+#include "module.h"
+
+int e;
+
+EXPORT_SYMBOL(e);
+
diff --git a/tests/data/src/export_dep.c b/tests/data/src/export_dep.c
new file mode 100644 (file)
index 0000000..ef32589
--- /dev/null
@@ -0,0 +1,12 @@
+/* A module exporting a symbol, and requiring a symbol */
+#include "module.h"
+
+extern int exported1;
+int exported3;
+
+EXPORT_SYMBOL(exported3);
+
+static void foo(void)
+{
+       exported3 = exported1;
+}
diff --git a/tests/data/src/export_nodep.c b/tests/data/src/export_nodep.c
new file mode 100644 (file)
index 0000000..f4c2cc9
--- /dev/null
@@ -0,0 +1,7 @@
+/* A module exporting two symbols, and requiring none. */
+#include "module.h"
+
+int exported1, exported2;
+
+EXPORT_SYMBOL(exported1);
+EXPORT_SYMBOL(exported2);
diff --git a/tests/data/src/ieee1394_map.c b/tests/data/src/ieee1394_map.c
new file mode 100644 (file)
index 0000000..72ee47e
--- /dev/null
@@ -0,0 +1,51 @@
+/* Simple file with a ieee1394 map in it. */
+#define __stringify_1(x)       #x
+#define __stringify(x)         __stringify_1(x)
+
+#define MODULE_GENERIC_TABLE(gtype,name)                       \
+static const unsigned long __module_##gtype##_size             \
+  __attribute__ ((unused)) = sizeof(struct gtype##_id);                \
+static const struct gtype##_id * __module_##gtype##_table      \
+  __attribute__ ((unused)) = name;                             \
+extern const struct gtype##_id __mod_##gtype##_table           \
+  __attribute__ ((unused, alias(__stringify(name))))
+
+#define MODULE_DEVICE_TABLE(type,name)         \
+  MODULE_GENERIC_TABLE(type##_device,name)
+
+struct ieee1394_device_id {
+       unsigned int match_flags;
+       unsigned int vendor_id;
+       unsigned int model_id;
+       unsigned int specifier_id;
+       unsigned int version;
+       void *driverptr;
+};
+
+#define IEEE1394_MATCH_VENDOR_ID       0x0001
+#define IEEE1394_MATCH_MODEL_ID                0x0002
+#define IEEE1394_MATCH_SPECIFIER_ID    0x0004
+#define IEEE1394_MATCH_VERSION         0x0008
+
+/*
+ * Unit spec id and sw version entry for some protocols
+ */
+#define AVC_UNIT_SPEC_ID_ENTRY                                 0x0000A02D
+#define AVC_SW_VERSION_ENTRY                                   0x00010001
+#define CAMERA_UNIT_SPEC_ID_ENTRY                              0x0000A02D
+#define CAMERA_SW_VERSION_ENTRY                                        0x00000100
+
+static struct ieee1394_device_id ieee1394_ids[] 
+= { {
+       .match_flags    = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
+       .specifier_id   = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff,
+       .version        = AVC_SW_VERSION_ENTRY & 0xffffff
+}, {
+       .match_flags    = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
+       .specifier_id   = CAMERA_UNIT_SPEC_ID_ENTRY & 0xffffff,
+       .version        = CAMERA_SW_VERSION_ENTRY & 0xffffff
+},
+    { }
+};
+
+MODULE_DEVICE_TABLE(ieee1394, ieee1394_ids);
diff --git a/tests/data/src/input_map.c b/tests/data/src/input_map.c
new file mode 100644 (file)
index 0000000..2be8ace
--- /dev/null
@@ -0,0 +1,89 @@
+/* Simple file with an INPUT map in it. */
+#define __stringify_1(x)       #x
+#define __stringify(x)         __stringify_1(x)
+
+#define MODULE_GENERIC_TABLE(gtype,name)                       \
+static const unsigned long __module_##gtype##_size             \
+  __attribute__ ((unused)) = sizeof(struct gtype##_id);                \
+static const struct gtype##_id * __module_##gtype##_table      \
+  __attribute__ ((unused)) = name;                             \
+extern const struct gtype##_id __mod_##gtype##_table           \
+  __attribute__ ((unused, alias(__stringify(name))))
+
+#define MODULE_DEVICE_TABLE(type,name)         \
+  MODULE_GENERIC_TABLE(type##_device,name)
+
+#define INPUT_DEVICE_ID_MATCH_VENDOR   2
+#define INPUT_DEVICE_ID_MATCH_PRODUCT  4
+#define INPUT_DEVICE_ID_MATCH_VERSION  8
+
+#define INPUT_DEVICE_ID_MATCH_EVBIT    0x010
+#define INPUT_DEVICE_ID_MATCH_KEYBIT   0x020
+#define INPUT_DEVICE_ID_MATCH_RELBIT   0x040
+#define INPUT_DEVICE_ID_MATCH_ABSBIT   0x080
+#define INPUT_DEVICE_ID_MATCH_MSCIT    0x100
+#define INPUT_DEVICE_ID_MATCH_LEDBIT   0x200
+#define INPUT_DEVICE_ID_MATCH_SNDBIT   0x400
+#define INPUT_DEVICE_ID_MATCH_FFBIT    0x800
+
+#define INPUT_DEVICE_ID_MATCH_DEVICE\
+       (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT)
+#define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION\
+       (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION)
+
+#define EV_MAX                 0x1f
+#define KEY_MAX                        0x1ff
+#define REL_MAX                        0x0f
+#define ABS_MAX                        0x3f
+#define MSC_MAX                        0x07
+#define LED_MAX                        0x0f
+#define REP_MAX                        0x01
+#define SND_MAX                        0x07
+#define FF_MAX                 0x7f
+
+#define BIT(x) (1UL<<((x)%BITS_PER_LONG))
+#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
+
+struct input_id {
+       unsigned short bustype;
+       unsigned short vendor;
+       unsigned short product;
+       unsigned short version;
+};
+
+struct input_device_id {
+
+       unsigned long flags;
+
+       struct input_id id;
+
+       unsigned long evbit[NBITS(EV_MAX)];
+       unsigned long keybit[NBITS(KEY_MAX)];
+       unsigned long relbit[NBITS(REL_MAX)];
+       unsigned long absbit[NBITS(ABS_MAX)];
+       unsigned long mscbit[NBITS(MSC_MAX)];
+       unsigned long ledbit[NBITS(LED_MAX)];
+       unsigned long sndbit[NBITS(SND_MAX)];
+       unsigned long ffbit[NBITS(FF_MAX)];
+
+       unsigned long driver_info;
+};
+
+#define EV_SND                 0x12
+#define EV_KEY                 0x01
+
+static struct input_device_id kbd_ids[] = {
+       {
+                .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
+                .evbit = { BIT(EV_KEY) },
+        },
+       
+       {
+                .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
+                .evbit = { BIT(EV_SND) },
+        },     
+
+       { },    /* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(input, kbd_ids);
diff --git a/tests/data/src/input_map_new.c b/tests/data/src/input_map_new.c
new file mode 100644 (file)
index 0000000..d24599d
--- /dev/null
@@ -0,0 +1,94 @@
+/* Simple file with an INPUT map in it. */
+#define __stringify_1(x)       #x
+#define __stringify(x)         __stringify_1(x)
+
+#define MODULE_GENERIC_TABLE(gtype,name)                       \
+static const unsigned long __module_##gtype##_size             \
+  __attribute__ ((unused)) = sizeof(struct gtype##_id);                \
+static const struct gtype##_id * __module_##gtype##_table      \
+  __attribute__ ((unused)) = name;                             \
+extern const struct gtype##_id __mod_##gtype##_table           \
+  __attribute__ ((unused, alias(__stringify(name))))
+
+#define MODULE_DEVICE_TABLE(type,name)         \
+  MODULE_GENERIC_TABLE(type##_device,name)
+
+#define INPUT_DEVICE_ID_MATCH_VENDOR   2
+#define INPUT_DEVICE_ID_MATCH_PRODUCT  4
+#define INPUT_DEVICE_ID_MATCH_VERSION  8
+
+#define INPUT_DEVICE_ID_MATCH_EVBIT    0x010
+#define INPUT_DEVICE_ID_MATCH_KEYBIT   0x020
+#define INPUT_DEVICE_ID_MATCH_RELBIT   0x040
+#define INPUT_DEVICE_ID_MATCH_ABSBIT   0x080
+#define INPUT_DEVICE_ID_MATCH_MSCIT    0x100
+#define INPUT_DEVICE_ID_MATCH_LEDBIT   0x200
+#define INPUT_DEVICE_ID_MATCH_SNDBIT   0x400
+#define INPUT_DEVICE_ID_MATCH_FFBIT    0x800
+#define INPUT_DEVICE_ID_MATCH_SWBIT    0x1000
+
+#define INPUT_DEVICE_ID_MATCH_DEVICE\
+       (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT)
+#define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION\
+       (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION)
+
+#define EV_MAX                 0x1f
+#define KEY_MAX                        0x1ff
+#define REL_MAX                        0x0f
+#define ABS_MAX                        0x3f
+#define MSC_MAX                        0x07
+#define LED_MAX                        0x0f
+#define REP_MAX                        0x01
+#define SND_MAX                        0x07
+#define FF_MAX                 0x7f
+#define SW_MAX                 0x0f
+
+#define BIT(x) (1UL<<((x)%BITS_PER_LONG))
+#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
+
+struct input_id {
+       unsigned short bustype;
+       unsigned short vendor;
+       unsigned short product;
+       unsigned short version;
+};
+
+struct input_device_id {
+
+       unsigned long flags;
+
+       struct input_id id;
+
+       unsigned long evbit[NBITS(EV_MAX)];
+       unsigned long keybit[NBITS(KEY_MAX)];
+       unsigned long relbit[NBITS(REL_MAX)];
+       unsigned long absbit[NBITS(ABS_MAX)];
+       unsigned long mscbit[NBITS(MSC_MAX)];
+       unsigned long ledbit[NBITS(LED_MAX)];
+       unsigned long sndbit[NBITS(SND_MAX)];
+       unsigned long ffbit[NBITS(FF_MAX)];
+       unsigned long swbit[NBITS(SW_MAX)];
+
+       unsigned long driver_info;
+};
+
+#define EV_SND                 0x12
+#define EV_KEY                 0x01
+#define SW_0                   0
+
+static struct input_device_id kbd_ids[] = {
+       {
+                .flags = INPUT_DEVICE_ID_MATCH_EVBIT|INPUT_DEVICE_ID_MATCH_SWBIT,
+                .evbit = { BIT(EV_KEY) },
+               .swbit = { BIT(SW_0) },
+        },
+       
+       {
+                .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
+                .evbit = { BIT(EV_SND) },
+        },     
+
+       { },    /* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(input, kbd_ids);
diff --git a/tests/data/src/loop1.c b/tests/data/src/loop1.c
new file mode 100644 (file)
index 0000000..902cc01
--- /dev/null
@@ -0,0 +1,13 @@
+/* Part of a simple module loop */
+#include "module.h"
+
+extern int from_loop2;
+
+int from_loop1;
+
+EXPORT_SYMBOL(from_loop1);
+
+static void foo(void)
+{
+       from_loop1 = from_loop2;
+}
diff --git a/tests/data/src/loop2.c b/tests/data/src/loop2.c
new file mode 100644 (file)
index 0000000..0c77972
--- /dev/null
@@ -0,0 +1,13 @@
+/* Part of a simple module loop */
+#include "module.h"
+
+extern int from_loop1;
+
+int from_loop2;
+
+EXPORT_SYMBOL(from_loop2);
+
+static void foo(void)
+{
+       from_loop2 = from_loop1;
+}
diff --git a/tests/data/src/loop_dep.c b/tests/data/src/loop_dep.c
new file mode 100644 (file)
index 0000000..3f32635
--- /dev/null
@@ -0,0 +1,7 @@
+/* Requires a module in the loop */
+extern int from_loop1;
+
+static void foo(void)
+{
+       from_loop1 = 0;
+}
diff --git a/tests/data/src/modinfo.c b/tests/data/src/modinfo.c
new file mode 100644 (file)
index 0000000..dc6eb31
--- /dev/null
@@ -0,0 +1,31 @@
+/* Module with random crap in modinfo */
+#define __stringify_1(x)       #x
+#define __stringify(x)         __stringify_1(x)
+#define ___module_cat(a,b) __mod_ ## a ## b
+#define __module_cat(a,b) ___module_cat(a,b)
+#define MODULE_INFO(tag, info) \
+static const char __module_cat(tag,__LINE__)[] \
+       __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
+
+#define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
+#define MODULE_LICENSE(_license) MODULE_INFO(license, _license)
+#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
+#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
+#define MODULE_PARM_DESC(_parm, desc) MODULE_INFO(parm, #_parm ":" desc)
+
+MODULE_INFO(randomcrap, "my random crap which I use to test stuff with");
+MODULE_INFO(vermagic, "my magic");
+MODULE_AUTHOR("AUTHOR");
+MODULE_DESCRIPTION("DESCRIPTION");
+MODULE_ALIAS("ALIAS1");
+MODULE_ALIAS("ALIAS2");
+
+/* Parameter description, no param type (before 2.6.11) */
+MODULE_PARM_DESC(foo, "The number of foos on the card");
+
+/* Parameter, no description. */
+MODULE_INFO(parmtype, "undescribed:int");
+
+/* Parameter, with description */
+MODULE_INFO(parmtype, "described:uint");
+MODULE_PARM_DESC(described, "A well-described parameter");
diff --git a/tests/data/src/module.h b/tests/data/src/module.h
new file mode 100644 (file)
index 0000000..3474df1
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _MODULE_H
+#define _MODULE_H
+
+struct kernel_symbol
+{
+       unsigned long value;
+       const char *name;
+};
+
+#define EXPORT_SYMBOL(sym)                                     \
+       const char __ksymtab_string_##sym[]                     \
+       __attribute__((section("__ksymtab_strings"))) = #sym;   \
+       const struct kernel_symbol __ksymtab_##sym              \
+       __attribute__((section("__ksymtab")))                   \
+       = { (unsigned long)&sym, __ksymtab_string_##sym }
+
+#endif
diff --git a/tests/data/src/noexport_dep.c b/tests/data/src/noexport_dep.c
new file mode 100644 (file)
index 0000000..a8d3598
--- /dev/null
@@ -0,0 +1,7 @@
+/* A module exporting no symbols, and requiring two */
+extern int exported1, exported2;
+
+static void foo(void)
+{
+       exported1 = exported2;
+}
diff --git a/tests/data/src/noexport_doubledep.c b/tests/data/src/noexport_doubledep.c
new file mode 100644 (file)
index 0000000..fd3dcbf
--- /dev/null
@@ -0,0 +1,7 @@
+/* A module which requires symbols from two other sources */
+extern int exported1, exported2, exported3;
+
+static void foo(void)
+{
+       exported1 = exported2 = exported3;
+}
diff --git a/tests/data/src/noexport_nodep.c b/tests/data/src/noexport_nodep.c
new file mode 100644 (file)
index 0000000..9a287dc
--- /dev/null
@@ -0,0 +1 @@
+/* A module exporting no symbols, and requiring none */
diff --git a/tests/data/src/of_map.c b/tests/data/src/of_map.c
new file mode 100644 (file)
index 0000000..16ac10a
--- /dev/null
@@ -0,0 +1,52 @@
+/* Simple file with a PCI map in it. */
+#define __stringify_1(x)       #x
+#define __stringify(x)         __stringify_1(x)
+
+#define MODULE_GENERIC_TABLE(gtype,name)                       \
+static const unsigned long __module_##gtype##_size             \
+  __attribute__ ((unused)) = sizeof(struct gtype##_id);                \
+static const struct gtype##_id * __module_##gtype##_table      \
+  __attribute__ ((unused)) = name;                             \
+extern const struct gtype##_id __mod_##gtype##_table           \
+  __attribute__ ((unused, alias(__stringify(name))))
+
+#define MODULE_DEVICE_TABLE(type,name)         \
+  MODULE_GENERIC_TABLE(type##_device,name)
+
+struct of_device_id {
+       char name[32];
+       char type[32];
+       char compatible[128];
+       void *data;
+};
+
+static struct of_device_id of_ids[] = {
+       {
+               .name           = "test_name_1",
+       },
+       {
+               .type           = "test_type_1",
+       },
+       {
+               .compatible     = "test_compat_1",
+       },
+       {
+               .name           = "test_name_2",
+               .type           = "test_type_2",
+       },
+       {
+               .name           = "test_name_3",
+               .compatible     = "test_compat_2",
+       },
+       {
+               .type           = "test_type_3",
+               .compatible     = "test_compat_3",
+       },
+       {
+               .name           = "test_name_4",
+               .type           = "test_type_4",
+               .compatible     = "test_compat_4",
+       },
+       {}
+};
+MODULE_DEVICE_TABLE(of, of_ids);
diff --git a/tests/data/src/pci_map.c b/tests/data/src/pci_map.c
new file mode 100644 (file)
index 0000000..898dbcc
--- /dev/null
@@ -0,0 +1,30 @@
+/* Simple file with a PCI map in it. */
+#define __stringify_1(x)       #x
+#define __stringify(x)         __stringify_1(x)
+
+#define MODULE_GENERIC_TABLE(gtype,name)                       \
+static const unsigned long __module_##gtype##_size             \
+  __attribute__ ((unused)) = sizeof(struct gtype##_id);                \
+static const struct gtype##_id * __module_##gtype##_table      \
+  __attribute__ ((unused)) = name;                             \
+extern const struct gtype##_id __mod_##gtype##_table           \
+  __attribute__ ((unused, alias(__stringify(name))))
+
+#define MODULE_DEVICE_TABLE(type,name)         \
+  MODULE_GENERIC_TABLE(type##_device,name)
+
+#define PCI_ANY_ID (~0)
+
+struct pci_device_id {
+       unsigned int vendor, device;            /* Vendor and device ID or PCI_ANY_ID */
+       unsigned int subvendor, subdevice;      /* Subsystem ID's or PCI_ANY_ID */
+       unsigned int class, class_mask;         /* (class,subclass,prog-if) triplet */
+       unsigned long driver_data;              /* Data private to the driver */
+};
+
+static struct pci_device_id pci_ids[] = {
+       { 1, 2, 3, 4, 5, 6, 0xdeadbeef },
+       { 11, 12, 13, 14, 15, 16, 0xdeadbee5 },
+       {0,}    /* 0 terminated list. */
+};
+MODULE_DEVICE_TABLE(pci, pci_ids);
diff --git a/tests/data/src/pnp_map.c b/tests/data/src/pnp_map.c
new file mode 100644 (file)
index 0000000..c0a47b6
--- /dev/null
@@ -0,0 +1,54 @@
+/* Simple file with an ISAPNP map in it. */
+#define __stringify_1(x)       #x
+#define __stringify(x)         __stringify_1(x)
+
+#define MODULE_GENERIC_TABLE(gtype,name)                       \
+static const unsigned long __module_##gtype##_size             \
+  __attribute__ ((unused)) = sizeof(struct gtype##_id);                \
+static const struct gtype##_id * __module_##gtype##_table      \
+  __attribute__ ((unused)) = name;                             \
+extern const struct gtype##_id __mod_##gtype##_table           \
+  __attribute__ ((unused, alias(__stringify(name))))
+
+#define MODULE_DEVICE_TABLE(type,name)         \
+  MODULE_GENERIC_TABLE(type##_device,name)
+
+#define PNP_MAX_DEVICES                8
+#define PNP_ID_LEN             8
+
+struct pnp_device_id {
+       char id[PNP_ID_LEN];
+       unsigned long driver_data;      /* data private to the driver */
+};
+
+struct pnp_card_device_id {
+       char id[PNP_ID_LEN];
+       unsigned long driver_data;      /* data private to the driver */
+       struct {
+               char id[PNP_ID_LEN];
+       } devs[PNP_MAX_DEVICES];        /* logical devices */
+};
+
+static struct pnp_card_device_id snd_ad1816a_pnpids[] = {
+       /* Analog Devices AD1815 */
+       { .id = "ADS7150", .devs = { { .id = "ADS7150" }, { .id = "ADS7151" } } },
+       /* Analog Devices AD1816A - added by Kenneth Platz <kxp@atl.hp.com> */
+       { .id = "ADS7181", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } },
+       /* end */
+       { .id = "" }
+};
+
+MODULE_DEVICE_TABLE(pnp_card, snd_ad1816a_pnpids);
+
+/* All cs4232 based cards have the main ad1848 card either as CSC0000 or
+ * CSC0100. */
+static const struct pnp_device_id cs4232_pnp_table[] = {
+       { .id = "CSC0100", .driver_data = 0 },
+       { .id = "CSC0000", .driver_data = 0 },
+       /* Guillemot Turtlebeach something appears to be cs4232 compatible
+        * (untested) */
+       { .id = "GIM0100", .driver_data = 0 },
+       { .id = ""}
+};
+
+MODULE_DEVICE_TABLE(pnp, cs4232_pnp_table);
diff --git a/tests/data/src/rename-new.c b/tests/data/src/rename-new.c
new file mode 100644 (file)
index 0000000..30f496d
--- /dev/null
@@ -0,0 +1,87 @@
+/* Old-style module with module in __this_module */
+
+#define MODULE_NAME_LEN (64 - sizeof(unsigned long))
+struct kernel_symbol
+{
+       unsigned long value;
+       char name[MODULE_NAME_LEN];
+};
+
+struct list_head {
+       struct list_head *next, *prev;
+};
+
+struct kernel_symbol_group
+{
+       /* Links us into the global symbol list */
+       struct list_head list;
+
+       /* Module which owns it (if any) */
+       struct module *owner;
+
+       unsigned int num_syms;
+       const struct kernel_symbol *syms;
+};
+
+struct exception_table
+{
+       struct list_head list;
+
+       unsigned int num_entries;
+       const struct exception_table_entry *entry;
+};
+
+enum module_state
+{
+       MODULE_STATE_LIVE,
+       MODULE_STATE_COMING,
+       MODULE_STATE_GOING,
+};
+
+struct module
+{
+       enum module_state state;
+
+       /* Member of list of modules */
+       struct list_head list;
+
+       /* Unique handle for this module */
+       char name[MODULE_NAME_LEN];
+
+       /* Exported symbols */
+       struct kernel_symbol_group symbols;
+
+       /* Exception tables */
+       struct exception_table extable;
+
+       /* Startup function. */
+       int (*init)(void);
+
+       /* If this is non-NULL, vfree after init() returns */
+       void *module_init;
+
+       /* Here is the actual code + data, vfree'd on unload. */
+       void *module_core;
+
+       /* Here are the sizes of the init and core sections */
+       unsigned long init_size, core_size;
+
+       /* Arch-specific module values */
+       struct { } arch;
+
+       /* Am I unsafe to unload? */
+       int unsafe;
+
+       /* The command line arguments (may be mangled).  People like
+          keeping pointers to this stuff */
+       char *args;
+};
+
+#define __stringify_1(x)       #x
+#define __stringify(x)         __stringify_1(x)
+
+static struct module __this_module
+__attribute__((section("__module"))) = {
+       .name = "rename_new_" __stringify(BITS_PER_LONG),
+};
+
diff --git a/tests/data/src/rename-old.c b/tests/data/src/rename-old.c
new file mode 100644 (file)
index 0000000..d915dc5
--- /dev/null
@@ -0,0 +1,87 @@
+/* Old-style module with module in .gnu.linkonce.this_module */
+
+#define MODULE_NAME_LEN (64 - sizeof(unsigned long))
+struct kernel_symbol
+{
+       unsigned long value;
+       char name[MODULE_NAME_LEN];
+};
+
+struct list_head {
+       struct list_head *next, *prev;
+};
+
+struct kernel_symbol_group
+{
+       /* Links us into the global symbol list */
+       struct list_head list;
+
+       /* Module which owns it (if any) */
+       struct module *owner;
+
+       unsigned int num_syms;
+       const struct kernel_symbol *syms;
+};
+
+struct exception_table
+{
+       struct list_head list;
+
+       unsigned int num_entries;
+       const struct exception_table_entry *entry;
+};
+
+enum module_state
+{
+       MODULE_STATE_LIVE,
+       MODULE_STATE_COMING,
+       MODULE_STATE_GOING,
+};
+
+struct module
+{
+       enum module_state state;
+
+       /* Member of list of modules */
+       struct list_head list;
+
+       /* Unique handle for this module */
+       char name[MODULE_NAME_LEN];
+
+       /* Exported symbols */
+       struct kernel_symbol_group symbols;
+
+       /* Exception tables */
+       struct exception_table extable;
+
+       /* Startup function. */
+       int (*init)(void);
+
+       /* If this is non-NULL, vfree after init() returns */
+       void *module_init;
+
+       /* Here is the actual code + data, vfree'd on unload. */
+       void *module_core;
+
+       /* Here are the sizes of the init and core sections */
+       unsigned long init_size, core_size;
+
+       /* Arch-specific module values */
+       struct { } arch;
+
+       /* Am I unsafe to unload? */
+       int unsafe;
+
+       /* The command line arguments (may be mangled).  People like
+          keeping pointers to this stuff */
+       char *args;
+};
+
+#define __stringify_1(x)       #x
+#define __stringify(x)         __stringify_1(x)
+
+static struct module __this_module
+__attribute__((section(".gnu.linkonce.this_module"))) = {
+       .name = "rename_old_" __stringify(BITS_PER_LONG),
+};
+
diff --git a/tests/data/src/rename-version.c b/tests/data/src/rename-version.c
new file mode 100644 (file)
index 0000000..b366ab4
--- /dev/null
@@ -0,0 +1,4 @@
+/* Module with version sections in it */
+
+const char vermagic[] __attribute__((section("__vermagic"))) = "my version magic";
+const char modversions[] __attribute__((section("__versions"))) = "my versions";
diff --git a/tests/data/src/unknown.c b/tests/data/src/unknown.c
new file mode 100644 (file)
index 0000000..88f38be
--- /dev/null
@@ -0,0 +1,7 @@
+/* An undefined symbol */
+extern int undefined;
+
+static void foo(void)
+{
+       undefined = 1;
+}
diff --git a/tests/data/src/usb_map.c b/tests/data/src/usb_map.c
new file mode 100644 (file)
index 0000000..0c54714
--- /dev/null
@@ -0,0 +1,51 @@
+/* Simple file with a USB map in it. */
+#define __stringify_1(x)       #x
+#define __stringify(x)         __stringify_1(x)
+
+#define MODULE_GENERIC_TABLE(gtype,name)                       \
+static const unsigned long __module_##gtype##_size             \
+  __attribute__ ((unused)) = sizeof(struct gtype##_id);                \
+static const struct gtype##_id * __module_##gtype##_table      \
+  __attribute__ ((unused)) = name;                             \
+extern const struct gtype##_id __mod_##gtype##_table           \
+  __attribute__ ((unused, alias(__stringify(name))))
+
+#define MODULE_DEVICE_TABLE(type,name)         \
+  MODULE_GENERIC_TABLE(type##_device,name)
+
+#define USB_DEVICE(vend,prod) \
+       .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), .idProduct = (prod)
+
+struct usb_device_id {
+       /* which fields to match against? */
+       unsigned short          match_flags;
+
+       /* Used for product specific matches; range is inclusive */
+       unsigned short          idVendor;
+       unsigned short          idProduct;
+       unsigned short          bcdDevice_lo;
+       unsigned short          bcdDevice_hi;
+
+       /* Used for device class matches */
+       unsigned char           bDeviceClass;
+       unsigned char           bDeviceSubClass;
+       unsigned char           bDeviceProtocol;
+
+       /* Used for interface class matches */
+       unsigned char           bInterfaceClass;
+       unsigned char           bInterfaceSubClass;
+       unsigned char           bInterfaceProtocol;
+
+       /* not matched against */
+       unsigned long   driver_info;
+};
+
+struct usb_device_id usb_ids[] = {
+       {  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+          0xdeadbeef },
+       {  11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+          0xdeadbee5 },
+       { }
+};
+
+MODULE_DEVICE_TABLE(usb, usb_ids);
diff --git a/tests/runtests b/tests/runtests
new file mode 100755 (executable)
index 0000000..e5c8184
--- /dev/null
@@ -0,0 +1,190 @@
+#! /bin/bash
+# Shell script to run test suite.
+
+set -e
+
+usage()
+{
+    echo "Usage: tests/runtests [-v] [-v] [--valgrind] [test]"
+    echo " -v (or --verbose) prints each test as it is run"
+    echo " -vv (very verbose) traces test execution"
+    echo " --valgrind runs the test programs using the valgrind memory checker"
+    echo "The TEST_ENDIAN and TEST_BITS variables can be used to limit which"
+    echo "endianess (le, be) and bitness (32, 64) will be tested"
+    exit
+}
+
+while [ $# != 0 ]; do
+    case "$1" in
+    -v)
+        if [ -z "$VERBOSE" ]; then
+          VERBOSE=1
+        else
+          EXTRA_ARGS=-x
+        fi
+        ;;
+    -vv)
+        VERBOSE=1
+        EXTRA_ARGS=-x
+        ;;
+    --valgrind)
+        VALGRIND=1
+        ;;
+    -h|--help|-*)
+        usage
+        ;;
+    *)
+        [ -n "$TEST" ] && usage
+        TEST="$1"
+        ;;
+    esac
+    shift
+done
+
+# Creates a temporary file and exports the name of the file to
+# the provided argument.  Exits on error.
+# 
+# Usage: create_tempfile TEMPFILE
+#
+create_tempfile()
+{
+    if test $# = 0
+    then
+       echo "No argument passed to create_tempfile()"
+       exit 1
+    fi
+
+    if [ -x /bin/tempfile ]
+    then
+        # Debian 
+        export $1="`tempfile`"
+    elif [ -x  /bin/mktemp ]
+    then
+        # RedHat et. al.
+        export $1="`mktemp /tmp/modtest.XXXXXX`"
+    else
+        echo "Don't know how to make a temporary file on this "
+        echo "system, sorry."
+        exit 1
+    fi
+
+    if [ $? -ne 0 ]
+    then
+        echo "Can't create temporary file."
+        exit 1
+    fi
+}
+export -f create_tempfile
+
+if [ ! -e "tests/build" ]; then
+    echo Making build directory for tests
+    mkdir tests/build
+fi
+if [ ! -e "tests/tmp" ]; then
+    echo Making temporary directory for tests
+    mkdir tests/tmp
+fi
+
+: ${TEST_ENDIAN:=-be -le}
+_tmp=
+for e in $TEST_ENDIAN; do
+       case $e in
+       -be | -le)
+               _tmp="$_tmp $e"
+               ;;
+       be | le)
+               _tmp="$_tmp -$e"
+               ;;
+       *)
+               echo "Unknown endian: $e, valid values are \"be\" and \"le\"" >&2
+               exit 1
+       esac
+done
+TEST_ENDIAN="$_tmp"
+
+: ${TEST_BITS:=32 64}
+for b in $TEST_BITS; do
+       case $b in
+       32 | 64)
+               ;;
+       *)
+               echo "Unknown word size: $b, valid values are 32 and 64" >&2
+               exit 1
+       esac
+done
+
+for config in --enable-zlib --disable-zlib; do
+    echo Building with $config...
+
+    cd tests/build
+    ../../configure $config CFLAGS="-DJUST_TESTING -g -Wall" >/dev/null
+    make clean >/dev/null
+    # ismod.static doesn't build with -DJUST_TESTING and --enable-zlib
+    make insmod.static >/dev/null 2>&1 || touch insmod.static
+    make all >/dev/null
+    cd ../..
+
+    echo Testing with $config...
+    if grep -q CONFIG_USE_ZLIB=1 tests/build/Makefile; then
+       CONFIG_HAVE_ZLIB=1
+       export CONFIG_HAVE_ZLIB
+    else
+       unset CONFIG_HAVE_ZLIB
+    fi
+
+    # Create endianness links
+    case `file tests/build/modprobe` in
+       *MSB*) ENDIAN=be;;
+       *LSB*) ENDIAN=le;;
+       *) echo Unknown endian! >&2; exit 1;;
+    esac
+    ln -sfn 64-$ENDIAN tests/data/64
+    ln -sfn 32-$ENDIAN tests/data/32
+
+    # Make them run the valgrind wrappers if requested.
+    if [ -n "$VALGRIND" ]; then
+       PATH=`pwd`/tests/valgrind:$PATH
+    else
+       PATH=`pwd`/tests/build:$PATH
+    fi
+
+    # By default, we want to look like a new kernel.
+    MODTEST_UNAME=2.6.27
+    export MODTEST_UNAME
+
+    MODTEST_OVERRIDE_ROOT=tests/tmp
+    export MODTEST_OVERRIDE_ROOT
+
+    if [ -n "$TEST" ]; then DOING=0; else DOING=1; fi
+
+    for dir in `find tests/test-* -type d | sort`
+      do
+
+      if [ -z "$VERBOSE" ]; then
+         echo -n Running tests for $dir.
+      else
+         echo Running tests for $dir.
+      fi
+      shopt -s nullglob
+      for f in $dir/[0-9]*.sh; do
+         if [ $DOING -eq 0 ]; then
+             case "$f" in *$TEST*) DOING=1;; *) continue;; esac
+         fi
+
+         rm -rf tests/tmp/*
+         if sh -e $EXTRA_ARGS $f; then
+             if [ -z "$VERBOSE" ]; then
+                 echo -n .
+             else
+                 echo Tests $f succeeded.
+             fi
+         else
+             echo Test for $f failed.
+             exit 1
+         fi
+      done
+      if [ -z "$VERBOSE" ]; then echo; fi
+    done
+done
+
+exit 0
diff --git a/tests/test-depmod/02simple.sh b/tests/test-depmod/02simple.sh
new file mode 100755 (executable)
index 0000000..718e058
--- /dev/null
@@ -0,0 +1,141 @@
+#! /bin/sh
+# Simple tests of generation of 32-bit and 64-bit modules.dep
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Expect no output.
+[ "`depmod 2>&1`" = "" ]
+
+# Check modules.dep results: expect 5 lines
+[ "`grep -vc '^#' < $MODULE_DIR/modules.dep`" = "5" ]
+
+[ "`grep -w export_dep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko" ]
+[ "`grep -w noexport_dep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko" ]
+[ "`grep -w export_nodep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "export_nodep-$BITNESS.ko:" ]
+[ "`grep -w noexport_nodep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "noexport_nodep-$BITNESS.ko:" ]
+[ "`grep -w noexport_doubledep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko" ]
+
+# Check modules.symbols results: expect 3 lines
+[ "`grep -vc '^#' < $MODULE_DIR/modules.symbols`" = "3" ]
+
+[ "`grep -w symbol:exported1 $MODULE_DIR/modules.symbols`" = "alias symbol:exported1 export_nodep_$BITNESS" ]
+[ "`grep -w symbol:exported2 $MODULE_DIR/modules.symbols`" = "alias symbol:exported2 export_nodep_$BITNESS" ]
+[ "`grep -w symbol:exported3 $MODULE_DIR/modules.symbols`" = "alias symbol:exported3 export_dep_$BITNESS" ]
+
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+# Synonyms
+[ "`depmod $MODTEST_UNAME`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -a`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -a $MODTEST_UNAME`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -A $MODTEST_UNAME`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e -A $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --all`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --quick`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e --quick`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e --quick $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --errsyms --quick`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --errsyms --quick $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+# Combined should form stdout versions.
+grep -vh '^#' $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.symbols.old > $MODULE_DIR/modules.all.old
+
+# Stdout versions.
+depmod -n | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -a -n | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -n -a $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -e -n -A $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+done
+done
diff --git a/tests/test-depmod/04maps.sh b/tests/test-depmod/04maps.sh
new file mode 100755 (executable)
index 0000000..8d30f8f
--- /dev/null
@@ -0,0 +1,159 @@
+#! /bin/sh
+# Test of generation of 32-bit and 64-bit maps
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/map/ccw_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/pci_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/usb_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/ieee1394_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/pnp_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/input_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/of_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/input_map_new-$BITNESS.ko \
+   $MODULE_DIR
+
+# Expect no output.
+[ "`depmod`" = "" ]
+
+# Check PCI: expect 2 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.pcimap` = 2 ]
+
+[ "`grep pci_map $MODULE_DIR/modules.pcimap`" = "pci_map-$BITNESS           0x00000001 0x00000002 0x00000003 0x00000004 0x00000005 0x00000006 0x0
+pci_map-$BITNESS           0x0000000b 0x0000000c 0x0000000d 0x0000000e 0x0000000f 0x00000010 0x0" ]
+
+# Check USB: expect 2 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.usbmap` = 2 ]
+
+[ "`grep usb_map $MODULE_DIR/modules.usbmap`" = "usb_map-$BITNESS           0x0001      0x0002   0x0003    0x0004       0x0005       0x06         0x07            0x08            0x09            0x0a               0x0b               0x0
+usb_map-$BITNESS           0x000b      0x000c   0x000d    0x000e       0x000f       0x10         0x11            0x12            0x13            0x14               0x15               0x0" ]
+
+# Check CCW: expect 2 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.ccwmap` = 2 ]
+
+[ "`grep ccw_map $MODULE_DIR/modules.ccwmap`" = "ccw_map-$BITNESS           0x000f      0x0001  0x03      0x0002  0x04
+ccw_map-$BITNESS           0x000f      0x000b  0x0d      0x000c  0x0e" ]
+
+# Check ieee1394: expect 2 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.ieee1394map` = 2 ]
+
+#%-20s 0x%08x  0x%06x  0x%06x 0x%06x     0x%06x\n",
+#+             name, fw->match_flags, fw->vendor_id, fw->model_id,
+#+             fw->specifier_id, fw->version);
+[ "`grep ieee1394_map $MODULE_DIR/modules.ieee1394map`" = "ieee1394_map-$BITNESS      0x0000000c  0x000000  0x000000 0x00a02d     0x010001
+ieee1394_map-$BITNESS      0x0000000c  0x000000  0x000000 0x00a02d     0x000100" ]
+
+# Check pnp: expect 5 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.isapnpmap` = 5 ]
+
+#%-20s  0x%04x     0x%04x     0x00000000  0x%04x     0x%04x    ...
+# For normal table:
+# name, 0xffff, 0xffff, 0x00000000, device, vendor
+# For card table:
+# name, vendor, device, driverinfo, device, vendor, [ device, vendor ]
+[ "`grep pnp_map $MODULE_DIR/modules.isapnpmap`" = "pnp_map-$BITNESS           0xffff     0xffff     0x00000000  0x630e     0x0001    
+pnp_map-$BITNESS           0xffff     0xffff     0x00000000  0x630e     0x0000    
+pnp_map-$BITNESS           0xffff     0xffff     0x00000000  0x2d1d     0x0001    
+pnp_map-$BITNESS           0x9304     0x5071     0x00000000  0x9304     0x5071     0x9304     0x5171    
+pnp_map-$BITNESS           0x9304     0x8171     0x00000000  0x9304     0x8071     0x9304     0x8171    " ]
+
+# Check input: expect 4 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.inputmap` = 4 ]
+
+# module         matchBits bustype vendor product version evBits keyBits relBits absBits mscBits ledBits sndBits ffBits [swBits] driver_info
+[ "`grep input_map $MODULE_DIR/modules.inputmap`" = "input_map-$BITNESS        0x10  0x0  0x0  0x0  0x0  2  0  0  0  0  0  0  0  0x0
+input_map-$BITNESS        0x10  0x0  0x0  0x0  0x0  40000  0  0  0  0  0  0  0  0x0
+input_map_new-$BITNESS    0x1010  0x0  0x0  0x0  0x0  2  0  0  0  0  0  0  0  1  0x0
+input_map_new-$BITNESS    0x10  0x0  0x0  0x0  0x0  40000  0  0  0  0  0  0  0  0  0x0" ] ||
+ [ "`grep input_map $MODULE_DIR/modules.inputmap`" = "input_map_new-$BITNESS    0x1010  0x0  0x0  0x0  0x0  2  0  0  0  0  0  0  0  1  0x0
+input_map_new-$BITNESS    0x10  0x0  0x0  0x0  0x0  40000  0  0  0  0  0  0  0  0  0x0
+input_map-$BITNESS        0x10  0x0  0x0  0x0  0x0  2  0  0  0  0  0  0  0  0x0
+input_map-$BITNESS        0x10  0x0  0x0  0x0  0x0  40000  0  0  0  0  0  0  0  0x0" ]
+
+#
+# Check of: expect 7 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.ofmap` = 7 ]
+
+# of module          name                 type                 compatible
+[ "`grep of_map $MODULE_DIR/modules.ofmap`" = "of_map-$BITNESS            test_name_1          *                    *
+of_map-$BITNESS            *                    test_type_1          *
+of_map-$BITNESS            *                    *                    test_compat_1
+of_map-$BITNESS            test_name_2          test_type_2          *
+of_map-$BITNESS            test_name_3          *                    test_compat_2
+of_map-$BITNESS            *                    test_type_3          test_compat_3
+of_map-$BITNESS            test_name_4          test_type_4          test_compat_4" ]
+
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+mv $MODULE_DIR/modules.pcimap $MODULE_DIR/modules.pcimap.old
+mv $MODULE_DIR/modules.usbmap $MODULE_DIR/modules.usbmap.old
+mv $MODULE_DIR/modules.ccwmap $MODULE_DIR/modules.ccwmap.old
+mv $MODULE_DIR/modules.ieee1394map $MODULE_DIR/modules.ieee1394map.old
+mv $MODULE_DIR/modules.isapnpmap $MODULE_DIR/modules.isapnpmap.old
+mv $MODULE_DIR/modules.inputmap $MODULE_DIR/modules.inputmap.old
+mv $MODULE_DIR/modules.ofmap $MODULE_DIR/modules.ofmap.old
+
+# Synonyms
+[ "`depmod -a`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+diff -u $MODULE_DIR/modules.pcimap.old $MODULE_DIR/modules.pcimap
+diff -u $MODULE_DIR/modules.usbmap.old $MODULE_DIR/modules.usbmap
+diff -u $MODULE_DIR/modules.ccwmap.old $MODULE_DIR/modules.ccwmap
+diff -u $MODULE_DIR/modules.ieee1394map.old $MODULE_DIR/modules.ieee1394map
+diff -u $MODULE_DIR/modules.isapnpmap.old $MODULE_DIR/modules.isapnpmap
+diff -u $MODULE_DIR/modules.inputmap.old $MODULE_DIR/modules.inputmap
+diff -u $MODULE_DIR/modules.ofmap.old $MODULE_DIR/modules.ofmap
+
+[ "`depmod -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+diff -u $MODULE_DIR/modules.pcimap.old $MODULE_DIR/modules.pcimap
+diff -u $MODULE_DIR/modules.usbmap.old $MODULE_DIR/modules.usbmap
+diff -u $MODULE_DIR/modules.ccwmap.old $MODULE_DIR/modules.ccwmap
+diff -u $MODULE_DIR/modules.ieee1394map.old $MODULE_DIR/modules.ieee1394map
+diff -u $MODULE_DIR/modules.isapnpmap.old $MODULE_DIR/modules.isapnpmap
+diff -u $MODULE_DIR/modules.inputmap.old $MODULE_DIR/modules.inputmap
+diff -u $MODULE_DIR/modules.ofmap.old $MODULE_DIR/modules.ofmap
+
+[ "`depmod -e -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+diff -u $MODULE_DIR/modules.pcimap.old $MODULE_DIR/modules.pcimap
+diff -u $MODULE_DIR/modules.usbmap.old $MODULE_DIR/modules.usbmap
+diff -u $MODULE_DIR/modules.ccwmap.old $MODULE_DIR/modules.ccwmap
+diff -u $MODULE_DIR/modules.ieee1394map.old $MODULE_DIR/modules.ieee1394map
+diff -u $MODULE_DIR/modules.isapnpmap.old $MODULE_DIR/modules.isapnpmap
+diff -u $MODULE_DIR/modules.inputmap.old $MODULE_DIR/modules.inputmap
+diff -u $MODULE_DIR/modules.ofmap.old $MODULE_DIR/modules.ofmap
+
+[ "`depmod -e -A $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+diff -u $MODULE_DIR/modules.pcimap.old $MODULE_DIR/modules.pcimap
+diff -u $MODULE_DIR/modules.usbmap.old $MODULE_DIR/modules.usbmap
+diff -u $MODULE_DIR/modules.ccwmap.old $MODULE_DIR/modules.ccwmap
+diff -u $MODULE_DIR/modules.ieee1394map.old $MODULE_DIR/modules.ieee1394map
+diff -u $MODULE_DIR/modules.isapnpmap.old $MODULE_DIR/modules.isapnpmap
+diff -u $MODULE_DIR/modules.inputmap.old $MODULE_DIR/modules.inputmap
+diff -u $MODULE_DIR/modules.ofmap.old $MODULE_DIR/modules.ofmap
+
+# We expect the same from -n.
+grep -hv '^#' $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.pcimap.old $MODULE_DIR/modules.usbmap.old $MODULE_DIR/modules.ccwmap.old $MODULE_DIR/modules.ieee1394map.old $MODULE_DIR/modules.isapnpmap.old $MODULE_DIR/modules.inputmap.old $MODULE_DIR/modules.ofmap.old > tests/tmp/out
+
+# Stdout versions.
+depmod -n | grep -v '^#' > tests/tmp/stdout
+diff -u tests/tmp/out tests/tmp/stdout
+
+depmod -a -n | grep -v '^#' > $MODULE_DIR/modules.dep
+diff -u tests/tmp/out tests/tmp/stdout
+
+depmod -n -a $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.dep
+diff -u tests/tmp/out tests/tmp/stdout
+
+depmod -e -n -A $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.dep
+diff -u tests/tmp/out tests/tmp/stdout
+
+done
+done
diff --git a/tests/test-depmod/05loop.sh b/tests/test-depmod/05loop.sh
new file mode 100755 (executable)
index 0000000..a2c47e3
--- /dev/null
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Loop detection test.
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/loop/loop1-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/loop/loop2-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/loop/loop_dep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Expect no normal output.
+[ "`depmod 2>tests/tmp/stderr`" = "" ]
+
+# Check results: expect 0 lines (all have loops).
+[ `grep -vc '^#' < $MODULE_DIR/modules.dep` = 0 ]
+
+# Now, we should have only one error report, for loop1, and 3
+# warnings.
+[ `grep -vc '^#' < tests/tmp/stderr` = 4 ]
+
+[ "`grep -w /lib/modules/$MODTEST_UNAME/loop1-$BITNESS.ko\ ignored tests/tmp/stderr`" = "WARNING: Module /lib/modules/$MODTEST_UNAME/loop1-$BITNESS.ko ignored, due to loop" ]
+[ "`grep -w /lib/modules/$MODTEST_UNAME/loop2-$BITNESS.ko tests/tmp/stderr`" = "WARNING: Module /lib/modules/$MODTEST_UNAME/loop2-$BITNESS.ko ignored, due to loop" ]
+[ "`grep -w /lib/modules/$MODTEST_UNAME/loop_dep-$BITNESS.ko tests/tmp/stderr`" = "WARNING: Module /lib/modules/$MODTEST_UNAME/loop_dep-$BITNESS.ko ignored, due to loop" ]
+[ "`grep -w detected tests/tmp/stderr`" = "WARNING: Loop detected: /lib/modules/$MODTEST_UNAME/loop1-$BITNESS.ko needs loop2-$BITNESS.ko which needs loop1-$BITNESS.ko again!" ]
+
+done
+done
diff --git a/tests/test-depmod/06undefined.sh b/tests/test-depmod/06undefined.sh
new file mode 100755 (executable)
index 0000000..666358d
--- /dev/null
@@ -0,0 +1,26 @@
+#! /bin/sh
+# Check for undefined symbols.
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/unknown/unknown-$BITNESS.ko \
+   $MODULE_DIR
+
+touch tests/tmp/empty
+
+# Without -e, doesn't matter.
+[ "`depmod -F /empty 2>&1`" = "" ]
+
+# Without -F doesn't matter
+[ "`depmod -e 2>&1`" = "" ]
+
+[ "`depmod -e -F /empty 2>&1`" = "WARNING: /lib/modules/$MODTEST_UNAME/unknown-$BITNESS.ko needs unknown symbol undefined" ]
+
+done
+done
diff --git a/tests/test-depmod/07complex.sh b/tests/test-depmod/07complex.sh
new file mode 100755 (executable)
index 0000000..aee0921
--- /dev/null
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Complex tests of generation of 32-bit and 64-bit modules.dep
+# Direct dependencies:
+#   A: B C D
+#   B: E
+#   C: B E
+#   D: B
+#   E:
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/complex/complex_a-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/complex/complex_b-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/complex/complex_c-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/complex/complex_d-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/complex/complex_e-$BITNESS.ko \
+   $MODULE_DIR
+
+# Expect no output.
+[ "`depmod 2>&1`" = "" ]
+
+# Check results: expect 5 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.dep` = 5 ]
+
+# Could be a: c d b e or A: d c b e.
+[ "`grep -w complex_a-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "complex_a-$BITNESS.ko: complex_c-$BITNESS.ko complex_d-$BITNESS.ko complex_b-$BITNESS.ko complex_e-$BITNESS.ko" ] || [ "`grep -w complex_a-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "complex_a-$BITNESS.ko: complex_d-$BITNESS.ko complex_c-$BITNESS.ko complex_b-$BITNESS.ko complex_e-$BITNESS.ko" ]
+
+[ "`grep -w complex_b-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "complex_b-$BITNESS.ko: complex_e-$BITNESS.ko" ]
+
+[ "`grep -w complex_c-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "complex_c-$BITNESS.ko: complex_b-$BITNESS.ko complex_e-$BITNESS.ko" ]
+
+[ "`grep -w complex_d-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "complex_d-$BITNESS.ko: complex_b-$BITNESS.ko complex_e-$BITNESS.ko" ]
+
+[ "`grep -w complex_e-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "complex_e-$BITNESS.ko:" ]
+
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+# Synonyms
+[ "`depmod -a`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+
+[ "`depmod -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+
+[ "`depmod -e -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+
+[ "`depmod -e -A $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+
+# Combined should form stdout versions.
+grep -vh '^#' $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.symbols.old > $MODULE_DIR/modules.all.old
+
+# Stdout versions.
+depmod -n | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -a -n | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -n -a $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -e -n -A $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+done
+done
diff --git a/tests/test-depmod/08basedir.sh b/tests/test-depmod/08basedir.sh
new file mode 100755 (executable)
index 0000000..b013d3b
--- /dev/null
@@ -0,0 +1,79 @@
+#! /bin/sh
+# Simple tests of generation of 32-bit and 64-bit modules.dep with basedir
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/BASEDIR/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Expect no output.
+[ "`depmod -b /BASEDIR 2>&1`" = "" ]
+
+# Check results: expect 5 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.dep` = 5 ]
+
+[ "`grep -w export_dep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko" ]
+[ "`grep -w noexport_dep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko" ]
+[ "`grep -w export_nodep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "export_nodep-$BITNESS.ko:" ]
+[ "`grep -w noexport_nodep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "noexport_nodep-$BITNESS.ko:" ]
+[ "`grep -w noexport_doubledep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko" ]
+
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+
+# Synonyms
+[ "`depmod -b /BASEDIR  -a`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+
+[ "`depmod -b /BASEDIR -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+
+[ "`depmod -b /BASEDIR -e -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+
+[ "`depmod -b /BASEDIR -e -A $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+
+[ "`depmod --basedir /BASEDIR -e -A $MODTEST_VERSION 2>&1`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+
+[ "`depmod --basedir=/BASEDIR -e -A $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+
+# Combined should form stdout versions.
+grep -vh '^#' $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.symbols > $MODULE_DIR/modules.all.old
+
+# Stdout versions.
+depmod -b /BASEDIR -n | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -b /BASEDIR -a -n | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -b /BASEDIR -n -a $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -b /BASEDIR -e -n -A $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+done
+done
diff --git a/tests/test-depmod/09alias.sh b/tests/test-depmod/09alias.sh
new file mode 100755 (executable)
index 0000000..05741fc
--- /dev/null
@@ -0,0 +1,42 @@
+#! /bin/sh
+
+# Test alias generation.
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/alias/alias-$BITNESS.ko \
+   $MODULE_DIR
+
+# Expect no normal output.
+[ "`depmod 2>&1`" = "" ]
+
+# Check results: expect 2 lines.
+[ `grep -vc '^#' < $MODULE_DIR/modules.alias` = 2 ]
+
+[ "`grep alias1 < $MODULE_DIR/modules.alias`" = "alias alias1 alias_$BITNESS" ]
+[ "`grep alias2 < $MODULE_DIR/modules.alias`" = "alias alias2 alias_$BITNESS" ]
+
+# Version with stuff in .modinfo section.
+
+rm -rf tests/tmp/*
+
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko \
+   $MODULE_DIR
+
+# Expect no normal output.
+[ "`depmod 2>&1`" = "" ]
+
+# Check results: expect 2 lines.
+[ `grep -vc '^#' < $MODULE_DIR/modules.alias` = 2 ]
+
+[ "`grep ALIAS1 < $MODULE_DIR/modules.alias`" = "alias ALIAS1 modinfo_$BITNESS" ]
+[ "`grep ALIAS2 < $MODULE_DIR/modules.alias`" = "alias ALIAS2 modinfo_$BITNESS" ]
+
+done
+done
diff --git a/tests/test-depmod/11quick.sh b/tests/test-depmod/11quick.sh
new file mode 100755 (executable)
index 0000000..8449373
--- /dev/null
@@ -0,0 +1,78 @@
+#! /bin/sh
+# Check that -A works correctly.
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Copy modules instead of linking, so we can play with their timestamps.
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+cp tests/data/$BITNESS$ENDIAN/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+# First time, there is no modules.dep, so it will be generated.
+# Expect no output.
+[ "`depmod -A 2>&1`" = "" ]
+
+# Check modules.dep results: expect 5 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.dep` = 5 ]
+
+[ "`grep -w export_dep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko" ]
+[ "`grep -w noexport_dep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko" ]
+[ "`grep -w export_nodep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "export_nodep-$BITNESS.ko:" ]
+[ "`grep -w noexport_nodep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "noexport_nodep-$BITNESS.ko:" ]
+[ "`grep -w noexport_doubledep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko" ]
+
+# Check modules.symbols results: expect 3 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.symbols` = 3 ]
+
+[ "`grep -w symbol:exported1 $MODULE_DIR/modules.symbols`" = "alias symbol:exported1 export_nodep_$BITNESS" ]
+[ "`grep -w symbol:exported2 $MODULE_DIR/modules.symbols`" = "alias symbol:exported2 export_nodep_$BITNESS" ]
+[ "`grep -w symbol:exported3 $MODULE_DIR/modules.symbols`" = "alias symbol:exported3 export_dep_$BITNESS" ]
+
+cp $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+cp $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+# Now, second run should do nothing.
+cp /dev/null $MODULE_DIR/modules.dep
+cp /dev/null $MODULE_DIR/modules.symbols
+[ "`depmod -A 2>&1`" = "" ]
+diff -u /dev/null $MODULE_DIR/modules.dep
+diff -u /dev/null $MODULE_DIR/modules.symbols
+
+# Touch a directory, nothing.
+sleep 1
+touch $MODULE_DIR
+
+[ "`depmod -A 2>&1`" = "" ]
+diff -u /dev/null $MODULE_DIR/modules.dep
+diff -u /dev/null $MODULE_DIR/modules.symbols
+
+# Touch a non-module, nothing.
+echo "Test" > $MODULE_DIR/README
+[ "`depmod -A 2>&1`" = "" ]
+diff -u /dev/null $MODULE_DIR/modules.dep
+diff -u /dev/null $MODULE_DIR/modules.symbols
+
+# Touch a module, wham.
+touch $MODULE_DIR/noexport_doubledep-$BITNESS.ko
+[ "`depmod -A 2>&1`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols
+
+# Deleting a module does nothing.
+cp /dev/null $MODULE_DIR/modules.dep
+cp /dev/null $MODULE_DIR/modules.symbols
+rm $MODULE_DIR/noexport_doubledep-$BITNESS.ko
+[ "`depmod -A 2>&1`" = "" ]
+diff -u /dev/null $MODULE_DIR/modules.dep
+diff -u /dev/null $MODULE_DIR/modules.symbols
+
+done
+done
diff --git a/tests/test-depmod/12compressed.sh b/tests/test-depmod/12compressed.sh
new file mode 100755 (executable)
index 0000000..696fd73
--- /dev/null
@@ -0,0 +1,145 @@
+#! /bin/sh
+# Check that compressed modules work correctly; based on 02simple.sh
+
+[ -n "$CONFIG_HAVE_ZLIB" ] || exit 0
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Copy modules instead of linking, so we can compress them
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+cp tests/data/$BITNESS$ENDIAN/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+gzip `find $MODULE_DIR -name '*.ko'`
+
+# First time, there is no modules.dep, so it will be generated.
+# Expect no output.
+[ "`depmod -A 2>&1`" = "" ]
+
+# Check modules.dep results: expect 5 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.dep` = 5 ]
+
+[ "`grep -w export_dep-$BITNESS.ko.gz: $MODULE_DIR/modules.dep`" = "export_dep-$BITNESS.ko.gz: export_nodep-$BITNESS.ko.gz" ]
+[ "`grep -w noexport_dep-$BITNESS.ko.gz: $MODULE_DIR/modules.dep`" = "noexport_dep-$BITNESS.ko.gz: export_nodep-$BITNESS.ko.gz" ]
+[ "`grep -w export_nodep-$BITNESS.ko.gz: $MODULE_DIR/modules.dep`" = "export_nodep-$BITNESS.ko.gz:" ]
+[ "`grep -w noexport_nodep-$BITNESS.ko.gz: $MODULE_DIR/modules.dep`" = "noexport_nodep-$BITNESS.ko.gz:" ]
+[ "`grep -w noexport_doubledep-$BITNESS.ko.gz: $MODULE_DIR/modules.dep`" = "noexport_doubledep-$BITNESS.ko.gz: export_dep-$BITNESS.ko.gz export_nodep-$BITNESS.ko.gz" ]
+
+# Check modules.symbols results: expect 3 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.symbols` = 3 ]
+
+[ "`grep -w symbol:exported1 $MODULE_DIR/modules.symbols`" = "alias symbol:exported1 export_nodep_$BITNESS" ]
+[ "`grep -w symbol:exported2 $MODULE_DIR/modules.symbols`" = "alias symbol:exported2 export_nodep_$BITNESS" ]
+[ "`grep -w symbol:exported3 $MODULE_DIR/modules.symbols`" = "alias symbol:exported3 export_dep_$BITNESS" ]
+
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+# Synonyms
+[ "`depmod $MODTEST_UNAME`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -a`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -a $MODTEST_UNAME`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -A $MODTEST_UNAME`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e -A $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --all`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --quick`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e --quick`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e --quick $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --errsyms --quick`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --errsyms --quick $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+# Combined should form stdout versions.
+grep -vh '^#' $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.symbols.old > $MODULE_DIR/modules.all.old
+
+# Stdout versions.
+depmod -n | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -a -n | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -n -a $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -e -n -A $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+done
+done
diff --git a/tests/test-depmod/13compressed-maps.sh b/tests/test-depmod/13compressed-maps.sh
new file mode 100755 (executable)
index 0000000..5f2a077
--- /dev/null
@@ -0,0 +1,154 @@
+#! /bin/sh
+# Test of generation of 32-bit and 64-bit maps, gzipped modules.
+
+[ -n "$CONFIG_HAVE_ZLIB" ] || exit 0
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+mkdir tests/tmp/data
+for f in tests/data/$BITNESS$ENDIAN/map/*.ko; do
+    gzip < $f > tests/tmp/data/`basename $f .ko`.ko.gz
+done
+
+
+rm -rf tests/tmp/*
+
+# Copy modules instead of linking, so we can compress them
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+cp tests/data/$BITNESS$ENDIAN/map/ccw_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/pci_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/usb_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/ieee1394_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/pnp_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/input_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/of_map-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/map/input_map_new-$BITNESS.ko \
+   $MODULE_DIR
+gzip `find $MODULE_DIR -name '*.ko'`
+
+# Expect no output.
+[ "`depmod`" = "" ]
+
+# Check PCI: expect 2 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.pcimap` = 2 ]
+
+[ "`grep pci_map $MODULE_DIR/modules.pcimap`" = "pci_map-$BITNESS           0x00000001 0x00000002 0x00000003 0x00000004 0x00000005 0x00000006 0x0
+pci_map-$BITNESS           0x0000000b 0x0000000c 0x0000000d 0x0000000e 0x0000000f 0x00000010 0x0" ]
+
+# Check USB: expect 2 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.usbmap` = 2 ]
+
+[ "`grep usb_map $MODULE_DIR/modules.usbmap`" = "usb_map-$BITNESS           0x0001      0x0002   0x0003    0x0004       0x0005       0x06         0x07            0x08            0x09            0x0a               0x0b               0x0
+usb_map-$BITNESS           0x000b      0x000c   0x000d    0x000e       0x000f       0x10         0x11            0x12            0x13            0x14               0x15               0x0" ]
+
+# Check CCW: expect 2 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.ccwmap` = 2 ]
+
+[ "`grep ccw_map $MODULE_DIR/modules.ccwmap`" = "ccw_map-$BITNESS           0x000f      0x0001  0x03      0x0002  0x04
+ccw_map-$BITNESS           0x000f      0x000b  0x0d      0x000c  0x0e" ]
+
+# Check ieee1394: expect 2 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.ieee1394map` = 2 ]
+
+#%-20s 0x%08x  0x%06x  0x%06x 0x%06x     0x%06x\n",
+#+             name, fw->match_flags, fw->vendor_id, fw->model_id,
+#+             fw->specifier_id, fw->version);
+[ "`grep ieee1394_map $MODULE_DIR/modules.ieee1394map`" = "ieee1394_map-$BITNESS      0x0000000c  0x000000  0x000000 0x00a02d     0x010001
+ieee1394_map-$BITNESS      0x0000000c  0x000000  0x000000 0x00a02d     0x000100" ]
+
+# Check input: expect 4 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.inputmap` = 4 ]
+
+# module         matchBits bustype vendor product version evBits keyBits relBits absBits mscBits ledBits sndBits ffBits [swBits] driver_info
+[ "`grep input_map $MODULE_DIR/modules.inputmap`" = "input_map_new-$BITNESS    0x1010  0x0  0x0  0x0  0x0  2  0  0  0  0  0  0  0  1  0x0
+input_map_new-$BITNESS    0x10  0x0  0x0  0x0  0x0  40000  0  0  0  0  0  0  0  0  0x0
+input_map-$BITNESS        0x10  0x0  0x0  0x0  0x0  2  0  0  0  0  0  0  0  0x0
+input_map-$BITNESS        0x10  0x0  0x0  0x0  0x0  40000  0  0  0  0  0  0  0  0x0" ] || [ "`grep input_map $MODULE_DIR/modules.inputmap`" = "input_map-$BITNESS        0x10  0x0  0x0  0x0  0x0  2  0  0  0  0  0  0  0  0x0
+input_map-$BITNESS        0x10  0x0  0x0  0x0  0x0  40000  0  0  0  0  0  0  0  0x0
+input_map_new-$BITNESS    0x1010  0x0  0x0  0x0  0x0  2  0  0  0  0  0  0  0  1  0x0
+input_map_new-$BITNESS    0x10  0x0  0x0  0x0  0x0  40000  0  0  0  0  0  0  0  0  0x0" ]
+
+# Check of: expect 7 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.ofmap` = 7 ]
+
+# of module          name                 type                 compatible
+[ "`grep of_map $MODULE_DIR/modules.ofmap`" = "of_map-$BITNESS            test_name_1          *                    *
+of_map-$BITNESS            *                    test_type_1          *
+of_map-$BITNESS            *                    *                    test_compat_1
+of_map-$BITNESS            test_name_2          test_type_2          *
+of_map-$BITNESS            test_name_3          *                    test_compat_2
+of_map-$BITNESS            *                    test_type_3          test_compat_3
+of_map-$BITNESS            test_name_4          test_type_4          test_compat_4" ]
+
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+mv $MODULE_DIR/modules.pcimap $MODULE_DIR/modules.pcimap.old
+mv $MODULE_DIR/modules.usbmap $MODULE_DIR/modules.usbmap.old
+mv $MODULE_DIR/modules.ccwmap $MODULE_DIR/modules.ccwmap.old
+mv $MODULE_DIR/modules.ieee1394map $MODULE_DIR/modules.ieee1394map.old
+mv $MODULE_DIR/modules.isapnpmap $MODULE_DIR/modules.isapnpmap.old
+mv $MODULE_DIR/modules.inputmap $MODULE_DIR/modules.inputmap.old
+mv $MODULE_DIR/modules.ofmap $MODULE_DIR/modules.ofmap.old
+
+# Synonyms
+[ "`depmod -a`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+diff -u $MODULE_DIR/modules.pcimap.old $MODULE_DIR/modules.pcimap
+diff -u $MODULE_DIR/modules.usbmap.old $MODULE_DIR/modules.usbmap
+diff -u $MODULE_DIR/modules.ccwmap.old $MODULE_DIR/modules.ccwmap
+diff -u $MODULE_DIR/modules.ieee1394map.old $MODULE_DIR/modules.ieee1394map
+diff -u $MODULE_DIR/modules.isapnpmap.old $MODULE_DIR/modules.isapnpmap
+diff -u $MODULE_DIR/modules.inputmap.old $MODULE_DIR/modules.inputmap
+diff -u $MODULE_DIR/modules.ofmap.old $MODULE_DIR/modules.ofmap
+
+[ "`depmod -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+diff -u $MODULE_DIR/modules.pcimap.old $MODULE_DIR/modules.pcimap
+diff -u $MODULE_DIR/modules.usbmap.old $MODULE_DIR/modules.usbmap
+diff -u $MODULE_DIR/modules.ccwmap.old $MODULE_DIR/modules.ccwmap
+diff -u $MODULE_DIR/modules.ieee1394map.old $MODULE_DIR/modules.ieee1394map
+diff -u $MODULE_DIR/modules.isapnpmap.old $MODULE_DIR/modules.isapnpmap
+diff -u $MODULE_DIR/modules.inputmap.old $MODULE_DIR/modules.inputmap
+diff -u $MODULE_DIR/modules.ofmap.old $MODULE_DIR/modules.ofmap
+
+[ "`depmod -e -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+diff -u $MODULE_DIR/modules.pcimap.old $MODULE_DIR/modules.pcimap
+diff -u $MODULE_DIR/modules.usbmap.old $MODULE_DIR/modules.usbmap
+diff -u $MODULE_DIR/modules.ccwmap.old $MODULE_DIR/modules.ccwmap
+diff -u $MODULE_DIR/modules.ieee1394map.old $MODULE_DIR/modules.ieee1394map
+diff -u $MODULE_DIR/modules.isapnpmap.old $MODULE_DIR/modules.isapnpmap
+diff -u $MODULE_DIR/modules.inputmap.old $MODULE_DIR/modules.inputmap
+diff -u $MODULE_DIR/modules.ofmap.old $MODULE_DIR/modules.ofmap
+
+[ "`depmod -e -A $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep
+diff -u $MODULE_DIR/modules.pcimap.old $MODULE_DIR/modules.pcimap
+diff -u $MODULE_DIR/modules.usbmap.old $MODULE_DIR/modules.usbmap
+diff -u $MODULE_DIR/modules.ccwmap.old $MODULE_DIR/modules.ccwmap
+diff -u $MODULE_DIR/modules.ieee1394map.old $MODULE_DIR/modules.ieee1394map
+diff -u $MODULE_DIR/modules.isapnpmap.old $MODULE_DIR/modules.isapnpmap
+diff -u $MODULE_DIR/modules.inputmap.old $MODULE_DIR/modules.inputmap
+diff -u $MODULE_DIR/modules.ofmap.old $MODULE_DIR/modules.ofmap
+
+# We expect the same from -n.
+grep -hv '^#' $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.pcimap.old $MODULE_DIR/modules.usbmap.old $MODULE_DIR/modules.ccwmap.old $MODULE_DIR/modules.ieee1394map.old $MODULE_DIR/modules.isapnpmap.old $MODULE_DIR/modules.inputmap.old $MODULE_DIR/modules.ofmap.old > tests/tmp/out
+
+# Stdout versions.
+depmod -n | grep -v '^#' > tests/tmp/stdout
+diff -u tests/tmp/out tests/tmp/stdout
+
+depmod -a -n | grep -v '^#' > $MODULE_DIR/modules.dep
+diff -u tests/tmp/out tests/tmp/stdout
+
+depmod -n -a $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.dep
+diff -u tests/tmp/out tests/tmp/stdout
+
+depmod -e -n -A $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.dep
+diff -u tests/tmp/out tests/tmp/stdout
+
+done
+done
diff --git a/tests/test-depmod/14updates.sh b/tests/test-depmod/14updates.sh
new file mode 100755 (executable)
index 0000000..f42bf77
--- /dev/null
@@ -0,0 +1,155 @@
+#! /bin/sh
+# Simple tests of generation of 32-bit and 64-bit modules.dep
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR/kernel
+ln tests/data/$BITNESS$ENDIAN/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR/kernel
+
+# More inputs
+mkdir -p $MODULE_DIR/updates
+ln tests/data/$BITNESS$ENDIAN/normal/export_nodep-$BITNESS.ko \
+   $MODULE_DIR/updates
+
+# First we try update which overrides, then not
+for iter in override not-override; do
+
+# Expect no output.
+[ "`depmod 2>&1`" = "" ]
+
+# Check modules.dep results: expect 5 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.dep` = 5 ]
+
+# Other lines must refer to updates/, not kernels/ module.
+[ "`grep -w export_dep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "kernel/export_dep-$BITNESS.ko: updates/export_nodep-$BITNESS.ko" ]
+[ "`grep -w noexport_dep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "kernel/noexport_dep-$BITNESS.ko: updates/export_nodep-$BITNESS.ko" ]
+[ "`grep -w noexport_nodep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "kernel/noexport_nodep-$BITNESS.ko:" ]
+[ "`grep -w noexport_doubledep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "kernel/noexport_doubledep-$BITNESS.ko: kernel/export_dep-$BITNESS.ko updates/export_nodep-$BITNESS.ko" ]
+[ "`grep -w export_nodep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "updates/export_nodep-$BITNESS.ko:" ]
+
+# Check modules.symbols results: expect 3 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.symbols` = 3 ]
+
+[ "`grep -w symbol:exported1 $MODULE_DIR/modules.symbols`" = "alias symbol:exported1 export_nodep_$BITNESS" ]
+[ "`grep -w symbol:exported2 $MODULE_DIR/modules.symbols`" = "alias symbol:exported2 export_nodep_$BITNESS" ]
+[ "`grep -w symbol:exported3 $MODULE_DIR/modules.symbols`" = "alias symbol:exported3 export_dep_$BITNESS" ]
+
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+# Synonyms
+[ "`depmod $MODTEST_UNAME`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -a`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -a $MODTEST_UNAME`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -A $MODTEST_UNAME`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e -A $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --all`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --quick`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e --quick`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e --quick $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --errsyms --quick`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --errsyms --quick $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+# Combined should form stdout versions.
+grep -vh '^#' $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.symbols.old > $MODULE_DIR/modules.all.old
+
+# Stdout versions.
+depmod -n | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -a -n | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -n -a $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -e -n -A $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+# For second run, don't override.
+rm -f $MODULE_DIR/kernel/export_nodep-$BITNESS.ko
+rm -f $MODULE_DIR/modules*
+done # override
+
+done # 32/64-bit
+done
diff --git a/tests/test-depmod/15symlink.sh b/tests/test-depmod/15symlink.sh
new file mode 100755 (executable)
index 0000000..968f4fd
--- /dev/null
@@ -0,0 +1,153 @@
+#! /bin/sh
+# Test that we ignore symlinks.
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR/kernel
+ln tests/data/$BITNESS$ENDIAN/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR/kernel
+
+# Should not find this through symlink
+mkdir tests/tmp/nogo
+ln -s ../../../nogo $MODULE_DIR/build
+ln tests/data/$BITNESS$ENDIAN/alias/alias-$BITNESS.ko $MODULE_DIR/nogo
+
+# SHOULD go through updates symlink (SuSE want shared updates)
+mkdir tests/tmp/updates
+ln -s ../../../updates $MODULE_DIR/updates
+ln tests/data/$BITNESS$ENDIAN/rename/rename-new-$BITNESS.ko tests/tmp/updates
+
+# Expect no output.
+[ "`depmod 2>&1`" = "" ]
+
+# Check modules.dep results: expect 6 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.dep` = 6 ]
+
+[ "`grep -w export_dep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "kernel/export_dep-$BITNESS.ko: kernel/export_nodep-$BITNESS.ko" ]
+[ "`grep -w noexport_dep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "kernel/noexport_dep-$BITNESS.ko: kernel/export_nodep-$BITNESS.ko" ]
+[ "`grep -w noexport_nodep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "kernel/noexport_nodep-$BITNESS.ko:" ]
+[ "`grep -w noexport_doubledep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "kernel/noexport_doubledep-$BITNESS.ko: kernel/export_dep-$BITNESS.ko kernel/export_nodep-$BITNESS.ko" ]
+[ "`grep -w export_nodep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "kernel/export_nodep-$BITNESS.ko:" ]
+[ "`grep -w rename-new-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "updates/rename-new-$BITNESS.ko:" ]
+
+# Check modules.symbols results: expect 3 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.symbols` = 3 ]
+
+[ "`grep -w symbol:exported1 $MODULE_DIR/modules.symbols`" = "alias symbol:exported1 export_nodep_$BITNESS" ]
+[ "`grep -w symbol:exported2 $MODULE_DIR/modules.symbols`" = "alias symbol:exported2 export_nodep_$BITNESS" ]
+[ "`grep -w symbol:exported3 $MODULE_DIR/modules.symbols`" = "alias symbol:exported3 export_dep_$BITNESS" ]
+
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+# Synonyms
+[ "`depmod $MODTEST_UNAME`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -a`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -a $MODTEST_UNAME`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -A $MODTEST_UNAME`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e -A`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e -A $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --all`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --quick`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e --quick`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e --quick $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --errsyms --quick`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --errsyms --quick $MODTEST_VERSION`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+# Combined should form stdout versions.
+grep -vh '^#' $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.symbols.old > $MODULE_DIR/modules.all.old
+
+# Stdout versions.
+depmod -n | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -a -n | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -n -a $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -e -n -A $MODTEST_VERSION | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+rm -rf tests/tmp/*
+done # 32/64-bit
+done
diff --git a/tests/test-depmod/16specific-modules.sh b/tests/test-depmod/16specific-modules.sh
new file mode 100755 (executable)
index 0000000..13647ff
--- /dev/null
@@ -0,0 +1,92 @@
+#! /bin/sh
+# Test depmod with specific names on the cmdline (bug report from Andrew Snare)
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+ALL="/lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko /lib/modules/$MODTEST_UNAME/noexport_dep-$BITNESS.ko /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko /lib/modules/$MODTEST_UNAME/noexport_doubledep-$BITNESS.ko"
+
+# Expect no output.
+[ "`depmod $ALL 2>&1`" = "" ]
+
+# Check modules.dep results: expect 5 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.dep` = 5 ]
+
+[ "`grep -w export_dep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko" ]
+[ "`grep -w noexport_dep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko" ]
+[ "`grep -w export_nodep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "export_nodep-$BITNESS.ko:" ]
+[ "`grep -w noexport_nodep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "noexport_nodep-$BITNESS.ko:" ]
+[ "`grep -w noexport_doubledep-$BITNESS.ko: $MODULE_DIR/modules.dep`" = "noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko" ]
+
+# Check modules.symbols results: expect 3 lines
+[ `grep -vc '^#' < $MODULE_DIR/modules.symbols` = 3 ]
+
+[ "`grep -w symbol:exported1 $MODULE_DIR/modules.symbols`" = "alias symbol:exported1 export_nodep_$BITNESS" ]
+[ "`grep -w symbol:exported2 $MODULE_DIR/modules.symbols`" = "alias symbol:exported2 export_nodep_$BITNESS" ]
+[ "`grep -w symbol:exported3 $MODULE_DIR/modules.symbols`" = "alias symbol:exported3 export_dep_$BITNESS" ]
+
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+# Synonyms
+[ "`depmod $MODTEST_UNAME $ALL`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e $ALL`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod -e $MODTEST_VERSION $ALL`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --errsyms $ALL`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+[ "`depmod --errsyms $MODTEST_VERSION $ALL`" = "" ]
+diff -u $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.dep >/dev/null
+mv $MODULE_DIR/modules.dep $MODULE_DIR/modules.dep.old
+diff -u $MODULE_DIR/modules.symbols.old $MODULE_DIR/modules.symbols >/dev/null
+mv $MODULE_DIR/modules.symbols $MODULE_DIR/modules.symbols.old
+
+# Combined should form stdout versions.
+grep -vh '^#' $MODULE_DIR/modules.dep.old $MODULE_DIR/modules.symbols.old > $MODULE_DIR/modules.all.old
+
+# Stdout versions.
+depmod -n $ALL | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -n $MODTEST_VERSION $ALL | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+depmod -e -n $MODTEST_VERSION $ALL | grep -v '^#' > $MODULE_DIR/modules.all
+diff -u $MODULE_DIR/modules.all.old $MODULE_DIR/modules.all >/dev/null
+mv $MODULE_DIR/modules.all $MODULE_DIR/modules.all.old
+
+done
+done
+
diff --git a/tests/test-insmod/02simple.sh b/tests/test-insmod/02simple.sh
new file mode 100755 (executable)
index 0000000..5248513
--- /dev/null
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+# If it doesn't exist, kill it.
+[ "`insmod nonexistent-file 2>&1`" = "insmod: can't read 'nonexistent-file': No such file or directory" ]
+
+# Make sure it passes module correctly.
+SIZE=`wc -c < tests/test-insmod/02simple.sh`
+[ "`insmod tests/test-insmod/02simple.sh`" = "INIT_MODULE: $SIZE " ]
+
+# Check options passed intact.
+[ "`insmod tests/test-insmod/02simple.sh a`" = "INIT_MODULE: $SIZE a " ]
+[ "`insmod tests/test-insmod/02simple.sh a b`" = "INIT_MODULE: $SIZE a b " ]
diff --git a/tests/test-insmod/03options.sh b/tests/test-insmod/03options.sh
new file mode 100755 (executable)
index 0000000..b120564
--- /dev/null
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+SIZE=`wc -c < tests/test-insmod/02simple.sh`
+# Old options are ignored.
+[ "`insmod -p tests/test-insmod/02simple.sh`" = "INIT_MODULE: $SIZE " ]
+[ "`insmod -s tests/test-insmod/02simple.sh`" = "INIT_MODULE: $SIZE " ]
+[ "`insmod -f tests/test-insmod/02simple.sh`" = "INIT_MODULE: $SIZE " ]
+[ "`insmod -p -f -s tests/test-insmod/02simple.sh`" = "INIT_MODULE: $SIZE " ]
+
+# --version and -v
+VERSION=`grep ^VERSION tests/build/Makefile | sed 's/.*=[      ]*//'`
+[ "`insmod -V`" = "module-init-tools version $VERSION" ]
+[ "`insmod --version`" = "module-init-tools version $VERSION" ]
+
+# Don't try to quote or anything: we're not smart enough.
+[ "`insmod tests/test-insmod/02simple.sh 'foo="baz bar"'`" = "INIT_MODULE: $SIZE foo=\"baz bar\" " ]
diff --git a/tests/test-insmod/04stdin.sh b/tests/test-insmod/04stdin.sh
new file mode 100755 (executable)
index 0000000..1891760
--- /dev/null
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+SIZE=`wc -c < tests/test-insmod/02simple.sh`
+[ "`insmod - < tests/test-insmod/02simple.sh`" = "INIT_MODULE: $SIZE " ]
+[ "`insmod -s - < tests/test-insmod/02simple.sh`" = "INIT_MODULE: $SIZE " ]
+[ "`insmod -f - < tests/test-insmod/02simple.sh`" = "INIT_MODULE: $SIZE " ]
+[ "`insmod -p -f -s - < tests/test-insmod/02simple.sh`" = "INIT_MODULE: $SIZE " ]
diff --git a/tests/test-lsmod/01empty.sh b/tests/test-lsmod/01empty.sh
new file mode 100755 (executable)
index 0000000..fbfb4e9
--- /dev/null
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+mkdir -p tests/tmp/proc
+touch tests/tmp/proc/modules
+
+# This should be true
+[ "`lsmod`" = "Module                  Size  Used by" ]
diff --git a/tests/test-lsmod/03oldstyle.sh b/tests/test-lsmod/03oldstyle.sh
new file mode 100755 (executable)
index 0000000..b07e874
--- /dev/null
@@ -0,0 +1,29 @@
+#! /bin/sh
+
+mkdir -p tests/tmp/proc
+
+# Old style has dependencies like: "name size usecount [dep] [dep]..."
+echo 'foo 100 0' > tests/tmp/proc/modules
+echo 'bar 101 1' >> tests/tmp/proc/modules
+echo 'baz 102 1 baz_dep' >> tests/tmp/proc/modules
+echo 'bazz 2147483648 2147483648 bazz_dep bazz_dep2' >> tests/tmp/proc/modules
+echo 'fuzz 104 1 fuzz_dep [permenant]' >> tests/tmp/proc/modules
+echo 'fuzzy 105 1 fuzzy_dep [permenant] [unsafe]' >> tests/tmp/proc/modules
+echo 'fuzzier 106 0 [permenant] [unsafe]' >> tests/tmp/proc/modules
+
+[ "`lsmod`" = "Module                  Size  Used by
+foo                      100  0 
+bar                      101  1 
+baz                      102  1 baz_dep
+bazz                2147483648  2147483648 bazz_dep bazz_dep2
+fuzz                     104  1 fuzz_dep [permenant]
+fuzzy                    105  1 fuzzy_dep [permenant] [unsafe]
+fuzzier                  106  0 [permenant] [unsafe]" ]
+
+# If CONFIG_MODULE_UNLOAD=n: simply "name size"
+echo 'baz 102' > tests/tmp/proc/modules
+echo 'bazz 2147483648' >> tests/tmp/proc/modules
+
+[ "`lsmod`" = "Module                  Size  Used by
+baz                      102
+bazz                2147483648" ]
diff --git a/tests/test-lsmod/04newstyle.sh b/tests/test-lsmod/04newstyle.sh
new file mode 100755 (executable)
index 0000000..a39878f
--- /dev/null
@@ -0,0 +1,26 @@
+#! /bin/sh
+
+mkdir -p tests/tmp/proc
+
+# new style has dependencies like: "name size usecount [dep],[dep] [other]"
+echo 'foo 100 0 -' > tests/tmp/proc/modules
+echo 'bar 101 1 -' >> tests/tmp/proc/modules
+echo 'baz 102 1 baz_dep,' >> tests/tmp/proc/modules
+echo 'bazz 2147483648 2147483648 bazz_dep,bazz_dep2,' >> tests/tmp/proc/modules
+echo 'fuzz 104 1 fuzz_dep,[permenant],' >> tests/tmp/proc/modules
+echo 'fuzzy 105 1 fuzzy_dep,[permenant],[unsafe],' >> tests/tmp/proc/modules
+echo 'fuzzier 106 0 [permenant],[unsafe],' >> tests/tmp/proc/modules
+echo 'newstyle 107 0 - unknownfield' >> tests/tmp/proc/modules
+echo 'newstyle2 108 0 newstyle2_dep, unknownfield unknownfield2' >> tests/tmp/proc/modules
+
+# This should be true
+[ "`lsmod`" = "Module                  Size  Used by
+foo                      100  0 
+bar                      101  1 
+baz                      102  1 baz_dep
+bazz                2147483648  2147483648 bazz_dep,bazz_dep2
+fuzz                     104  1 fuzz_dep,[permenant]
+fuzzy                    105  1 fuzzy_dep,[permenant],[unsafe]
+fuzzier                  106  0 [permenant],[unsafe]
+newstyle                 107  0 
+newstyle2                108  0 newstyle2_dep" ]
diff --git a/tests/test-modindex/05order.sh b/tests/test-modindex/05order.sh
new file mode 100644 (file)
index 0000000..24676d5
--- /dev/null
@@ -0,0 +1,47 @@
+#! /bin/sh
+
+# Index preserves order of values for same key
+
+modindex -o tests/tmp/index << EOF
+a 1
+a 2
+a 3
+EOF
+
+[ "`modindex -d tests/tmp/index`" = "a 1
+a 2
+a 3" ]
+
+modindex -o tests/tmp/index << EOF
+a 3
+a 2
+a 1
+EOF
+
+[ "`modindex -d tests/tmp/index`" = "a 3
+a 2
+a 1" ]
+
+# Index preserves order of values across multiple keys
+
+modindex -o tests/tmp/index << EOF
+*a 1
+b* 2
+* 3
+EOF
+
+[ "`modindex -w ba tests/tmp/index`" = "Found value(s):
+1
+2
+3" ]
+
+modindex -o tests/tmp/index << EOF
+* 1
+b* 2
+*a 3
+EOF
+
+[ "`modindex -w ba tests/tmp/index`" = "Found value(s):
+1
+2
+3" ]
diff --git a/tests/test-modinfo/02all.sh b/tests/test-modinfo/02all.sh
new file mode 100755 (executable)
index 0000000..e98c7d6
--- /dev/null
@@ -0,0 +1,50 @@
+#! /bin/sh
+
+# Test modinfo extraction: works for *any* endiannes.
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko \
+   $MODULE_DIR
+
+echo "/lib/modules/$MODTEST_UNAME/modinfo-$BITNESS.ko: /lib/modules/$MODTEST_UNAME/modinfo-crap-$BITNESS.ko" > $MODULE_DIR/modules.dep
+
+# Found by reading modules.dep
+OUTPUT1=`modinfo modinfo-$BITNESS 2>&1 | md5sum`
+# Found by absolute path.
+OUTPUT2=`modinfo /lib/modules/$MODTEST_UNAME/modinfo-$BITNESS.ko 2>&1 | md5sum`
+
+# Same except for filename
+[ x"$OUTPUT1" = x"$OUTPUT2" ]
+
+# Expect 10 lines.
+OUTPUT=`modinfo tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko 2>&1`
+[ `echo "$OUTPUT" | wc -l` -eq 10 ]
+
+# Test each one.
+[ "`echo "$OUTPUT" | grep filename`" =    "filename:       tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko" ]
+[ "`echo "$OUTPUT" | grep vermagic`" =    "vermagic:       my magic" ]
+[ "`echo "$OUTPUT" | grep author`" =      "author:         AUTHOR" ]
+[ "`echo "$OUTPUT" | grep description`" = "description:    DESCRIPTION" ]
+[ "`echo "$OUTPUT" | grep ALIAS1`" =      "alias:          ALIAS1" ]
+[ "`echo "$OUTPUT" | grep ALIAS2`" =      "alias:          ALIAS2" ]
+[ "`echo "$OUTPUT" | grep foo`" =         "parm:           foo:The number of foos on the card" ]
+[ "`echo "$OUTPUT" | grep ' described'`" =         "parm:           described:A well-described parameter (uint)" ]
+[ "`echo "$OUTPUT" | grep ' undescribed'`" =         "parm:           undescribed:int" ]
+
+# Test filename from modules.dep
+[ "`modinfo modinfo-$BITNESS | grep filename`" =    "filename:       /lib/modules/$MODTEST_UNAME/modinfo-$BITNESS.ko" ]
+
+# Test multiple modules on cmdline.
+[ `modinfo tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko 2>&1 | wc -l` -eq 20 ]
+
+# Test 0-fill
+[ "`modinfo -0 tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko 2>&1 | tr -dc '\000' | tr '\000' @`" = "@@@@@@@@@@" ]
+
+done
+done
diff --git a/tests/test-modinfo/03field.sh b/tests/test-modinfo/03field.sh
new file mode 100755 (executable)
index 0000000..9649247
--- /dev/null
@@ -0,0 +1,54 @@
+#! /bin/sh
+
+# Test modinfo extraction: works for *any* endiannes.
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko \
+   $MODULE_DIR
+
+echo "/lib/modules/$MODTEST_UNAME/modinfo-$BITNESS.ko: /lib/modules/$MODTEST_UNAME/modinfo-crap-$BITNESS.ko" > $MODULE_DIR/modules.dep
+
+# Test individual field extraction: by module search and abs. path
+for file in modinfo-$BITNESS tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko; do
+    [ "`modinfo -F randomcrap $file 2>&1`" = "my random crap which I use to test stuff with" ]
+    [ "`modinfo -F vermagic $file 2>&1`" = "my magic" ]
+    [ "`modinfo -F author $file 2>&1`" = "AUTHOR" ]
+    [ "`modinfo -a $file 2>&1`" = "AUTHOR" ]
+    [ "`modinfo -F description $file 2>&1`" = "DESCRIPTION" ]
+    [ "`modinfo -d $file 2>&1`" = "DESCRIPTION" ]
+    [ "`modinfo -F alias $file 2>&1`" = "ALIAS1
+ALIAS2" ] || [ "`modinfo -F alias $file 2>&1`" = "ALIAS2
+ALIAS1" ]
+    [ "`modinfo -F parm $file 2>&1`" = "foo:The number of foos on the card
+described:A well-described parameter" ] ||
+    [ "`modinfo -F parm $file 2>&1`" = "described:A well-described parameter
+foo:The number of foos on the card" ]
+
+    [ "`modinfo -F parmtype $file 2>&1`" = "described:uint
+undescribed:int" ] ||
+    [ "`modinfo -F parmtype $file 2>&1`" = "undescribed:int
+described:uint" ]
+    [ "`modinfo -F unknown $file 2>&1`" = "" ]
+done
+
+# Test filename output
+[ "`modinfo -F filename modinfo-$BITNESS 2>&1`" = "/lib/modules/$MODTEST_UNAME/modinfo-$BITNESS.ko" ]
+[ "`modinfo -n modinfo-$BITNESS 2>&1`" = "/lib/modules/$MODTEST_UNAME/modinfo-$BITNESS.ko" ]
+[ "`modinfo -F filename tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko 2>&1`" = "tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko" ]
+[ "`modinfo -n tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko 2>&1`" = "tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko" ]
+
+# Test multiple modules on cmdline.
+[ "`modinfo -F vermagic tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko 2>&1`" = "my magic
+my magic" ]
+
+# Test 0-fill
+[ "`modinfo -0 -F alias tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko 2>&1 | tr '\000' @`" = "ALIAS1@ALIAS2@" ]
+
+done
+done
diff --git a/tests/test-modinfo/04compressed.sh b/tests/test-modinfo/04compressed.sh
new file mode 100755 (executable)
index 0000000..afc0930
--- /dev/null
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Test modinfo extraction on compressed modules.
+
+[ -n "$CONFIG_HAVE_ZLIB" ] || exit 0
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Copy modules instead of linking, so we can compress them
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+cp tests/data/$BITNESS$ENDIAN/modinfo/modinfo-$BITNESS.ko \
+   $MODULE_DIR
+
+gzip $MODULE_DIR/modinfo-$BITNESS.ko
+
+echo "/lib/modules/$MODTEST_UNAME/modinfo-$BITNESS.ko.gz: /lib/modules/$MODTEST_UNAME/modinfo-crap-$BITNESS.ko.gz" > $MODULE_DIR/modules.dep
+
+# Test individual field extraction: by module search and abs. path
+for file in modinfo-$BITNESS $MODULE_DIR/modinfo-$BITNESS.ko.gz; do
+    [ "`modinfo -F randomcrap $file 2>&1`" = "my random crap which I use to test stuff with" ]
+    [ "`modinfo -F vermagic $file 2>&1`" = "my magic" ]
+    [ "`modinfo -F author $file 2>&1`" = "AUTHOR" ]
+    [ "`modinfo -F description $file 2>&1`" = "DESCRIPTION" ]
+    [ "`modinfo -F alias $file 2>&1`" = "ALIAS1
+ALIAS2" ] || [ "`modinfo -F alias $file 2>&1`" = "ALIAS2
+ALIAS1" ]
+    [ "`modinfo -F parm $file 2>&1`" = "foo:The number of foos on the card
+described:A well-described parameter" ] ||
+    [ "`modinfo -F parm $file 2>&1`" = "described:A well-described parameter
+foo:The number of foos on the card" ]
+
+    [ "`modinfo -F parmtype $file 2>&1`" = "described:uint
+undescribed:int" ] ||
+    [ "`modinfo -F parmtype $file 2>&1`" = "undescribed:int
+described:uint" ]
+    [ "`modinfo -F unknown $file 2>&1`" = "" ]
+done
+
+# Test multiple modules on cmdline.
+[ "`modinfo -F vermagic $MODULE_DIR/modinfo-$BITNESS.ko.gz $MODULE_DIR/modinfo-$BITNESS.ko.gz 2>&1`" = "my magic
+my magic" ]
+
+# Test 0-fill
+[ "`modinfo -0 -F alias $MODULE_DIR/modinfo-$BITNESS.ko.gz 2>&1 | tr '\000' @`" = "ALIAS1@ALIAS2@" ]
+
+done
+done
diff --git a/tests/test-modprobe-indexed/02simple.sh b/tests/test-modprobe-indexed/02simple.sh
new file mode 100644 (file)
index 0000000..5861899
--- /dev/null
@@ -0,0 +1,28 @@
+#! /bin/sh
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Set up modules.dep.bin file
+echo "noexport_nodep_$BITNESS noexport_nodep-$BITNESS.ko:" | modindex -o $MODULE_DIR/modules.dep.bin
+
+SIZE=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+
+# No args
+[ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE " ]
+
+# With quoted args
+[ "`modprobe noexport_nodep-$BITNESS 'foo="bar baz"' 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
+# With unquoted args
+[ "`modprobe noexport_nodep-$BITNESS foo=\"bar baz\" 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
+
+# Check underscore equivalence.
+[ "`modprobe noexport-nodep-$BITNESS foo=\"bar baz\" 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
+[ "`modprobe noexport-nodep_$BITNESS foo=\"bar baz\" 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
+[ "`modprobe noexport_nodep_$BITNESS foo=\"bar baz\" 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
diff --git a/tests/test-modprobe-indexed/03deps.sh b/tests/test-modprobe-indexed/03deps.sh
new file mode 100644 (file)
index 0000000..8dfd32b
--- /dev/null
@@ -0,0 +1,105 @@
+#! /bin/sh
+# Test module dependencies.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Now create modules.dep.bin
+cat > $MODULE_DIR/modules.dep.bin.temp <<EOF
+noexport_nodep_$BITNESS noexport_nodep-$BITNESS.ko:
+noexport_doubledep_$BITNESS noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko
+noexport_dep_$BITNESS noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+export_nodep_$BITNESS export_nodep-$BITNESS.ko:
+export_dep_$BITNESS export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+EOF
+modindex -o $MODULE_DIR/modules.dep.bin < $MODULE_DIR/modules.dep.bin.temp
+
+# Insertion
+SIZE_NOEXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+SIZE_EXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`
+SIZE_NOEXPORT_DEP=`wc -c < tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko`
+SIZE_EXPORT_DEP=`wc -c < tests/data/$BITNESS/normal/export_dep-$BITNESS.ko`
+SIZE_NOEXPORT_DOUBLEDEP=`wc -c < tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko`
+
+# Empty /sys/module/
+mkdir -p tests/tmp/sys/module
+
+[ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP " ]
+[ "`modprobe noexport_nodep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP OPTIONS" ]
+
+[ "`modprobe export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
+[ "`modprobe export_nodep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP OPTIONS" ]
+
+[ "`modprobe noexport_dep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_NOEXPORT_DEP " ]
+[ "`modprobe noexport_dep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_NOEXPORT_DEP OPTIONS" ]
+
+[ "`modprobe export_dep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_EXPORT_DEP " ]
+[ "`modprobe export_dep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_EXPORT_DEP OPTIONS" ]
+
+[ "`modprobe noexport_doubledep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_EXPORT_DEP 
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP " ]
+[ "`modprobe noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_EXPORT_DEP 
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP OPTIONS" ]
+
+# Now make a fake /sys/module structure for the test
+mkdir -p tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_doubledep_$BITNESS
+echo live > tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_doubledep_$BITNESS/initstate
+
+# Removal
+[ "`modprobe -r noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL 
+DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r export_dep-$BITNESS 2>&1`" = "DELETE_MODULE: export_dep_$BITNESS EXCL 
+DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r noexport_doubledep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_doubledep_$BITNESS EXCL 
+DELETE_MODULE: export_dep_$BITNESS EXCL 
+DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+
+# Removal with renaming.
+rm -rf tests/tmp/sys/module/*
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/newname
+echo live > tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/newname/initstate
+echo 0 > tests/tmp/sys/module/noexport_nodep_$BITNESS/refcnt
+echo 0 > tests/tmp/sys/module/export_nodep_$BITNESS/refcnt
+echo 0 > tests/tmp/sys/module/noexport_dep_$BITNESS/refcnt
+echo 0 > tests/tmp/sys/module/export_dep_$BITNESS/refcnt
+echo 0 > tests/tmp/sys/module/newname/refcnt
+
+[ "`modprobe -o newname -r noexport_doubledep-$BITNESS 2>&1`" = "DELETE_MODULE: newname EXCL 
+DELETE_MODULE: export_dep_$BITNESS EXCL 
+DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
diff --git a/tests/test-modprobe-indexed/03underscores.sh b/tests/test-modprobe-indexed/03underscores.sh
new file mode 100644 (file)
index 0000000..3d4ff39
--- /dev/null
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Check underscore synonymity everywhere.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Set up modules.dep.bin file.
+cat > $MODULE_DIR/modules.dep.bin.temp <<EOF
+noexport_nodep_$BITNESS noexport_nodep-$BITNESS.ko:
+export_nodep_$BITNESS export_nodep-$BITNESS.ko:
+EOF
+modindex -o $MODULE_DIR/modules.dep.bin < $MODULE_DIR/modules.dep.bin.temp
+
+# Now make a fake /sys/module structure for the test
+mkdir -p tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_doubledep_$BITNESS
+touch tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+touch tests/tmp/sys/module/noexport_dep_$BITNESS/initstate
+touch tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+touch tests/tmp/sys/module/export_dep_$BITNESS/initstate
+touch tests/tmp/sys/module/noexport_doubledep_$BITNESS/initstate
+
+# Set up config file.
+mkdir -p tests/tmp/etc/modprobe.d
+echo "alias alias-_ noexport-nodep_$BITNESS" > tests/tmp/etc/modprobe.d/modprobe.conf
+echo "options export-nodep_$BITNESS option-_" >> tests/tmp/etc/modprobe.d/modprobe.conf
+echo "install test-_ echo install-_" >> tests/tmp/etc/modprobe.d/modprobe.conf
+echo "remove test-_ echo remove-_" >> tests/tmp/etc/modprobe.d/modprobe.conf
+echo "install test-include echo Included" >> tests/tmp/etc/modprobe.d/modprobe-include.conf
+
+SIZE1=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+SIZE2=`wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`
+
+# On command line (-r and normal)
+[ "`modprobe noexport-nodep_$BITNESS 2>&1`" = "INIT_MODULE: $SIZE1 " ]
+[ "`modprobe -r noexport-nodep_$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+
+# In alias commands (source and target)
+[ "`modprobe alias-_ 2>&1`" = "INIT_MODULE: $SIZE1 " ]
+[ "`modprobe alias_- 2>&1`" = "INIT_MODULE: $SIZE1 " ]
+[ "`modprobe -r alias-_ 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r alias_- 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+
+# In option commands (NOT in arguments)
+[ "`modprobe export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE2 option-_" ]
+[ "`modprobe export-nodep_$BITNESS 2>&1`" = "INIT_MODULE: $SIZE2 option-_" ]
+
+# In install commands
+[ "`modprobe test-_ 2>&1`" = "SYSTEM: echo install-_" ]
+[ "`modprobe test_- 2>&1`" = "SYSTEM: echo install-_" ]
+
+# In remove commands
+[ "`modprobe -r test-_ 2>&1`" = "SYSTEM: echo remove-_" ]
+[ "`modprobe -r test_- 2>&1`" = "SYSTEM: echo remove-_" ]
+
+# NOT in include commands
+[ "`modprobe test-include 2>&1`" = "SYSTEM: echo Included" ]
+[ "`modprobe test_include 2>&1`" = "SYSTEM: echo Included" ]
diff --git a/tests/test-modprobe-indexed/10alias.sh b/tests/test-modprobe-indexed/10alias.sh
new file mode 100644 (file)
index 0000000..c2a2f5a
--- /dev/null
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Test for modules.alias usage.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR/kernel
+ln tests/data/$BITNESS/alias/alias-$BITNESS.ko \
+   $MODULE_DIR/kernel
+
+SIZE=`wc -c < tests/data/$BITNESS/alias/alias-$BITNESS.ko`
+
+echo "alias_$BITNESS /lib/modules/$MODTEST_UNAME/kernel/alias-$BITNESS.ko:" > $MODULE_DIR/modules.dep.bin.temp
+echo "foo /lib/modules/$MODTEST_UNAME/kernel/foo.ko:" >> $MODULE_DIR/modules.dep.bin.temp
+modindex -o $MODULE_DIR/modules.dep.bin < $MODULE_DIR/modules.dep.bin.temp
+
+rm -f $MODULE_DIR/modules.alias
+rm -f $MODULE_DIR/modules.alias.bin
+rm -f tests/tmp/etc/modprobe.d/modprobe.conf
+
+cp tests/data/$BITNESS/complex/complex_a-$BITNESS.ko $MODULE_DIR/kernel/foo.ko
+SIZE2=`wc -c < $MODULE_DIR/kernel/foo.ko`
+
+# Shouldn't complain if can't open modules.alias
+[ "`modprobe bar 2>&1`" = "FATAL: Module bar not found." ]
+
+# Now, alias found in modules.alias works.
+echo "bar alias_$BITNESS" > $MODULE_DIR/modules.alias.bin.temp
+modindex -o $MODULE_DIR/modules.alias.bin < $MODULE_DIR/modules.alias.bin.temp
+[ "`modprobe bar 2>&1`" = "INIT_MODULE: $SIZE " ]
+
+# Normal alias should override it.
+mkdir -p tests/tmp/etc/modprobe.d
+echo 'alias bar foo' > tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe foo 2>&1`" = "INIT_MODULE: $SIZE2 " ]
+
+# If there's a real module, alias from modules.alias must NOT override.
+echo "foo alias_$BITNESS" > $MODULE_DIR/modules.alias.bin.temp
+modindex -o $MODULE_DIR/modules.alias.bin < $MODULE_DIR/modules.alias.bin.temp
+[ "`modprobe foo 2>&1`" = "INIT_MODULE: $SIZE2 " ]
+
+# If there's an install command, modules.alias must not override.
+echo 'install bar echo foo' > tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe bar 2>&1`" = "SYSTEM: echo foo" ]
+echo 'remove bar echo foo remove' > tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe -r bar 2>&1`" = "SYSTEM: echo foo remove" ]
+
+# Should gather up options from other alias name as well.
+echo "bar alias_$BITNESS" > $MODULE_DIR/modules.alias.bin.temp
+modindex -o $MODULE_DIR/modules.alias.bin < $MODULE_DIR/modules.alias.bin.temp
+echo "options bar option1" > tests/tmp/etc/modprobe.d/modprobe.conf
+echo "options alias_$BITNESS option2" >> tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe bar 2>&1`" = "INIT_MODULE: $SIZE option2 option1" ]
+
+# Duplicated alias: both get probed (either order)
+echo "bar foo" >> $MODULE_DIR/modules.alias.bin.temp
+modindex -o $MODULE_DIR/modules.alias.bin < $MODULE_DIR/modules.alias.bin.temp
+OUT="`modprobe bar 2>&1`"
+
+[ "$OUT" = "INIT_MODULE: $SIZE option2 option1
+INIT_MODULE: $SIZE2 option1" ] || [ "$OUT" = "INIT_MODULE: $SIZE2 option1
+INIT_MODULE: $SIZE option2 option1" ]
diff --git a/tests/test-modprobe-indexed/16showdepends.sh b/tests/test-modprobe-indexed/16showdepends.sh
new file mode 100644 (file)
index 0000000..e8e4182
--- /dev/null
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Test --show-depends.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Now create modules.dep.bin
+cat > $MODULE_DIR/modules.dep.temp <<EOF
+noexport_nodep_$BITNESS noexport_nodep-$BITNESS.ko:
+noexport_doubledep_$BITNESS noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko
+noexport_dep_$BITNESS noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+export_nodep_$BITNESS export_nodep-$BITNESS.ko:
+export_dep_$BITNESS export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+EOF
+# Build modules.dep.bin, which modprobe will prefer
+modindex -o $MODULE_DIR/modules.dep.bin < $MODULE_DIR/modules.dep.temp
+
+[ "`modprobe --show-depends noexport_nodep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko " ]
+[ "`modprobe --show-depends export_nodep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko " ]
+[ "`modprobe --show-depends noexport_dep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/noexport_dep-$BITNESS.ko " ]
+[ "`modprobe --show-depends export_dep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko " ]
+[ "`modprobe --show-depends noexport_doubledep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/noexport_doubledep-$BITNESS.ko " ]
+
+# Nothing in stderr...
+[ `wc -c < tests/tmp/stderr` = 0 ]
diff --git a/tests/test-modprobe/02proc.sh b/tests/test-modprobe/02proc.sh
new file mode 100755 (executable)
index 0000000..d7db770
--- /dev/null
@@ -0,0 +1,103 @@
+#! /bin/sh
+
+# Test handling of /proc/modules.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   $MODULE_DIR
+
+mkdir tests/tmp/proc
+
+# Now create modules.dep
+cat > tests/tmp/lib/modules/$MODTEST_UNAME/modules.dep <<EOF
+noexport_nodep-$BITNESS.ko:
+export_nodep-$BITNESS.ko:
+EOF
+
+SIZE_NOEXPORT_NODEP=$(echo `wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`)
+SIZE_EXPORT_NODEP=$(echo `wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`)
+
+# If it can't open /proc/modules, it should try anyway.
+rm -f tests/tmp/proc/modules
+
+[ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP " ]
+[ "`modprobe export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
+
+[ "`modprobe -r noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+
+# If it doesn't exist in /proc/modules, remove should succeed.
+touch tests/tmp/proc/modules
+[ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP " ]
+[ "`modprobe export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
+[ "`modprobe -r -v noexport_nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+[ "`modprobe -r -v export_nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+[ "`modprobe -r -v noexport-nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+[ "`modprobe -r -v export-nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+# ... unless --first-time is specified (won't print status due to set -e).
+[ "`modprobe --first-time -r noexport_nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS is not in kernel." ]
+[ "`modprobe --first-time -r export_nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS is not in kernel." ]
+[ "`modprobe --first-time -r noexport-nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS is not in kernel." ]
+[ "`modprobe --first-time -r export-nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS is not in kernel." ]
+
+# Old-style /proc (no unload support).
+echo "noexport_nodep_$BITNESS $SIZE_NOEXPORT_NODEP" > tests/tmp/proc/modules
+echo "export_nodep_$BITNESS $SIZE_EXPORT_NODEP" >> tests/tmp/proc/modules
+
+# If it does exist, insertion should "succeed".
+[ "`modprobe -v noexport_nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+[ "`modprobe -v export_nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+[ "`modprobe -v noexport-nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+[ "`modprobe -v export-nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+# .. unless --first-time is specified.
+[ "`modprobe --first-time noexport_nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time export_nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time noexport-nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time export-nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS already in kernel." ]
+
+# Removal should still try.
+[ "`modprobe -r noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+
+# New-style /proc without unload support
+echo "noexport_nodep_$BITNESS $SIZE_NOEXPORT_NODEP - -" > tests/tmp/proc/modules
+echo "export_nodep_$BITNESS $SIZE_EXPORT_NODEP - -" >> tests/tmp/proc/modules
+
+[ "`modprobe --first-time noexport_nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time export_nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time noexport-nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time export-nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS already in kernel." ]
+# Removal should still try.
+[ "`modprobe -r noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+
+# Should fail if refcounts non-zero.  Old-style
+echo "noexport_nodep_$BITNESS $SIZE_NOEXPORT_NODEP 1" > tests/tmp/proc/modules
+echo "export_nodep_$BITNESS $SIZE_EXPORT_NODEP 1" >> tests/tmp/proc/modules
+
+[ "`modprobe -r noexport_nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS is in use." ]
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS is in use." ]
+[ "`modprobe -r noexport-nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS is in use." ]
+[ "`modprobe -r export-nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS is in use." ]
+
+# New-style /proc
+echo "noexport_nodep_$BITNESS $SIZE_NOEXPORT_NODEP 1 -" > tests/tmp/proc/modules
+echo "export_nodep_$BITNESS $SIZE_EXPORT_NODEP 1 something_else, extrafield" >> tests/tmp/proc/modules
+
+[ "`modprobe --first-time noexport_nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time export_nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time noexport-nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time export-nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS already in kernel." ]
+
+[ "`modprobe -r noexport_nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS is in use." ]
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS is in use." ]
+[ "`modprobe -r noexport-nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS is in use." ]
+[ "`modprobe -r export-nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS is in use." ]
+
diff --git a/tests/test-modprobe/02simple.sh b/tests/test-modprobe/02simple.sh
new file mode 100755 (executable)
index 0000000..aa41769
--- /dev/null
@@ -0,0 +1,29 @@
+#! /bin/sh
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Set up modules.dep file.
+echo "# A comment" > $MODULE_DIR/modules.dep
+echo "/lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko:" >> $MODULE_DIR/modules.dep
+
+SIZE=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+
+# No args
+[ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE " ]
+
+# With quoted args
+[ "`modprobe noexport_nodep-$BITNESS 'foo="bar baz"' 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
+# With unquoted args
+[ "`modprobe noexport_nodep-$BITNESS foo=\"bar baz\" 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
+
+# Check underscore equivalence.
+[ "`modprobe noexport-nodep-$BITNESS foo=\"bar baz\" 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
+[ "`modprobe noexport-nodep_$BITNESS foo=\"bar baz\" 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
+[ "`modprobe noexport_nodep_$BITNESS foo=\"bar baz\" 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
diff --git a/tests/test-modprobe/02sys.sh b/tests/test-modprobe/02sys.sh
new file mode 100755 (executable)
index 0000000..462e418
--- /dev/null
@@ -0,0 +1,88 @@
+#! /bin/sh
+
+# Test handling of /sys/module/.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Now create modules.dep
+cat > $MODULE_DIR/modules.dep <<EOF
+noexport_nodep-$BITNESS.ko:
+export_nodep-$BITNESS.ko:
+EOF
+
+SIZE_NOEXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+SIZE_EXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`
+
+# If it can't open /sys/module, it should try anyway.
+[ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP " ]
+[ "`modprobe export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
+
+[ "`modprobe -r noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+
+# If it doesn't exist in /sys/module/, remove should succeed.
+mkdir -p tests/tmp/sys/module
+
+[ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP " ]
+[ "`modprobe export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
+[ "`modprobe -r -v noexport_nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+[ "`modprobe -r -v export_nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+[ "`modprobe -r -v noexport-nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+[ "`modprobe -r -v export-nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+# ... unless --first-time is specified (won't print status due to set -e).
+[ "`modprobe --first-time -r noexport_nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS is not in kernel." ]
+[ "`modprobe --first-time -r export_nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS is not in kernel." ]
+[ "`modprobe --first-time -r noexport-nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS is not in kernel." ]
+[ "`modprobe --first-time -r export-nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS is not in kernel." ]
+
+# Now make a fake /sys/module structure for the test
+# Note: no refcnt files (no unload support)
+mkdir -p tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+echo live > tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+
+# If it does exist, insertion should "succeed".
+[ "`modprobe -v noexport_nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+[ "`modprobe -v export_nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+[ "`modprobe -v noexport-nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+[ "`modprobe -v export-nodep-$BITNESS 2>&1; echo $?`" = "0" ]
+# .. unless --first-time is specified.
+[ "`modprobe --first-time noexport_nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time export_nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time noexport-nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time export-nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS already in kernel." ]
+
+# Removal should try (despite lack of unload support)
+[ "`modprobe -r noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+
+# Note: refcnt files (unload support)
+rm -rf tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+echo live > tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+echo 1 > tests/tmp/sys/module/export_nodep_$BITNESS/refcnt
+echo 1 > tests/tmp/sys/module/noexport_nodep_$BITNESS/refcnt
+
+[ "`modprobe --first-time noexport_nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time export_nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time noexport-nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS already in kernel." ]
+[ "`modprobe --first-time export-nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS already in kernel." ]
+
+[ "`modprobe -r noexport_nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS is in use." ]
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS is in use." ]
+[ "`modprobe -r noexport-nodep-$BITNESS 2>&1`" = "FATAL: Module noexport_nodep_$BITNESS is in use." ]
+[ "`modprobe -r export-nodep-$BITNESS 2>&1`" = "FATAL: Module export_nodep_$BITNESS is in use." ]
diff --git a/tests/test-modprobe/03deps.sh b/tests/test-modprobe/03deps.sh
new file mode 100755 (executable)
index 0000000..efc20ca
--- /dev/null
@@ -0,0 +1,105 @@
+#! /bin/sh
+# Test module dependencies.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Now create modules.dep
+cat > $MODULE_DIR/modules.dep <<EOF
+# Should handle comments.
+noexport_nodep-$BITNESS.ko:
+noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko
+noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+export_nodep-$BITNESS.ko:
+export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+EOF
+
+# Insertion
+SIZE_NOEXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+SIZE_EXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`
+SIZE_NOEXPORT_DEP=`wc -c < tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko`
+SIZE_EXPORT_DEP=`wc -c < tests/data/$BITNESS/normal/export_dep-$BITNESS.ko`
+SIZE_NOEXPORT_DOUBLEDEP=`wc -c < tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko`
+
+# Empty /sys/module/
+mkdir -p tests/tmp/sys/module
+
+[ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP " ]
+[ "`modprobe noexport_nodep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP OPTIONS" ]
+
+[ "`modprobe export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
+[ "`modprobe export_nodep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP OPTIONS" ]
+
+[ "`modprobe noexport_dep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_NOEXPORT_DEP " ]
+[ "`modprobe noexport_dep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_NOEXPORT_DEP OPTIONS" ]
+
+[ "`modprobe export_dep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_EXPORT_DEP " ]
+[ "`modprobe export_dep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_EXPORT_DEP OPTIONS" ]
+
+[ "`modprobe noexport_doubledep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_EXPORT_DEP 
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP " ]
+[ "`modprobe noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_EXPORT_DEP 
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP OPTIONS" ]
+
+# Now make a fake /sys/module structure for the test
+mkdir -p tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_doubledep_$BITNESS
+echo live > tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_doubledep_$BITNESS/initstate
+
+# Removal
+[ "`modprobe -r noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL 
+DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r export_dep-$BITNESS 2>&1`" = "DELETE_MODULE: export_dep_$BITNESS EXCL 
+DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r noexport_doubledep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_doubledep_$BITNESS EXCL 
+DELETE_MODULE: export_dep_$BITNESS EXCL 
+DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+
+# Removal with renaming.
+rm -rf tests/tmp/sys/module/*
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/newname
+echo live > tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/newname/initstate
+echo 0 > tests/tmp/sys/module/noexport_nodep_$BITNESS/refcnt
+echo 0 > tests/tmp/sys/module/export_nodep_$BITNESS/refcnt
+echo 0 > tests/tmp/sys/module/noexport_dep_$BITNESS/refcnt
+echo 0 > tests/tmp/sys/module/export_dep_$BITNESS/refcnt
+echo 0 > tests/tmp/sys/module/newname/refcnt
+
+[ "`modprobe -o newname -r noexport_doubledep-$BITNESS 2>&1`" = "DELETE_MODULE: newname EXCL 
+DELETE_MODULE: export_dep_$BITNESS EXCL 
+DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
diff --git a/tests/test-modprobe/03underscores.sh b/tests/test-modprobe/03underscores.sh
new file mode 100755 (executable)
index 0000000..c1e55e2
--- /dev/null
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Check underscore synonymity everywhere.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Set up modules.dep file.
+echo "# A comment" > $MODULE_DIR/modules.dep
+echo "noexport_nodep-$BITNESS.ko:" >> $MODULE_DIR/modules.dep
+echo "export_nodep-$BITNESS.ko:" >> $MODULE_DIR/modules.dep
+
+# Set up config file.
+mkdir -p tests/tmp/etc/modprobe.d
+echo "alias alias-_ noexport-nodep_$BITNESS" > tests/tmp/etc/modprobe.d/modprobe.conf
+echo "options export-nodep_$BITNESS option-_" >> tests/tmp/etc/modprobe.d/modprobe.conf
+echo "install test-_ echo install-_" >> tests/tmp/etc/modprobe.d/modprobe.conf
+echo "remove test-_ echo remove-_" >> tests/tmp/etc/modprobe.d/modprobe.conf
+echo "install test-include echo Included" >> tests/tmp/etc/modprobe.d/modprobe-include.conf
+
+SIZE1=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+SIZE2=`wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`
+
+# On command line (-r and normal)
+[ "`modprobe noexport-nodep_$BITNESS 2>&1`" = "INIT_MODULE: $SIZE1 " ]
+[ "`modprobe -r noexport-nodep_$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+
+# In alias commands (source and target)
+[ "`modprobe alias-_ 2>&1`" = "INIT_MODULE: $SIZE1 " ]
+[ "`modprobe alias_- 2>&1`" = "INIT_MODULE: $SIZE1 " ]
+[ "`modprobe -r alias-_ 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r alias_- 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+
+# In option commands (NOT in arguments)
+[ "`modprobe export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE2 option-_" ]
+[ "`modprobe export-nodep_$BITNESS 2>&1`" = "INIT_MODULE: $SIZE2 option-_" ]
+
+# In install commands
+[ "`modprobe test-_ 2>&1`" = "SYSTEM: echo install-_" ]
+[ "`modprobe test_- 2>&1`" = "SYSTEM: echo install-_" ]
+
+# In remove commands
+[ "`modprobe -r test-_ 2>&1`" = "SYSTEM: echo remove-_" ]
+[ "`modprobe -r test_- 2>&1`" = "SYSTEM: echo remove-_" ]
+
+# NOT in include commands
+[ "`modprobe test-include 2>&1`" = "SYSTEM: echo Included" ]
+[ "`modprobe test_include 2>&1`" = "SYSTEM: echo Included" ]
diff --git a/tests/test-modprobe/04config.sh b/tests/test-modprobe/04config.sh
new file mode 100755 (executable)
index 0000000..342cc18
--- /dev/null
@@ -0,0 +1,228 @@
+#! /bin/sh
+# Test configuration file handling.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Simple dump out test.
+touch tests/tmp/empty
+[ "`modprobe -C /empty -c 2>&1`" = "" ]
+[ "`modprobe --config /empty --showconfig 2>&1`" = "" ]
+
+# Explicitly mentioned config files must exist.
+[ "`modprobe -C FILE-WHICH-DOESNT-EXIST foo 2>&1`" = "FATAL: Failed to open config file FILE-WHICH-DOESNT-EXIST: No such file or directory" ]
+
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+touch $MODULE_DIR/modules.dep
+
+[ "`modprobe foo 2>&1`" = "FATAL: Module foo not found." ]
+
+# Create a simple config file.
+mkdir -p tests/tmp/etc/modprobe.d
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+# Various aliases
+alias alias_to_foo foo
+alias alias_to_bar bar
+alias alias_to_export_dep-$BITNESS export_dep-$BITNESS
+alias alias_to_noexport_dep-$BITNESS noexport_dep-$BITNESS
+alias alias_to_noexport_nodep-$BITNESS noexport_nodep-$BITNESS
+alias alias_to_noexport_doubledep-$BITNESS noexport_doubledep-$BITNESS
+alias alias_to_noexport_nodep-$BITNESS_with_tabbed_options noexport_nodep-$BITNESS
+
+# Various options, including options to aliases.
+options alias_to_export_dep-$BITNESS I am alias to export_dep
+options export_dep-$BITNESS I am export_dep
+options alias_to_noexport_dep-$BITNESS I am alias to noexport_dep
+options noexport_dep-$BITNESS I am noexport_dep
+options alias_to_noexport_nodep-$BITNESS I am alias to noexport_nodep
+options noexport_nodep-$BITNESS I am noexport_nodep
+options alias_to_noexport_doubledep-$BITNESS I am alias to noexport_doubledep
+options noexport_doubledep-$BITNESS I am noexport_doubledep
+options alias_to_noexport_nodep-$BITNESS_with_tabbed_options index=0 id="Thinkpad" isapnp=0 \\
+       port=0x530 cport=0x538 fm_port=0x388 \\
+       mpu_port=-1 mpu_irq=-1 \\
+       irq=9 dma1=1 dma2=3 \\
+       enable=1 isapnp=0
+
+# Install commands
+install bar echo Installing bar
+install foo echo Installing foo
+install export_nodep-$BITNESS echo Installing export_nodep
+
+# Remove commands
+remove bar echo Removing bar
+remove foo echo Removing foo
+remove export_nodep-$BITNESS echo Removing export_nodep
+EOF
+
+# Now create a second file
+cat > tests/tmp/etc/modprobe.d/modprobe-include.conf <<EOF
+install baz echo Installing baz
+remove baz echo Removing baz
+
+alias alias_to_baz baz
+EOF
+
+# Create inputs
+ln tests/data/$BITNESS/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Now create modules.dep
+cat > $MODULE_DIR/modules.dep <<EOF
+noexport_nodep-$BITNESS.ko:
+noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko
+noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+export_nodep-$BITNESS.ko:
+export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+EOF
+
+SIZE_NOEXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+SIZE_EXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`
+SIZE_NOEXPORT_DEP=`wc -c < tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko`
+SIZE_EXPORT_DEP=`wc -c < tests/data/$BITNESS/normal/export_dep-$BITNESS.ko`
+SIZE_NOEXPORT_DOUBLEDEP=`wc -c < tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko`
+
+# Empty /sys/module/ for install commands
+mkdir -p tests/tmp/sys/module
+
+# Test ignoring install commands
+[ "`modprobe --ignore-install export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
+[ "`modprobe -i export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
+[ "`modprobe -i foo 2>&1`" = "FATAL: Module foo not found." ]
+
+# Test install commands (fake modules)
+[ "`modprobe foo 2>&1`" = "SYSTEM: echo Installing foo" ]
+[ "`modprobe bar 2>&1`" = "SYSTEM: echo Installing bar" ]
+[ "`modprobe baz 2>&1`" = "SYSTEM: echo Installing baz" ]
+
+# Test install of a what is also a real module.
+[ "`modprobe export_nodep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep" ]
+
+# Test install of what is also a real module via dependency.
+[ "`modprobe noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
+
+# Test ignoring install commands: only effects commandline.
+[ "`modprobe -i noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
+
+# Test options
+[ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep" ]
+[ "`modprobe noexport_nodep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep OPTIONS" ]
+
+[ "`modprobe noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
+[ "`modprobe noexport_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep OPTIONS" ]
+
+[ "`modprobe export_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep" ]
+[ "`modprobe export_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep OPTIONS" ]
+
+[ "`modprobe noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep" ]
+[ "`modprobe noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep OPTIONS" ]
+
+# Test aliases doing insertion.
+[ "`modprobe alias_to_noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep I am alias to noexport_nodep" ]
+[ "`modprobe alias_to_noexport_nodep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep I am alias to noexport_nodep OPTIONS" ]
+
+[ "`modprobe alias_to_noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep I am alias to noexport_dep" ]
+[ "`modprobe alias_to_noexport_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep I am alias to noexport_dep OPTIONS" ]
+
+[ "`modprobe alias_to_export_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep I am alias to export_dep" ]
+[ "`modprobe alias_to_export_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep I am alias to export_dep OPTIONS" ]
+
+[ "`modprobe alias_to_noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep" ]
+[ "`modprobe alias_to_noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep" ]
+[ "`modprobe alias_to_noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep OPTIONS" ]
+
+[ "`modprobe alias_to_foo 2>&1`" = "SYSTEM: echo Installing foo" ]
+[ "`modprobe alias_to_bar 2>&1`" = "SYSTEM: echo Installing bar" ]
+[ "`modprobe alias_to_baz 2>&1`" = "SYSTEM: echo Installing baz" ]
+
+# Test tab-to-spaces conversion, and \ wrapping.
+[ "`modprobe alias_to_noexport_nodep-$BITNESS_with_tabbed_options 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep index=0 id=\"Thinkpad\" isapnp=0  port=0x530 cport=0x538 fm_port=0x388  mpu_port=-1 mpu_irq=-1  irq=9 dma1=1 dma2=3  enable=1 isapnp=0" ]
+
+# Populate /sys/module/ for remove commands
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_doubledep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_dep_$BITNESS
+echo live > tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_doubledep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_dep_$BITNESS/initstate
+
+# Test ignoring remove commands.
+[ "`modprobe -r --ignore-remove export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r -i export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+[ "`modprobe -i -r foo 2>&1`" = "FATAL: Module foo not found." ]
+
+# Test remove commands (fake modules)
+[ "`modprobe -r foo 2>&1`" = "SYSTEM: echo Removing foo" ]
+[ "`modprobe -r bar 2>&1`" = "SYSTEM: echo Removing bar" ]
+[ "`modprobe -r baz 2>&1`" = "SYSTEM: echo Removing baz" ]
+
+# Test remove of a what is also a real module.
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "SYSTEM: echo Removing export_nodep" ]
+
+# Test remove of what is also a real module via dependency.
+[ "`modprobe -r noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL 
+SYSTEM: echo Removing export_nodep" ]
+
+# Test ignoring remove commands: only effects commandline.
+[ "`modprobe -r -i noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL 
+SYSTEM: echo Removing export_nodep" ]
+
+# Test aliases doing removal.
+[ "`modprobe -r alias_to_noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r alias_to_noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL 
+SYSTEM: echo Removing export_nodep" ]
+[ "`modprobe -r alias_to_export_dep-$BITNESS 2>&1`" = "DELETE_MODULE: export_dep_$BITNESS EXCL 
+SYSTEM: echo Removing export_nodep" ]
+[ "`modprobe -r alias_to_noexport_doubledep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_doubledep_$BITNESS EXCL 
+DELETE_MODULE: export_dep_$BITNESS EXCL 
+SYSTEM: echo Removing export_nodep" ]
+
+[ "`modprobe -r alias_to_foo 2>&1`" = "SYSTEM: echo Removing foo" ]
+[ "`modprobe -r alias_to_bar 2>&1`" = "SYSTEM: echo Removing bar" ]
+[ "`modprobe -r alias_to_baz 2>&1`" = "SYSTEM: echo Removing baz" ]
+
+# Now test install precaution in the absence of /sys/modules
+rm -r tests/tmp/sys/module
+
+# Test install and remove commands (fake modules)
+# No caution necessary here
+[ "`modprobe foo 2>&1`" = "SYSTEM: echo Installing foo" ]
+[ "`modprobe -r foo 2>&1`" = "SYSTEM: echo Removing foo" ]
+
+# Test install and remove of a what is also a real module.
+[ "`modprobe export_nodep-$BITNESS 2>&1`" = "WARNING: /sys/module/ not present or too old, and /proc/modules does not exist.
+WARNING: Ignoring install commands for export_nodep_$BITNESS in case it is already loaded.
+INIT_MODULE: $SIZE_EXPORT_NODEP " ]
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "WARNING: /sys/module/ not present or too old, and /proc/modules does not exist.
+WARNING: Ignoring remove commands for export_nodep_$BITNESS in case it is not loaded.
+DELETE_MODULE: export_nodep_32 EXCL " ]
diff --git a/tests/test-modprobe/06rename.sh b/tests/test-modprobe/06rename.sh
new file mode 100755 (executable)
index 0000000..59b5f13
--- /dev/null
@@ -0,0 +1,100 @@
+#! /bin/sh
+# Test the module renaming code.
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# We need to dump the module to make sure the name has changed.
+MODTEST_DUMP_INIT=1
+export MODTEST_DUMP_INIT
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/rename/rename-new-$BITNESS.ko \
+   tests/data/$BITNESS$ENDIAN/rename/rename-old-$BITNESS.ko \
+   $MODULE_DIR
+
+# Set up modules.dep file (neither has dependencies).
+echo "# A comment" > $MODULE_DIR/modules.dep
+echo "/lib/modules/$MODTEST_UNAME/rename-new-$BITNESS.ko:" >> $MODULE_DIR/modules.dep
+echo "/lib/modules/$MODTEST_UNAME/rename-old-$BITNESS.ko:" >> $MODULE_DIR/modules.dep
+
+# Test old-style module 
+[ "`modprobe rename-old-$BITNESS 2> tests/tmp/out`" = "" ]
+strings tests/tmp/out | grep -q 'rename_old'
+if strings tests/tmp/out | grep -q 'short'; then exit 1; fi
+
+[ "`modprobe -o short rename-old-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_old'; then exit 1; fi
+strings tests/tmp/out | grep -q 'short'
+
+[ "`modprobe -o very_very_long_name rename-old-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_old'; then exit 1; fi
+strings tests/tmp/out | grep -q 'very_very_long_name'
+
+[ "`modprobe -o short rename-old-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_old'; then exit 1; fi
+strings tests/tmp/out | grep -q 'short'
+
+[ "`modprobe -o very_very_long_name rename-old-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_old'; then exit 1; fi
+strings tests/tmp/out | grep -q 'very_very_long_name'
+
+[ "`modprobe --name short rename-old-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_old'; then exit 1; fi
+strings tests/tmp/out | grep -q 'short'
+
+[ "`modprobe --name very_very_long_name rename-old-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_old'; then exit 1; fi
+strings tests/tmp/out | grep -q 'very_very_long_name'
+
+[ "`modprobe --name=short rename-old-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_old'; then exit 1; fi
+strings tests/tmp/out | grep -q 'short'
+
+[ "`modprobe --name=very_very_long_name rename-old-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_old'; then exit 1; fi
+strings tests/tmp/out | grep -q 'very_very_long_name'
+
+# Test new-style module 
+[ "`modprobe rename-new-$BITNESS 2> tests/tmp/out`" = "" ]
+strings tests/tmp/out | grep -q 'rename_new'
+if strings tests/tmp/out | grep -q 'short'; then exit 1; fi
+
+[ "`modprobe -o short rename-new-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_new'; then exit 1; fi
+strings tests/tmp/out | grep -q 'short'
+
+[ "`modprobe -o very_very_long_name rename-new-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_new'; then exit 1; fi
+strings tests/tmp/out | grep -q 'very_very_long_name'
+
+[ "`modprobe -o short rename-new-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_new'; then exit 1; fi
+strings tests/tmp/out | grep -q 'short'
+
+[ "`modprobe -o very_very_long_name rename-new-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_new'; then exit 1; fi
+strings tests/tmp/out | grep -q 'very_very_long_name'
+
+[ "`modprobe --name short rename-new-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_new'; then exit 1; fi
+strings tests/tmp/out | grep -q 'short'
+
+[ "`modprobe --name very_very_long_name rename-new-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_new'; then exit 1; fi
+strings tests/tmp/out | grep -q 'very_very_long_name'
+
+[ "`modprobe --name=short rename-new-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_new'; then exit 1; fi
+strings tests/tmp/out | grep -q 'short'
+
+[ "`modprobe --name=very_very_long_name rename-new-$BITNESS 2> tests/tmp/out`" = "" ]
+if strings tests/tmp/out | grep -q 'rename_new'; then exit 1; fi
+strings tests/tmp/out | grep -q 'very_very_long_name'
+
+done
+done
diff --git a/tests/test-modprobe/07wildalias.sh b/tests/test-modprobe/07wildalias.sh
new file mode 100755 (executable)
index 0000000..9be53b7
--- /dev/null
@@ -0,0 +1,27 @@
+#! /bin/sh
+# Test wildcard aliases.
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+touch $MODULE_DIR/modules.dep
+
+# Create a simple config file.
+mkdir -p tests/tmp/etc/modprobe.d
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+# Various aliases
+alias *wildcard-_* foo
+alias /dev/test* bar
+EOF
+
+# Simple test.
+[ "`modprobe wildcard-_aaa 2>&1`" = "FATAL: Module foo not found." ]
+[ "`modprobe wildcard-_ 2>&1`" = "FATAL: Module foo not found." ]
+[ "`modprobe wildcard_- 2>&1`" = "FATAL: Module foo not found." ]
+[ "`modprobe anotherwildcard-_ 2>&1`" = "FATAL: Module foo not found." ]
+[ "`modprobe anotherwildcard-_aaa 2>&1`" = "FATAL: Module foo not found." ]
+[ "`modprobe /dev/test 2>&1`" = "FATAL: Module bar not found." ]
+[ "`modprobe /dev/test/tmp 2>&1`" = "FATAL: Module bar not found." ]
+[ "`modprobe /dev/test7  2>&1`" = "FATAL: Module bar not found." ]
diff --git a/tests/test-modprobe/09configerrors.sh b/tests/test-modprobe/09configerrors.sh
new file mode 100755 (executable)
index 0000000..ab140e9
--- /dev/null
@@ -0,0 +1,101 @@
+#! /bin/sh
+# Test various config file errors.
+
+rm -rf tests/tmp/*
+
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+touch $MODULE_DIR/modules.dep
+
+# Test bad alias syntax
+mkdir -p tests/tmp/etc/modprobe.d
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+alias
+alias foo
+EOF
+
+[ "`modprobe foo 2>&1`" = "WARNING: /etc/modprobe.d/modprobe.conf line 1: ignoring bad line starting with 'alias'
+WARNING: /etc/modprobe.d/modprobe.conf line 2: ignoring bad line starting with 'alias'
+FATAL: Module foo not found." ]
+
+# Bad option syntax
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+options
+options foo
+EOF
+
+[ "`modprobe foo 2>&1`" = "WARNING: /etc/modprobe.d/modprobe.conf line 1: ignoring bad line starting with 'options'
+WARNING: /etc/modprobe.d/modprobe.conf line 2: ignoring bad line starting with 'options'
+FATAL: Module foo not found." ]
+
+# Bad include syntax
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+include
+EOF
+
+[ "`modprobe foo 2>&1`" = "WARNING: /etc/modprobe.d/modprobe.conf line 1: ignoring bad line starting with 'include'
+FATAL: Module foo not found." ]
+
+# Bad install syntax
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+install
+install foo
+EOF
+
+[ "`modprobe foo 2>&1`" = "WARNING: /etc/modprobe.d/modprobe.conf line 1: ignoring bad line starting with 'install'
+WARNING: /etc/modprobe.d/modprobe.conf line 2: ignoring bad line starting with 'install'
+FATAL: Module foo not found." ]
+
+# Bad remove syntax
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+remove
+remove foo
+EOF
+
+[ "`modprobe foo 2>&1`" = "WARNING: /etc/modprobe.d/modprobe.conf line 1: ignoring bad line starting with 'remove'
+WARNING: /etc/modprobe.d/modprobe.conf line 2: ignoring bad line starting with 'remove'
+FATAL: Module foo not found." ]
+
+# Complete junk
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+complete junk and stuff
+rubbish
+EOF
+
+[ "`modprobe foo 2>&1`" = "WARNING: /etc/modprobe.d/modprobe.conf line 1: ignoring bad line starting with 'complete'
+WARNING: /etc/modprobe.d/modprobe.conf line 2: ignoring bad line starting with 'rubbish'
+FATAL: Module foo not found." ]
+
+# Line numbering counted correctly.
+echo "#comment" > tests/tmp/etc/modprobe.d/modprobe.conf
+echo "remove" >> tests/tmp/etc/modprobe.d/modprobe.conf
+
+[ "`modprobe foo 2>&1`" = "WARNING: /etc/modprobe.d/modprobe.conf line 2: ignoring bad line starting with 'remove'
+FATAL: Module foo not found." ]
+
+echo "" > tests/tmp/etc/modprobe.d/modprobe.conf
+echo "remove" >> tests/tmp/etc/modprobe.d/modprobe.conf
+
+[ "`modprobe foo 2>&1`" = "WARNING: /etc/modprobe.d/modprobe.conf line 2: ignoring bad line starting with 'remove'
+FATAL: Module foo not found." ]
+
+echo "  # Comment" > tests/tmp/etc/modprobe.d/modprobe.conf
+echo "remove" >> tests/tmp/etc/modprobe.d/modprobe.conf
+
+[ "`modprobe foo 2>&1`" = "WARNING: /etc/modprobe.d/modprobe.conf line 2: ignoring bad line starting with 'remove'
+FATAL: Module foo not found." ]
+
+echo "  # Comment \\" > tests/tmp/etc/modprobe.d/modprobe.conf
+echo "with multiple lines" >> tests/tmp/etc/modprobe.d/modprobe.conf
+echo "remove" >> tests/tmp/etc/modprobe.d/modprobe.conf
+
+[ "`modprobe foo 2>&1`" = "WARNING: /etc/modprobe.d/modprobe.conf line 3: ignoring bad line starting with 'remove'
+FATAL: Module foo not found." ]
+
+echo "remove foo \\" > tests/tmp/etc/modprobe.d/modprobe.conf
+echo "  bar" >> tests/tmp/etc/modprobe.d/modprobe.conf
+echo "remove" >> tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe foo 2>&1`" = "WARNING: /etc/modprobe.d/modprobe.conf line 3: ignoring bad line starting with 'remove'
+FATAL: Module foo not found." ]
+
+
diff --git a/tests/test-modprobe/10alias.sh b/tests/test-modprobe/10alias.sh
new file mode 100755 (executable)
index 0000000..c5abf43
--- /dev/null
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Test for modules.alias usage.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR/kernel
+ln tests/data/$BITNESS/alias/alias-$BITNESS.ko \
+   $MODULE_DIR/kernel
+
+SIZE=`wc -c < tests/data/$BITNESS/alias/alias-$BITNESS.ko`
+
+echo "/lib/modules/$MODTEST_UNAME/kernel/alias-$BITNESS.ko:" > $MODULE_DIR/modules.dep
+echo "/lib/modules/$MODTEST_UNAME/kernel/foo.ko:" >> $MODULE_DIR/modules.dep
+
+cp tests/data/$BITNESS/complex/complex_a-$BITNESS.ko $MODULE_DIR/kernel/foo.ko
+SIZE2=`wc -c < $MODULE_DIR/kernel/foo.ko`
+
+# Shouldn't complain if can't open modules.alias
+[ "`modprobe bar 2>&1`" = "FATAL: Module bar not found." ]
+
+# Now, alias found in modules.alias works.
+echo "alias bar alias-$BITNESS" > $MODULE_DIR/modules.alias
+[ "`modprobe bar 2>&1`" = "INIT_MODULE: $SIZE " ]
+
+# Normal alias should override it.
+mkdir -p tests/tmp/etc/modprobe.d
+echo 'alias bar foo' > tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe foo 2>&1`" = "INIT_MODULE: $SIZE2 " ]
+
+# If there's a real module, alias from modules.alias must NOT override.
+echo "alias foo alias-$BITNESS" > $MODULE_DIR/modules.alias
+[ "`modprobe foo 2>&1`" = "INIT_MODULE: $SIZE2 " ]
+
+# If there's an install command, modules.alias must not override.
+echo 'install bar echo foo' > tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe bar 2>&1`" = "SYSTEM: echo foo" ]
+echo 'remove bar echo foo remove' > tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe -r bar 2>&1`" = "SYSTEM: echo foo remove" ]
+
+# Should gather up options from other alias name as well.
+echo "alias bar alias-$BITNESS" > $MODULE_DIR/modules.alias
+echo "options bar option1" > tests/tmp/etc/modprobe.d/modprobe.conf
+echo "options alias-$BITNESS option2" >> tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe bar 2>&1`" = "INIT_MODULE: $SIZE option2 option1" ]
+
+# Duplicated alias: both get probed (either order)
+echo "alias bar foo" >> $MODULE_DIR/modules.alias
+OUT="`modprobe bar 2>&1`"
+
+[ "$OUT" = "INIT_MODULE: $SIZE option2 option1
+INIT_MODULE: $SIZE2 option1" ] || [ "$OUT" = "INIT_MODULE: $SIZE2 option1
+INIT_MODULE: $SIZE option2 option1" ]
diff --git a/tests/test-modprobe/11stripversions.sh b/tests/test-modprobe/11stripversions.sh
new file mode 100755 (executable)
index 0000000..1ad76ea
--- /dev/null
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Test the version removal code
+
+section_attributes()
+{
+    readelf -W -S "$1" | cut -d\] -f2- | awk '{print $1 " " $7}' | grep -w -- "$2"
+}
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# We need to dump the module to make sure the name has changed.
+MODTEST_DUMP_INIT=1
+export MODTEST_DUMP_INIT
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS$ENDIAN/rename/rename-version-$BITNESS.ko \
+   $MODULE_DIR
+
+# Set up modules.dep file (neither has dependencies).
+echo "# A comment" > $MODULE_DIR/modules.dep
+echo "/lib/modules/$MODTEST_UNAME/rename-version-$BITNESS.ko:" >> $MODULE_DIR/modules.dep
+
+# Check it without removing.
+[ "`modprobe rename-version-$BITNESS 2> tests/tmp/out`" = "" ]
+[ "`section_attributes tests/tmp/out __versions`" = "__versions A" ]
+[ "`section_attributes tests/tmp/out __vermagic`" = "__vermagic A" ]
+
+# Now remove them (turns off ALLOC bit)
+[ "`modprobe --force rename-version-$BITNESS 2> tests/tmp/out`" = "" ]
+[ "`section_attributes tests/tmp/out __versions`" = "__versions 0" ]
+[ "`section_attributes tests/tmp/out __vermagic`" = "__vermagic 0" ]
+
+# Now remove them individually instead.
+[ "`modprobe --force-vermagic rename-version-$BITNESS 2> tests/tmp/out`" = "" ]
+[ "`section_attributes tests/tmp/out __versions`" = "__versions A" ]
+[ "`section_attributes tests/tmp/out __vermagic`" = "__vermagic 0" ]
+[ "`modprobe --force-modversion rename-version-$BITNESS 2> tests/tmp/out`" = "" ]
+[ "`section_attributes tests/tmp/out __versions`" = "__versions 0" ]
+[ "`section_attributes tests/tmp/out __vermagic`" = "__vermagic A" ]
+
+done
+done
+
+exit 0
diff --git a/tests/test-modprobe/12whitespace.sh b/tests/test-modprobe/12whitespace.sh
new file mode 100755 (executable)
index 0000000..5a1d817
--- /dev/null
@@ -0,0 +1,204 @@
+#! /bin/sh
+# Test for spaces in configuration files: based on 04config.sh
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Simple dump out test.
+touch tests/tmp/empty
+[ "`modprobe -C /empty -c 2>&1`" = "" ]
+[ "`modprobe --config /empty --showconfig 2>&1`" = "" ]
+
+# Explicitly mentioned config files must exist.
+[ "`modprobe -C FILE-WHICH-DOESNT-EXIST foo 2>&1`" = "FATAL: Failed to open config file FILE-WHICH-DOESNT-EXIST: No such file or directory" ]
+
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+touch $MODULE_DIR/modules.dep
+
+[ "`modprobe foo 2>&1`" = "FATAL: Module foo not found." ]
+
+# Create a simple config file.
+mkdir -p tests/tmp/etc/modprobe.d
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+# Various aliases
+alias   alias_to_foo   foo
+alias   alias_to_bar   bar
+alias   alias_to_export_dep-$BITNESS   export_dep-$BITNESS
+alias   alias_to_noexport_dep-$BITNESS   noexport_dep-$BITNESS
+alias   alias_to_noexport_nodep-$BITNESS   noexport_nodep-$BITNESS
+alias   alias_to_noexport_doubledep-$BITNESS   noexport_doubledep-$BITNESS
+
+# Various options, including options to aliases.
+options   alias_to_export_dep-$BITNESS   I am alias to export_dep
+options   export_dep-$BITNESS   I am export_dep
+options   alias_to_noexport_dep-$BITNESS   I am alias to noexport_dep
+options   noexport_dep-$BITNESS   I am noexport_dep
+options   alias_to_noexport_nodep-$BITNESS   I am alias to noexport_nodep
+options   noexport_nodep-$BITNESS   I am noexport_nodep
+options   alias_to_noexport_doubledep-$BITNESS   I am alias to noexport_doubledep
+options   noexport_doubledep-$BITNESS   I am noexport_doubledep
+
+# Install commands
+install   bar   echo Installing   bar
+install   foo   echo Installing   foo
+install   export_nodep-$BITNESS   echo Installing   export_nodep
+
+# Remove commands
+remove   bar   echo Removing   bar
+remove   foo   echo Removing   foo
+remove   export_nodep-$BITNESS   echo Removing   export_nodep
+EOF
+
+# Now create this included file
+cat > tests/tmp/etc/modprobe.d/modprobe-include.conf <<EOF
+install   baz   echo Installing   baz
+remove   baz   echo Removing   baz
+
+alias   alias_to_baz   baz
+EOF
+
+# Create inputs
+ln tests/data/$BITNESS/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Now create modules.dep
+cat > $MODULE_DIR/modules.dep <<EOF
+noexport_nodep-$BITNESS.ko:
+noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko
+noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+export_nodep-$BITNESS.ko:
+export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+EOF
+
+SIZE_NOEXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+SIZE_EXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`
+SIZE_NOEXPORT_DEP=`wc -c < tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko`
+SIZE_EXPORT_DEP=`wc -c < tests/data/$BITNESS/normal/export_dep-$BITNESS.ko`
+SIZE_NOEXPORT_DOUBLEDEP=`wc -c < tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko`
+
+# Empty /sys/module/ for install commands
+mkdir -p tests/tmp/sys/module
+
+# Test ignoring install commands.
+[ "`modprobe --ignore-install export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
+[ "`modprobe -i export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
+[ "`modprobe -i foo 2>&1`" = "FATAL: Module foo not found." ]
+
+# Test install commands (fake modules)
+[ "`modprobe foo 2>&1`" = "SYSTEM: echo Installing   foo" ]
+[ "`modprobe bar 2>&1`" = "SYSTEM: echo Installing   bar" ]
+[ "`modprobe baz 2>&1`" = "SYSTEM: echo Installing   baz" ]
+
+# Test install of a what is also a real module.
+[ "`modprobe export_nodep-$BITNESS 2>&1`" = "SYSTEM: echo Installing   export_nodep" ]
+
+# Test install of what is also a real module via dependency.
+[ "`modprobe noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
+
+# Test ignoring install commands: only effects commandline.
+[ "`modprobe -i noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
+
+# Test options
+[ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep" ]
+[ "`modprobe noexport_nodep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep OPTIONS" ]
+
+[ "`modprobe noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
+[ "`modprobe noexport_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep OPTIONS" ]
+
+[ "`modprobe export_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep" ]
+[ "`modprobe export_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep OPTIONS" ]
+
+[ "`modprobe noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep" ]
+[ "`modprobe noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep OPTIONS" ]
+
+# Test aliases doing insertion.
+[ "`modprobe alias_to_noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep I am alias to noexport_nodep" ]
+[ "`modprobe alias_to_noexport_nodep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep I am alias to noexport_nodep OPTIONS" ]
+
+[ "`modprobe alias_to_noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep I am alias to noexport_dep" ]
+[ "`modprobe alias_to_noexport_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep I am alias to noexport_dep OPTIONS" ]
+
+[ "`modprobe alias_to_export_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep I am alias to export_dep" ]
+[ "`modprobe alias_to_export_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep I am alias to export_dep OPTIONS" ]
+
+[ "`modprobe alias_to_noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep" ]
+[ "`modprobe alias_to_noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep" ]
+[ "`modprobe alias_to_noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing   export_nodep
+INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep OPTIONS" ]
+
+[ "`modprobe alias_to_foo 2>&1`" = "SYSTEM: echo Installing   foo" ]
+[ "`modprobe alias_to_bar 2>&1`" = "SYSTEM: echo Installing   bar" ]
+[ "`modprobe alias_to_baz 2>&1`" = "SYSTEM: echo Installing   baz" ]
+
+# Populate /sys/module/ for remove commands
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_doubledep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_dep_$BITNESS
+echo live > tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_doubledep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_dep_$BITNESS/initstate
+
+# Test ignoring remove commands.
+
+[ "`modprobe -r --ignore-remove export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r -i export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
+[ "`modprobe -i -r foo 2>&1`" = "FATAL: Module foo not found." ]
+
+# Test remove commands (fake modules)
+[ "`modprobe -r foo 2>&1`" = "SYSTEM: echo Removing   foo" ]
+[ "`modprobe -r bar 2>&1`" = "SYSTEM: echo Removing   bar" ]
+[ "`modprobe -r baz 2>&1`" = "SYSTEM: echo Removing   baz" ]
+
+# Test remove of a what is also a real module.
+[ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "SYSTEM: echo Removing   export_nodep" ]
+
+# Test remove of what is also a real module via dependency.
+[ "`modprobe -r noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL 
+SYSTEM: echo Removing   export_nodep" ]
+
+# Test ignoring remove commands: only effects commandline.
+[ "`modprobe -r -i noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL 
+SYSTEM: echo Removing   export_nodep" ]
+
+# Test aliases doing removal.
+[ "`modprobe -r alias_to_noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+[ "`modprobe -r alias_to_noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL 
+SYSTEM: echo Removing   export_nodep" ]
+[ "`modprobe -r alias_to_export_dep-$BITNESS 2>&1`" = "DELETE_MODULE: export_dep_$BITNESS EXCL 
+SYSTEM: echo Removing   export_nodep" ]
+[ "`modprobe -r alias_to_noexport_doubledep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_doubledep_$BITNESS EXCL 
+DELETE_MODULE: export_dep_$BITNESS EXCL 
+SYSTEM: echo Removing   export_nodep" ]
+
+[ "`modprobe -r alias_to_foo 2>&1`" = "SYSTEM: echo Removing   foo" ]
+[ "`modprobe -r alias_to_bar 2>&1`" = "SYSTEM: echo Removing   bar" ]
+[ "`modprobe -r alias_to_baz 2>&1`" = "SYSTEM: echo Removing   baz" ]
diff --git a/tests/test-modprobe/13dryrun.sh b/tests/test-modprobe/13dryrun.sh
new file mode 100755 (executable)
index 0000000..04552d6
--- /dev/null
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Test module dependencies.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Now create modules.dep
+cat > $MODULE_DIR/modules.dep <<EOF
+# Should handle comments.
+noexport_nodep-$BITNESS.ko:
+noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko
+noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+export_nodep-$BITNESS.ko:
+export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+EOF
+
+[ "`modprobe -v -n noexport_nodep-$BITNESS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko " ]
+[ "`modprobe -v -n noexport_nodep-$BITNESS OPTIONS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko OPTIONS" ]
+
+[ "`modprobe -v -n export_nodep-$BITNESS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko " ]
+[ "`modprobe -v -n export_nodep-$BITNESS OPTIONS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko OPTIONS" ]
+
+[ "`modprobe -v -n noexport_dep-$BITNESS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/noexport_dep-$BITNESS.ko " ]
+[ "`modprobe -v -n noexport_dep-$BITNESS OPTIONS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/noexport_dep-$BITNESS.ko OPTIONS" ]
+
+[ "`modprobe -v -n export_dep-$BITNESS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko " ]
+[ "`modprobe -v -n export_dep-$BITNESS OPTIONS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko OPTIONS" ]
+
+[ "`modprobe -v -n noexport_doubledep-$BITNESS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/noexport_doubledep-$BITNESS.ko " ]
+[ "`modprobe -v -n noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/noexport_doubledep-$BITNESS.ko OPTIONS" ]
+
+# Test alias and options resolution
+mkdir -p tests/tmp/etc/modprobe.d
+echo "alias foo noexport_doubledep-$BITNESS" > tests/tmp/etc/modprobe.d/modprobe.conf
+echo "options noexport_doubledep-$BITNESS OPTIONS" >> tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe -v -n foo 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/noexport_doubledep-$BITNESS.ko OPTIONS" ]
+
+# Now make a fake /sys/module structure for the test
+mkdir -p tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_doubledep_$BITNESS
+echo live > tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_doubledep_$BITNESS/initstate
+
+# Removal
+[ "`modprobe -v -n -r noexport_nodep-$BITNESS 2>&1`" = "rmmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko" ]
+[ "`modprobe -v -n -r export_nodep-$BITNESS 2>&1`" = "rmmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko" ]
+[ "`modprobe -v -n -r noexport_dep-$BITNESS 2>&1`" = "rmmod /lib/modules/$MODTEST_UNAME/noexport_dep-$BITNESS.ko
+rmmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko" ]
+[ "`modprobe -v -n -r export_dep-$BITNESS 2>&1`" = "rmmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko
+rmmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko" ]
+[ "`modprobe -v -n -r noexport_doubledep-$BITNESS 2>&1`" = "rmmod /lib/modules/$MODTEST_UNAME/noexport_doubledep-$BITNESS.ko
+rmmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko
+rmmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko" ]
diff --git a/tests/test-modprobe/15env.sh b/tests/test-modprobe/15env.sh
new file mode 100755 (executable)
index 0000000..461e34a
--- /dev/null
@@ -0,0 +1,56 @@
+#! /bin/sh
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Now create modules.dep and modules.conf
+echo /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko: > $MODULE_DIR/modules.dep
+
+mkdir -p tests/tmp/etc/modprobe.d
+echo install foo modprobe noexport_nodep-$BITNESS > tests/tmp/etc/modprobe.d/modprobe.conf
+echo install foo modprobe bar > tests/tmp/etc/modprobe2.conf
+echo install bar echo DOING BAR >> tests/tmp/etc/modprobe2.conf
+
+SIZE_NOEXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+
+# Test normal args, then in env.
+[ "`modprobe -v noexport_nodep-$BITNESS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko 
+INIT_MODULE: $SIZE_NOEXPORT_NODEP " ]
+[ "`MODPROBE_OPTIONS=-v modprobe noexport_nodep-$BITNESS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko 
+INIT_MODULE: $SIZE_NOEXPORT_NODEP " ]
+
+[ "`modprobe -q noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP " ]
+[ "`MODPROBE_OPTIONS=-q modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP " ]
+
+[ "`modprobe -n noexport_nodep-$BITNESS 2>&1`" = "" ]
+[ "`MODPROBE_OPTIONS=-n modprobe noexport_nodep-$BITNESS 2>&1`" = "" ]
+
+[ "`modprobe -n -v noexport_nodep-$BITNESS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko " ]
+[ "`MODPROBE_OPTIONS="-n -v" modprobe noexport_nodep-$BITNESS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko " ]
+
+# Test argument inheritence.
+MODTEST_DO_SYSTEM=1
+export MODTEST_DO_SYSTEM
+
+[ "`modprobe -v foo 2>&1`" = "install modprobe noexport_nodep-$BITNESS
+insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko 
+INIT_MODULE: $SIZE_NOEXPORT_NODEP " ]
+[ "`MODPROBE_OPTIONS=-v modprobe foo 2>&1`" = "install modprobe noexport_nodep-$BITNESS
+insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko 
+INIT_MODULE: $SIZE_NOEXPORT_NODEP " ]
+
+[ "`modprobe -C /etc/modprobe2.conf foo 2>&1`" = "DOING BAR" ]
+[ "`MODPROBE_OPTIONS='-C /etc/modprobe2.conf' modprobe foo 2>&1`" = "DOING BAR" ]
+
+[ "`modprobe -C /etc/modprobe2.conf -v foo 2>&1`" = "install modprobe bar
+install echo DOING BAR
+DOING BAR" ]
+[ "`MODPROBE_OPTIONS='-C /etc/modprobe2.conf' modprobe -v foo 2>&1`" = "install modprobe bar
+install echo DOING BAR
+DOING BAR" ]
diff --git a/tests/test-modprobe/16showdepends.sh b/tests/test-modprobe/16showdepends.sh
new file mode 100755 (executable)
index 0000000..1d7b00c
--- /dev/null
@@ -0,0 +1,113 @@
+#! /bin/sh
+# Test --show-depends.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Now create modules.dep
+cat > $MODULE_DIR/modules.dep <<EOF
+# Should handle comments.
+/lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko:
+/lib/modules/$MODTEST_UNAME/noexport_doubledep-$BITNESS.ko: /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko
+/lib/modules/$MODTEST_UNAME/noexport_dep-$BITNESS.ko: /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko
+/lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko:
+/lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko: /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko
+EOF
+
+[ "`modprobe --show-depends noexport_nodep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko " ]
+[ "`modprobe --show-depends export_nodep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko " ]
+[ "`modprobe --show-depends noexport_dep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/noexport_dep-$BITNESS.ko " ]
+[ "`modprobe --show-depends export_dep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko " ]
+[ "`modprobe --show-depends noexport_doubledep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/noexport_doubledep-$BITNESS.ko " ]
+
+# Nothing in stderr...
+[ `wc -c < tests/tmp/stderr` = 0 ]
+
+# All in /sys/module/; should make no difference.
+mkdir -p tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+echo live > tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+
+[ "`modprobe --show-depends noexport_nodep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko " ]
+[ "`modprobe --show-depends export_nodep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko " ]
+[ "`modprobe --show-depends noexport_dep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/noexport_dep-$BITNESS.ko " ]
+[ "`modprobe --show-depends export_dep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko " ]
+[ "`modprobe --show-depends noexport_doubledep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko 
+insmod /lib/modules/$MODTEST_UNAME/noexport_doubledep-$BITNESS.ko " ]
+
+# Nothing in stderr...
+[ `wc -c < tests/tmp/stderr` = 0 ]
+
+# Module commands printed, ignored.
+mkdir -p tests/tmp/etc/modprobe.d
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+install noexport_nodep-$BITNESS echo noexport_nodep-$BITNESS
+install export_nodep-$BITNESS echo export_nodep-$BITNESS
+install noexport_dep-$BITNESS echo noexport_dep-$BITNESS
+install export_dep-$BITNESS echo export_dep-$BITNESS
+install noexport_doubledep-$BITNESS echo noexport_doubledep-$BITNESS
+EOF
+
+[ "`modprobe --show-depends noexport_nodep-$BITNESS 2>>tests/tmp/stderr`" = "install echo noexport_nodep-$BITNESS" ]
+[ "`modprobe --show-depends export_nodep-$BITNESS 2>>tests/tmp/stderr`" = "install echo export_nodep-$BITNESS" ]
+[ "`modprobe --show-depends noexport_dep-$BITNESS 2>>tests/tmp/stderr`" = "install echo export_nodep-$BITNESS
+install echo noexport_dep-$BITNESS" ]
+[ "`modprobe --show-depends export_dep-$BITNESS 2>>tests/tmp/stderr`" = "install echo export_nodep-$BITNESS
+install echo export_dep-$BITNESS" ]
+[ "`modprobe --show-depends noexport_doubledep-$BITNESS 2>>tests/tmp/stderr`" = "install echo export_nodep-$BITNESS
+install echo export_dep-$BITNESS
+install echo noexport_doubledep-$BITNESS" ]
+# Nothing in stderr...
+[ `wc -c < tests/tmp/stderr` = 0 ]
+
+# Module options printed.
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+options noexport_nodep-$BITNESS opt1
+options export_nodep-$BITNESS opt2
+options noexport_dep-$BITNESS opt3
+options export_dep-$BITNESS opt4
+options noexport_doubledep-$BITNESS opt5
+EOF
+
+[ "`modprobe --show-depends noexport_nodep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko opt1" ]
+[ "`modprobe --show-depends export_nodep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko opt2" ]
+[ "`modprobe --show-depends noexport_dep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko opt2
+insmod /lib/modules/$MODTEST_UNAME/noexport_dep-$BITNESS.ko opt3" ]
+[ "`modprobe --show-depends export_dep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko opt2
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko opt4" ]
+[ "`modprobe --show-depends noexport_doubledep-$BITNESS 2>>tests/tmp/stderr`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko opt2
+insmod /lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko opt4
+insmod /lib/modules/$MODTEST_UNAME/noexport_doubledep-$BITNESS.ko opt5" ]
+# Nothing in stderr...
+[ `wc -c < tests/tmp/stderr` = 0 ]
+
+# Via aliases works.
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+options noexport_nodep-$BITNESS opt1
+alias foo noexport_nodep-$BITNESS
+options foo fooopt
+EOF
+
+[ "`modprobe --show-depends foo`" = "insmod /lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko opt1 fooopt" ]
+# Nothing in stderr...
+[ `wc -c < tests/tmp/stderr` = 0 ]
diff --git a/tests/test-modprobe/17compressed.sh b/tests/test-modprobe/17compressed.sh
new file mode 100755 (executable)
index 0000000..da92036
--- /dev/null
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Test compressed modules.
+
+[ -n "$CONFIG_HAVE_ZLIB" ] || exit 0
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Copy modules instead of linking, so we can compress them
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+cp tests/data/$BITNESS$ENDIAN/normal/noexport_nodep-$BITNESS.ko \
+   $MODULE_DIR
+
+gzip $MODULE_DIR/noexport_nodep-$BITNESS.ko
+
+# Set up modules.dep file.
+echo "# A comment" > $MODULE_DIR/modules.dep
+echo "/lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko.gz:" >> $MODULE_DIR/modules.dep
+
+SIZE=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+
+# No args
+[ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE " ]
+
+# With args
+[ "`modprobe noexport_nodep-$BITNESS foo=\"bar baz\" 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
+
+# Check underscore equivalence.
+[ "`modprobe noexport-nodep-$BITNESS foo=\"bar baz\" 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
+[ "`modprobe noexport-nodep_$BITNESS foo=\"bar baz\" 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
+[ "`modprobe noexport_nodep_$BITNESS foo=\"bar baz\" 2>&1`" = "INIT_MODULE: $SIZE foo=\"bar baz\"" ]
+
+done
+done
diff --git a/tests/test-modprobe/18multiremove.sh b/tests/test-modprobe/18multiremove.sh
new file mode 100755 (executable)
index 0000000..296536d
--- /dev/null
@@ -0,0 +1,43 @@
+#! /bin/sh
+# modprobe -r supports multiple module names now.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Now create modules.dep
+cat > $MODULE_DIR/modules.dep <<EOF
+# Should handle comments.
+noexport_nodep-$BITNESS.ko:
+noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko
+noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+export_nodep-$BITNESS.ko:
+export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+EOF
+
+# Now make a fake /sys/module structure for the test
+mkdir -p tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_doubledep_$BITNESS
+echo live > tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_doubledep_$BITNESS/initstate
+
+# Removal
+[ "`modprobe -r noexport_nodep-$BITNESS export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL 
+DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
diff --git a/tests/test-modprobe/19quiet.sh b/tests/test-modprobe/19quiet.sh
new file mode 100755 (executable)
index 0000000..da96580
--- /dev/null
@@ -0,0 +1,79 @@
+#! /bin/sh
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Set up modules.dep file.
+echo "# A comment" > $MODULE_DIR/modules.dep
+echo "noexport_nodep-$BITNESS.ko:" >> $MODULE_DIR/modules.dep
+echo "bogus-$BITNESS.ko:" >> $MODULE_DIR/modules.dep
+
+mkdir -p tests/tmp/etc/modprobe.d
+echo "install some-command modprobe crap && echo SUCCESS" > tests/tmp/etc/modprobe.d/modprobe.conf 
+echo "remove some-command modprobe -r crap && echo SUCCESS" >> tests/tmp/etc/modprobe.d/modprobe.conf 
+echo "alias foobar crap" >> tests/tmp/etc/modprobe.d/modprobe.conf 
+
+SIZE=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+
+# -q works as normal.
+[ "`modprobe -q noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE " ]
+
+# -q on non-existent fail, quietly.
+[ "`modprobe -q crap 2>&1`" = "" ]
+if modprobe -q crap; then exit 1; fi
+
+# -q on alias to non-existent succeeds, quietly.
+[ "`modprobe -q foobar 2>&1`" = "" ]
+if modprobe -q foobar; then exit 1; fi
+
+# -q on some other problem gives errors.
+[ "`modprobe -q bogus-$BITNESS 2>&1`" != "" ]
+if modprobe -q bogus-$BITNESS 2>/dev/null; then exit 1; fi
+
+MODTEST_DO_SYSTEM=1
+export MODTEST_DO_SYSTEM
+# Normal install command will fail.
+[ "`modprobe some-command 2>&1`" = "FATAL: Module crap not found.
+FATAL: Error running install command for some_command" ]
+if modprobe some-command 2>/dev/null; then exit 1; fi
+
+# -q doesn't cause "modprobe crap" to succeed, but is passed through install.
+[ "`modprobe -q some-command 2>&1`" = "FATAL: Error running install command for some_command" ]
+if modprobe -q some-command 2>/dev/null; then exit 1; fi
+
+# Now make a fake /sys/module structure for the test
+mkdir -p tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+mkdir -p tests/tmp/sys/module/export_dep_$BITNESS
+mkdir -p tests/tmp/sys/module/noexport_doubledep_$BITNESS
+echo live > tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/export_dep_$BITNESS/initstate
+echo live > tests/tmp/sys/module/noexport_doubledep_$BITNESS/initstate
+
+# -q works as normal.
+[ "`modprobe -r -q noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
+
+# -q on non-existent module fails, silently.
+[ "`modprobe -r -q crap 2>&1`" = "" ]
+if modprobe -r -q crap; then exit 1; fi
+
+MODTEST_DO_SYSTEM=1
+export MODTEST_DO_SYSTEM
+# Normal remove command will fail.
+[ "`modprobe -r some-command 2>&1`" = "FATAL: Module crap not found.
+FATAL: Error running remove command for some_command" ]
+if modprobe -r some-command 2>/dev/null; then exit 1; fi
+
+# -q doesn't cause "modprobe -r crap" to succeed, but silences it.
+[ "`modprobe -r -q some-command 2>&1`" = "FATAL: Error running remove command for some_command" ]
+if modprobe -r -q some-command 2>/dev/null; then exit 1; fi
diff --git a/tests/test-modprobe/20oldstyle.sh b/tests/test-modprobe/20oldstyle.sh
new file mode 100755 (executable)
index 0000000..5e898dc
--- /dev/null
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Test old-style module crap.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR/drivers/type
+ln tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   $MODULE_DIR/drivers/type
+
+mkdir -p $MODULE_DIR/other/type
+ln tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   $MODULE_DIR/other/type
+
+# Set up modules.dep file.
+echo "# A comment" > $MODULE_DIR/modules.dep
+echo "/lib/modules/$MODTEST_UNAME/drivers/type/noexport_nodep-$BITNESS.ko:" >> $MODULE_DIR/modules.dep
+echo "/lib/modules/$MODTEST_UNAME/other/type/export_nodep-$BITNESS.ko:" >> $MODULE_DIR/modules.dep
+
+SIZE1=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
+SIZE2=`wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`
+
+# -l lists all of them (either order)
+[ "`modprobe -l 2>&1`" = "/lib/modules/$MODTEST_UNAME/drivers/type/noexport_nodep-$BITNESS.ko
+/lib/modules/$MODTEST_UNAME/other/type/export_nodep-$BITNESS.ko" ] ||
+[ "`modprobe -l 2>&1`" = "/lib/modules/$MODTEST_UNAME/other/type/export_nodep-$BITNESS.ko
+/lib/modules/$MODTEST_UNAME/drivers/type/noexport_nodep-$BITNESS.ko" ]
+
+# -l -t foo lists none of them.
+[ "`modprobe -l -t foo 2>&1`" = "" ]
+
+# -l -t type lists all of them (either order)
+[ "`modprobe -l -t type 2>&1`" = "/lib/modules/$MODTEST_UNAME/drivers/type/noexport_nodep-$BITNESS.ko
+/lib/modules/$MODTEST_UNAME/other/type/export_nodep-$BITNESS.ko" ] ||
+[ "`modprobe -l -t type 2>&1`" = "/lib/modules/$MODTEST_UNAME/other/type/export_nodep-$BITNESS.ko
+/lib/modules/$MODTEST_UNAME/drivers/type/noexport_nodep-$BITNESS.ko" ]
+
+# -l -t drivers lists one.
+[ "`modprobe -l -t drivers 2>&1`" = "/lib/modules/$MODTEST_UNAME/drivers/type/noexport_nodep-$BITNESS.ko" ]
+
+# -l -t drivers/type lists one.
+[ "`modprobe -l -t drivers/type 2>&1`" = "/lib/modules/$MODTEST_UNAME/drivers/type/noexport_nodep-$BITNESS.ko" ]
+
+# -l -t other lists one.
+[ "`modprobe -l -t other 2>&1`" = "/lib/modules/$MODTEST_UNAME/other/type/export_nodep-$BITNESS.ko" ]
+
+# -l -t other/type lists one.
+[ "`modprobe -l -t other/type 2>&1`" = "/lib/modules/$MODTEST_UNAME/other/type/export_nodep-$BITNESS.ko" ]
+
+# Wildcard works.
+[ "`modprobe -l -t type 'noexport-nodep*' 2>&1`" = "/lib/modules/$MODTEST_UNAME/drivers/type/noexport_nodep-$BITNESS.ko" ]
+
+# -t type without -l not supported
+modprobe -t type 2>&1 | grep -q Usage
+modprobe -a -t type 2>&1 | grep -q Usage
+
+# -a with one arg succeeds.
+[ "`modprobe -a noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE1 " ]
+# ... even with - and _ confused.
+[ "`modprobe -a noexport-nodep_$BITNESS 2>&1`" = "INIT_MODULE: $SIZE1 " ]
+
+# With two args succeeds.
+[ "`modprobe -a noexport_nodep-$BITNESS export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE1 
+INIT_MODULE: $SIZE2 " ]
+
+# Does second even if first screws up.
+[ "`modprobe -a crap export_nodep-$BITNESS 2>&1`" = "WARNING: Module crap not found.
+INIT_MODULE: $SIZE2 " ]
diff --git a/tests/test-modprobe/21wildinstall.sh b/tests/test-modprobe/21wildinstall.sh
new file mode 100755 (executable)
index 0000000..18b1913
--- /dev/null
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Test wildcard install/remove commands.
+
+rm -rf tests/tmp/*
+
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+touch $MODULE_DIR/modules.dep
+
+MODTEST_DO_SYSTEM=1
+export MODTEST_DO_SYSTEM
+
+# Create a simple config file.
+mkdir -p tests/tmp/etc/modprobe.d
+cat > tests/tmp/etc/modprobe.d/modprobe.conf <<EOF
+# Various aliases
+install *wildcard-_* echo installing \$MODPROBE_MODULE.
+remove *wildcard-_* echo removing \$MODPROBE_MODULE.
+EOF
+
+# Install...
+[ "`modprobe wildcard-_aaa 2>&1`" = "installing wildcard__aaa." ]
+[ "`modprobe wildcard-_ 2>&1`" = "installing wildcard__." ]
+[ "`modprobe wildcard_- 2>&1`" = "installing wildcard__." ]
+[ "`modprobe anotherwildcard-_ 2>&1`" = "installing anotherwildcard__." ]
+[ "`modprobe anotherwildcard-_aaa 2>&1`" = "installing anotherwildcard__aaa." ]
+
+# Remove...
+[ "`modprobe -r wildcard-_aaa 2>&1`" = "removing wildcard__aaa." ]
+[ "`modprobe -r wildcard-_ 2>&1`" = "removing wildcard__." ]
+[ "`modprobe -r wildcard_- 2>&1`" = "removing wildcard__." ]
+[ "`modprobe -r anotherwildcard-_ 2>&1`" = "removing anotherwildcard__." ]
+[ "`modprobe -r anotherwildcard-_aaa 2>&1`" = "removing anotherwildcard__aaa." ]
diff --git a/tests/test-modprobe/22recursiveinstall.sh b/tests/test-modprobe/22recursiveinstall.sh
new file mode 100755 (executable)
index 0000000..53b0c60
--- /dev/null
@@ -0,0 +1,61 @@
+#! /bin/sh
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Now create modules.dep
+cat > $MODULE_DIR/modules.dep <<EOF
+noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
+export_nodep-$BITNESS.ko:
+EOF
+
+# Insertion
+SIZE_EXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`
+SIZE_NOEXPORT_DEP=`wc -c < tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko`
+
+# Empty /sys/module/
+mkdir -p tests/tmp/sys/module
+
+# Check it pulls in both.
+[ "`modprobe noexport_dep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+INIT_MODULE: $SIZE_NOEXPORT_DEP " ]
+
+# Check it's happy if we tell it dep is already installed
+mkdir -p tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+echo "live" >tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+
+[ "`modprobe noexport_dep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_DEP " ]
+
+# If there's an install command, it will be done.
+# Clean up sysfs (so we don't think it's loaded)
+rm -rf tests/tmp/sys/module/*
+
+mkdir -p tests/tmp/etc/modprobe.d
+echo "install export_nodep-$BITNESS COMMAND" > tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe noexport_dep-$BITNESS 2>&1`" = "SYSTEM: COMMAND
+INIT_MODULE: $SIZE_NOEXPORT_DEP " ]
+
+# If it's in /sys/module, install command WONT be done.
+mkdir -p tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
+echo "live" >tests/tmp/sys/module/export_nodep_$BITNESS/initstate
+
+[ "`modprobe noexport_dep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_DEP " ]
+
+# Do dependencies even if install command.
+# clean up sysfs (so we don't think it's loaded)
+rm -rf tests/tmp/sys/module/*
+
+echo "install noexport_dep-$BITNESS COMMAND" > tests/tmp/etc/modprobe.d/modprobe.conf
+
+[ "`modprobe noexport_dep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP 
+SYSTEM: COMMAND" ]
diff --git a/tests/test-modprobe/23recursive-deps.sh b/tests/test-modprobe/23recursive-deps.sh
new file mode 100755 (executable)
index 0000000..f425e9b
--- /dev/null
@@ -0,0 +1,38 @@
+#! /bin/sh
+
+# If A depends on B and C, and B is installed, C still needs to be installed!
+# (Bug in 3.0-pre6 & 3.0-pre7).
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/export_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Now create modules.dep
+cat > $MODULE_DIR/modules.dep <<EOF
+# Should handle comments.
+noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko
+EOF
+
+# Now, export-dep is in /sys/module (actually this can't happen, since it
+# depends on export_nodep, but this is to test).
+mkdir -p tests/tmp/sys/module
+mkdir -p tests/tmp/sys/module/export_dep_$BITNESS
+echo "live" > tests/tmp/sys/module/export_dep_$BITNESS/initstate
+
+SIZE_EXPORT_NODEP=`wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`
+SIZE_NOEXPORT_DOUBLEDEP=`wc -c < tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko`
+
+[ "`modprobe -v noexport_doubledep-$BITNESS 2>&1`" = "insmod /lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko 
+INIT_MODULE: $SIZE_EXPORT_NODEP 
+insmod /lib/modules/$MODTEST_UNAME/noexport_doubledep-$BITNESS.ko 
+INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP " ]
diff --git a/tests/test-modprobe/26blacklist.sh b/tests/test-modprobe/26blacklist.sh
new file mode 100755 (executable)
index 0000000..482ee93
--- /dev/null
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Test for blacklist usage.
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+# Create inputs
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR/kernel
+ln tests/data/$BITNESS/alias/alias-$BITNESS.ko \
+   $MODULE_DIR/kernel
+
+SIZE=`wc -c < tests/data/$BITNESS/alias/alias-$BITNESS.ko`
+
+echo "/lib/modules/$MODTEST_UNAME/kernel/alias-$BITNESS.ko:" > $MODULE_DIR/modules.dep
+echo "/lib/modules/$MODTEST_UNAME/kernel/foo.ko:" >> $MODULE_DIR/modules.dep
+cp tests/data/$BITNESS/complex/complex_a-$BITNESS.ko $MODULE_DIR/kernel/foo.ko
+SIZE2=`wc -c < $MODULE_DIR/kernel/foo.ko`
+
+# First, alias found in modules.alias works.
+echo "alias bar alias-$BITNESS" > $MODULE_DIR/modules.alias
+[ "`modprobe bar 2>&1`" = "INIT_MODULE: $SIZE " ]
+
+# Blacklist makes it fail.
+mkdir -p tests/tmp/etc/modprobe.d
+echo "blacklist alias-$BITNESS" > tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe bar 2>&1`" = "FATAL: Module bar not found." ]
+
+# Blacklist doesn't effect other aliases.
+echo "alias bar foo" >> $MODULE_DIR/modules.alias
+[ "`modprobe bar 2>&1`" = "INIT_MODULE: $SIZE2 " ]
+
+# Blacklist both.
+echo "blacklist foo" >> tests/tmp/etc/modprobe.d/modprobe.conf
+[ "`modprobe bar 2>&1`" = "FATAL: Module bar not found." ]
+
+# Remove blacklist, all works.
+rm -f tests/tmp/etc/modprobe.d/modprobe.conf
+RESULT="`modprobe bar 2>&1`"
+[ "$RESULT" = "INIT_MODULE: $SIZE 
+INIT_MODULE: $SIZE2 " ] || [ "$RESULT" = "INIT_MODULE: $SIZE2
+INIT_MODULE: $SIZE " ]
diff --git a/tests/test-modprobe/27cmdline-install-remove.sh b/tests/test-modprobe/27cmdline-install-remove.sh
new file mode 100755 (executable)
index 0000000..9411222
--- /dev/null
@@ -0,0 +1,33 @@
+#! /bin/sh
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko \
+   $MODULE_DIR
+
+# Set up modules.dep file.
+echo "# A comment" > $MODULE_DIR/modules.dep
+echo "/lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko:" >> $MODULE_DIR/modules.dep
+
+# Set up modprobe.conf file: one at end, one with text either side.
+mkdir -p tests/tmp/etc/modprobe.d
+echo "options noexport_nodep-$BITNESS file-options" > tests/tmp/etc/modprobe.d/modprobe.conf
+echo "install noexport_nodep-$BITNESS modprobe --ignore-install noexport_nodep-$BITNESS \$CMDLINE_OPTS" >> tests/tmp/etc/modprobe.d/modprobe.conf
+echo "install othertarget echo \$CMDLINE_OPTS otheropts" >> tests/tmp/etc/modprobe.d/modprobe.conf
+
+# Empty /sys/module/ for install commands
+mkdir -p tests/tmp/sys/module
+
+# With quoted args
+[ "`modprobe noexport_nodep-$BITNESS 'foo="bar baz"' 2>&1`" = "SYSTEM: modprobe --ignore-install noexport_nodep-$BITNESS foo=\"bar baz\"" ]
+# With unquoted args
+[ "`modprobe noexport_nodep-$BITNESS foo=\"bar baz\" 2>&1`" = "SYSTEM: modprobe --ignore-install noexport_nodep-$BITNESS foo=\"bar baz\"" ]
+
+# Same with other target.
+[ "`modprobe othertarget 'foo="bar baz"' 2>&1`" = "SYSTEM: echo foo=\"bar baz\" otheropts" ]
+# With unquoted args
+[ "`modprobe othertarget foo=\"bar baz\" 2>&1`" = "SYSTEM: echo foo=\"bar baz\" otheropts" ]
diff --git a/tests/test-modprobe/28softdep.sh b/tests/test-modprobe/28softdep.sh
new file mode 100644 (file)
index 0000000..234a214
--- /dev/null
@@ -0,0 +1,67 @@
+#! /bin/sh
+
+BITNESS=32
+
+rm -rf tests/tmp/*
+
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+
+# Set up modules
+mkdir -p $MODULE_DIR
+ln tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko $MODULE_DIR/a.ko
+ln -s a.ko $MODULE_DIR/b.ko
+ln -s a.ko $MODULE_DIR/c.ko
+ln -s a.ko $MODULE_DIR/d.ko
+ln -s a.ko $MODULE_DIR/e.ko
+ln -s a.ko $MODULE_DIR/f.ko
+
+# Set up dependencies
+cat > $MODULE_DIR/modules.dep << EOF
+/lib/modules/$MODTEST_UNAME/a.ko:
+/lib/modules/$MODTEST_UNAME/b.ko:
+/lib/modules/$MODTEST_UNAME/c.ko:
+/lib/modules/$MODTEST_UNAME/d.ko:
+/lib/modules/$MODTEST_UNAME/e.ko:
+/lib/modules/$MODTEST_UNAME/f.ko:
+EOF
+
+# Test softdeps
+
+mkdir -p tests/tmp/etc/modprobe.d
+cat > tests/tmp/etc/modprobe.d/modprobe.conf << EOF
+alias a_alias a
+alias c_alias c
+softdep c pre: a_alias b post: d e
+softdep e post: f
+softdep f pre: a
+EOF
+
+# Insert-test
+
+R1=`modprobe -v c_alias 2>&1 | \
+       grep -v INIT_MODULE\: | \
+       sed -e "s/\/lib\/modules\/$MODTEST_UNAME\///g"`
+R2=`echo $R1`  # remove newlines
+[ "$R2" = "insmod a.ko insmod b.ko insmod c.ko insmod d.ko insmod e.ko insmod a.ko insmod f.ko" ]
+
+# Remove-test
+
+R1=`modprobe -v -r c_alias 2>&1 | \
+       grep -v DELETE_MODULE\: | \
+       sed -e "s/\/lib\/modules\/$MODTEST_UNAME\///g"`
+R2=`echo $R1`  # remove newlines
+[ "$R2" = "rmmod f.ko rmmod a.ko rmmod e.ko rmmod d.ko rmmod c.ko rmmod b.ko rmmod a.ko" ]
+
+# Test loop detector
+
+mkdir -p tests/tmp/etc/modprobe.d
+cat > tests/tmp/etc/modprobe.d/modprobe.conf << EOF
+alias a_alias a
+softdep a pre: b
+softdep b pre: a
+EOF
+
+R1=`modprobe -v a_alias 2>&1 | cat` # shell won't assign to R1 without no-op cat.
+# This comparison will fail if MAX_RECURSION is odd. In that case: s/b/a/g
+[ "$R1" = "FATAL: modprobe: softdep dependency loop encountered inserting b" ]
+
diff --git a/tests/test-rmmod/02namefix.sh b/tests/test-rmmod/02namefix.sh
new file mode 100755 (executable)
index 0000000..08eb02e
--- /dev/null
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+mkdir -p tests/tmp/proc
+
+# Old style
+echo 'foo_bar 100 0' > tests/tmp/proc/modules
+
+[ "`rmmod foo_bar`" = "DELETE_MODULE: foo_bar EXCL NONBLOCK " ]
+
+[ "`rmmod /lib/modules/$MODTEST_UNAME/kernel/foo_bar.o`" = "DELETE_MODULE: foo_bar EXCL NONBLOCK " ]
+
+[ "`rmmod /lib/modules/$MODTEST_UNAME/kernel/foo_bar.ko`" = "DELETE_MODULE: foo_bar EXCL NONBLOCK " ]
+
+[ "`rmmod /lib/modules/$MODTEST_UNAME/kernel/foo-bar.ko`" = "DELETE_MODULE: foo_bar EXCL NONBLOCK " ]
+
+[ "`rmmod foo-bar`" = "DELETE_MODULE: foo_bar EXCL NONBLOCK " ]
diff --git a/tests/test-rmmod/03inuse.sh b/tests/test-rmmod/03inuse.sh
new file mode 100755 (executable)
index 0000000..5d5ae1a
--- /dev/null
@@ -0,0 +1,50 @@
+#! /bin/sh
+
+mkdir -p tests/tmp/proc
+
+# Old style
+echo 'foo_bar 100 1' > tests/tmp/proc/modules
+
+[ "`rmmod foo_bar 2>&1`" = "ERROR: Module foo_bar is in use" ]
+[ "`rmmod foo-bar 2>&1`" = "ERROR: Module foo_bar is in use" ]
+
+# Old style with dependencies
+echo 'foo_bar 100 1 dep1' > tests/tmp/proc/modules
+
+[ "`rmmod foo_bar 2>&1`" = "ERROR: Module foo_bar is in use by dep1" ]
+[ "`rmmod foo-bar 2>&1`" = "ERROR: Module foo_bar is in use by dep1" ]
+
+echo 'foo_bar 100 1 dep1 dep2' > tests/tmp/proc/modules
+
+[ "`rmmod foo_bar 2>&1`" = "ERROR: Module foo_bar is in use by dep1 dep2" ]
+[ "`rmmod foo-bar 2>&1`" = "ERROR: Module foo_bar is in use by dep1 dep2" ]
+
+# New style
+echo 'foo_bar 100 1 -' > tests/tmp/proc/modules
+
+[ "`rmmod foo_bar 2>&1`" = "ERROR: Module foo_bar is in use" ]
+[ "`rmmod foo-bar 2>&1`" = "ERROR: Module foo_bar is in use" ]
+
+echo 'foo_bar 100 1 a,' > tests/tmp/proc/modules
+
+[ "`rmmod foo_bar 2>&1`" = "ERROR: Module foo_bar is in use by a" ]
+[ "`rmmod foo-bar 2>&1`" = "ERROR: Module foo_bar is in use by a" ]
+
+echo 'foo_bar 100 1 a,b,' > tests/tmp/proc/modules
+
+[ "`rmmod foo_bar 2>&1`" = "ERROR: Module foo_bar is in use by a,b" ]
+[ "`rmmod foo-bar 2>&1`" = "ERROR: Module foo_bar is in use by a,b" ]
+
+echo 'foo_bar 100 1 a,b, newoption' > tests/tmp/proc/modules
+
+[ "`rmmod foo_bar 2>&1`" = "ERROR: Module foo_bar is in use by a,b" ]
+[ "`rmmod foo-bar 2>&1`" = "ERROR: Module foo_bar is in use by a,b" ]
+
+# Not in use (newstyle)
+echo 'foo_bar 100 0 -' > tests/tmp/proc/modules
+[ "`rmmod foo_bar`" = "DELETE_MODULE: foo_bar EXCL NONBLOCK " ]
+[ "`rmmod foo-bar`" = "DELETE_MODULE: foo_bar EXCL NONBLOCK " ]
+
+echo 'foo_bar 100 0 - newoption' > tests/tmp/proc/modules
+[ "`rmmod foo_bar`" = "DELETE_MODULE: foo_bar EXCL NONBLOCK " ]
+[ "`rmmod foo-bar`" = "DELETE_MODULE: foo_bar EXCL NONBLOCK " ]
diff --git a/tests/test-rmmod/04flags.sh b/tests/test-rmmod/04flags.sh
new file mode 100755 (executable)
index 0000000..e3bdbce
--- /dev/null
@@ -0,0 +1,26 @@
+#! /bin/sh
+
+mkdir -p tests/tmp/proc
+
+# Old style
+echo 'foo_bar 100 0' > tests/tmp/proc/modules
+
+[ "`rmmod -f foo_bar`" = "DELETE_MODULE: foo_bar EXCL TRUNC NONBLOCK " ]
+[ "`rmmod -f foo-bar`" = "DELETE_MODULE: foo_bar EXCL TRUNC NONBLOCK " ]
+
+[ "`rmmod -f /lib/modules/$MODTEST_UNAME/kernel/foo_bar.o`" = "DELETE_MODULE: foo_bar EXCL TRUNC NONBLOCK " ]
+[ "`rmmod -f /lib/modules/$MODTEST_UNAME/kernel/foo_bar.ko`" = "DELETE_MODULE: foo_bar EXCL TRUNC NONBLOCK " ]
+[ "`rmmod -f /lib/modules/$MODTEST_UNAME/kernel/foo-bar.ko`" = "DELETE_MODULE: foo_bar EXCL TRUNC NONBLOCK " ]
+
+[ "`rmmod -w foo_bar`" = "DELETE_MODULE: foo_bar EXCL " ]
+[ "`rmmod -w foo-bar`" = "DELETE_MODULE: foo_bar EXCL " ]
+
+[ "`rmmod -w /lib/modules/$MODTEST_UNAME/kernel/foo_bar.o`" = "DELETE_MODULE: foo_bar EXCL " ]
+[ "`rmmod -w /lib/modules/$MODTEST_UNAME/kernel/foo_bar.ko`" = "DELETE_MODULE: foo_bar EXCL " ]
+[ "`rmmod -w /lib/modules/$MODTEST_UNAME/kernel/foo-bar.ko`" = "DELETE_MODULE: foo_bar EXCL " ]
+
+# Both should work on "in-use" modules.
+echo 'foo_bar 100 1' > tests/tmp/proc/modules
+
+[ "`rmmod -f foo_bar`" = "DELETE_MODULE: foo_bar EXCL TRUNC NONBLOCK " ]
+[ "`rmmod -w foo_bar`" = "DELETE_MODULE: foo_bar EXCL " ]
diff --git a/tests/test-rmmod/05noproc.sh b/tests/test-rmmod/05noproc.sh
new file mode 100755 (executable)
index 0000000..a03c733
--- /dev/null
@@ -0,0 +1,17 @@
+#! /bin/sh
+
+mkdir -p tests/tmp/proc
+
+# We allow this in case proc is not mounted.
+[ "`rmmod foo_bar`" = "DELETE_MODULE: foo_bar EXCL NONBLOCK " ]
+
+# We don't allow any other errors.  Doesn't work if we're root.
+if [ `id -u` -ne 0 ]; then
+    touch tests/tmp/proc/modules
+    chmod 000 tests/tmp/proc/modules
+
+    [ "`rmmod foo_bar 2>&1`" = "FATAL: can't open /proc/modules: Permission denied" ]
+
+    # But -f doesn't care
+    [ "`rmmod -f foo_bar`" = "DELETE_MODULE: foo_bar EXCL TRUNC NONBLOCK " ]
+fi
diff --git a/tests/test-rmmod/06multi.sh b/tests/test-rmmod/06multi.sh
new file mode 100755 (executable)
index 0000000..8762eff
--- /dev/null
@@ -0,0 +1,26 @@
+#! /bin/sh
+
+mkdir -p tests/tmp/proc
+
+# Old style
+echo 'foo 100 0' > tests/tmp/proc/modules
+echo 'bar 100 0' >> tests/tmp/proc/modules
+
+[ "`rmmod foo bar`" = "DELETE_MODULE: foo EXCL NONBLOCK 
+DELETE_MODULE: bar EXCL NONBLOCK " ]
+
+[ "`rmmod -f foo bar`" = "DELETE_MODULE: foo EXCL TRUNC NONBLOCK 
+DELETE_MODULE: bar EXCL TRUNC NONBLOCK " ]
+
+[ "`rmmod -w foo bar`" = "DELETE_MODULE: foo EXCL 
+DELETE_MODULE: bar EXCL " ]
+
+# First examine stdout (mixing them gives unpredictable results)
+[ "`rmmod foo bar baz 2>/dev/null`" = "DELETE_MODULE: foo EXCL NONBLOCK 
+DELETE_MODULE: bar EXCL NONBLOCK " ]
+[ "`rmmod baz foo bar 2>/dev/null`" = "DELETE_MODULE: foo EXCL NONBLOCK 
+DELETE_MODULE: bar EXCL NONBLOCK " ]
+
+# Now examine stderr.
+[ "`rmmod foo bar baz 2>&1 >/dev/null`" = "ERROR: Module baz does not exist in /proc/modules" ]
+[ "`rmmod baz foo bar 2>&1 >/dev/null`" = "ERROR: Module baz does not exist in /proc/modules" ]
diff --git a/tests/valgrind/suppressions b/tests/valgrind/suppressions
new file mode 100644 (file)
index 0000000..16289f8
--- /dev/null
@@ -0,0 +1,33 @@
+{
+   Glibc goes boom from _start (Debian glibc 2.3.5-3)
+   Memcheck:Cond
+   obj:/lib/ld-2.3.5.so
+   obj:/lib/ld-2.3.5.so
+   obj:/lib/ld-2.3.5.so
+   obj:/lib/ld-2.3.5.so
+   obj:/lib/ld-2.3.5.so
+}
+{
+    GCC strlen() builtin generates questionable reads
+    Memcheck:Addr4
+    fun:output_symbols
+    fun:main
+}
+{
+    GCC strlen() builtin generates questionable reads
+    Memcheck:Addr4
+    fun:output_aliases
+    fun:main
+}
+{
+    GCC strlen() builtin generates questionable reads
+    Memcheck:Addr4
+    fun:output_symbols_bin
+    fun:main
+}
+{
+    GCC strlen() builtin generates questionable reads
+    Memcheck:Addr4
+    fun:output_aliases_bin
+    fun:main
+}
diff --git a/tests/valgrind/valgrindme.sh b/tests/valgrind/valgrindme.sh
new file mode 100755 (executable)
index 0000000..5d4cade
--- /dev/null
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+# Make sure it finds the real one this time.
+PATH=`pwd`/tests/build:$PATH
+valgrind -q --num-callers=8 --leak-check=yes --suppressions=tests/valgrind/suppressions --log-fd=3 `basename $0` "$@" 3>tests/tmp/valgrind
+ret=$?
+
+if [ -s tests/tmp/valgrind ]; then
+    echo VALGRIND FAILED for $0 "$@" > /proc/$PPID/fd/1
+    cat tests/tmp/valgrind > /proc/$PPID/fd/1
+    kill $PPID
+    exit 1
+fi
+exit $ret
diff --git a/util.c b/util.c
new file mode 100644 (file)
index 0000000..59db9cb
--- /dev/null
+++ b/util.c
@@ -0,0 +1,234 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+#include <elf.h>
+#include <sys/types.h>
+#include <regex.h>
+#include "logging.h"
+#include "util.h"
+
+/*
+ * Read one logical line from a configuration file.
+ *
+ * Line endings may be escaped with backslashes, to form one logical line from
+ * several physical lines.  No end of line character(s) are included in the
+ * result.
+ *
+ * If linenum is not NULL, it is incremented by the number of physical lines
+ * which have been read.
+ */
+char *getline_wrapped(FILE *file, unsigned int *linenum)
+{
+       int size = 256;
+       int i = 0;
+       char *buf = NOFAIL(malloc(size));
+       for(;;) {
+               int ch = getc_unlocked(file);
+
+               switch(ch) {
+               case EOF:
+                       if (i == 0) {
+                               free(buf);
+                               return NULL;
+                       }
+                       /* else fall through */
+
+               case '\n':
+                       if (linenum)
+                               (*linenum)++;
+                       if (i == size)
+                               buf = NOFAIL(realloc(buf, size + 1));
+                       buf[i] = '\0';
+                       return buf;
+
+               case '\\':
+                       ch = getc_unlocked(file);
+
+                       if (ch == '\n') {
+                               if (linenum)
+                                       (*linenum)++;
+                               continue;
+                       }
+                       /* else fall through */
+
+               default:
+                       buf[i++] = ch;
+
+                       if (i == size) {
+                               size *= 2;
+                               buf = NOFAIL(realloc(buf, size));
+                       }
+               }
+       }
+}
+
+/*
+ * Convert filename to the module name.  Works if filename == modname, too.
+ */
+void filename2modname(char *modname, const char *filename)
+{
+       const char *afterslash;
+       unsigned int i;
+
+       afterslash = my_basename(filename);
+
+       /* Convert to underscores, stop at first . */
+       for (i = 0; afterslash[i] && afterslash[i] != '.'; i++) {
+               if (afterslash[i] == '-')
+                       modname[i] = '_';
+               else
+                       modname[i] = afterslash[i];
+       }
+       modname[i] = '\0';
+}
+
+/*
+ * Replace dashes with underscores.
+ * Dashes inside character range patterns (e.g. [0-9]) are left unchanged.
+ */
+char *underscores(char *string)
+{
+       unsigned int i;
+
+       if (!string)
+               return NULL;
+
+       for (i = 0; string[i]; i++) {
+               switch (string[i]) {
+               case '-':
+                       string[i] = '_';
+                       break;
+
+               case ']':
+                       warn("Unmatched bracket in %s\n", string);
+                       break;
+
+               case '[':
+                       i += strcspn(&string[i], "]");
+                       if (!string[i])
+                               warn("Unmatched bracket in %s\n", string);
+                       break;
+               }
+       }
+       return string;
+}
+
+/*
+ * strtbl_add - add a string to a string table.
+ *
+ * @str: string to add
+ * @tbl: current string table. NULL = allocate new table
+ *
+ * Allocates an array of pointers to strings.
+ * The strings themselves are not actually kept in the table.
+ *
+ * Returns reallocated and updated string table. NULL = out of memory.
+ *
+ * Implementation note: The string table is designed to be lighter-weight
+ * and faster than a more conventional linked list that stores the strings
+ * in the list elements, as it does far fewer malloc/realloc calls
+ * and avoids copying entirely.
+ */
+struct string_table *strtbl_add(const char *str, struct string_table *tbl)
+{
+       if (tbl == NULL) {
+               const char max = 100;
+               tbl = malloc(sizeof(*tbl) + sizeof(char *) * max);
+               if (!tbl)
+                       return NULL;
+               tbl->max = max;
+               tbl->cnt = 0;
+       }
+       if (tbl->cnt >= tbl->max) {
+               tbl->max *= 2;
+               tbl = realloc(tbl, sizeof(*tbl) + sizeof(char *) * tbl->max);
+               if (!tbl)
+                       return NULL;
+       }
+       tbl->str[tbl->cnt] = str;
+       tbl->cnt += 1;
+
+       return tbl;
+}
+
+/*
+ * strtbl_free - string table destructor
+ */
+void strtbl_free(struct string_table *tbl)
+{
+       free(tbl);
+}
+
+/*
+ * Get the basename in a pathname.
+ * Unlike the standard implementation, this does not copy the string.
+ */
+char *my_basename(const char *path)
+{
+       const char *base = strrchr(path, '/');
+       if (base)
+               return (char *) base + 1;
+       return (char *) path;
+}
+
+/*
+ * Find the next string in an ELF section.
+ */
+const char *next_string(const char *string, unsigned long *secsize)
+{
+       /* Skip non-zero chars */
+       while (string[0]) {
+               string++;
+               if ((*secsize)-- <= 1)
+                       return NULL;
+       }
+
+       /* Skip any zero padding. */
+       while (!string[0]) {
+               string++;
+               if ((*secsize)-- <= 1)
+                       return NULL;
+       }
+       return string;
+}
+
+/*
+ * Get CPU endianness. 0 = unknown, 1 = ELFDATA2LSB = little, 2 = ELFDATA2MSB = big
+ */
+int __attribute__ ((pure)) native_endianness()
+{
+       /* Encoding the endianness enums in a string and then reading that
+        * string as a 32-bit int, returns the correct endianness automagically.
+        */
+       return (char) *((uint32_t*)("\1\0\0\2"));
+}
+
+/*
+ * Compare "string" with extended regex "pattern". Include backward compatible
+ * matching of "*" as a wildcard by replacing it with ".*" automatically.
+ */
+int regex_match(const char *string, const char *pattern)
+{
+       int status;
+       regex_t re;
+       char *fix_pattern;
+
+       /* backward compatibility with old "match" code */
+       if (strncmp("*", pattern, 1) != 0)
+               fix_pattern = (char *)pattern;
+       else
+               fix_pattern = ".*"; /* match everything */
+
+       if (regcomp(&re, fix_pattern, REG_EXTENDED|REG_NOSUB) != 0)
+               return 0;       /* alloc failure */
+
+       status = regexec(&re, string, (size_t) 0, NULL, 0);
+       regfree(&re);
+
+       if (status != 0)
+               return 0;       /* no match */
+
+       return 1;       /* match */
+}
diff --git a/util.h b/util.h
new file mode 100644 (file)
index 0000000..2b50ca5
--- /dev/null
+++ b/util.h
@@ -0,0 +1,49 @@
+#ifndef _UTIL_H
+#define _UTIL_H
+
+#include <stdio.h>
+
+struct string_table
+{
+       unsigned int cnt;
+       unsigned int max;
+       const char *str[0];
+};
+
+char *getline_wrapped(FILE *file, unsigned int *linenum);
+
+void filename2modname(char *modname, const char *filename);
+char *underscores(char *string);
+char *my_basename(const char *path);
+
+struct string_table *strtbl_add(const char *str, struct string_table *tbl);
+void strtbl_free(struct string_table *tbl);
+
+const char *next_string(const char *string, unsigned long *secsize);
+
+/*
+ * Change endianness of x if conv is true.
+ */
+#define END(x, conv)                                                   \
+({                                                                     \
+       typeof(x) __x;                                                  \
+       if (conv) __swap_bytes(&(x), &(__x), sizeof(__x));              \
+       else __x = (x);                                                 \
+       __x;                                                            \
+})
+
+static inline void __swap_bytes(const void *src, void *dest, unsigned int size)
+{
+       unsigned int i;
+       for (i = 0; i < size; i++)
+               ((unsigned char*)dest)[i] = ((unsigned char*)src)[size - i-1];
+}
+
+int native_endianness(void);
+
+#define streq(a,b) (strcmp((a),(b)) == 0)
+#define strstarts(a,start) (strncmp((a),(start), strlen(start)) == 0)
+
+int regex_match(const char *string, const char *pattern);
+
+#endif
diff --git a/zlibsupport.c b/zlibsupport.c
new file mode 100644 (file)
index 0000000..597820e
--- /dev/null
@@ -0,0 +1,100 @@
+/* Support for compressed modules.  Willy Tarreau <willy@meta-x.org>
+ * did the support for modutils, Andrey Borzenkov <arvidjaar@mail.ru>
+ * ported it to module-init-tools, and I said it was too ugly to live
+ * and rewrote it 8).
+ *
+ * (C) 2003 Rusty Russell, IBM Corporation.
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include "zlibsupport.h"
+#include "logging.h"
+#include "testing.h"
+
+#ifdef CONFIG_USE_ZLIB
+#include <zlib.h>
+
+void *grab_contents(gzFile *gzfd, unsigned long *size)
+{
+       unsigned int max = 16384;
+       void *buffer = NOFAIL(malloc(max));
+       int ret;
+
+       *size = 0;
+       while ((ret = gzread(gzfd, buffer + *size, max - *size)) > 0) {
+               *size += ret;
+               if (*size == max)
+                       buffer = NOFAIL(realloc(buffer, max *= 2));
+       }
+       if (ret < 0) {
+               free(buffer);
+               buffer = NULL;
+       }
+
+       return buffer;
+}
+
+/* gzopen handles uncompressed files transparently. */
+void *grab_file(const char *filename, unsigned long *size)
+{
+       gzFile gzfd;
+       void *buffer;
+
+       errno = 0;
+       gzfd = gzopen(filename, "rb");
+       if (!gzfd) {
+               if (errno == ENOMEM)
+                       fatal("Memory allocation failure in gzopen\n");
+               return NULL;
+       }
+       buffer = grab_contents(gzfd, size);
+       gzclose(gzfd);
+       return buffer;
+}
+
+void release_file(void *data, unsigned long size)
+{
+       free(data);
+}
+#else /* ... !CONFIG_USE_ZLIB */
+
+void *grab_fd(int fd, unsigned long *size)
+{
+       struct stat st;
+       void *map;
+       int ret;
+
+       ret = fstat(fd, &st);
+       if (ret < 0)
+               return NULL;
+       *size = st.st_size;
+       map = mmap(0, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+       if (map == MAP_FAILED)
+               map = NULL;
+       return map;
+}
+
+void *grab_file(const char *filename, unsigned long *size)
+{
+       int fd;
+       void *map;
+
+       fd = open(filename, O_RDONLY, 0);
+       if (fd < 0)
+               return NULL;
+       map = grab_fd(fd, size);
+       close(fd);
+       return map;
+}
+
+void release_file(void *data, unsigned long size)
+{
+       munmap(data, size);
+}
+#endif
diff --git a/zlibsupport.h b/zlibsupport.h
new file mode 100644 (file)
index 0000000..be3c729
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef _ZLIB_SUPPORT_H
+#define _ZLIB_SUPPORT_H
+
+/* Grab file.  Decompresses if that is supported.  Returns NULL on error. */
+extern void *grab_file(const char *filename, unsigned long *size);
+extern void *grab_fd(int fd, unsigned long *size);
+
+/* Free it up. */
+extern void release_file(void *data, unsigned long size);
+
+#endif /* _ZLIB_SUPPORT_H */