summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 67487a9b68d52af57b9ed91647e0991de3772d17 (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
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
# "Makefile" for scm Scheme Interpreter
# Copyright (C) 1990-2008, 2010 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program.  If not, see
# <http://www.gnu.org/licenses/>.

# Author: Aubrey Jaffer

# These are normally set in "config.status"; defaults are here so that
# "make" won't complain about target redefinitions.
snapdir=$(HOME)/pub/
infodir=$(HOME)/info/
htmldir=$(HOME)/public_html/

SHELL = /bin/sh
INSTALL = install
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_INFO = ginstall-info

SCMLIT = ./scmlit
SCMEXE = ./scm
BUILD = ./build -hsystem

TEXI2HTML = /usr/local/bin/texi2html -split -verbose
TEXI2PDF = texi2pdf
VIEWPDF = evince
MAKEDEV = $(MAKE) -f $(HOME)/makefile.dev
CHPAT = $(HOME)/bin/chpat
RSYNC = rsync -av
Uploadee = csail
SCMOPTS = udscm[45].opt scm[45].opt

# OS-X 10.6, but harmless for other OS.
SETARCH = env DYLD_NO_PIE=1
# Fedora-Core-1
#SETARCH = setarch i386

#CC = gcc
#CFLAGS = -g
#LIBS =
#LD = $(CC) -g
LD = $(CC)

# VERSION is defined in "patchlvl.h"
# RELEASE is for RPMs
RELEASE = 1

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

# ./configure --distdir=${HOME}/dist/ --snapdir=${HOME}/pub/ --htmldir=${HOME}/public_html/ --pdfdir=${HOME}/public_html/

config.status:
	./configure
Makefile: config.status
include config.status

libscmdir = $(libdir)scm/
windistdir = /c/Voluntocracy/dist/
rpm_prefix = $(HOME)/rpmbuild/
prevdocsdir = prevdocs/

# This should be moved to "config.status"
x11incdir=/usr/include/

# directory where COPYING and InitXXX.scm reside.
#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 bytenumb.c differ.c
ufiles = pre-crt0.c ecrt0.c gmalloc.c unexec.c unexelf.c unexhp9k800.c	\
	unexsunos4.c unexalpha.c unexsgi.c unexmacosx.c			\
	macosx-config.h lastfile.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
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
# continue-ia64.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)

tfiles = r4rstest.scm example.scm pi.scm pi.c split.scm bench.scm \
	syntest2.scm syntest1.scm
texifiles = scm.texi fdl.texi indexes.texi platform.txi features.txi
dfiles = ANNOUNCE README COPYING COPYING.LESSER scm.1 scm.doc QUICKREF \
	$(texifiles) scm.info Xlibscm.info Xlibscm.texi \
	hobbit.info hobbit.texi
mfiles = configure Makefile build.scm build build.bat requires.scm \
	.gdbinit mkimpcat.scm disarm.scm scm.spec scm.nsi
sfiles = setjump.mar setjump.s ugsetjump.s continue-ia64.S \
	 get-contoffset-ia64.c
wbfiles = wbtab.scm rwb-isam.scm
catfiles = implcat slibcat
afiles = $(dfiles) ChangeLog $(cfiles) $(hfiles) $(ifiles) $(tfiles)	\
	$(mfiles) $(hobfiles) $(sfiles) $(ufiles) $(xfiles)		\
	version.txi # $(wbfiles) $(turfiles)

lsdfiles = $(ifiles) $(hobfiles) COPYING COPYING.LESSER r4rstest.scm	\
	build.scm mkimpcat.scm patchlvl.h
#*.sl

ctagfiles = $(hfiles) $(cfiles) $(xfiles)
tagfiles = $(ctagfiles) $(ifiles) $(sfiles) $(mfiles)	\
	Xlibscm.texi hobbit.texi build hobbit.scm
#	# $(ufiles) ChangeLog $(dfiles)

installdirs:
	mkdir -p $(DESTDIR)$(includedir)
	mkdir -p $(DESTDIR)$(bindir)
	mkdir -p $(DESTDIR)$(libdir)
	mkdir -p $(DESTDIR)$(libscmdir)
	mkdir -p $(DESTDIR)$(mandir)man1/
	mkdir -p $(DESTDIR)$(infodir)
	mkdir -p $(DESTDIR)$(pdfdir)
	mkdir -p $(DESTDIR)$(dvidir)

platform.txi: build.scm
	$(MAKE) $(SCMLIT)
	$(SCMLIT) -r database-browse -l build.scm \
	-e "(browse build 'platform)" > platform.txi
features.txi: build build.scm
	$(MAKE) $(SCMLIT)
	$(SCMLIT) -l build -e"(make-features-txi)"

scm.dvi: $(texifiles) Makefile
	$(TEXI2DVI) -b -c $<
Xlibscm.dvi: Xlibscm.texi version.txi
	$(TEXI2DVI) -b -c $<
hobbit.dvi: hobbit.texi version.txi
	$(TEXI2DVI) -b -c $<
dvi:	scm.dvi Xlibscm.dvi hobbit.dvi
xdvi:	scm.dvi
	xdvi $<
Xdvi:	Xlibscm.dvi
	xdvi $<
hobdvi:	hobbit.dvi
	xdvi $<
install-dvi: scm.dvi Xlibscm.dvi hobbit.dvi
	$(INSTALL_DATA) $< Xlibscm.dvi hobbit.dvi $(DESTDIR)$(dvidir)

scm.pdf: $(texifiles)
	$(TEXI2PDF) -b -c $<
Xlibscm.pdf: Xlibscm.texi version.txi
	$(TEXI2PDF) -b -c $<
hobbit.pdf: hobbit.texi version.txi
	$(TEXI2PDF) -b -c $<
pdf:	scm.pdf Xlibscm.pdf hobbit.pdf
xpdf:	scm.pdf
	$(VIEWPDF) $<
Xpdf:	Xlibscm.pdf
	$(VIEWPDF) $<
hobpdf:	hobbit.pdf
	$(VIEWPDF) $<
install-pdf: scm.pdf Xlibscm.pdf hobbit.pdf
	$(INSTALL_DATA) $< Xlibscm.pdf hobbit.pdf $(DESTDIR)$(pdfdir)

scm_toc.html: $(texifiles)
	$(TEXI2HTML) $<
$(DESTDIR)$(htmldir)scm_toc.html: scm_toc.html installdirs
	-rm -f scm_stoc.html
	if [ -f $(prevdocsdir)scm_toc.html ]; \
	  then hitch $(prevdocsdir)scm_\*.html scm_\*.html \
		$(DESTDIR)$(htmldir); \
	  else $(INSTALL_DATA) scm_*.html $(DESTDIR)$(htmldir); fi

Xlibscm_toc.html:  Xlibscm.texi version.txi
	$(TEXI2HTML) $<
$(DESTDIR)$(htmldir)Xlibscm_toc.html: Xlibscm_toc.html installdirs
	-rm -f Xlibscm_stoc.html
	chpat '</HEAD>' '<LINK REL="icon" HREF="Logo/SCM.ico">\
<LINK REL="shortcut icon" HREF="Logo/SCM.ico">\
</HEAD>' Xlibscm_*.html
	$(INSTALL_DATA) Xlibscm_*.html $(DESTDIR)$(htmldir)

hobbit_toc.html: hobbit.texi version.txi
	$(TEXI2HTML) $<
$(DESTDIR)$(htmldir)hobbit_toc.html: hobbit_toc.html installdirs
	-rm -f hobbit_stoc.html
	chpat '</HEAD>' '<LINK REL="icon" HREF="Logo/SCM.ico">\
<LINK REL="shortcut icon" HREF="Logo/SCM.ico">\
</HEAD>' hobbit_*.html
	$(INSTALL_DATA) hobbit_*.html $(DESTDIR)$(htmldir)

# html: scm_toc.html Xlibscm_toc.html hobbit_toc.html

# install-html: $(DESTDIR)$(htmldir)scm_toc.html \
# 	$(DESTDIR)$(htmldir)Xlibscm_toc.html \
# 	$(DESTDIR)$(htmldir)hobbit_toc.html

html/scm: $(texifiles)
	mkdir -p html
	rm -rf html/scm
	$(MAKEINFO) --html $< -o html/scm
	if type icoize>/dev/null; then icoize ../Logo/SCM.ico html/scm/*.html; fi
$(DESTDIR)$(htmldir)scm: html/scm
	-rm -rf $(DESTDIR)$(htmldir)scm
	mkdir -p $(DESTDIR)$(htmldir)scm
	$(INSTALL_DATA) html/scm/*.html $(DESTDIR)$(htmldir)scm

html/Xlibscm: Xlibscm.texi version.txi
	mkdir -p html
	rm -rf html/Xlibscm
	$(MAKEINFO) --html $< -o html/Xlibscm
	if type icoize>/dev/null; then icoize ../Logo/SCM.ico html/Xlibscm/*.html; fi
$(DESTDIR)$(htmldir)Xlibscm: html/Xlibscm
	-rm -rf $(DESTDIR)$(htmldir)Xlibscm
	mkdir -p $(DESTDIR)$(htmldir)Xlibscm
	$(INSTALL_DATA) html/Xlibscm/*.html $(DESTDIR)$(htmldir)Xlibscm

html/hobbit: hobbit.texi version.txi
	mkdir -p html
	rm -rf html/hobbit
	$(MAKEINFO) --html $< -o html/hobbit
	if type icoize>/dev/null; then icoize ../Logo/SCM.ico html/hobbit/*.html; fi
$(DESTDIR)$(htmldir)hobbit: html/hobbit
	-rm -rf $(DESTDIR)$(htmldir)hobbit
	mkdir -p $(DESTDIR)$(htmldir)hobbit
	$(INSTALL_DATA) html/hobbit/*.html $(DESTDIR)$(htmldir)hobbit

html: html/scm html/Xlibscm html/hobbit

install-html: $(DESTDIR)$(htmldir)scm \
	$(DESTDIR)$(htmldir)Xlibscm \
	$(DESTDIR)$(htmldir)hobbit


scm-$(VERSION).info: $(texifiles)
	$(MAKEINFO) $< --no-split -o $@
scm.info: scm-$(VERSION).info
	if [ -f $(prevdocsdir)scm.info ]; \
	  then infobar $(prevdocsdir)scm.info $< $@; \
	  else cp $< $@; fi
$(DESTDIR)$(infodir)scm.info: scm.info installdirs
	$(INSTALL_DATA) -p $< $@
	-rm $(DESTDIR)$(infodir)scm.info.gz
	$(POST_INSTALL)    # Post-install commands follow.
	-$(INSTALL_INFO) $@ $(DESTDIR)$(infodir)dir

Xlibscm.info: Xlibscm.texi version.txi
	$(MAKEINFO) $< --no-split -o $@
$(DESTDIR)$(infodir)Xlibscm.info: Xlibscm.info installdirs
	$(INSTALL_DATA) $< $@
	-rm $(DESTDIR)$(infodir)Xlibscm.info*.gz
	$(POST_INSTALL)    # Post-install commands follow.
	-$(INSTALL_INFO) $@ $(DESTDIR)$(infodir)dir

hobbit.info: hobbit.texi version.txi
	$(MAKEINFO) $< --no-split -o hobbit.info
$(DESTDIR)$(infodir)hobbit.info: hobbit.info installdirs
	$(INSTALL_DATA) $< $@
	-rm $(DESTDIR)$(infodir)hobbit.info*.gz
	$(POST_INSTALL)    # Post-install commands follow.
	-$(INSTALL_INFO) $@ $(DESTDIR)$(infodir)dir

install-info: $(DESTDIR)$(infodir)scm.info \
	  $(DESTDIR)$(infodir)Xlibscm.info \
	  $(DESTDIR)$(infodir)hobbit.info
info:	install-info

$(DESTDIR)$(infodir)scm.info.gz: $(DESTDIR)$(infodir)scm.info
	gzip -f $<
$(DESTDIR)$(infodir)Xlibscm.info.gz: $(DESTDIR)$(infodir)Xlibscm.info
	gzip -f $<
$(DESTDIR)$(infodir)hobbit.info.gz: $(DESTDIR)$(infodir)hobbit.info
	gzip -f $<
install-infoz: $(DESTDIR)$(infodir)scm.info.gz \
	  $(DESTDIR)$(infodir)Xlibscm.info.gz \
	  $(DESTDIR)$(infodir)hobbit.info.gz
infoz:	install-infoz

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

# configure.usage: configure
# 	$(srcdir)configure --help >$@ 2>&1

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

docs: README scm.doc install-html install-pdf install-dvi install-infoz

prevdocs: $(prevdocsdir)scm_toc.html $(prevdocsdir)scm.info
$(prevdocsdir)scm_toc.html:
$(prevdocsdir)scm.info:
	cd $(prevdocsdir); unzip -a $(distdir)scm*.zip
	rm $(prevdocsdir)scm/scm.info
	cd $(prevdocsdir)scm; $(MAKE) scm.info; $(MAKE) scm_toc.html
	cd $(prevdocsdir); mv -f scm/scm.info scm/*.html ./
	rm -rf $(prevdocsdir)scm
	-rm -f scm-$(VERSION).info

alld5: udscm5.opt scmlit
	if grep -ie dynamic-linking udscm5.opt>/dev/null && ! $(MAKE) dlls; \
	then \
	  if sed "s/dynamic-linking//g" < udscm5.opt > tmp.opt; then \
	  mv -f tmp.opt udscm5.opt; fi; \
	  if sed "s/dynamic-linking//g" < scm5.opt > tmp.opt; then \
	  mv -f tmp.opt scm5.opt; fi \
	fi
	if ! $(MAKE) dscm5; then $(MAKE) scm5; fi

all5: scm5.opt scmlit
	if grep -ie dynamic-linking scm5.opt>/dev/null && ! $(MAKE) dlls; \
	then \
	  if sed "s/dynamic-linking//g" < scm5.opt > tmp.opt; then \
	  mv -f tmp.opt scm5.opt; fi \
	fi
	$(MAKE) scm5; fi

all:
	if [ -f udscm5.opt -o ! -f scm5.opt ]; then $(MAKE) alld5; \
	else $(MAKE) all5; fi

#	$(MAKE) wbscm.so

require.scm:
	cp -p requires.scm require.scm

# SCMLIT -- Make 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 CHEAP_CONTINUATIONS" >> 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
continue-ia64.o: continue-ia64.S get-contoffset-ia64.c
	gcc -o get-contoffset-ia64 get-contoffset-ia64.c
	./get-contoffset-ia64 contoffset-ia64.S
	gcc -c -o continue-ia64.o continue-ia64.S

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

# R4RS interpreter (not dumpable)
scm4.opt:
	echo "-F cautious bignums arrays inexact" >> scm4.opt
	echo "-F engineering-notation dynamic-linking" >> scm4.opt
#	if type gcc; then echo "--compiler-options=\"-fno-guess-branch-probability\"" >> scm4.opt; fi
scm4:	$(cfiles) $(hfiles) build.scm build scm4.opt
	$(BUILD) -f scm4.opt -o scm -s $(IMPLPATH)
	-rm $(ofiles) scmmain.o
	$(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) checkmacro

# http://www.opensubscriber.com/message/emacs-devel@gnu.org/1007118.html
# Kernels later than 2.6.11 must do (as root) before dumping:
#echo 0 > /proc/sys/kernel/randomize_va_space

# dumpable R4RS interpreter
udscm4.opt:
	$(MAKE) scm4.opt
	cat scm4.opt > udscm4.opt
	echo "-F dump" >> 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
	strip udscm4
dscm4:	udscm4 $(ifiles) require.scm
	if [ -f /proc/sys/kernel/randomize_va_space -a\
	     "`cat /proc/sys/kernel/randomize_va_space`" != "0" ]; then {\
	   cat /proc/sys/kernel/randomize_va_space > randomize_va_space.tmp;\
	   echo 0 > /proc/sys/kernel/randomize_va_space;\
	} fi
	-rm -f slibcat implcat scm~
	-mv scm scm~
	echo "(quit)" | $(SETARCH) ./udscm4 -no-init-file -o scm
	if [ -f randomize_va_space.tmp ]; then {\
	   cat randomize_va_space.tmp > /proc/sys/kernel/randomize_va_space;\
	   rm randomize_va_space.tmp;\
	} fi

# dumpable R5RS interpreter
udscm5.opt:
	$(MAKE) scm5.opt
	cat scm5.opt > udscm5.opt
	echo "-F dump" >> udscm5.opt
udscm5:	$(cfiles) $(ufiles) $(hfiles) build.scm build udscm5.opt
	$(BUILD) -f udscm5.opt -o udscm5 -s $(IMPLPATH)
	-rm $(ofiles) scmmain.o
	strip udscm5
dscm5:	udscm5 $(ifiles) require.scm
	if [ -f /proc/sys/kernel/randomize_va_space -a\
	     "`cat /proc/sys/kernel/randomize_va_space`" != "0" ]; then {\
	   cat /proc/sys/kernel/randomize_va_space > randomize_va_space.tmp;\
	   echo 0 > /proc/sys/kernel/randomize_va_space;\
	} fi
	-rm -f slibcat implcat scm~
	-mv scm scm~
	echo "(quit)" | $(SETARCH) ./udscm5 -no-init-file -r5 -o scm
	if [ -f randomize_va_space.tmp ]; then {\
	   cat randomize_va_space.tmp > /proc/sys/kernel/randomize_va_space;\
	   rm randomize_va_space.tmp;\
	} fi
	$(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 $(cfiles) $(ufiles) $(hfiles) build.scm build
	$(BUILD) -f gdb.opt -o udgdbscm -s $(IMPLPATH)
gdbscm: udgdbscm $(ifiles) require.scm
	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
libscm.a:	libscm.opt scm.h scmfig.h
	$(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
dlls:	dlls.opt
	$(BUILD) -t dll -f dlls.opt -F rev2-procedures	#-c sc2.c
	$(BUILD) -t dll -f dlls.opt -F byte	      	#-c byte.c
	$(BUILD) -t dll -f dlls.opt -F array-for-each 	#-c ramap.c
	$(BUILD) -t dll -f dlls.opt -F differ	      	#-c differ.c
	$(BUILD) -t dll -f dlls.opt -F generalized-c-arguments	#-c gsubr.c
	$(BUILD) -t dll -f dlls.opt -F record		#-c record.c
	-$(BUILD) -t dll -f dlls.opt -F byte-number inexact bignums
	-$(BUILD) -t dll -f dlls.opt -F i/o-extensions	#-c ioext.c
	-$(BUILD) -t dll -f dlls.opt -F posix		#-c posix.c
	-$(BUILD) -t dll -f dlls.opt -F socket		#-c socket.c
	-$(BUILD) -t dll -f dlls.opt -F unix		#-c unix.c
	-$(BUILD) -t dll -f dlls.opt -F regex		#-c rgx.c
	-$(BUILD) -t dll -f dlls.opt -F curses		#-c crs.c
	-$(BUILD) -t dll -f dlls.opt -F edit-line
	-$(MAKE) x.so
#	-$(MAKE) turtlegr.so
mydlls: dlls			# legacy

rwb-isam.scm wbtab.scm: ../wb/rwb-isam.scm ../wb/wbtab.scm
	-cp -f ../wb/rwb-isam.scm ../wb/wbtab.scm ./
wbscm.so: dlls.opt build.scm scm.h scmfig.h ../wb/c/*.c $(wbfiles)
	$(MAKE) $(SCMLIT)
	$(BUILD) -t dll -f dlls.opt -F wb
	$(SCMLIT) -lmkimpcat.scm

turtlegr.so: dlls.opt scm.h scmfig.h
	$(BUILD) -t dll -f dlls.opt -F turtlegr

x.so:	x.c x.h xevent.h dlls.opt scm.h scmfig.h
	$(BUILD) -t dll -f dlls.opt -F x
# Generate x11 include and Scheme files
x11.scm:	inc2scm Makefile
	rm -f x11.scm
	$(SCMLIT) -l inc2scm x11.scm x: $(x11incdir) \
	 X11/X.h X11/cursorfont.h X11/Xlib.h X11/Xutil.h
keysymdef.scm:	inc2scm Makefile
	rm -f keysymdef.scm
	$(SCMLIT) -l inc2scm keysymdef.scm x: $(x11incdir) \
	 X11/keysym.h X11/keysymdef.h
xevent.h xevent.scm xatoms.scm:	xgen.scm Makefile
	$(SCMLIT) -l xgen.scm $(x11incdir)X11/Xlib.h
# x.h:	x.c xevent.h
# 	if [ -x "$(CPROTO)" ]; then $(CPROTO) x.c > x.h; fi

# **************** Tests and Performance ****************
# Check SCMLIT; SCM
checklit: require.scm
	$(SCMLIT) -fr4rstest.scm -e'(test-sc4)(test-delay)(gc)' \
	-e '(or (null? errs) (quit 1))' < /dev/null
Checklit: require.scm
	$(SCMLIT) --no-symbol-case-fold -fr4rstest.scm -e'(test-sc4)(test-delay)(gc)' \
	-e '(or (null? errs) (quit 1))' < /dev/null
check:	r4rstest.scm require.scm
	$(SCMEXE) -fr4rstest.scm -e'(test-sc4)(test-cont)(test-delay)(gc)' \
	-e '(or (null? errs) (quit 1))' < /dev/null
Check:	r4rstest.scm require.scm
	$(SCMEXE) --no-symbol-case-fold -fr4rstest.scm -e'(test-sc4)(test-cont)(test-delay)(gc)' \
	-e '(or (null? errs) (quit 1))' < /dev/null
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))' < /dev/null

# 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)"

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

install-man: scm.1 installdirs
	-$(INSTALL_DATA) $< $(DESTDIR)$(mandir)man1/

install-lib: $(lsdfiles) installdirs
	$(INSTALL_DATA) $(lsdfiles) $(DESTDIR)$(libscmdir)
	$(INSTALL_PROGRAM) build $(DESTDIR)$(libscmdir)
	if [ -f x.so ]; \
		then $(INSTALL_DATA) $(xafiles) $(DESTDIR)$(libscmdir); fi
	if [ -f byte.so ]; \
	 	then $(INSTALL_DATA) *.so $(DESTDIR)$(libscmdir); fi
	if [ -f wbscm.so ]; \
		then $(INSTALL_DATA) $(wbfiles) $(DESTDIR)$(libscmdir); fi
	test -f $(DESTDIR)$(libscmdir)require.scm || \
		$(INSTALL_DATA) requires.scm $(DESTDIR)$(libscmdir)require.scm
	if [ -f libscm.a ]; \
		then $(INSTALL_DATA) libscm.a $(DESTDIR)$(libdir)libscm.a; fi

install: install-man install-lib install-infoz installdirs
	$(INSTALL_PROGRAM) scm scmlit $(DESTDIR)$(bindir)
	-strip $(DESTDIR)$(bindir)scmlit
	$(INSTALL_DATA) scm.h scmfig.h scmflags.h $(DESTDIR)$(includedir)
	$(DESTDIR)$(bindir)scm -br new-catalog

uninstall:
	$(PRE_UNINSTALL)     # Pre-uninstall commands follow.
	-$(INSTALL_INFO) --delete $(DESTDIR)$(infodir)scm.info $(DESTDIR)$(infodir)dir
	-$(INSTALL_INFO) --delete $(DESTDIR)$(infodir)Xlibscm.info $(DESTDIR)$(infodir)dir
	-$(INSTALL_INFO) --delete $(DESTDIR)$(infodir)hobbit.info $(DESTDIR)$(infodir)dir
	$(NORMAL_UNINSTALL)  # Normal commands follow.
	-rm $(DESTDIR)$(bindir)scm $(DESTDIR)$(bindir)scmlit
	-rm $(DESTDIR)$(mandir)man1/scm.1
	-rm $(DESTDIR)$(includedir)scm.h \
	    $(DESTDIR)$(includedir)scmfig.h \
	    $(DESTDIR)$(includedir)scmflags.h
	-rm $(DESTDIR)$(libdir)libscm.a
	-(cd $(DESTDIR)$(libscmdir); \
	  rm $(lsdfiles) build $(xafiles) *.so require.scm \
	     $(wbfiles) $(catfiles))
	-rm $(DESTDIR)$(infodir)scm.info.gz \
	    $(DESTDIR)$(infodir)Xlibscm.info.gz \
	    $(DESTDIR)$(infodir)hobbit.info.gz
	$(POST_UNINSTALL)     # Post-uninstall commands follow.
	-rmdir $(DESTDIR)$(libscmdir)

################ WINDOWS INSTALLER DEFINITIONS ################

winscm5.opt:
	echo "-F arrays array-for-each byte i/o-extensions" >> winscm5.opt
	echo "-F bignums inexact engineering-notation" >> winscm5.opt
	echo "-F cautious rev2-procedures macro" >> winscm5.opt
	echo "-F wb-no-threads" >> winscm5.opt
gw32scmwb.sh:	scmlit winscm5.opt build.scm Makefile version.txi
	./build -p gnu-win32 -f winscm5.opt -w gw32scmwb.sh
scm.exe:	gw32scmwb.sh
	./gw32scmwb.sh

hobbit.html: hobbit.texi
	$(MAKEINFO) --html --no-split hobbit.texi
scm.html: $(texifiles)
	$(MAKEINFO) --html --no-split scm.texi

## to build a windows installer
## make sure makeinfo and NSIS are available on the commandline
w32install:	scm.exe hobbit.html scm.html
	makensis scm.nsi

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

ver = $(VERSION)

temp/scm:	$(afiles)
	-rm -rf temp
	mkdir -p temp/scm
	ln $(afiles) temp/scm

release:	dist pdf	# rpm
	cvs tag -F scm-$(VERSION)
	$(INSTALL_DATA) ANNOUNCE $(htmldir)SCM_ANNOUNCE.txt
	$(RSYNC) $(htmldir)SCM.html $(htmldir)SCM_ANNOUNCE.txt	\
	 $(htmldir)hobbit.pdf $(htmldir)Xlibscm.pdf		\
	 $(Uploadee):public_html/
	$(RSYNC) $(distdir)README $(distdir)scm-$(VERSION).zip		\
	 $(distdir)scm-$(VERSION)-$(RELEASE).*.rpm $(Uploadee):dist/
# upload $(distdir)README $(distdir)scm-$(VERSION).zip ftp.gnu.org:gnu/jacal/
#	 $(distdir)scm-$(VERSION)-$(RELEASE).x86_64.rpm

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

dist:	$(distdir)scm-$(VERSION).zip
$(distdir)scm-$(VERSION).zip:	temp/scm
	$(MAKEDEV) DEST=$(distdir) PROD=scm ver=-$(VERSION) zip

upgnu:	$(distdir)scm-$(VERSION).tar.gz
	cd $(distdir); gnupload --to ftp.gnu.org:scm scm-$(VERSION).tar.gz
tar.gz:	$(distdir)scm-$(VERSION).tar.gz
$(distdir)scm-$(VERSION).tar.gz:	temp/scm/
	$(MAKEDEV) DEST=$(distdir) PROD=scm ver=-$(VERSION) tar.gz

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

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:	$(windistdir)scm-$(VERSION).zip
$(windistdir)scm-$(VERSION).zip: temp/scm $(turfiles) SCM.ico scm.html hobbit.html
	cp -f ../wb/wbtab.scm ../wb/rwb-isam.scm temp/scm/
	$(MAKEDEV) DEST=$(windistdir) PROD=scm ver=-$(VERSION) zip
	-cd ..; zip -9ur $(windistdir)scm-$(VERSION).zip \
		scm/turtle scm/turtlegr.c scm/grtest.scm \
		scm/SCM.ico \
		scm/scm.html scm/hobbit.html
	zip -d $(windistdir)scm-$(VERSION).zip scm/scm.info scm/Xlibscm.info scm/hobbit.info
pubzip:	$(snapdir)scm.zip
$(snapdir)scm.zip:	temp/scm
	$(MAKEDEV) DEST=$(snapdir) PROD=scm zip

diffs:	pubdiffs
pubdiffs:	temp/scm
	$(MAKEDEV) DEST=$(snapdir) PROD=scm pubdiffs
distdiffs:	temp/scm
	$(MAKEDEV) DEST=$(distdir) PROD=scm ver=$(ver) distdiffs

CITERS = ANNOUNCE hobbit.texi hobbit.scm \
	../jacal/ANNOUNCE ../jacal/jacal.texi \
	../wb/ANNOUNCE ../wb/README ../wb/wb.texi \
	../synch/ANNOUNCE \
	$(distdir)README \
	$(windistdir)unzipall.bat $(windistdir)buildall \
	$(htmldir)JACAL.html $(htmldir)README.html \
	$(htmldir)SIMSYNCH.html $(htmldir)SLIB.html \
	$(htmldir)FreeSnell/ANNOUNCE $(htmldir)FreeSnell/index.html
CITES = scm.spec scm.nsi ../wb/wb.spec $(htmldir)SCM.html

updates:	Init$(ver).scm
	$(CHPAT) scm-$(VERSION) scm-$(ver) $(CITERS)
	$(CHPAT) $(VERSION) $(ver) $(CITES)
	$(MAKE) README

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

new:	updates
	echo @set SCMVERSION $(ver) > version.txi
	echo @set SCMDATE `date +"%B %Y"` >> version.txi
	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)

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}' -

ctags:	$(ctagfiles)
	etags $(ctagfiles)

TAGS:	$(tagfiles)
	etags $(tagfiles)
tags:	TAGS

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