Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / libio / dbz / Makefile.in
1 srcdir = .
2 CFLAGS = -g
3 C_FLAGS = $(CFLAGS) -I$(srcdir) -I.. -I$(srcdir)/.. -DDBZ_FINISH='_IO_flush_all()'
4 CC = `if [ -f ../../../gcc/gcc ] ; \
5         then echo ../../../gcc/gcc -B../../../gcc/ ; \
6         else echo gcc ; fi`
7 LIBIO = ../libio.a ../../libiberty/libiberty.a
8 LIBS = $(LIBIO)
9 # LIBS = ../libcnews.a
10 DBM =
11 RFC = -DHAVERFCIZE
12 CASE = case.o
13 DEBUG = -DDBZDEBUG
14 LINTFLAGS = -h $(DEBUG) $(RFC) -I$(srcdir)
15 LDFLAGS =
16 # =()<NEWSBIN = @<NEWSBIN>@>()=
17 NEWSBIN = /usr/lib/newsbin
18 # workaround for System V make bug
19 SHELL = /bin/sh
20
21 # database sizes for performance tests, regression, and regression prime-find
22 TSIZE=12007
23 RSIZE=4019
24 RPSIZE=2679
25
26 #### host and target dependent Makefile fragments come in here.
27 ##
28
29 # history files for regression and performance tests
30 RHIST=hist3.3
31 R2HIST=hist10
32 THIST=hist13
33
34 #all:   dbz
35 all:
36 install:
37 install-info:
38 info:
39
40 check: r
41         $(MAKE) rclean
42
43 bininstall:     dbz
44         cp dbz $(NEWSBIN)
45
46 cmp:    dbz
47         cmp dbz $(NEWSBIN)/dbz
48
49 newsinstall:
50         : nothing
51
52 u:      dbz.o
53         ar ruv ../libcnews.a dbz.o
54         cmp dbz.h ../h/dbz.h
55
56 t:      tdbz fake
57
58 lint:
59         lint $(LINTFLAGS) dbzmain.c dbz.c
60
61 .c.o:
62         $(CC) $(C_FLAGS) -c $<
63
64 rdbz.o: rdbz.c
65         $(CC) $(C_FLAGS) $(DEBUG) -DDEFSIZE=$(RSIZE) -c rdbz.c
66
67 rdbzmain.o: rdbzmain.c
68         $(CC) $(C_FLAGS) $(RFC) -c rdbzmain.c
69
70 tdbz.o: $(srcdir)/dbz.c
71         cp $(srcdir)/dbz.c tdbz.c
72         $(CC) $(C_FLAGS) -DDEFSIZE=$(TSIZE) -c tdbz.c
73         rm tdbz.c
74
75 dbz:    dbzmain.o $(CASE)
76         $(CC) $(LDFLAGS) dbzmain.o $(CASE) $(PRE) $(DBM) $(LIBS) $(POST) -o $@
77
78 tdbz:   dbzmain.o tdbz.o $(CASE)
79         $(CC) $(LDFLAGS) dbzmain.o tdbz.o $(CASE) $(PRE) $(LIBS) $(POST) -o $@
80
81 rdbz:   rdbzmain.o rdbz.o $(CASE)
82         $(CC) $(LDFLAGS) rdbzmain.o rdbz.o $(CASE) $(PRE) $(LIBS) $(POST) -o $@
83
84 fake:   fake.o random.o
85         $(CC) $(LDFLAGS) fake.o random.o $(PRE) $(LIBS) $(POST) -o $@
86
87 byteflip:       byteflip.o
88         $(CC) $(LDFLAGS) byteflip.o $(PRE) $(LIBS) $(POST) -o $@
89
90 hist10: fake
91         ./fake -t -e 75 10000 >$@
92
93 hist3.3:        fake
94         ./fake -t -e 75 3300 >$@
95
96 hist13: fake
97         ./fake -t -e 75 13000 >$@
98
99 r:      $(srcdir)/getmap $(srcdir)/revbytes $(srcdir)/altbytes stamp-r8
100         : success!
101
102 stamp-r0:
103         : 'WARNING:  creates about 2MB of debris; do "make rclean" afterward'
104         rm -f dbase dbase[23] dbase.* dbase[23].*
105         test ! -d xx || rmdir xx
106         @touch stamp-r0
107
108 stamp-r1: $(RHIST) $(R2HIST) stamp-r0
109         : crude check of synthetic history file
110         ( sed 25q $(RHIST) ; tail -25 $(RHIST) ) >histjunk
111         cmp histjunk $(srcdir)/firstlast25
112         rm histjunk
113         @touch stamp-r1
114
115 r2a: rdbz stamp-r1
116         : basic tests, exercising as many options as possible
117         cp $(RHIST) dbase
118         mkdir xx
119         chmod -w xx
120         ./rdbz -E 1000 -0 -M -i -S -u -U -C xx dbase
121         rmdir xx
122         sed '/> 0/d' $(RHIST) >dbase.used
123         test "`cat dbase.used | wc -l`" -eq "`sed -n '2s/ .*//p' dbase.dir`" ;
124
125 stamp-r2: r2a
126         cp $(RHIST) dbase2
127         ./rdbz -E 1000 -0 -p $(RPSIZE) -t '     ' dbase2
128         cmp $(RHIST) dbase
129         cmp dbase dbase2
130         cmp dbase.dir dbase2.dir
131         cmp dbase.pag dbase2.pag
132         ./rdbz -E 1000 -0 -c dbase
133         ./rdbz -E 1000 -0 -c -i -q -M -U dbase
134         @touch stamp-r2
135
136 stamp-r3: stamp-r2
137         : build a database and then add to it
138         sed 1000q $(RHIST) >dbase2
139         sed 1,1000d $(RHIST) >dbase2.add
140         ./rdbz -E 1000 -0 dbase2
141         ./rdbz -E 1000 -0 -a dbase2 dbase2.add
142         cmp dbase dbase2
143         cmp dbase.dir dbase2.dir
144         cmp dbase.pag dbase2.pag
145         @touch stamp-r3
146
147 stamp-r4: stamp-r3
148         : build based on existing one, test extraction and readonly files
149         ./rdbz -E 1000 -0 -f dbase dbase2
150         test "`cat dbase.used | wc -l`" -eq "`awk 'NR==2{print $$1}' dbase2.dir`" ;
151         test "`cat dbase.used | wc -l`" -eq "`awk 'NR==2{print $$2}' dbase2.dir`" ;
152         chmod -w dbase2.dir dbase2.pag
153         ./rdbz -E 1000 -x dbase2 dbase >dbase.temp
154         cmp dbase.used dbase.temp
155         @touch stamp-r4
156
157 stamp-r5: stamp-r4
158         : try some small case perversions
159         sed 's/\(@[^    ]*\)A/\1a/' dbase >dbase.ick
160         ./rdbz -E 1000 -x dbase2 dbase.ick >dbase.temp
161         cmp dbase.used dbase.temp
162         sed -n 's/A\([^         ]*@\)/a\1/p' dbase >dbase.ick
163         ./rdbz -x dbase2 dbase.ick >dbase.temp
164         test ! -s dbase.temp ;
165         rm -f dbase2.dir dbase2.pag
166         @touch stamp-r5
167
168 stamp-r6: stamp-r5
169         : try it without tags, case-insensitive, with case perversions
170         ./rdbz -E 1000 -0 -p '0 b 1' dbase2
171         tr 'ABCDEFGHIJKLMnopqrstuvwxyz' 'abcdefghijklmNOPQRSTUVWXYZ' <dbase2 >dbase.ick
172         ./rdbz -E 1000 -x dbase2 dbase.ick >dbase.temp
173         cmp dbase.used dbase.temp
174         rm -f dbase.temp dbase.ick
175         @touch stamp-r6
176
177 stamp-r7: byteflip stamp-r6
178         : test various perversions of byte ordering
179         awk -f $(srcdir)/revbytes dbase.dir >dbase2.dir
180         ./byteflip `$(srcdir)/getmap dbase.dir` `$(srcdir)/getmap dbase2.dir` <dbase.pag >dbase2.pag
181         cp dbase dbase2
182         ./rdbz -E 1000 -0 -c dbase2
183         awk -f $(srcdir)/altbytes dbase.dir >dbase2.dir
184         dd conv=swab <dbase.pag >dbase2.pag
185         ./rdbz -E 1000 -0 -c dbase2
186         cp dbase2 dbase3
187         ./rdbz -E 1000 -0 -f dbase2 dbase3
188         ./rdbz -E 1000 -0 -c dbase3
189         test " `$(srcdir)/getmap dbase2.dir`" = " `$(srcdir)/getmap dbase3.dir`" ;
190         @touch stamp-r7
191
192 stamp-r8: stamp-r7
193         : test massive overflow, throw in case sensitivity and tag mask
194         cp $(R2HIST) dbase
195         ./rdbz -E 1000 -0 -p '0 0 7ffc0000' dbase
196         ./rdbz -E 1000 -0 -cq dbase
197         sed 100q dbase | egrep '[aA].*  ' | tr aA Aa >dbase.ick
198         ./rdbz -x dbase dbase.ick >dbase.temp
199         test ! -s dbase.temp ;
200         @touch stamp-r8
201
202 rclean:
203         rm -f dbase dbase[23] dbase.* dbase[23].* fake fake.o random.o
204         rm -f rdbz rdbz.o rdbzmain.o $(RHIST) $(R2HIST) byteflip byteflip.o
205         rm -f histjunk core stamp-r? *~
206         test ! -d xx || rmdir xx
207
208 mostlyclean: rclean
209         rm -f *.o [a-z]dbz [a-z][a-z]dbz junk* PostScript.out
210         rm -f hist* dbase* *.bak mon.out gmon.out core dbm.h
211
212 clean:  mostlyclean
213         rm -f dbz
214
215 distclean: clean
216         rm -rf Makefile config.status rdbz.c rdbzmain.c
217
218 maintainer-clean realclean: distclean