chiark / gitweb /
document changes to make version 4.26
[bible-kjv.git] / Makefile
1 # -*-Fundamental-*-
2 ###############################################################################
3 #
4 # File:         Makefile
5 # RCS:          $Header: /home/matthew/cvs/bible-kjv-4.10/Makefile,v 2.11 2005/01/22 23:31:01 matthew Exp $
6 # Description:  Makefile for Bible Retrieval System
7 # Author:       Chip Chapin, Hewlett Packard Company
8 # Created:      Thu Aug 24 17:26:25 1989
9 # Modified:     Tue Apr 27 12:57:45 1993 (Chip Chapin) chip@hpclbis
10 # Language:     make
11 # Package:      Bible Retrieval System
12 # Status:       Experimental (Do Not Distribute)
13 #
14 ###############################################################################
15 #
16 # Revisions:
17 #
18 # $Log: Makefile,v $
19 # Revision 2.11  2005/01/22 23:31:01  matthew
20 # Remove -traditional, since newer GCCs then object to ANSI
21 # prototypes...
22 #
23 # Revision 2.10  2005/01/22 18:51:01  matthew
24 # add more warnings
25 #
26 # Revision 2.9  2005/01/21 18:00:25  matthew
27 # Remove -fwritable-strings
28 #
29 # Revision 2.8  2003/07/26 10:05:06  matthew
30 # 4.15 release
31 #
32 # Revision 2.7  2003/01/09 13:29:08  matthew
33 # Remove a bit more cruft with clean
34 #
35 # Revision 2.6  2003/01/08 19:18:31  matthew
36 # add an -f flag to the rm -f squish.stats, so this doesnt barf
37 #
38 # Revision 2.5  2003/01/08 18:29:12  matthew
39 # patch from IWJ to make this -j compatible
40 #
41 # Revision 2.4  2003/01/08 16:14:17  matthew
42 # tidy up header a little
43 #
44 # Revision 2.3  2003/01/08 16:13:29  matthew
45 # remove clobber target, and make clean target remove everything that should go
46 #
47 # Revision 2.2  2003/01/08 16:08:50  matthew
48 # clean target now removes things created by makeindex2
49 #
50 # Revision 2.1  2003/01/08 15:50:53  matthew
51 # applied debian patch
52 #
53 # Revision 2.0  2003/01/08 15:29:51  matthew
54 # versions collected from the net
55 #
56 # Revision 1.27  93/04/27  12:57:55  12:57:55  chip (Chip Chapin)
57 # Removed dependencies from "install" target".
58 #
59 ###############################################################################
60
61 # name of main program -- this determines a lot of other names
62 PROGRAM       = bible
63
64 # name of supplemental index file -- generated from raw data file
65 PROGINDEX     = $(PROGRAM)-index
66
67 README        = README.$(PROGRAM)
68
69 # primary man page
70 MAN           = $(PROGRAM).1
71
72 # raw data file
73 RAWDATA       = $(PROGRAM).rawtext
74
75 # Derived data file.  Comes from processing raw data file.
76 DATA          = $(PROGRAM).data
77
78 # Ninstall package
79 NINSTPKG      = $(PROGRAM).pkg
80
81 # where to install this stuff
82 DEST          = /usr
83 #DEST         = $(HOME)/local
84 DESTBIN       = $(DEST)/bin
85 DESTLIB       = $(DEST)/lib
86 DESTMAN       = $(DEST)/share/man
87 DESTMAN1      = $(DESTMAN)/man1
88
89 # I use environment variables for these...
90 #CFLAGS       = -g
91 CFLAGS        = -Wall -Wformat -Werror -Wshadow -W -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wcast-align -Wcast-qual -Wbad-function-cast -Wpointer-arith -g2 -ggdb -DDESTLIB=\"$(DESTLIB)\"
92 LDFLAGS       = 
93 LDADD         = -lreadline
94
95 # release directories.  Nobody should care about this but me
96 FTPHOME       = /mnt/ftp
97 RELEASEDIR    = $(FTPHOME)/pub/$(PROGRAM)
98 NINSTDIR      = /usr/adm/netdist
99 NINSTPKGDIR   = $(NINSTDIR)/packages
100
101 # This is only used by the author when making a new release ftp-able.
102 INSTALL       = .do cp
103
104 LD            = cc
105
106 MAKEFILE      = Makefile
107
108 PRINT         = pr
109
110 SHELL         = /bin/sh
111
112 MKDIR       = install -d
113
114 ###############################################################################
115 # Sources, objects, and tools
116 ###############################################################################
117 # PROGOBJS and PROGSRCS are the components of the main program.
118 PROGOBJS      = $(PROGRAM).o \
119                 brl-index.o \
120                 brl.o \
121                 $(PROGINDEX).o \
122                 tsl.o \
123                 util.o \
124                 compresslib.o
125
126 PROGSRCS      = $(PROGRAM).c \
127                 brl-index.c \
128                 brl.c \
129                 $(PROGINDEX).c \
130                 tsl.c \
131                 util.c \
132                 compresslib.c
133
134 # TOOLOBJS and TOOLSRCS are objects and sources used in building TOOLS.
135 TOOLOBJS      = buildcmp.o \
136                 makeindex.o \
137                 makeconcfile.o \
138                 squish.o
139
140 TOOLSRCS      = buildcmp.c \
141                 makeindex.c \
142                 makeconcfile.c \
143                 squish.c
144
145 TOOLS         = buildcmp squish makeindex makeconcfile
146
147 # TOOLS2 are additional scripts and data files used in constructing stuff.
148 TOOLS2        = makeindex2 \
149                 makeconcordance \
150                 makeconc.pl \
151                 $(PROGRAM).stopwords
152
153 # HDRS lists all header files used by PROGRAM and TOOLS
154 HDRS          = brl.h \
155                 brl-startverse.h \
156                 brl-startchapter.h \
157                 tsl.h \
158                 util.h \
159                 version.h
160
161
162 ###############################################################################
163 # Distribution and version-control packages
164 ###############################################################################
165 # SRCS includes all archivable sources except headers, both tools and program
166 SRCS          = $(PROGSRCS) \
167                 $(TOOLSRCS) \
168                 $(TOOLS2)
169
170 # DOC includes all available program documentation
171 DOC           = $(README) \
172                 README.ftp \
173                 $(MAN)
174
175 # List of files controlled by RCS
176 RCSFILES      = $(DOC) \
177                 $(SRCS) \
178                 $(HDRS) \
179                 $(MAKEFILE) \
180                 $(NINSTPKG) \
181                 testall
182
183 # PROGDIST contains only those files needed to build PROGRAM, plus doc.
184 PROGDIST      = $(HDRS) \
185                 $(PROGSRCS) \
186                 $(MAKEFILE) \
187                 $(DOC)
188
189 # DATADIST contains the fully-processed compressed data files
190 DATADIST      = $(DATA) $(DATA).conc
191
192 # TOOLSDIST contains all additional files needed to build a new
193 # version of this application from scratch, including re-processing data.
194 TOOLSDIST     = $(TOOLSRCS) \
195                 $(TOOLS2) \
196                 $(NINSTPKG) \
197                 testall 
198
199
200 ###############################################################################
201 # TARGETS
202 ###############################################################################
203 $(PROGRAM):     $(PROGOBJS)
204                 @echo "Linking $@ ..."
205                 @$(LD) $(LDFLAGS) $(PROGOBJS) $(LDADD) -o $@
206                 @echo "done"
207
208
209 all:            $(PROGRAM) $(TOOLS) $(DATA) $(DATA).conc
210
211 buildcmp:       buildcmp.o compresslib.o util.o
212                 @echo "Linking $@ ..."
213                 @$(LD) $(LDFLAGS) $@.o compresslib.o util.o -o $@
214                 @echo "done"
215                 
216 squish:         squish.o
217                 @echo "Linking $@ ..."
218                 @$(LD) $(LDFLAGS) $@.o -o $@
219                 @echo "done"
220                 
221 makeindex:      makeindex.o
222                 @echo "Linking $@ ..."
223                 @$(LD) $(LDFLAGS) $@.o -o $@
224                 @echo "done"
225                 
226 makeconcfile:   makeconcfile.o util.o
227                 @echo "Linking $@ ..."
228                 @$(LD) $(LDFLAGS) $@.o util.o -o $@
229                 @echo "done"
230                 
231 brl-startverse.h:       $(RAWDATA)
232                 ./makeindex2 $(RAWDATA)
233
234 brl-startchapter.h: brl-startverse.h
235
236 ###############################################################################
237 # The nested makes are used on the following items to
238 # avoid establishing an explicit dependency on those files.
239 # Such a dependency causes lots of extra work.
240 $(DATA).conc:   $(PROGRAM).rawconcordance
241                 make makeconcfile
242                 ./makeconcfile $@ < $(PROGRAM).rawconcordance
243
244 squish.data:    $(RAWDATA)
245                 make squish
246                 if ./squish -w 65536 -v < $(RAWDATA) >squish.tmpdata; \
247                 then    mv squish.tmpdata squish.data; \
248                 else    rm -f squish.tmpdata squish.stats; fi
249                 
250 squish.stats:   squish.data
251
252 $(PROGINDEX).c: $(RAWDATA)
253                 make makeindex
254                 ./makeindex $(RAWDATA) > $@
255
256 $(DATA):        squish.stats squish.data
257                 make buildcmp
258                 ./buildcmp
259                 mv squish.output $@
260
261
262 #
263 ###############################################################################
264
265 # The next one ensures that $(PROGINDEX).c gets its dependency satisfied.
266 # Note that $(PROGINDEX).c is included in source distributions, while 
267 # $(RAWDATA) is NOT included in all distributions.  $(PROGINDEX).c does NOT 
268 # need to be rebuilt unless someone (probably me) has munged $(RAWDATA).
269 SAFEDATE = 0101000193
270 $(RAWDATA):
271                 @touch $(SAFEDATE) $@
272                 @if [ -r $(SAFEDATE) ]; then \
273                         /bin/rm $(SAFEDATE) $@; \
274                         if [ -x /usr/5bin/touch ]; then \
275                                 /usr/5bin/touch $(SAFEDATE) $@; \
276                         else \
277                                 # major kludge alert! ... \
278                                 touch brl-startverse.h brl-startchapter.h; \
279                         fi; \
280                 fi
281                 @echo "  A dummy $(RAWDATA) file has been created."
282
283 # The dependency on $(RAWDATA) helps to ensure that the raw concordance file
284 # is not rebuilt unnecessarily.
285 $(PROGRAM).rawconcordance:      $(RAWDATA)
286                 @echo "To exclude \"stopwords\" from concordance use this:"
287                 @echo "     ./makeconc.pl bible.stopwords"
288                 @echo "NOTE: The next command will FAIL if you don't have PERL."
289                 @echo "  If it fails, edit Makefile to use this instead:"
290                 @echo "     ./makeconcordance"
291                 @echo "Here we go..."
292                 ./makeconc.pl
293 #               ./makeconcordance
294
295 $(MAN).gz:      $(MAN)
296                 /bin/rm $@
297                 gzip < $(MAN) > $(MAN).gz
298
299 clean:;         @rm -f $(PROGOBJS) $(TOOLOBJS) core brl-startverse.h brl-startchapter.h vrs2num.index $(PROGINDEX).c $(PROGRAM) $(TOOLS) $(DATADIST) squish.stats squish.data tags $(PROGRAM).rawconcordance $(PROGRAM).wordcounts
300
301 #Don't use this. Use clean :-)
302 #clobber:;      @rm -f $(PROGOBJS) $(TOOLOBJS) $(PROGRAM) $(TOOLS) $(DATA) \
303                         $(PROGINDEX).c squish.stats squish.data core tags
304
305 # depend:;      @mkmf -f $(MAKEFILE) ROOT=$(ROOT)
306
307 echo:;          @echo $(HDRS) $(SRCS)
308
309 index:;         @ctags -wx $(HDRS) $(SRCS)
310
311 print:;         @$(PRINT) $(HDRS) $(SRCS)
312
313 tags:           $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
314
315
316
317 ###############################################################################
318 # Distribution Targets
319 ###############################################################################
320 shar:           $(PROGRAM).shar $(DATA).shar $(PROGRAM)-tools.shar
321
322 $(PROGRAM).shar: $(PROGDIST)
323                 shar -cstem $(PROGDIST) > $<
324
325 $(DATA).shar:   $(DATADIST)
326                 shar -cstem $(DATADIST) > $<
327
328 $(PROGRAM)-tools.shar: $(TOOLSDIST)
329                 shar -cstem $(TOOLSDIST) > $<
330
331
332 TARFILES      = $(PROGRAM).tar.Z \
333                 $(DATA).tar \
334                 $(PROGRAM)-tools.tar.Z \
335                 $(PROGRAM).rawtext.Z
336
337 tar:            $(TARFILES)
338
339 $(PROGRAM).tar.Z: $(PROGDIST)
340                 tar cvf $(PROGRAM).tar $(PROGDIST)
341                 compress $(PROGRAM).tar
342
343 $(DATA).tar:    $(DATADIST)
344                 tar cvf $@ $(DATADIST)
345
346 $(PROGRAM)-tools.tar.Z: $(TOOLSDIST)
347                 tar cvf $(PROGRAM)-tools.tar $(TOOLSDIST)
348                 compress $(PROGRAM)-tools.tar
349
350 # compress raw text data (without deleting uncompressed)
351 $(PROGRAM).rawtext.Z:   $(PROGRAM).rawtext
352                 compress <$(PROGRAM).rawtext >$@
353                 
354 linustape:      tar
355                 @echo "Writing Linus tape on device /dev/rct...\c"
356                 @echo $(TARFILES) | cpio -ocv | tcio -orveVS 8 /dev/rct
357                 @echo " done."
358
359 dattape:        tar
360                 @echo "Writing tar-format tape on device /dev/dat...\c"
361                 tar cvf /dev/dat README.ftp $(TARFILES)
362                 @echo " done."
363
364
365
366 ###############################################################################
367 # Testing Targets
368 ###############################################################################
369 stdresults:     test.results
370                 @echo "Storing Standard test results in test.stdresults...\c"
371                 @cp test.results test.stdresults
372                 @touch stdresults
373                 @echo " done."
374
375 test.results:   testall $(PROGRAM)
376                 @echo "Running Test Suite (results in test.results)...\c"
377                 @./testall > test.results 2>&1
378                 @echo " test suite completed"
379
380 test:           test.results test.stdresults
381                 @echo "Comparing results to standard results"
382                 @if diff -c test.results test.stdresults; \
383                 then echo "  results OK."; \
384                 else echo "  results differ.  Possible error."; fi
385
386
387 ###############################################################################
388 # Release/Version Control/Installation Targets
389 # Except for "install" this will be of no interest to users other than 
390 # the author. 
391 ###############################################################################
392 checkin:        $(RCSFILES)
393                 ci -l $?
394                 touch checkin
395
396 relcheckin:     checkin 
397                 @if [ "$(RELNAME)" = "" ]; \
398                 then echo "*** No RELNAME value specified ***"; \
399                 echo "*** Set RELNAME to release name and export it ***"; \
400                 exit 1; fi
401                 @if [ "$(CFLAGS)" != "-O" ]; \
402                 then echo "*** CFLAGS not set to -O for release ***"; \
403                 echo "*** Set CFLAGS to -O and export it ***"; \
404                 exit 1; fi
405                 rcs -n"$(RELNAME):" -sRel $(RCSFILES)
406                 echo "$(RELNAME)" > relcheckin
407
408 ## $(RCSFILES):;        co $@
409
410 # The nested makes are here because the timestamps don't get updated
411 # correctly from the ci -l otherwise.
412 release:        relcheckin
413                 make all
414                 strip $(PROGRAM)
415                 make stdresults
416                 make tar
417                 make relinstall
418                 touch release
419
420 # The "relinstall" target puts all the pieces of a new release into place on 
421 # my home distribution machine.  Probably nobody else will want this...
422 relinstall: $(PROGRAM) $(DATA) $(DATA).conc $(TARFILES) \
423             $(MAN) $(README) README.ftp ninstall
424                 if hp9000s800;then $(INSTALL) $(PROGRAM) $(RELEASEDIR)/$(PROGRAM).hp-s800;fi
425                 $(INSTALL) $(DATA) $(RELEASEDIR)
426                 $(INSTALL) $(DATA).conc $(RELEASEDIR)
427                 $(INSTALL) $(TARFILES) $(RELEASEDIR)
428                 $(INSTALL) $(MAN) $(RELEASEDIR)
429                 $(INSTALL) $(README) $(RELEASEDIR)/$(README)
430                 $(INSTALL) README.ftp $(RELEASEDIR)/README.ftp
431
432 ninstall:       $(NINSTPKG)
433                 $(INSTALL) $(NINSTPKG) $(NINSTPKGDIR)
434                 .do $(NINSTDIR)/restartd
435
436 # The "install" target could be of general use.  That's why there are
437 # no explicit dependencies here.  They just confuse things...
438 install:
439                 @if [ ! -r $(DEST) ]; then $(MKDIR) $(DEST); fi
440                 @echo Installing $(PROGRAM) in $(DESTBIN)
441                 @if [ ! -r $(DESTBIN) ]; then $(MKDIR) $(DESTBIN); fi
442                 @if [ $(DESTBIN) != . ]; then \
443                 ((cd $(DESTBIN);rm -f $(PROGRAM)); \
444                 cp $(PROGRAM) $(DESTBIN)); \
445                 chown bin $(DESTBIN)/$(PROGRAM); \
446                 chgrp bin $(DESTBIN)/$(PROGRAM); \
447                 chmod 755 $(DESTBIN)/$(PROGRAM); fi
448                 @echo Installing $(DATA) and $(DATA).conc in $(DESTLIB)
449                 @if [ ! -r $(DESTLIB) ]; then $(MKDIR) $(DESTLIB); fi
450                 @if [ $(DESTLIB) != . ]; then \
451                 cp $(DATA) $(DATA).conc $(DESTLIB); \
452                 chown bin $(DESTLIB)/$(DATA) $(DESTLIB)/$(DATA).conc; \
453                 chgrp bin $(DESTLIB)/$(DATA) $(DESTLIB)/$(DATA).conc; \
454                 chmod 644 $(DESTLIB)/$(DATA) $(DESTLIB)/$(DATA).conc; fi
455                 @if [ ! -r $(DESTMAN) ]; then $(MKDIR) $(DESTMAN); fi
456                 @echo Installing $(MAN) in $(DESTMAN1)
457                 @if [ ! -r $(DESTMAN1) ]; then $(MKDIR) $(DESTMAN1); fi
458                 @if [ $(DESTMAN1) != . ]; then \
459                 cp $(MAN) $(DESTMAN1)/$(MAN); \
460                 chown bin $(DESTMAN1)/$(MAN); \
461                 chgrp bin $(DESTMAN1)/$(MAN); \
462                 chmod 644 $(DESTMAN1)/$(MAN); fi
463
464 uninstall:;     @echo Un-installing $(PROGRAM), $(DATA) and $(MAN)
465                 rm -f $(DESTBIN)/$(PROGRAM)
466                 rm -f $(DESTLIB)/$(DATA) $(DESTLIB)/$(DATA).conc
467                 rm -f $(DESTMAN1)/$(MAN)
468
469 # update:               $(DESTBIN)/$(PROGRAM) $(DESTLIB)/$(DATA)
470
471
472
473 ###############################################################################
474 # Header DEPENDENCIES
475 ###############################################################################
476 ###
477 $(PROGRAM).o:   brl.h tsl.h util.h version.h
478 brl.o:          brl.h tsl.h util.h
479 tsl.o:          tsl.h util.h
480 buildcmp.o:     tsl.h util.h
481 makeconcfile.o: tsl.h util.h
482 brl-index.o:    brl-startverse.h brl-startchapter.h