summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: b483503d82e6a2380a125200ae57ebef5cda1155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
# Copyright (C) 1990-1999 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software; see the file COPYING.  If not, write to
# the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111, USA.
#
# As a special exception, the Free Software Foundation gives permission
# for additional uses of the text contained in its release of SCM.
#
# The exception is that, if you link the SCM library with other files
# to produce an executable, this does not by itself cause the
# resulting executable to be covered by the GNU General Public License.
# Your use of that executable is in no way restricted on account of
# linking the SCM library code into it.
#
# This exception does not however invalidate any other reasons why
# the executable file might be covered by the GNU General Public License.
#
# This exception applies only to the code released by the
# Free Software Foundation under the name SCM.  If you copy
# code from other Free Software Foundation releases into a copy of
# SCM, as the General Public License permits, the exception does
# not apply to the code that you add in this way.  To avoid misleading
# anyone as to the status of such modified files, you must delete
# this exception notice from them.
#
# If you write modifications of your own for SCM, it is your choice
# whether to permit this exception to apply to your modifications.
# If you do not wish that, delete this exception notice.

# "Makefile" for scm Scheme Interpreter
# Author: Aubrey Jaffer

SHELL = /bin/sh
#CC = gcc
#CFLAGS = -g
#LIBS =
#LD = $(CC) -g
LD = $(CC)
SCMLIT = ./scmlit
SCMEXE = ./scm
#SHOBJS = *.sl
SHOBJS = *.so

#BUILD = ./build -hsystem -p svr4-gcc-sun-ld
BUILD = ./build -hsystem

# Workaround for unexec on Fedora Linux i386
#SETARCH = setarch i386

#for RPMs
RELEASE = 1

intro:
	@echo
	@echo "This is the scm$(VERSION) distribution.  Read \"scm.info\""
	@echo "to learn how to build and install SCM.  Or browse"
	@echo "      http://swiss.csail.mit.edu/~jaffer/SCM"
	@echo
	$(MAKE) scm

srcdir.mk:	Makefile
	echo "CPROTO=`type cproto | sed 's%.* %%'`" > srcdir.mk
	echo "srcdir=`pwd`/" >> srcdir.mk
#srcdir=$(HOME)/scm/
#srcdir=/usr/local/src/scm/
include srcdir.mk

# directory where COPYING and InitXXX.scm reside.
#IMPLPATH = /usr/local/src/scm/
#this one is good for bootstrapping
#IMPLPATH = `pwd`/
IMPLPATH=$(srcdir)
include patchlvl.h
IMPLINIT = $(IMPLPATH)Init$(VERSION).scm

# If pathname where InitXXX.scm resides is not known in advance then
# SCM_INIT_PATH is the environment variable whose value is the
# pathname where InitXXX.scm resides.

hfiles = scm.h scmfig.h setjump.h patchlvl.h continue.h
cfiles = scmmain.c scm.c time.c repl.c ioext.c scl.c sys.c eval.c	\
	subr.c sc2.c unif.c rgx.c crs.c dynl.c record.c posix.c socket.c\
	unix.c rope.c ramap.c gsubr.c edline.c continue.c	\
	findexec.c script.c debug.c byte.c differ.c
ofiles = scm.o time.o repl.o scl.o sys.o eval.o subr.o unif.o rope.o \
	continue.o findexec.o script.o debug.o
# ramap.o
ifiles = Init$(VERSION).scm Transcen.scm Link.scm Macro.scm Macexp.scm \
	Tscript.scm compile.scm Iedline.scm Idiffer.scm
hobfiles = hobbit.scm scmhob.scm scmhob.h
turfiles = turtlegr.c turtle grtest.scm
xafiles = xatoms.scm x11.scm xevent.scm keysymdef.scm
xfiles = x.c x.h xgen.scm xevent.h inc2scm $(xafiles)

all:	require.scm
	$(MAKE) mydlls
	$(MAKE) dscm5
	$(MAKE) x.so
	$(MAKE) db.so
require.scm:
	cp -p requires.scm require.scm

# SCMLIT -- try making this first!
scmlit:	$(ofiles) scmmain.o require.scm Makefile
	$(LD) -o scmlit $(ofiles) scmmain.o $(LIBS)
	$(MAKE) checklit
