Required by "use /sys/module/ rather than parsing legacy /proc/modules"
[mit.git] / Makefile.am
blob560b02b1f477c980c2ccbfbb6f3c599ebf7cda00
1 insmod_SOURCES = insmod.c testing.h
2 lsmod_SOURCES = lsmod.c testing.h
3 modprobe_SOURCES = modprobe.c logging.c index.c zlibsupport.c logging.h index.h testing.h zlibsupport.h
4 rmmod_SOURCES = rmmod.c testing.h
5 depmod_SOURCES = depmod.c logging.c index.c moduleops.c tables.c zlibsupport.c depmod.h logging.h index.h moduleops.h tables.h list.h testing.h  zlibsupport.h
6 modinfo_SOURCES = modinfo.c zlibsupport.c testing.h zlibsupport.h
7 modindex_SOURCES = modindex.c logging.c index.c logging.h index.h
9 insmod_static_SOURCES = insmod.c
10 insmod_static_LDFLAGS = -static
11 # We don't want the $(zlib_flags) here: that makes a dynamic executable
12 insmod_static_LDADD = 
14 EXTRA_insmod_SOURCES = backwards_compat.c
15 EXTRA_lsmod_SOURCES = backwards_compat.c
16 EXTRA_modprobe_SOURCES = 
17 EXTRA_rmmod_SOURCES = backwards_compat.c
18 EXTRA_insmod_static_SOURCES = backwards_compat.c
19 EXTRA_depmod_SOURCES = moduleops_core.c
20 EXTRA_modinfo_SOURCES = backwards_compat.c
22 MAN5 = modprobe.conf.5 modules.dep.5 depmod.conf.5
23 MAN8 = depmod.8 insmod.8 lsmod.8 rmmod.8 modprobe.8 modinfo.8
24 SGML = $(addprefix doc/,  $(MAN5:%.5=%.sgml) $(MAN8:%.8=%.sgml))
25 man_MANS = $(MAN5) $(MAN8)
26 # If they haven't overridden mandir, fix it (never /man!)
27 mandir =$(shell if [ @mandir@ = $(prefix)/man ]; then if [ $(prefix) = / ]; then echo /usr/share/man; else echo $(prefix)/share/man; fi; else echo @mandir@; fi)
29 TESTSUITE := $(shell find tests -type f ! -name '*~') tests/vg-suppressions
31 EXTRA_DIST = generate-modprobe.conf modprobe.devfs FAQ CODING stress_modules.sh install-with-care $(SGML) $(man_MANS) $(TESTSUITE)
33 sbin_PROGRAMS = insmod modprobe rmmod depmod modinfo insmod.static
34 bin_PROGRAMS = lsmod
35 sbin_SCRIPTS = generate-modprobe.conf
36 noinst_PROGRAMS=modindex
37 INSTALL = $(SHELL) $(top_srcdir)/install-with-care
39 TESTS = tests/runtests
41 DIST_DIR := /home/rusty/devel/kernel/www/modules/
43 MAINTAINERCLEANFILES := $(man_MANS)
45 # According to Warren Togami, RH has docbook2man in the docbook-utils rpm.
46 DOCBOOKTOMAN := $(shell if command -v docbook-to-man >/dev/null 2>&1; then echo docbook-to-man; else echo docbook2man; fi)
48 # docbook2man writes file itself, doesn't do stdout.
49 %.8: doc/%.sgml
50         if [ "$(DOCBOOKTOMAN)" = "docbook2man" ]; then                     \
51             $(DOCBOOKTOMAN) $< > /dev/null 2>&1;                       \
52         else                                                               \
53             $(DOCBOOKTOMAN) $< 2>&1 > $@ | sed 's/^[^:]*://';              \
54         fi
56 %.5: doc/%.sgml
57         if [ "$(DOCBOOKTOMAN)" = "docbook2man" ]; then                     \
58             $(DOCBOOKTOMAN) $< > /dev/null 2>&1;                       \
59         else                                                               \
60             $(DOCBOOKTOMAN) $< 2>&1 > $@ | sed 's/^[^:]*://';              \
61         fi
63 # docbook2man creates extra crap files which need cleaning.
64 distclean: killbuildmanpages
66 killbuildmanpages:
67         rm -f doc/*.tmp manpage.refs manpage.links
69 tarball: $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz
71 $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz: dist
72         mv module-init-tools-$(VERSION).tar.gz $@
74 srpm: $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz
75         ln -sf $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz /usr/src/rpm/SOURCES/
76         set -e; RELEASE=`grep '^Release:' /usr/src/rpm/SPECS/modutils.spec | awk '{ print $$2 }'`; \
77         if [ "`grep '%define mit_ver' /usr/src/rpm/SPECS/modutils.spec | awk '{print $$3}'`" != $(VERSION) ]; then \
78                 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; \
79                 rpm -ba /tmp/modutils.spec; \
80                 mv /usr/src/rpm/SRPMS/modutils-2.4.21-`expr $$RELEASE + 1`.src.rpm $(DIST_DIR); \
81                 mv /tmp/modutils.spec /usr/src/rpm/SPECS/modutils.spec; \
82         else \
83                 rpm -ba /usr/src/rpm/SPECS/modutils.spec; \
84                 mv /usr/src/rpm/SRPMS/modutils-2.4.21-$$RELEASE.src.rpm $(DIST_DIR); \
85         fi
87 # No testsuite?
88 tests/runtests:
89         mkdir tests
90         echo '#! /bin/sh' > $@
91         echo '# Install the testsuite over this dir. ' >> $@
92         chmod a+x $@
94 $(DIST_DIR)/module-init-tools-testsuite-$(VERSION).tar.gz:
95         ln -sfn `pwd` /tmp/module-init-tools-$(VERSION) 
96         cd /tmp && tar --exclude '*~' -c -z -f $@ module-init-tools-$(VERSION)/tests
97         rm /tmp/module-init-tools-$(VERSION)
99 release: check clean tarball
101 moveold: check-for-sbin check-for-old move-old-targets
103 check-for-sbin:
104         if [ "`echo $(DESTDIR)$(sbindir) | tr -s / /`" = /sbin ]; then :;    \
105         else                                                                 \
106                 echo moveold usually only makes sense when installing into /sbin; \
107                 exit 1;                                                      \
108         fi
110 check-for-old:
111         if [ -f /sbin/lsmod.old ]; then                                 \
112                 echo Someone already moved old versions. >&2; exit 1;   \
113         fi
115 # Don't just move symlinks, reset them to point to xxx.old.
116 # RedHat 8.0 doesn't ship with readlink by default.  Use ls -l.
117 # Also, make symlink from /bin to /sbin for lsmod (FHS compliant).
118 move-old-targets:
119         for f in lsmod modprobe rmmod depmod insmod modinfo; do             \
120             if [ -L /sbin/$$f ]; then                                       \
121                 ln -sf `ls -l /sbin/$$f | sed 's/.* -> //'`.old /sbin/$$f;  \
122             fi;                                                             \
123             mv /sbin/$$f /sbin/$$f.old;                                     \
124             if [ -f /usr/share/man/man8/$$f.8.gz ]; then                    \
125                 mv /usr/share/man/man8/$$f.8.gz                             \
126                         /usr/share/man/man8/$$f.old.8.gz;                   \
127             elif [ -f /usr/share/man/man8/$$f.8.bz2 ]; then                 \
128                 mv /usr/share/man/man8/$$f.8.bz2                            \
129                         /usr/share/man/man8/$$f.old.8.bz2;                  \
130             else                                                            \
131                 mv /usr/share/man/man8/$$f.8 /usr/share/man/man8/$$f.old.8; \
132             fi;                                                             \
133         done
134         for f in kallsyms ksyms; do                                         \
135             if [ -L /sbin/$$f ]; then                                       \
136                 ln -sf `ls -l /sbin/$$f | sed 's/.* -> //'`.old /sbin/$$f;  \
137             fi;                                                             \
138         done
139         ln -s /sbin/lsmod.old /bin/lsmod.old
141 # For installs in /usr/local/sbin
142 links:
143         for f in insmod modprobe rmmod depmod; do ln -s /sbin/$$f $(DESTDIR)$(sbindir)/$$f.old; done
144         for f in  lsmod; do ln -s /sbin/$$f $(DESTDIR)$(bindir)/$$f.old; done