build: fix release process to drive tools such as git, gpg, and scp
[opensuse:module-init-tools.git] / Makefile.am
1 ACLOCAL_AMFLAGS = -I m4
2
3 insmod_SOURCES = insmod.c testing.h
4 lsmod_SOURCES = lsmod.c testing.h
5 modprobe_SOURCES = modprobe.c zlibsupport.c zlibsupport.h testing.h
6 rmmod_SOURCES = rmmod.c testing.h
7 depmod_SOURCES = depmod.c zlibsupport.c tables.c \
8         zlibsupport.h tables.h testing.h
9 modinfo_SOURCES = modinfo.c zlibsupport.c zlibsupport.h testing.h
10 modindex_SOURCES = modindex.c zlibsupport.c zlibsupport.h testing.h
11
12 insmod_static_SOURCES = insmod.c
13 insmod_static_LDFLAGS = -static
14 # We don't want the $(zlib_flags) here: that makes a dynamic executable
15 insmod_static_LDADD = libmodtools.a
16
17 EXTRA_insmod_SOURCES =
18 EXTRA_lsmod_SOURCES =
19 EXTRA_modprobe_SOURCES = 
20 EXTRA_rmmod_SOURCES =
21 EXTRA_insmod_static_SOURCES =
22 EXTRA_depmod_SOURCES =
23 EXTRA_modinfo_SOURCES =
24
25 libmodtools_a_SOURCES = util.c logging.c index.c config_filter.c elfops.c \
26         util.h depmod.h logging.h index.h list.h config_filter.h elfops.h
27 libmodtools_a_CFLAGS = -ffunction-sections
28
29 EXTRA_libmodtools_a_SOURCES = elfops_core.c
30
31 insmod_LDADD = $(LDADD) libmodtools.a
32 lsmod_LDADD = $(LDADD) libmodtools.a
33 modprobe_LDADD = $(LDADD) libmodtools.a
34 rmmod_LDADD = $(LDADD) libmodtools.a
35 depmod_LDADD = $(LDADD) libmodtools.a
36 modinfo_LDADD = $(LDADD) libmodtools.a
37 modindex_LDADD = $(LDADD) libmodtools.a
38
39 MAN5 = modprobe.conf.5 modules.dep.5 depmod.conf.5 modprobe.d.5
40 MAN8 = depmod.8 insmod.8 lsmod.8 rmmod.8 modprobe.8 modinfo.8
41 SGML = $(addprefix doc/,  $(MAN5:%.5=%.sgml) $(MAN8:%.8=%.sgml))
42 dist_man_MANS = $(MAN5) $(MAN8)
43 # If they haven't overridden mandir, fix it (never /man!)
44 mandir =$(shell if [ @mandir@ = $(prefix)/man ]; then if [ $(prefix) = / ]; then echo /usr/share/man; else echo $(prefix)/share/man; fi; else echo @mandir@; fi)
45
46 TESTSUITE := $(shell test -e @srcdir@/tests && find @srcdir@/tests -type f ! -name '*~')
47
48 EXTRA_DIST = generate-modprobe.conf FAQ CODING stress_modules.sh install-with-care $(SGML) $(man_MANS) $(TESTSUITE)
49
50 sbin_PROGRAMS = insmod modprobe rmmod depmod modinfo
51 if BUILD_STATIC_UTILS
52 sbin_PROGRAMS += insmod.static
53 endif
54 bin_PROGRAMS = lsmod
55 noinst_PROGRAMS=modindex
56 noinst_LIBRARIES = libmodtools.a
57 INSTALL = $(SHELL) $(top_srcdir)/install-with-care
58
59 DIST_DIR := /data/work/releases/module-init-tools/
60
61 GIT_RELEASE_REMOTE := origin
62 GIT_RELEASE_BRANCH := master
63 SCP_RELEASE_URL := "jcm@master.kernel.org:/pub/linux/utils/kernel/module-init-tools/"
64
65
66 MAINTAINERCLEANFILES := $(man_MANS)
67
68 # docbook2man writes file itself, doesn't do stdout.
69 %.8: doc/%.sgml
70         if [ "$(DOCBOOKTOMAN)" = "docbook2man" ]; then                     \
71             $(DOCBOOKTOMAN) $< > /dev/null 2>&1;                       \
72         else                                                               \
73             $(DOCBOOKTOMAN) $< 2>&1 > $@ | sed 's/^[^:]*://';              \
74         fi
75
76 %.5: doc/%.sgml
77         if [ "$(DOCBOOKTOMAN)" = "docbook2man" ]; then                     \
78             $(DOCBOOKTOMAN) $< > /dev/null 2>&1;                       \
79         else                                                               \
80             $(DOCBOOKTOMAN) $< 2>&1 > $@ | sed 's/^[^:]*://';              \
81         fi
82
83 # docbook2man creates extra crap files which need cleaning.
84 distclean-local: killbuildmanpages
85
86 killbuildmanpages:
87         rm -f doc/*.tmp manpage.refs manpage.links
88
89 tarball: $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz
90
91 #$(DIST_DIR)/module-init-tools-$(VERSION).tar.gz: dist
92 #       mv module-init-tools-$(VERSION).tar.gz $@
93
94 # git based version
95 $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz:
96         cd $$(git rev-parse --show-toplevel) && git archive --format=tar --prefix=module-init-tools-$(VERSION)/ v$(VERSION) | (cd $(DIST_DIR) && tar xv)
97         cd $(DIST_DIR)/module-init-tools-$(VERSION) && aclocal -I m4 && automake --add-missing --copy && autoconf
98         cd $(DIST_DIR) && tar cvfz module-init-tools-$(VERSION).tar.gz module-init-tools-$(VERSION)
99
100 $(DIST_DIR)/.pushed/module-init-tools-$(VERSION).tar.gz:
101         mkdir -p $(DIST_DIR)/.pushed
102         ln -s $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz $(DIST_DIR)/.pushed/module-init-tools-$(VERSION).tar.gz
103
104 gpg-tarball: $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz.sign
105
106 $(DIST_DIR)/.pushed/module-init-tools-$(VERSION).tar.gz.sign:
107         mkdir -p $(DIST_DIR)/.pushed
108         ln -s $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz.sign $(DIST_DIR)/.pushed/module-init-tools-$(VERSION).tar.gz.sign
109
110 $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz.sign: tarball
111         cd $(DIST_DIR) && gpg -a -b -s -o module-init-tools-$(VERSION).tar.gz.sign module-init-tools-$(VERSION).tar.gz
112
113 srpm: $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz
114         ln -sf $(DIST_DIR)/module-init-tools-$(VERSION).tar.gz /usr/src/rpm/SOURCES/
115         set -e; RELEASE=`grep '^Release:' /usr/src/rpm/SPECS/modutils.spec | awk '{ print $$2 }'`; \
116         if [ "`grep '%define mit_ver' /usr/src/rpm/SPECS/modutils.spec | awk '{print $$3}'`" != $(VERSION) ]; then \
117                 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; \
118                 rpm -ba /tmp/modutils.spec; \
119                 mv /usr/src/rpm/SRPMS/modutils-2.4.21-`expr $$RELEASE + 1`.src.rpm $(DIST_DIR); \
120                 mv /tmp/modutils.spec /usr/src/rpm/SPECS/modutils.spec; \
121         else \
122                 rpm -ba /usr/src/rpm/SPECS/modutils.spec; \
123                 mv /usr/src/rpm/SRPMS/modutils-2.4.21-$$RELEASE.src.rpm $(DIST_DIR); \
124         fi
125
126 # No testsuite?
127 tests/runtests:
128         mkdir tests
129         echo '#! /bin/sh' > $@
130         echo '# Install the testsuite over this dir. ' >> $@
131         chmod a+x $@
132
133 $(DIST_DIR)/module-init-tools-testsuite-$(VERSION).tar.gz:
134         ln -sfn `pwd` /tmp/module-init-tools-$(VERSION) 
135         cd /tmp && tar --exclude '*~' -c -z -f $@ module-init-tools-$(VERSION)/tests
136         rm /tmp/module-init-tools-$(VERSION)
137
138 old-release: check clean tarball
139
140 # git based release
141 git-clean:
142         git gc
143         git prune
144
145 git-tag:
146         if [ "xv$(VERSION)" != x$$(git tag -l v$(VERSION)) ]; \
147         then \
148                 git tag v$(VERSION); \
149         fi
150
151 git-push:
152         git push $(GIT_RELEASE_REMOTE) $(GIT_RELEASE_BRANCH) --tags
153
154 scp-tarball: $(DIST_DIR)/.pushed/module-init-tools-$(VERSION).tar.gz $(DIST_DIR)/.pushed/module-init-tools-$(VERSION).tar.gz.sign
155         cd $(DIST_DIR) && scp -C module-init-tools-$(VERSION).tar.gz module-init-tools-$(VERSION).tar.gz.sign $(SCP_RELEASE_URL)
156
157 git-release: git-clean git-tag
158
159 release: git-release
160
161 sign-release: git-release gpg-tarball
162
163 push-release: sign-release git-push scp-tarball
164
165 push: push-release