scmflags.h:	scmflags
scmflags:
	echo "#ifndef IMPLINIT" > newflags.h
	echo "#define IMPLINIT \"$(IMPLINIT)\"" >> newflags.h
	echo "#endif" >> newflags.h
	echo "#define CAUTIOUS" >> newflags.h
	-if (cmp -s newflags.h scmflags.h) then rm newflags.h; \
		 else mv newflags.h scmflags.h; fi
.c.o:
	$(CC) -c $(CFLAGS) $< -o $@
scm.o:	scm.c scm.h scmfig.h scmflags.h patchlvl.h
scmmain.o:	scmmain.c scm.h scmfig.h scmflags.h patchlvl.h
scl.o:	scl.c scm.h scmfig.h scmflags.h
eval.o:	eval.c scm.h scmfig.h scmflags.h setjump.h
debug.o: debug.c scm.h scmfig.h scmflags.h setjump.h
unif.o:	unif.c scm.h scmfig.h scmflags.h
#ramap.o:	ramap.c scm.h scmfig.h scmflags.h
repl.o:	repl.c scm.h scmfig.h scmflags.h setjump.h
sys.o:	sys.c scm.h scmfig.h scmflags.h setjump.h
time.o:	time.c scm.h scmfig.h scmflags.h
subr.o:	subr.c scm.h scmfig.h scmflags.h
rope.o:	rope.c scm.h scmfig.h scmflags.h
continue.o: continue.c continue.h setjump.h scm.h scmfig.h scmflags.h

# Simple build with bignums for running JACAL
scm:	scmlit
	$(BUILD) -s $(IMPLPATH) -F cautious bignums arrays # i/o-extensions
	$(MAKE) check

# R5RS interpreter (not dumpable)
scm5.opt:
	echo "-F cautious bignums arrays inexact" >> scm5.opt
	echo "-F engineering-notation dynamic-linking" >> scm5.opt
	echo "-F macro" >> scm5.opt
#	if type gcc; then echo "--compiler-options=\"-fno-guess-branch-probability\"" >> scm5.opt; fi
scm5:	$(cfiles) $(hfiles) build.scm build scm5.opt
	$(BUILD) -f scm5.opt -o scm -s $(IMPLPATH)
	rm $(ofiles) scmmain.o
	-$(MAKE) check
	-$(MAKE) checkmacro

# dumpable R4RS interpreter
udscm4.opt:
	echo "-F cautious bignums arrays inexact" >> udscm4.opt
	echo "-F engineering-notation dump dynamic-linking" >> udscm4.opt
#	if type gcc; then echo "--compiler-options=\"-fno-guess-branch-probability\"" >> udscm4.opt; fi
udscm4:	$(cfiles) $(hfiles) build.scm build udscm4.opt
	$(BUILD) -f udscm4.opt -o udscm4 -s $(IMPLPATH)
	rm $(ofiles) scmmain.o
dscm4:	udscm4 $(ifiles) require.scm
	-rm slibcat implcat
	-mv scm scm~
	echo "(quit)" | $(SETARCH) ./udscm4 -no-init-file -o scm

# dumpable R5RS interpreter
udscm5.opt:
	$(MAKE) udscm4.opt
	cat udscm4.opt >> udscm5.opt
	echo "-F macro" >> udscm5.opt
#	echo "-DNO_SYM_GC" >> udscm5.opt
udscm5:	$(cfiles) $(hfiles) build.scm build Makefile udscm5.opt
	$(BUILD) -f udscm5.opt -o udscm5 -s $(IMPLPATH)
	rm $(ofiles) scmmain.o
dscm5:	udscm5 $(ifiles) require.scm
	-rm slibcat implcat
	-mv scm scm~
	echo "(quit)" | $(SETARCH) ./udscm5 -no-init-file -r5 -o scm
	$(MAKE) check
	$(MAKE) checkmacro

# R5RS interpreter for debugging with GDB.
gdb.opt: udscm5.opt
	cat udscm5.opt >> gdb.opt
	echo "-F debug" >> gdb.opt
	echo "--compiler-options=-Wall" >> gdb.opt
	echo "--linker-options=-Wall" >> gdb.opt
	echo "-D NO_ENV_CACHE" >> gdb.opt
#	echo "-DTEST_FARLOC -DTEST_SCM2PTR" >> gdb.opt
udgdbscm: gdb.opt
	$(BUILD) -f gdb.opt -o udgdbscm -s $(IMPLPATH)
gdbscm: udgdbscm
	echo "(quit)" | $(SETARCH) ./udgdbscm -no-init-file -r5 -o gdbscm

