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