chiark / gitweb /
Makefile: Installation refactoring (5)
[userv.git] / Makefile.in
1 #  userv - Makefile.in
2 #  
3 #  userv is
4 #  Copyright 1996-2017 Ian Jackson <ian@davenant.greenend.org.uk>.
5 #  Copyright 2000      Ben Harris <bjh21@cam.ac.uk>
6 #  Copyright 2016-2017 Peter Benie <pjb1008@cam.ac.uk>
7 #  
8 #  This is free software; you can redistribute it and/or modify it
9 #  under the terms of the GNU General Public License as published by
10 #  the Free Software Foundation; either version 3 of the License, or
11 #  (at your option) any later version.
12 #  
13 #  This program is distributed in the hope that it will be useful, but
14 #  WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 #  General Public License for more details.
17 #  
18 #  You should have received a copy of the GNU General Public License
19 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21
22 VERSION=@VERSION@
23 VEREXT=std
24
25 CC=@CC@
26 CFLAGS=@CFLAGS@ $(XCFLAGS) -DVERSION='"$(VERSION)"' -DVEREXT='"$(VEREXT)"' $(WERROR) $(XCFLAGS)
27 OPTIMISE=@OPTIMISE@
28 CPPFLAGS=@DEBUGDEFS@ $(XCPPFLAGS)
29 LDLIBS=@DEBUGLIBS@ @LIBS@ $(XLDLIBS)
30
31 M4=m4
32 M4FLAGS=
33 LEX=flex
34 MD5SUM=@MD5SUM_SIMPLE@
35 CWD=$(shell pwd)
36
37 INSTALL_GROUP=0  # root or wheel
38 INSTALL_FLAGS=-o root -g $(INSTALL_GROUP)
39
40 INSTALL=@INSTALL@
41 INSTALL_PROGRAM=@INSTALL_PROGRAM@ $(INSTALL_FLAGS)
42 INSTALL_DATA=@INSTALL_DATA@ $(INSTALL_FLAGS)
43 INSTALL_DIR=$(INSTALL) -d
44 INSTALL_DIR_ETC=$(INSTALL_DIR)
45 prefix=@prefix@
46 exec_prefix=$(prefix)
47 share_prefix=$(prefix)/share
48 bindir=$(exec_prefix)/bin
49 mandir=$(share_prefix)/man
50 man1dir=$(mandir)/man1
51 man8dir=$(mandir)/man8
52 sbindir=$(exec_prefix)/sbin
53 etcdir=/etc
54 etcsubdir=$(etcdir)/userv
55 docdir=$(share_prefix)/doc/userv
56
57 TARGETS=        daemon client
58 TARGETS_DOC_PS= spec.ps overview.ps
59 TARGETS_DOC_RM= $(TARGETS_DOC_PS) spec.html
60 TARGETS_DOC=    $(TARGETS_DOC_PS) spec.html/index.html
61 MAN1PAGES=      userv.1
62 MAN8PAGES=      uservd.8
63
64 SOURCES=        Makefile.in configure.in acconfig.h                     \
65                 client.c common.h                                       \
66                 overlord.c process.c servexec.c                         \
67                 daemon.h debug.c parser.c lib.c lib.h                   \
68                 language.i4 lexer.l.m4 tokens.h.m4
69
70 CONFIG_RESULTS= config.status config.log config.h config.cache \
71                 Makefile pcsum.h
72
73 GENSHIP_CLEAN=  lexer.l lexer.c tokens.h config.h.in spec.sgml $(TARGETS_DOC)
74 GENSHIP=        $(GENSHIP_CLEAN) configure
75
76 all:            $(TARGETS)
77
78 docs:           $(TARGETS_DOC)
79
80 install:        all
81                 $(INSTALL_DIR) $(addprefix $(DESTDIR), $(bindir) $(sbindir))
82                 $(INSTALL_PROGRAM) -m 755 daemon $(DESTDIR)$(sbindir)/uservd
83                 $(INSTALL_PROGRAM) -m 4755 client $(DESTDIR)$(bindir)/userv
84                 set -e; for f in '' /default.d /services.d /override.d; do \
85                         $(INSTALL_DIR_ETC) $(DESTDIR)$(etcsubdir)$$f; \
86                 done
87                 set -e; for f in system.default system.override; do     \
88                         if test ! -f $(DESTDIR)$(etcsubdir)/$$f; then   \
89                                 $(INSTALL_DATA) $$f $(DESTDIR)$(etcsubdir); \
90                         fi;                                             \
91                 done
92
93 install-strip:
94                 $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
95
96 install-doc install-docs:       $(TARGETS_DOC)
97                 $(INSTALL_DIR) $(addprefix $(DESTDIR),                  \
98                         $(docdir) $(docdir)/spec.html                   \
99                         $(mandir) $(man1dir) $(man8dir)                 \
100                 )
101                 $(INSTALL_DATA) -m 644 $(TARGETS_DOC_PS) $(DESTDIR)$(docdir)/.
102                 $(INSTALL_DATA) -m 644 spec.html/*.html \
103                         $(DESTDIR)$(docdir)/spec.html/.
104                 $(INSTALL_DATA) -m 644 $(MAN1PAGES) $(DESTDIR)$(man1dir)
105                 $(INSTALL_DATA) -m 644 $(MAN8PAGES) $(DESTDIR)$(man8dir)
106
107 uninstall:
108                 rm -f $(bindir)/userv $(sbindir)/uservd
109
110 uninstall-doc uninstall-docs:
111                 cd $docdir && rm -rf $(TARGETS_DOC_RM)
112
113 check:
114                 @echo There is no validation suite for this package.
115
116 daemon:         overlord.o process.o servexec.o parserlexer.o debug.o lib.o both.o
117                 $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
118
119 client:         client.o both.o
120                 $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
121
122 lexer.l:        language.i4
123
124 spec.sgml:      spec.sgml.in Makefile
125                 sed -e '/<version><\/version>/ s/>/&$(VERSION)/' \
126                         spec.sgml.in >$@.new && mv -f $@.new $@
127
128 client.o:       config.h common.h pcsum.h both.h version.h
129
130 process.o:      config.h common.h pcsum.h both.h daemon.h lib.h tokens.h
131
132 overlord.o:     config.h common.h pcsum.h daemon.h
133
134 servexec.o:     config.h common.h pcsum.h daemon.h lib.h version.h
135
136 lib.o:          config.h common.h lib.h
137
138 debug.o:        config.h common.h pcsum.h daemon.h lib.h tokens.h
139
140 parserlexer.o:  lexer.c parser.c config.h common.h pcsum.h daemon.h lib.h tokens.h
141 # lexer.c #include's parser.c at the end.  Blame flex.
142                 $(CC) -c $(CPPFLAGS) $(CFLAGS) lexer.c -o $@
143
144 pcsum.h:        common.h config.h config.status Makefile
145                 cat $^ | $(MD5SUM) \
146                         | sed -e 's/  -$$//; s/../0x&,/g; s/,$$//;' \
147                         >pcsum.h.new
148                 cmp pcsum.h.new pcsum.h || mv -f pcsum.h.new pcsum.h
149                 @rm -f pcsum.h.new
150
151 version.h:      Makefile
152                 echo '#define VERSION "$(VERSION)"' >$@.new && mv -f $@.new $@
153
154 tokens.h:       language.i4
155
156 autoconf configure:
157                 autoheader
158                 autoconf
159
160 clean:
161                 find -name '*.orig' -o -name '*~' -o -name '.*~' \
162                         -o -name '*#' -o -name '.#*' -o -name '*.bak' \
163                         | xargs -r rm
164                 rm -rf $(TARGETS) *.o core version.h
165                 rm -f overview.eps
166                 rm -f spec.lout* spec.text* spec.ps* spec.sgml.new spec.tex
167                 rm -f lout.li *.ld *.lix *.ldx
168                 rm -f userv-*.tar.gz vd/*
169
170 distclean mostlyclean:  clean
171                 rm -f $(CONFIG_RESULTS)
172
173 maintainer-clean:       distclean
174                 rm -rf $(GENSHIP_CLEAN) spec.html/*.html
175
176 dist-prep:      $(GENSHIP)
177
178 pre-checkin:
179                 ./configure
180                 $(MAKE) dist-prep
181
182 dist_tmp=dist_tmp/userv-$(VERSION)
183 dist_prune=\( -name CVS -o -name 'dist_tmp*' -o -name slash-etc -o -name vd \)
184 dist:                   dist-prep distclean
185         rm -rf dist_tmp*
186         mkdir dist_tmp $(dist_tmp)
187         find $(dist_prune) -prune -o -type d -print | \
188                 sed -e 's#.*#mkdir -p $(dist_tmp)/&#' | sh
189         find $(dist_prune) -prune -o -type f -print | \
190                 sed -e 's#.*#ln & $(dist_tmp)/&#' | sh
191         cd dist_tmp && tar cf ../$(dist_tmp).tar `basename $(dist_tmp)`
192         gzip -9 $(dist_tmp).tar
193         mv $(dist_tmp).tar.gz .
194
195 linecount:      $(SOURCES)
196                 wc -l $^
197
198 %.html/index.html:      %.sgml
199                         debiandoc2html $<
200
201 %.ps:           %.sgml
202                 debiandoc2ps -1 -O $< >$@.new && mv $@.new $@
203
204 %.ps:           %.fig
205                 fig2dev -L ps -c -l dummy -P -z A4 $< >$@.new && mv $@.new $@
206
207 %.l:            %.l.m4
208                 $(M4) $(M4FLAGS) -- $< >$@.new && mv $@.new $@
209
210 %.h:            %.h.m4
211                 $(M4) $(M4FLAGS) -- $< >$@.new && mv $@.new $@
212
213 %:              %.m4
214                 $(M4) $(M4FLAGS) -- $< >$@.new && mv $@.new $@