# R4RS interpreter for profiling
pg.opt: udscm4.opt
	cat udscm4.opt >> pg.opt
	echo "--compiler-options=-pg" >> pg.opt
	echo "--linker-options=-pg" >> pg.opt
	echo "-DLACK_SETITIMER" >> pg.opt
udpgscm: pg.opt
	$(BUILD) -f pg.opt -o udpgscm -s $(IMPLPATH)
pgscm:  udpgscm
	echo "(quit)" | $(SETARCH) ./udpgscm -no-init-file -o pgscm

# R4RS SCM library
libscm.opt:
	echo "-F cautious bignums arrays inexact" >> libscm.opt
	echo "-F engineering-notation" >> libscm.opt
	echo "-F dynamic-linking" >> libscm.opt
mylib:	libscm.a
libscm.a:	libscm.opt
	$(BUILD) -t lib -f libscm.opt
libtest:	libscm.a libtest.c
	$(LD) -o libtest libtest.c libscm.a -ldl -lm -lc
	./libtest

# DLLs for dynamic linking
dlls.opt:
	echo "--compiler-options=-Wall" >> dlls.opt
	echo "--linker-options=-Wall" >> dlls.opt
mydlls:	dlls.opt
	if [ -f /usr/lib/libreadline.so ]; \
		then $(BUILD) -t dll -f dlls.opt -F edit-line; fi
	$(BUILD) -t dll -f dlls.opt -F curses
	$(BUILD) -t dll -f dlls.opt -c sc2.c
	$(BUILD) -t dll -f dlls.opt -c rgx.c
	$(BUILD) -t dll -f dlls.opt -c record.c
	$(BUILD) -t dll -f dlls.opt -c gsubr.c
	$(BUILD) -t dll -f dlls.opt -c ioext.c
	$(BUILD) -t dll -f dlls.opt -c posix.c
	$(BUILD) -t dll -f dlls.opt -c unix.c
	$(BUILD) -t dll -f dlls.opt -c socket.c
	$(BUILD) -t dll -f dlls.opt -c ramap.c
	$(BUILD) -t dll -f dlls.opt -c byte.c

rwb-isam.scm wbtab.scm: ../wb/rwb-isam.scm ../wb/wbtab.scm
	cp ../wb/rwb-isam.scm ../wb/wbtab.scm ./
db.so: dlls.opt rwb-isam.scm wbtab.scm
	if [ -f ../wb/blink.c ]; then \
		$(BUILD) -t dll -f dlls.opt -F wb; fi

differ.so:		differ.c
	$(BUILD) -t dll -f dlls.opt -F differ
myturtle:	dlls.opt
	$(BUILD) -t dll -f dlls.opt -F turtlegr

x.so:	x.c x.h xevent.h dlls.opt
	$(BUILD) -t dll -f dlls.opt -F x

# Generate x11 include and Scheme files
incdir=/usr/include/
x11.scm:	inc2scm
	rm -f x11.scm
	$(SCMLIT) -l inc2scm x11.scm x: $(incdir) X11/X.h X11/cursorfont.h X11/Xlib.h \
	 X11/Xutil.h
keysymdef.scm:	inc2scm
	rm -f keysymdef.scm
	$(SCMLIT) -l inc2scm keysymdef.scm x: $(incdir) X11/keysym.h X11/keysymdef.h
xevent.h xevent.scm xatoms.scm:	xgen.scm Makefile
	$(SCMLIT) -l xgen.scm $(incdir)X11/Xlib.h
x.h:	x.c xevent.h
	if [ -x "$(CPROTO)" ]; then $(CPROTO) x.c > x.h; fi

# Check SCM; SCMLIT function.
checklit:
	$(SCMLIT) -fr4rstest.scm -e'(test-sc4)(test-cont)(test-delay)(gc)' \
	-e '(or (null? errs) (quit 1))'
check:	r4rstest.scm
	$(SCMEXE) -fr4rstest.scm -e'(test-sc4)(test-cont)(test-delay)(gc)' \
	-e '(or (null? errs) (quit 1))'
checkmacro: syntest1.scm syntest2.scm r4rstest.scm
	$(SCMEXE) -rmacro -fsyntest1.scm -fsyntest2.scm \
	 -fr4rstest.scm -e'(test-sc4)(test-cont)(test-delay)' -fsyntest1 \
	-e '(or (null? errs) (quit 1))'

# Measuare running speed of SCM; SCMLIT.  Results are appended to file
# "BenchLog"
bench:
	echo `whoami`@`hostname` testing scm \
	 `$(SCMEXE) -e'(display *scm-version*)'` >> BenchLog
	echo  on `date` >> BenchLog
	ls -l scm >> BenchLog
	size scm >> BenchLog
	uname -a >> BenchLog
	$(SCMEXE) -lbench.scm
	-cat prng.log >> BenchLog
	echo >> BenchLog
	-cat pi.log >> BenchLog
	echo >> BenchLog
	echo
	tail -20 BenchLog
	-rm -f pi.log prng.log
benchlit:
	echo `whoami`@`hostname` testing scmlit \
	 `$(SCMLIT) -e'(display *scm-version*)'` >> BenchLog
	echo  on `date` >> BenchLog
	ls -l scmlit >> BenchLog
	size scmlit >> BenchLog
	uname -a >> BenchLog
	$(SCMLIT) -lbench.scm
	-cat prng.log >> BenchLog
	echo >> BenchLog
	-cat pi.log >> BenchLog
	echo >> BenchLog
	echo
	tail -20 BenchLog
	-rm -f pi.log prng.log
report:
	$(SCMLIT) -e"(slib:report #t)"
	$(SCMEXE) -e"(slib:report #t)"

implcat:	$(SHOBJS) mkimpcat.scm
	$(SCMLIT) -lmkimpcat.scm

htmldir=../public_html/
dvidir=../dvi/
dvi:	$(dvidir)scm.dvi $(dvidir)Xlibscm.dvi $(dvidir)hobbit.dvi
$(dvidir)scm.dvi:	version.txi scm.texi platform.txi features.txi\
	$(dvidir)scm.fn Makefile
#	cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;texi2dvi $(srcdir)scm.texi
	-(cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;texindex scm.??)
	cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;tex $(srcdir)scm.texi
$(dvidir)scm.fn:
	cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;tex $(srcdir)scm.texi
$(dvidir)Xlibscm.dvi:	version.txi Xlibscm.texi $(dvidir)Xlibscm.fn Makefile
#	cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;texi2dvi $(srcdir)Xlibscm.texi
	-(cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;texindex Xlibscm.??)
	cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;tex $(srcdir)Xlibscm.texi
$(dvidir)Xlibscm.fn:
	cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;tex $(srcdir)Xlibscm.texi
$(dvidir)hobbit.dvi:	version.txi hobbit.texi $(dvidir)hobbit.fn Makefile
#	cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;texi2dvi $(srcdir)hobbit.texi
	-(cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;texindex hobbit.??)
	cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;tex $(srcdir)hobbit.texi
$(dvidir)hobbit.fn:
	cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;tex $(srcdir)hobbit.texi
xdvi:	$(dvidir)scm.dvi
	xdvi -s 3 $(dvidir)scm.dvi
Xdvi:	$(dvidir)Xlibscm.dvi
	xdvi -s 3 $(dvidir)Xlibscm.dvi
hobdvi:	$(dvidir)hobbit.dvi
	xdvi -s 3 $(dvidir)hobbit.dvi

pdf:	$(htmldir)scm.pdf $(htmldir)Xlibscm.pdf $(htmldir)hobbit.pdf
$(htmldir)scm.pdf:	version.txi scm.texi platform.txi features.txi\
			$(dvidir)scm.fn Makefile
	cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;pdftex $(srcdir)scm.texi
	mv $(dvidir)scm.pdf $(htmldir)
$(htmldir)Xlibscm.pdf:	version.txi Xlibscm.texi $(dvidir)Xlibscm.fn Makefile
	cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;pdftex $(srcdir)Xlibscm.texi
	mv $(dvidir)Xlibscm.pdf $(htmldir)
$(htmldir)hobbit.pdf:	version.txi hobbit.texi $(dvidir)hobbit.fn Makefile
	cd $(dvidir);TEXINPUTS=$(srcdir):;export TEXINPUTS;pdftex $(srcdir)hobbit.texi
	mv $(dvidir)hobbit.pdf $(htmldir)
xpdf:	$(htmldir)scm.pdf
	xpdf -z 3 $(htmldir)scm.pdf
Xpdf:	$(htmldir)Xlibscm.pdf
	xpdf -z 3 $(htmldir)Xlibscm.pdf
hobpdf:	$(htmldir)hobbit.pdf
	xpdf -z 3 $(htmldir)hobbit.pdf

PREVDOCS = prevdocs/
html:	$(htmldir)scm_toc.html $(htmldir)Xlibscm_toc.html $(htmldir)hobbit_toc.html

TEXI2HTML = /usr/local/bin/texi2html -split -verbose
scm_toc.html:	version.txi scm.texi platform.txi features.txi
	${TEXI2HTML} scm.texi
Xlibscm_toc.html:	version.txi Xlibscm.texi
	${TEXI2HTML} Xlibscm.texi
hobbit_toc.html:	version.txi hobbit.texi
	${TEXI2HTML} hobbit.texi

$(htmldir)scm_toc.html:	scm_toc.html Makefile
	-rm -f scm_stoc.html
	if [ -f $(PREVDOCS)scm_toc.html ]; \
		then hitch $(PREVDOCS)scm_\*.html scm_\*.html $(htmldir); \
		else cp scm_*.html $(htmldir); fi
$(htmldir)Xlibscm_toc.html:	Xlibscm_toc.html Makefile
	-rm -f Xlibscm_stoc.html
	cp Xlibscm_*.html $(htmldir)
$(htmldir)hobbit_toc.html:	hobbit_toc.html Makefile
	-rm -f hobbit_stoc.html
	cp hobbit_*.html $(htmldir)

$(PREVDOCS)scm_toc.html:
$(PREVDOCS)scm.info:	srcdir.mk Makefile
	cd $(PREVDOCS); unzip -a $(dest)scm*.zip
	rm $(PREVDOCS)scm/scm.info
	cd $(PREVDOCS)scm; make scm.info; make scm_toc.html
	cd $(PREVDOCS); mv -f scm/scm.info scm/*.html ./
	rm -rf $(PREVDOCS)scm

################ INSTALL DEFINITIONS ################

rpm_prefix=/usr/src/redhat/

prefix = /usr/local/
exec_prefix = $(prefix)
# directory where `make install' will put executable.
bindir = $(exec_prefix)bin/
libdir = $(exec_prefix)lib/
libscmdir = $(libdir)scm/
# directory where `make install' will put manual page.
mandir = $(prefix)man/
man1dir = $(mandir)man1/
infodir = $(prefix)info/
includedir = $(prefix)include/

README:	build build.scm scm.info
	$(SCMEXE) -l build -e"(make-readme)"

info:	installinfo
installinfo:	$(infodir)scm.info $(infodir)Xlibscm.info $(infodir)hobbit.info

platform.txi:	build.scm
	$(SCMLIT) -r database-browse -l build.scm -e "(browse build 'platform)" \
	> platform.txi
features.txi:	build build.scm
	$(SCMLIT) -l build -e"(make-features-txi)"
scm.info:	version.txi scm.texi platform.txi features.txi
	makeinfo scm.texi --no-split -o scm.info
	mv scm.info scm$(VERSION).info
	if [ -f $(PREVDOCS)scm.info ]; \
		then infobar $(PREVDOCS)scm.info scm$(VERSION).info scm.info; \
		else cp scm$(VERSION).info scm.info; fi
$(infodir)scm.info:	scm.info
	cp -p scm.info $(infodir)scm.info
	-install-info $(infodir)scm.info $(infodir)dir
	-rm $(infodir)scm.info.gz

Xlibscm.info:	version.txi Xlibscm.texi
	makeinfo Xlibscm.texi --no-split -o Xlibscm.info
$(infodir)Xlibscm.info:	Xlibscm.info
	cp Xlibscm.info $(infodir)Xlibscm.info
	-install-info $(infodir)Xlibscm.info $(infodir)dir
	-rm $(infodir)Xlibscm.info*.gz

hobbit.info:	version.txi hobbit.texi
	makeinfo hobbit.texi --no-split -o hobbit.info
$(infodir)hobbit.info:	hobbit.info
	cp hobbit.info $(infodir)hobbit.info
	-install-info $(infodir)hobbit.info $(infodir)dir
	-rm $(infodir)hobbit.info*.gz

infoz:	installinfoz
installinfoz:	$(infodir)scm.info.gz $(infodir)Xlibscm.info.gz $(infodir)hobbit.info.gz
$(infodir)scm.info.gz:	$(infodir)scm.info
	gzip -f $(infodir)scm.info
$(infodir)Xlibscm.info.gz:	$(infodir)Xlibscm.info
	gzip -f $(infodir)Xlibscm.info
$(infodir)hobbit.info.gz:	$(infodir)hobbit.info
	gzip -f $(infodir)hobbit.info

install:	scm.1 db.so wbtab.scm rwb-isam.scm
	test -d $(bindir) || mkdir $(bindir)
	test -d $(mandir) || mkdir $(mandir)
	test -d $(man1dir) || mkdir $(man1dir)
	-cp scm scmlit $(bindir)
	-strip $(bindir)scmlit
	-cp scm.1 $(man1dir)
	test -d $(libdir) || mkdir $(libdir)
	test -d $(libscmdir) || mkdir $(libscmdir)
	-cp $(ifiles) $(hobfiles) COPYING r4rstest.scm $(libscmdir)
	test -f $(libscmdir)require.scm || \
		cp requires.scm $(libscmdir)require.scm
	-cp build build.scm mkimpcat.scm Iedline.scm $(SHOBJS) patchlvl.h\
		$(xafiles) $(libscmdir)
	-cp db.so wbtab.scm rwb-isam.scm $(libscmdir)

installlib:
	test -d $(includedir) || mkdir $(includedir)
	cp scm.h scmfig.h scmflags.h $(includedir)
	test -d $(libdir) || mkdir $(libdir)
	cp libscm.a $(libdir)libscm.a

uninstall:
	-rm $(bindir)scm $(bindir)scmlit
	-rm $(man1dir)scm.1
	-rm $(includedir)scm.h $(includedir)scmfig.h $(includedir)scmflags.h
	-rm $(libdir)libscm.a
	-(cd $(libscmdir); rm $(ifiles) $(hobfiles) COPYING r4rstest.scm)
	-(cd $(libscmdir); rm build build.scm mkimpcat.scm \
		$(SHOBJS) patchlvl.h $(xafiles))
	-(cd $(libscmdir); rm db.so wbtab.scm rwb-isam.scm require.scm)

uninstallinfo:
	-rm $(infodir)scm.info.gz $(infodir)Xlibscm.info.gz\
	    $(infodir)hobbit.info.gz

scm.doc:	scm.1
	nroff -man $< | ul -tunknown >$@

#### Stuff for maintaining SCM below ####

ver = $(VERSION)
version.txi:	patchlvl.h
	echo @set SCMVERSION $(ver) > version.txi
	echo @set SCMDATE `date +"%B %Y"` >> version.txi

RM_R = rm -rf
ufiles = pre-crt0.c ecrt0.c gmalloc.c unexec.c unexelf.c unexhp9k800.c \
	unexsunos4.c unexalpha.c unexsgi.c

#	cxux-crt0.s ecrt0.c gmalloc.c pre-crt0.c unexaix.c unexalpha.c \
#	unexapollo.c unexconvex.c unexec.c unexelf.c unexelf1.c \
#	unexencap.c unexenix.c unexfx2800.c unexhp9k800.c unexmips.c \
#	unexnext.c unexnt.c unexsgi.c unexsni.c unexsunos4.c

confiles = scmconfig.h.in mkinstalldirs acconfig-1.5.h install-sh \
	configure configure.in Makefile.in COPYING README.unix

tfiles = r4rstest.scm example.scm pi.scm pi.c split.scm bench.scm \
	syntest2.scm syntest1.scm
dfiles = ANNOUNCE README COPYING scm.1 scm.doc QUICKREF \
	scm.info scm.texi Xlibscm.info Xlibscm.texi hobbit.info hobbit.texi \
	version.txi platform.txi features.txi ChangeLog
mfiles = Makefile build.scm build build.bat requires.scm \
	.gdbinit mkimpcat.scm disarm.scm scm.spec
vfiles = setjump.mar setjump.s
wbfiles = wbtab.scm rwb-isam.scm
afiles = $(dfiles) $(cfiles) $(hfiles) $(ifiles) $(tfiles) $(mfiles) \
	$(hobfiles) $(vfiles) $(ufiles) $(xfiles) $(turfiles) $(wbfiles)

makedev = make -f $(HOME)/makefile.dev
CHPAT=$(HOME)/bin/chpat
RSYNC=rsync --rsync-path=bin/rsync -bav
UPLOADEE=swissnet_upload
dest = $(HOME)/dist/
DOSCM = /misc/usb1/scm/

temp/scm:	$(afiles)
	-$(RM_R) temp
	mkdir temp
	mkdir temp/scm
	ln $(afiles) temp/scm

release:	dist pdf	# rpm
	cvs tag -F scm$(VERSION)
	cp $(srcdir)ANNOUNCE $(htmldir)SCM_ANNOUNCE.txt
	$(RSYNC) $(htmldir)SCM.html $(htmldir)SCM_ANNOUNCE.txt $(UPLOADEE):public_html/
	$(RSYNC) $(dest)README $(dest)scm$(VERSION).zip \
	 $(dest)scm-$(VERSION)-$(RELEASE).src.rpm $(dest)scm-$(VERSION)-$(RELEASE).i386.rpm \
	 $(htmldir)hobbit.pdf $(htmldir)Xlibscm.pdf $(UPLOADEE):dist/
#	upload $(dest)README $(dest)scm$(VERSION).zip ftp.gnu.org:gnu/jacal/
#	$(MAKE) indiana
indiana:
	upload $(dest)scm$(VERSION).zip ftp@ftp.cs.indiana.edu:/pub/scheme-repository/incoming
	echo -e \
	'I have uploaded scm$(VERSION).zip to ftp.cs.indiana.edu:/pub/scheme-repository/incoming\n' \
	'for placement into ftp.cs.indiana.edu:/pub/scheme-repository/imp/' \
	 | mail -s 'SCM upload' -b jaffer scheme-repository-request@cs.indiana.edu

postnews:
	echo -e "Newsgroups: comp.lang.scheme\n" | cat - ANNOUNCE | \
	inews -h -O -S \
	-f "announce@voluntocracy.org (Aubrey Jaffer & Radey Shouman)" \
	 -t "SCM$(VERSION) Released" -d world

upzip:	$(HOME)/pub/scm.zip
	$(RSYNC) $(HOME)/pub/scm.zip $(UPLOADEE):pub/
	$(RSYNC) r4rstest.scm $(HOME)/dist/
	$(RSYNC) r4rstest.scm $(UPLOADEE):dist/

dist:	$(dest)scm$(VERSION).zip
$(dest)scm$(VERSION).zip:	temp/scm
	$(makedev) DEST=$(dest) PROD=scm ver=$(VERSION) zip

rpm:	pubzip
# $(dest)scm-$(VERSION)-$(RELEASE).i386.rpm:	$(dest)scm$(VERSION).zip
	cp -f $(HOME)/pub/scm.zip $(rpm_prefix)SOURCES/scm$(VERSION).zip
	rpmbuild -ba scm.spec	# --clean
	rm $(rpm_prefix)SOURCES/scm$(VERSION).zip
	mv $(rpm_prefix)RPMS/i386/scm-$(VERSION)-$(RELEASE).i386.rpm \
	   $(rpm_prefix)SRPMS/scm-$(VERSION)-$(RELEASE).src.rpm $(dest)

shar:	scm.shar
scm.shar:	temp/scm
	$(makedev) PROD=scm shar
dclshar:	scm.com
com:	scm.com
scm.com:	temp/scm
	$(makedev) PROD=scm com
zip:	scm.zip
scm.zip:	temp/scm
	$(makedev) PROD=scm zip
doszip:	$(DOSCM)dist/scm$(VERSION).zip
$(DOSCM)dist/scm$(VERSION).zip:	temp/scm turtle turtlegr.c grtest.scm
	$(makedev) DEST=$(DOSCM)dist/ PROD=scm ver=$(VERSION) zip
	cd ..; zip -9ur $(DOSCM)dist/scm$(VERSION).zip \
		scm/turtle scm/turtlegr.c scm/grtest.scm
	zip -d $(DOSCM)dist/scm$(VERSION).zip scm/scm.info scm/Xlibscm.info scm/hobbit.info
pubzip:	$(HOME)/pub/scm.zip
$(HOME)/pub/scm.zip:	temp/scm
	$(makedev) DEST=$(HOME)/pub/ PROD=scm zip

diffs:	pubdiffs
pubdiffs:	temp/scm
	$(makedev) DEST=$(HOME)/pub/ PROD=scm pubdiffs
distdiffs:	temp/scm
	$(makedev) DEST=$(dest) PROD=scm ver=$(ver) distdiffs

CITERS = ANNOUNCE ../jacal/ANNOUNCE \
	../wb/README ../wb/ANNOUNCE ../synch/ANNOUNCE \
	$(htmldir)README.html ../dist/README \
	$(htmldir)SLIB.html $(htmldir)JACAL.html \
	$(htmldir)SCM.html $(htmldir)SIMSYNCH.html \
	../jacal/jacal.texi ../wb/wb.texi \
	$(DOSCM)dist/install.bat $(DOSCM)dist/makefile \
	$(DOSCM)dist/mkdisk.bat hobbit.texi hobbit.scm

updates:	Init$(ver).scm
	$(CHPAT) scm$(VERSION) scm$(ver) $(CITERS)
	$(CHPAT) scm-$(VERSION) scm-$(ver) $(CITERS)
	$(CHPAT) $(VERSION) $(ver) ../wb/wb.spec $(htmldir)SCM.html scm.spec

Init$(ver).scm:
	mv -f Init$(VERSION).scm Init$(ver).scm
	$(CHPAT) $(VERSION) $(ver) patchlvl.h Init$(ver).scm

new:	updates
	echo `date -I` \ Aubrey Jaffer \ \<`whoami`@`hostname`\>> change
	echo>> change
	echo \	\* patchlvl.h \(SCMVERSION\): Bumped from $(VERSION) to $(ver).>>change
	echo>> change
	cat ChangeLog >> change
	mv -f change ChangeLog
	cvs remove Init$(VERSION).scm
	cvs add Init$(ver).scm
	cvs commit -m 'Init$(VERSION).scm changed to Init$(ver).scm' \
		Init$(VERSION).scm Init$(ver).scm
	cvs commit -m '(SCMVERSION): Bumped from $(VERSION) to $(ver).'
	cvs tag -F scm$(ver)

configtemp/scm:	$(confiles)
	-$(RM_R) configtemp/scm
	-mkdir configtemp
	mkdir configtemp/scm
	ln $(confiles) configtemp/scm
confdist:	scmconfig.tar.gz
scmconfig.tar.gz:	configtemp/scm
	cd configtemp; tar cohf ../scmconfig.tar scm
	chmod 664 scmconfig.tar
	-rm -f scmconfig.tar.*z
	gzip scmconfig.tar
	chmod 664 scmconfig.tar.*z

lint:	lints
lints:	$(cfiles) $(hfiles)
	lint $(CPPFLAGS) $(ALL_CFLAGS) $(cfiles) | tee lints
#	lint $(CPPFLAGS) $(ALL_CFLAGS) $(cfiles) | tee lintes

#seds to help find names not unique in first 8 characters (name8s)
# for BSD nm format
SED_TO_STRIP_NM=sed -e '/.*\.o$$/d' -e 's/.* _//' -e 's/.* T //'
#old, bad for T [^_] on suns: SED_TO_STRIP_NM=sed -e '/.*\.o$$/d' -e 's/.* _//'
# For a System V nm where plain C identifiers have _ prepended:
#SED_TO_STRIP_NM=sed -e '/^_[A-Za-z][A-za-z0-9_]*[	 |].*|extern|!d' -e 's/|/ /g' -e 's/^_//'
# For a System V nm where plain C identifiers have nothing prepended:
#SED_TO_STRIP_NM=sed -e '/^[A-Za-z][A-za-z0-9_]*[	 |].*|extern|!d' -e 's/|/ /g'

name8:	name8s
name8s:	scmlit
	nm scmlit |\
	$(SED_TO_STRIP_NM) |\
	sort -u|\
	awk '{	if (substr(l,1,8)==substr($$1,1,8)) {\
			if (p) print l;\
			print $$1;p=0;stat=1\
		}else p=1;\
		l=$$1\
	     }END{exit stat}' -

ctagfiles = $(hfiles) $(cfiles) $(xfiles)
ctags:	$(ctagfiles)
	etags $(ctagfiles)

TAGFILES = $(hfiles) $(cfiles) $(ifiles) $(vfiles)\
	version.txi scm.texi Xlibscm.texi hobbit.texi build $(xfiles) $(mfiles)\
	hobbit.scm
#	# $(ufiles) ChangeLog
TAGS:	$(TAGFILES)
	etags $(TAGFILES)
tags:	TAGS

mostlyclean:
clean:
	-rm -f core a.out ramap.o ramap.obj $(ofiles) scmmain.o lints
	-$(RM_R) *temp
distclean:	clean
	-rm -f $(EXECFILES) *.o *.obj a.out TAGS implcat slibcat gdbscm
realclean:	distclean
	-rm -f scm.doc
realempty:	temp/scm
	-rm -f $(afiles)
myclean:	clean
	-rm -f *~ *.bak *.orig *.rej tmp* \#* *\#