1# Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
2#     1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3#     2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
4#     Massachusetts Institute of Technology
5#
6# This file is part of MIT/GNU Scheme.
7#
8# MIT/GNU Scheme is free software; you can redistribute it and/or
9# modify it under the terms of the GNU General Public License as
10# published by the Free Software Foundation; either version 2 of the
11# License, or (at your option) any later version.
12#
13# MIT/GNU Scheme is distributed in the hope that it will be useful,
14# but 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 MIT/GNU Scheme; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21# 02110-1301, USA.
22
23# **** BEGIN BOILERPLATE ****
24
25SHELL = /bin/sh
26
27
28
29srcdir = .
30top_srcdir = .
31
32prefix = /usr/local
33exec_prefix = ${prefix}
34
35bindir = ${exec_prefix}/bin
36sbindir = ${exec_prefix}/sbin
37libexecdir = ${exec_prefix}/libexec
38datarootdir = ${prefix}/share
39datadir = ${datarootdir}
40sysconfdir = ${prefix}/etc
41sharedstatedir = ${prefix}/com
42localstatedir = ${prefix}/var
43libdir = ${exec_prefix}/lib
44infodir = ${datarootdir}/info
45mandir = ${datarootdir}/man
46includedir = ${prefix}/include
47oldincludedir = /usr/include
48
49DESTDIR =
50top_builddir = .
51
52INSTALL = /usr/bin/install -c
53INSTALL_PROGRAM = ${INSTALL}
54INSTALL_DATA = ${INSTALL} -m 644
55INSTALL_SCRIPT = ${INSTALL}
56
57LN_S = ln -s
58ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
59mkinstalldirs = $(SHELL) $(top_srcdir)/microcode/mkinstalldirs
60
61# **** END BOILERPLATE ****
62
63LIARC_BOOT_BUNDLES = compiler cref sf star-parser
64LIARC_BUNDLES = $(LIARC_BOOT_BUNDLES) edwin ffi imail sos ssp xml
65
66SUBDIRS = $(INSTALLED_SUBDIRS) 6001 rcs win32 xdoc
67INSTALLED_SUBDIRS = microcode runtime $(LIARC_BUNDLES)
68
69MIT_SCHEME_EXE = mit-scheme-x86-64
70AUXDIR_NAME = mit-scheme-x86-64
71AUXDIR = $(libdir)/mit-scheme-x86-64
72EDDIR = $(AUXDIR)/edwin
73
74default-target: all
75
76all: all-native
77
78check:
79	./microcode/scheme --library lib --batch-mode \
80	  --load ../tests/check.scm --eval '(%exit)'
81
82all-native: microcode/scheme
83all-native: lib/runtime.com
84all-native: lib/all.com
85all-native: all-compiler
86all-native: all-cref
87all-native: all-edwin
88all-native: all-ffi
89all-native: all-imail
90all-native: all-runtime
91all-native: all-sf
92all-native: all-sos
93all-native: all-ssp
94all-native: all-star-parser
95all-native: all-win32
96all-native: all-xml
97all-native: cross-target
98
99#COMPILER_SETTINGS_CROSS = (set! compiler:cross-compiling? true)
100#COMPILER_SETTINGS_LIARC = (set! compiler:invoke-c-compiler? false)
101
102TOOL_COMPILER_SETTINGS = \
103	$(COMPILER_SETTINGS_CROSS) \
104	$(COMPILER_SETTINGS_LIARC)
105
106HOST_SCHEME = '$(MIT_SCHEME_EXE)' --batch-mode
107TOOL_COMPILER = $(TOOL_TOOLCHAIN)
108TOOL_SYNTAXER = $(HOST_SCHEME) --band ./tools/syntaxer.com
109TOOL_TOOLCHAIN = $(HOST_SCHEME) --band ./tools/compiler.com \
110  --eval '(begin $(TOOL_COMPILER_SETTINGS))'
111
112.PHONY: toolchain
113toolchain: tools/compiler.com
114
115tools/compiler.com:
116	$(MAKE) -f Makefile.tools clean && $(MAKE) -f Makefile.tools allclean
117
118# This target toolchain crud is a kludge until the whole system can be
119# cross-compiled.  Currently only IMAIL can't be.
120TARGET_COMPILER_SETTINGS = \
121	$(COMPILER_SETTINGS_LIARC)
122
123TARGET_RUNTIME = ./microcode/scheme \
124	--library lib --band runtime.com --batch-mode
125TARGET_COMPILER = $(TARGET_RUNTIME) \
126	--eval '(load-option (quote COMPILER))' \
127	--eval '(begin $(TARGET_COMPILER_SETTINGS))'
128TARGET_SYNTAXER = $(TARGET_RUNTIME) \
129	--eval '(load-option (quote CREF))' \
130	--eval '(load-option (quote SF))'
131TARGET_TOOLCHAIN = $(TARGET_RUNTIME) \
132	--eval '(load-option (quote COMPILER))' \
133	--eval '(load-option (quote CREF))' \
134	--eval '(load-option (quote SF))' \
135	--eval '(begin $(TARGET_COMPILER_SETTINGS))'
136
137.PHONY: target-toolchain
138target-toolchain: all-compiler
139target-toolchain: all-cref
140target-toolchain: all-sf
141target-toolchain: cross-target
142target-toolchain: lib/runtime.com
143
144#microcode/scheme: all-runtime
145#microcode/scheme: microcode/svm1-defns.h
146microcode/scheme:
147	(cd microcode && $(MAKE) all)
148
149# XXX This should really depend on microcode/gen-nonce and
150# microcode/extract-liarc-decls instead of microcode/scheme, but
151# splitting up dependencies within the microcode subdirectory is more
152# trouble than it's worth right now.  Later, we should reorganize the
153# directory structure to better reflect the build rather than just
154# shoving all the C code into microcode/.
155.PHONY: liarc-bundle-tools
156liarc-bundle-tools: microcode/scheme
157
158lib/runtime.com: all-runtime
159lib/runtime.com: cross-target
160lib/runtime.com: microcode/scheme
161	(. etc/functions.sh && get_fasl_file && cd runtime \
162	  && (echo '(disk-save "../$@")' \
163	       | ../microcode/scheme --batch-mode --library ../lib \
164	           --fasl "$${FASL}"))
165
166lib/compiler.com: all-compiler
167lib/compiler.com: all-edwin
168lib/compiler.com: all-sf
169lib/compiler.com: lib/runtime.com
170lib/compiler.com: microcode/scheme
171	(echo '(begin' && \
172	 echo '  (load-option (quote COMPILER))' && \
173	 echo '  (load-option (quote SF))' && \
174	 echo '  (disk-save "$@"))') \
175	| ./microcode/scheme --batch-mode --library lib --band runtime.com
176
177lib/all.com: all-compiler
178lib/all.com: all-edwin
179lib/all.com: all-sf
180lib/all.com: lib/runtime.com
181lib/all.com: microcode/scheme
182	(echo '(begin' && \
183	 echo '  (load-option (quote COMPILER))' && \
184	 echo '  (load-option (quote SF))' && \
185	 echo '  (load-option (quote EDWIN))' && \
186	 echo '  (disk-save "$@"))') \
187	| ./microcode/scheme --batch-mode --library lib --band runtime.com
188
189.PHONY: save
190save:
191	@echo 'Saving objects...'
192	@rm -rf saved-objects && \
193	mkdir saved-objects && \
194	( \
195	  find $(SUBDIRS) -type f \
196	    \( \
197	      -name '*.bci' -o \
198	      -name '*.bin' -o \
199	      -name '*.c' -o \
200	      -name '*.com' -o \
201	      -name '*.crf' -o \
202	      -name '*.ext' -o \
203	      -name '*.fre' -o \
204	      -name '*.moc' -o \
205	      -name '*.o' -o \
206	      -name '*.pkd' -o \
207	      -name '*.so' -o \
208	      -false \
209	    \) \
210	    -print0 \
211	  | pax -rw -pe -l -v -d -0 saved-objects/. \
212	) || { rm -rf saved-objects; exit 1; }
213
214.PHONY: restore
215restore:
216	@echo 'Restoring objects...'
217	@if ! test -d saved-objects; then exit 1; fi && \
218	(cd saved-objects && pax -rw -pe -v . ../../.)
219
220### Stuff we build with the tools compiler necessarily from scratch.
221
222# This rule is for LIARC.
223.SUFFIXES: .bld .pkd .c
224.pkd.c .bld.c: toolchain
225	echo '(cbf "$<")' | $(TOOL_COMPILER)
226
227# Compiler (LIAR)
228
229# The subdirectories can be compiled independently and in parallel, but
230# syntaxing the compiler is too hairy right now to do without the
231# compiler.sf script(s).
232
233.PHONY: all-compiler
234all-compiler: compile-compiler
235#all-compiler: bundle-compiler
236
237.PHONY: bundle-compiler
238bundle-compiler: liarc-bundle-tools
239bundle-compiler: compile-compiler
240bundle-compiler: compiler/compiler-os2.c
241bundle-compiler: compiler/compiler-unx.c
242bundle-compiler: compiler/compiler-w32.c
243	(cd compiler && $(MAKE) compile-liarc-bundle)
244
245.PHONY: compile-compiler
246compile-compiler: compile-compiler-back
247compile-compiler: compile-compiler-base
248compile-compiler: compile-compiler-fggen
249compile-compiler: compile-compiler-fgopt
250compile-compiler: compile-compiler-machine
251compile-compiler: compile-compiler-rtlbase
252compile-compiler: compile-compiler-rtlgen
253compile-compiler: compile-compiler-rtlopt
254
255.PHONY: compile-compiler-back
256compile-compiler-back: toolchain
257compile-compiler-back: syntax-compiler
258	echo '(compile-directory "compiler/back")' | $(TOOL_COMPILER)
259
260.PHONY: compile-compiler-base
261compile-compiler-base: toolchain
262compile-compiler-base: syntax-compiler
263	echo '(compile-directory "compiler/base")' | $(TOOL_COMPILER)
264
265.PHONY: compile-compiler-fggen
266compile-compiler-fggen: toolchain
267compile-compiler-fggen: syntax-compiler
268	echo '(compile-directory "compiler/fggen")' | $(TOOL_COMPILER)
269
270.PHONY: compile-compiler-fgopt
271compile-compiler-fgopt: toolchain
272compile-compiler-fgopt: syntax-compiler
273	echo '(compile-directory "compiler/fgopt")' | $(TOOL_COMPILER)
274
275.PHONY: compile-compiler-machine
276compile-compiler-machine: toolchain
277compile-compiler-machine: syntax-compiler
278	echo '(compile-directory "compiler/machine")' | $(TOOL_COMPILER)
279
280.PHONY: compile-compiler-rtlbase
281compile-compiler-rtlbase: toolchain
282compile-compiler-rtlbase: syntax-compiler
283	echo '(compile-directory "compiler/rtlbase")' | $(TOOL_COMPILER)
284
285.PHONY: compile-compiler-rtlgen
286compile-compiler-rtlgen: toolchain
287compile-compiler-rtlgen: syntax-compiler
288	echo '(compile-directory "compiler/rtlgen")' | $(TOOL_COMPILER)
289
290.PHONY: compile-compiler-rtlopt
291compile-compiler-rtlopt: toolchain
292compile-compiler-rtlopt: syntax-compiler
293	echo '(compile-directory "compiler/rtlopt")' | $(TOOL_COMPILER)
294
295.PHONY: syntax-compiler
296syntax-compiler: toolchain
297#syntax-compiler: compiler/machines/svm/svm1-defns.h
298syntax-compiler: cref-compiler
299	(echo '(with-working-directory-pathname "compiler"' && \
300	 echo '  (lambda () (load "compiler.sf")))') \
301	| $(TOOL_SYNTAXER)
302
303.PHONY: cref-compiler
304cref-compiler: compiler/compiler-unx.pkd
305
306compiler/compiler-unx.pkd: toolchain
307compiler/compiler-unx.pkd: compiler/compiler.pkg
308compiler/compiler-unx.pkd: cref-runtime
309compiler/compiler-unx.pkd: cref-sf
310	(echo '(with-working-directory-pathname "compiler"' && \
311	 echo '  (lambda ()' && \
312	 echo '    (cref/generate-trivial-constructor "compiler")))') \
313	| $(TOOL_SYNTAXER)
314
315# XXX Kludgey bogus rules for liarc.
316compiler/compiler-os2.pkd: compiler/compiler-unx.pkd
317compiler/compiler-w32.pkd: compiler/compiler-unx.pkd
318
319# CREF
320
321.PHONY: all-cref
322all-cref: compile-cref
323#all-cref: bundle-cref
324
325.PHONY: bundle-cref
326bundle-cref: liarc-bundle-tools
327bundle-cref: compile-cref
328bundle-cref: cref/cref-os2.c
329bundle-cref: cref/cref-unx.c
330bundle-cref: cref/cref-w32.c
331	(cd cref && $(MAKE) compile-liarc-bundle)
332
333.PHONY: compile-cref
334compile-cref: toolchain
335compile-cref: syntax-cref
336	(echo '(with-working-directory-pathname "cref"' && \
337	 echo '  (lambda () (load "cref.cbf")))') \
338	| $(TOOL_COMPILER)
339
340.PHONY: syntax-cref
341syntax-cref: toolchain
342syntax-cref: cref-cref
343	(echo '(with-working-directory-pathname "cref"' && \
344	 echo '  (lambda () (load "cref.sf")))') \
345	| $(TOOL_SYNTAXER)
346
347.PHONY: cref-cref
348cref-cref: cref/cref-unx.pkd
349
350cref/cref-unx.pkd: toolchain
351cref/cref-unx.pkd: cref-runtime
352cref/cref-unx.pkd: cref/cref.pkg
353	(echo '(with-working-directory-pathname "cref"' && \
354	 echo '  (lambda ()' && \
355	 echo '    (cref/generate-trivial-constructor "cref")))') \
356	| $(TOOL_SYNTAXER)
357
358# XXX Kludgey bogus rules for liarc.
359cref/cref-os2.pkd: cref/cref-unx.pkd
360cref/cref-w32.pkd: cref/cref-unx.pkd
361
362# Runtime
363
364.PHONY: all-runtime
365all-runtime: compile-runtime
366#all-runtime: bundle-runtime
367
368.PHONY: bundle-runtime
369bundle-runtime: runtime/runtime-os2.c
370bundle-runtime: runtime/runtime-unx.c
371bundle-runtime: runtime/runtime-w32.c
372
373.PHONY: compile-runtime
374compile-runtime: toolchain
375compile-runtime: syntax-runtime
376	(echo '(with-working-directory-pathname "runtime"' && \
377	 echo '  (lambda () (load "runtime.cbf")))') \
378	| $(TOOL_COMPILER)
379
380.PHONY: compile-runtime
381syntax-runtime: toolchain
382syntax-runtime: cref-runtime
383	(echo '(with-working-directory-pathname "runtime"' && \
384	 echo '  (lambda () (load "runtime.sf")))') \
385	| $(TOOL_SYNTAXER)
386
387.PHONY: cref-runtime
388cref-runtime: runtime/runtime-unx.pkd
389
390runtime/runtime-unx.pkd: toolchain
391runtime/runtime-unx.pkd: runtime/runtime.pkg
392	(echo '(with-working-directory-pathname "runtime"' && \
393	 echo '  (lambda ()' && \
394	 echo '    (cref/generate-trivial-constructor "runtime")))') \
395	| $(TOOL_SYNTAXER)
396
397# XXX Kludgey bogus rules for liarc.
398runtime/runtime-os2.pkd: runtime/runtime-unx.pkd
399runtime/runtime-w32.pkd: runtime/runtime-unx.pkd
400
401# SF
402
403.PHONY: all-sf
404all-sf: compile-sf
405#all-sf: bundle-sf
406
407.PHONY: bundle-sf
408bundle-sf: liarc-bundle-tools
409bundle-sf: compile-sf
410bundle-sf: sf/sf-os2.c
411bundle-sf: sf/sf-unx.c
412bundle-sf: sf/sf-w32.c
413	(cd sf && $(MAKE) compile-liarc-bundle)
414
415.PHONY: compile-sf
416compile-sf: toolchain
417compile-sf: syntax-sf
418	(echo '(with-working-directory-pathname "sf"' && \
419	 echo '  (lambda () (load "sf.cbf")))') \
420	| $(TOOL_COMPILER)
421
422.PHONY: syntax-sf
423syntax-sf: toolchain
424syntax-sf: cref-sf
425	(echo '(with-working-directory-pathname "sf"' && \
426	 echo '  (lambda () (load "sf.sf")))') \
427	| $(TOOL_SYNTAXER)
428
429.PHONY: cref-sf
430cref-sf: sf/sf-unx.pkd
431
432sf/sf-unx.pkd: toolchain
433sf/sf-unx.pkd: cref-runtime
434sf/sf-unx.pkd: sf/sf.pkg
435	(echo '(with-working-directory-pathname "sf"' && \
436	 echo '  (lambda ()' && \
437	 echo '    (cref/generate-trivial-constructor "sf")))') \
438	| $(TOOL_SYNTAXER)
439
440# XXX Kludgey bogus rules for liarc.
441sf/sf-os2.pkd: sf/sf-unx.pkd
442sf/sf-w32.pkd: sf/sf-unx.pkd
443
444### More stuff we build with tools.  We could build it with the newly
445### built compiler in the native case, but we want to avoid having to
446### do that to encourage cross-compilation.
447
448# Edwin
449
450.PHONY: all-edwin
451all-edwin: compile-edwin
452#all-edwin: bundle-edwin
453
454.PHONY: bundle-edwin
455bundle-edwin: liarc-bundle-tools
456bundle-edwin: compile-edwin
457bundle-edwin: edwin/edwin.c
458bundle-edwin: edwin/edwin-os2.c
459bundle-edwin: edwin/edwin-unx.c
460bundle-edwin: edwin/edwin-w32.c
461	(cd edwin && $(MAKE) compile-liarc-bundle)
462
463edwin/edwin.bld: syntax-edwin
464
465.PHONY: compile-edwin
466compile-edwin: toolchain
467compile-edwin: syntax-edwin
468	(echo '(with-working-directory-pathname "edwin"' && \
469	 echo '  (lambda () (load "edwin.cbf")))') \
470	| $(TOOL_TOOLCHAIN)
471
472.PHONY: syntax-edwin
473syntax-edwin: toolchain
474syntax-edwin: cref-edwin
475	(echo '(with-working-directory-pathname "edwin"' && \
476	 echo '  (lambda () (load "edwin.sf")))') \
477	| $(TOOL_TOOLCHAIN)
478
479.PHONY: cref-edwin
480cref-edwin: edwin/edwin-unx.pkd
481
482edwin/edwin-unx.pkd: toolchain
483edwin/edwin-unx.pkd: cref-runtime
484edwin/edwin-unx.pkd: cref-win32
485edwin/edwin-unx.pkd: cref-xml
486edwin/edwin-unx.pkd: edwin/edwin.pkg
487	(echo '(with-working-directory-pathname "edwin"' && \
488	 echo '  (lambda ()' && \
489	 echo '    (cref/generate-trivial-constructor "edwin")))') \
490	| $(TOOL_SYNTAXER)
491
492# XXX Kludgey bogus rules for liarc.
493edwin/edwin-os2.pkd: edwin/edwin-unx.pkd
494edwin/edwin-w32.pkd: edwin/edwin-unx.pkd
495
496# FFI
497
498.PHONY: all-ffi
499all-ffi: compile-ffi
500#all-ffi: bundle-ffi
501
502.PHONY: bundle-ffi
503bundle-ffi: liarc-bundle-tools
504bundle-ffi: compile-ffi
505bundle-ffi: ffi/ffi-os2.c
506bundle-ffi: ffi/ffi-unx.c
507bundle-ffi: ffi/ffi-w32.c
508	(cd ffi && $(MAKE) compile-liarc-bundle)
509
510.PHONY: compile-ffi
511compile-ffi: toolchain
512compile-ffi: cref-ffi
513compile-ffi: syntax-cref	# XXX Urgh!  Should not be here!
514	(echo '(with-working-directory-pathname "ffi"' && \
515	 echo '  (lambda () (load "compile.scm")))') \
516	| $(TOOL_TOOLCHAIN)
517
518.PHONY: cref-ffi
519cref-ffi: ffi/ffi-unx.pkd
520
521ffi/ffi-unx.pkd: toolchain
522ffi/ffi-unx.pkd: cref-runtime
523ffi/ffi-unx.pkd: ffi/ffi.pkg
524	(echo '(with-working-directory-pathname "ffi"' && \
525	 echo '  (lambda ()' && \
526	 echo '    (cref/generate-trivial-constructor "ffi")))') \
527	| $(TOOL_SYNTAXER)
528
529# XXX Kludgey bogus rules for liarc.
530ffi/ffi-os2.pkd: ffi/ffi-unx.pkd
531ffi/ffi-w32.pkd: ffi/ffi-unx.pkd
532
533# SOS
534
535.PHONY: all-sos
536all-sos: compile-sos
537#all-sos: bundle-sos
538
539.PHONY: bundle-sos
540bundle-sos: liarc-bundle-tools
541bundle-sos: compile-sos
542bundle-sos: sos/sos-os2.c
543bundle-sos: sos/sos-unx.c
544bundle-sos: sos/sos-w32.c
545	(cd sos && $(MAKE) compile-liarc-bundle)
546
547.PHONY: compile-sos
548compile-sos: toolchain
549compile-sos: cref-sos
550	(echo '(with-working-directory-pathname "sos"' && \
551	 echo '  (lambda () (load "compile")))') \
552	| $(TOOL_TOOLCHAIN)
553
554.PHONY: cref-sos
555cref-sos: sos/sos-unx.pkd
556
557sos/sos-unx.pkd: toolchain
558sos/sos-unx.pkd: cref-runtime
559sos/sos-unx.pkd: sos/sos.pkg
560	(echo '(with-working-directory-pathname "sos"' && \
561	 echo '  (lambda ()' && \
562	 echo '    (cref/generate-trivial-constructor "sos")))') \
563	| $(TOOL_SYNTAXER)
564
565# XXX Kludgey bogus rules for liarc.
566sos/sos-os2.pkd: sos/sos-unx.pkd
567sos/sos-w32.pkd: sos/sos-unx.pkd
568
569# SSP
570
571.PHONY: all-ssp
572all-ssp: compile-ssp
573#all-ssp: bundle-ssp
574
575.PHONY: bundle-ssp
576bundle-ssp: liarc-bundle-tools
577bundle-ssp: compile-ssp
578bundle-ssp: ssp/ssp-os2.c
579bundle-ssp: ssp/ssp-unx.c
580bundle-ssp: ssp/ssp-w32.c
581	(cd ssp && $(MAKE) compile-liarc-bundle)
582
583.PHONY: compile-ssp
584compile-ssp: toolchain
585compile-ssp: cref-ssp
586	(echo '(with-working-directory-pathname "ssp"' && \
587	 echo '  (lambda () (load "compile")))') \
588	| $(TOOL_TOOLCHAIN)
589
590.PHONY: cref-ssp
591cref-ssp: ssp/ssp-unx.pkd
592
593ssp/ssp-unx.pkd: toolchain
594ssp/ssp-unx.pkd: cref-runtime
595ssp/ssp-unx.pkd: cref-xml
596ssp/ssp-unx.pkd: ssp/ssp.pkg
597	(echo '(with-working-directory-pathname "ssp"' && \
598	 echo '  (lambda ()' && \
599	 echo '    (cref/generate-trivial-constructor "ssp")))') \
600	| $(TOOL_SYNTAXER)
601
602# XXX Kludgey bogus rules for liarc.
603ssp/ssp-os2.pkd: ssp/ssp-unx.pkd
604ssp/ssp-w32.pkd: ssp/ssp-unx.pkd
605
606# *PARSER
607
608.PHONY: all-star-parser
609all-star-parser: compile-star-parser
610#all-star-parser: bundle-star-parser
611
612.PHONY: bundle-star-parser
613bundle-star-parser: liarc-bundle-tools
614bundle-star-parser: compile-star-parser
615bundle-star-parser: star-parser/parser-os2.c
616bundle-star-parser: star-parser/parser-unx.c
617bundle-star-parser: star-parser/parser-w32.c
618	(cd star-parser && $(MAKE) compile-liarc-bundle)
619
620.PHONY: compile-star-parser
621compile-star-parser: toolchain
622compile-star-parser: cref-star-parser
623	(echo '(with-working-directory-pathname "star-parser"' && \
624	 echo '  (lambda () (load "compile")))') \
625	| $(TOOL_TOOLCHAIN)
626
627.PHONY: cref-star-parser
628cref-star-parser: star-parser/parser-unx.pkd
629
630star-parser/parser-unx.pkd: toolchain
631star-parser/parser-unx.pkd: cref-runtime
632star-parser/parser-unx.pkd: star-parser/parser.pkg
633	(echo '(with-working-directory-pathname "star-parser"' && \
634	 echo '  (lambda ()' && \
635	 echo '    (cref/generate-trivial-constructor "parser")))') \
636	| $(TOOL_SYNTAXER)
637
638# XXX Kludgey bogus rules for liarc.
639star-parser/parser-os2.pkd: star-parser/parser-unx.pkd
640star-parser/parser-w32.pkd: star-parser/parser-unx.pkd
641
642# Windows FFI
643
644.PHONY: all-win32
645all-win32: compile-win32
646
647.PHONY: compile-win32
648compile-win32: toolchain
649compile-win32: syntax-win32
650	(echo '(with-working-directory-pathname "win32"' && \
651	 echo '  (lambda () (load "win32.cbf")))') \
652	| $(TOOL_COMPILER)
653
654.PHONY: syntax-win32
655syntax-win32: toolchain
656syntax-win32: cref-win32
657	(echo '(with-working-directory-pathname "win32"' && \
658	 echo '  (lambda () (load "win32.sf")))') \
659	| $(TOOL_SYNTAXER)
660
661.PHONY: cref-win32
662cref-win32: win32/win32-unx.pkd		# XXX Er...
663
664win32/win32-unx.pkd: toolchain
665win32/win32-unx.pkd: cref-runtime
666win32/win32-unx.pkd: win32/win32.pkg
667	(echo '(with-working-directory-pathname "win32"' && \
668	 echo '  (lambda ()' && \
669	 echo '    (cref/generate-trivial-constructor "win32")))') \
670	| $(TOOL_SYNTAXER)
671
672# XXX Kludgey bogus rules for liarc.
673win32/win32-os2.pkd: win32/win32-unx.pkd
674win32/win32-w32.pkd: win32/win32-unx.pkd
675
676# XML
677
678.PHONY: all-xml
679all-xml: compile-xml
680#all-xml: bundle-xml
681
682.PHONY: bundle-xml
683bundle-xml: liarc-bundle-tools
684bundle-xml: compile-xml
685bundle-xml: xml/xml-os2.c
686bundle-xml: xml/xml-unx.c
687bundle-xml: xml/xml-w32.c
688	(cd xml && $(MAKE) compile-liarc-bundle)
689
690.PHONY: compile-xml
691compile-xml: toolchain
692compile-xml: cref-xml
693	(echo '(with-working-directory-pathname "xml"' && \
694	 echo '  (lambda () (load "compile")))') \
695	| $(TOOL_TOOLCHAIN)
696
697.PHONY: cref-xml
698cref-xml: xml/xml-unx.pkd
699
700xml/xml-unx.pkd: toolchain
701xml/xml-unx.pkd: cref-runtime
702xml/xml-unx.pkd: cref-sos
703xml/xml-unx.pkd: cref-star-parser
704xml/xml-unx.pkd: xml/xml.pkg
705	(echo '(with-working-directory-pathname "xml"' && \
706	 echo '  (lambda ()' && \
707	 echo '    (cref/generate-trivial-constructor "xml")))') \
708	| $(TOOL_SYNTAXER)
709
710# XXX Kludgey bogus rules for liarc.
711xml/xml-os2.pkd: xml/xml-unx.pkd
712xml/xml-w32.pkd: xml/xml-unx.pkd
713
714### Cross-compilation finish-up.
715
716# We split this up into two targets, cross-host and cross-target, so
717# that you can type `make cross-host' to do everything on the
718# cross-compilation host, transfer everything over, and then run `make'
719# to do the rest, since the default target depends on cross-target.
720# (Rsync should help iterating this process.)
721#
722# Anything that depends on running the target code should depend on
723# cross-target, and there should be a plan for obviating the need to
724# run the target code.  Currently this is only IMAIL.
725
726.PHONY: cross-host
727cross-host: compile-compiler
728cross-host: compile-cref
729cross-host: compile-edwin
730cross-host: compile-ffi
731#cross-host: compile-imail
732cross-host: compile-runtime
733cross-host: compile-sf
734cross-host: compile-sos
735cross-host: compile-ssp
736cross-host: compile-star-parser
737cross-host: compile-win32
738cross-host: compile-xml
739cross-host: microcode/scheme
740cross-host: syntax-compiler
741cross-host: syntax-runtime
742
743.PHONY: cross-target
744cross-target: cross-host
745#cross-target: cross-end
746
747.PHONY: cross-end
748cross-end: cross-host
749	(echo '(let ((env (->environment (quote (RUNTIME)))))' && \
750	 echo '  (load "../compiler/base/crsend" env)' && \
751	 echo '  ((access FINISH-CROSS-COMPILATION:DIRECTORY env) ".."))') \
752	| (cd runtime && ../microcode/scheme --batch-mode --library ../lib \
753	    --fasl make.bin)
754
755### Stuff that depends on running the code we just compiled, because it
756### uses Edwin macros.  This is a kludge until we can fix macro phasing
757### and persuade the cross-compiler to load and run macros for the
758### target.
759
760# IMAIL
761
762.PHONY: all-imail
763all-imail: compile-imail
764#all-imail: bundle-imail
765
766.PHONY: bundle-imail
767bundle-imail: liarc-bundle-tools
768bundle-imail: compile-imail
769bundle-imail: imail/imail-os2.c
770bundle-imail: imail/imail-unx.c
771bundle-imail: imail/imail-w32.c
772	(cd imail && $(MAKE) compile-liarc-bundle)
773
774# Must write these rules explicitly because we use TARGET_COMPILER, not
775# TOOL_COMPILER.
776#
777# XXX These depend on imail/imail-unx.pkd intentionally because make
778# has no good way to express a rule that generates multiple files at
779# once.
780imail/imail-os2.c: imail/imail-unx.pkd
781	echo '(cbf "imail/imail-os2.pkd")' | $(TARGET_COMPILER)
782imail/imail-unx.c: imail/imail-unx.pkd
783	echo '(cbf "imail/imail-unx.pkd")' | $(TARGET_COMPILER)
784imail/imail-w32.c: imail/imail-unx.pkd
785	echo '(cbf "imail/imail-w32.pkd")' | $(TARGET_COMPILER)
786
787# XXX We enter lib/imail/ rather than imail/ so that liarc library
788# directory pathnames get resolved to builtin objects.  This is a
789# kludge.
790
791.PHONY: compile-imail
792compile-imail: target-toolchain
793compile-imail: compile-edwin
794compile-imail: compile-runtime
795compile-imail: compile-sos
796compile-imail: compile-star-parser
797compile-imail: cref-imail
798	(echo '(begin' && \
799	 echo '  (load-option (quote *PARSER))' && \
800	 echo '  (load-option (quote EDWIN))' && \
801	 echo '  (load-option (quote SOS))' && \
802	 echo '  (with-working-directory-pathname "lib/imail"' && \
803	 echo '    (lambda ()' && \
804	 echo '      (load "compile"))))') \
805	| $(TARGET_TOOLCHAIN)
806
807.PHONY: cref-imail
808cref-imail: imail/imail-unx.pkd
809
810#IMAIL_CREF_PRELOAD = \
811#	echo '(load-option (quote SOS))' && \
812#	echo '(load-option (quote EDWIN))' && \
813#	echo '(load-option (quote *PARSER))' &&
814
815imail/imail-unx.pkd: target-toolchain
816imail/imail-unx.pkd: cref-edwin
817imail/imail-unx.pkd: cref-runtime
818imail/imail-unx.pkd: cref-sos
819imail/imail-unx.pkd: cref-star-parser
820#imail/imail-unx.pkd: all-edwin
821#imail/imail-unx.pkd: all-runtime
822#imail/imail-unx.pkd: all-sos
823#imail/imail-unx.pkd: all-star-parser
824imail/imail-unx.pkd: imail/imail.pkg
825	(echo '(begin' && \
826	 $(IMAIL_CREF_PRELOAD) \
827	 echo '  (with-working-directory-pathname "lib/imail"' && \
828	 echo '    (lambda ()' && \
829	 echo '      (cref/generate-trivial-constructor "imail"))))') \
830	| $(TARGET_SYNTAXER)
831
832# **** Legacy serialized targets ****
833
834all-svm: microcode/svm1-defns.h
835	$(MAKE) compile-microcode
836	@$(top_srcdir)/etc/compile-svm.sh "$(MIT_SCHEME_EXE)"
837	$(MAKE) build-bands
838
839microcode/svm1-defns.h: compiler/machines/svm/svm1-defns.h
840	@$(top_srcdir)/etc/maybe-update-file.sh \
841	  compiler/machines/svm/svm1-defns.h \
842	  microcode/svm1-defns.h
843
844compiler/machines/svm/svm1-defns.h: \
845	  compiler/machines/svm/assembler-rules.scm \
846	  compiler/machines/svm/machine.scm \
847	  compiler/machines/svm/assembler-compiler.scm \
848	  compiler/machines/svm/assembler-runtime.scm \
849	  compiler/machines/svm/compile-assembler.scm
850	( cd compiler/machines/svm/ \
851	  && "$(MIT_SCHEME_EXE)" --batch-mode --load compile-assembler \
852		</dev/null )
853
854all-liarc:
855	@$(top_srcdir)/etc/c-compile.sh "$(MIT_SCHEME_EXE)" --batch-mode
856	$(MAKE) compile-liarc-bundles build-bands
857
858macosx-app: stamp_macosx-app
859
860stamp_macosx-app: all
861	etc/macosx/make-app.sh
862	echo "done" > $@
863
864compile-microcode:
865	(cd microcode && $(MAKE) all)
866
867stamp_install-microcode: compile-microcode
868	(cd microcode; $(MAKE) install)
869	echo "done" > $@
870
871build-bands:
872	@$(top_srcdir)/etc/build-bands.sh
873
874# **** Make liarc distribution from native ****
875
876liarc-dist:
877	@$(top_srcdir)/etc/compile-boot-compiler.sh "$(MIT_SCHEME_EXE)"
878	@$(top_srcdir)/etc/c-prepare.sh "$(MIT_SCHEME_EXE)"
879	$(MAKE) distclean
880
881# **** Build liarc from distribution ****
882
883stamp_compile-liarc-boot-bundles: stamp_install-microcode
884	etc/make-in-subdirs.sh compile-liarc-bundle $(LIARC_BOOT_BUNDLES)
885	echo "done" > $@
886
887stamp_install-liarc-boot-bundles: stamp_compile-liarc-boot-bundles
888	etc/make-in-subdirs.sh install-liarc-bundle $(LIARC_BOOT_BUNDLES)
889	echo "done" > $@
890
891stamp_build-liarc-boot-compiler: stamp_install-liarc-boot-bundles
892	@$(top_srcdir)/etc/build-boot-compiler.sh
893	echo "done" > $@
894
895stamp_install-liarc-boot-compiler: stamp_build-liarc-boot-compiler
896	$(MAKE) install-auxdir-top
897	echo "done" > $@
898
899stamp_liarc-compile-scheme:
900	@$(top_srcdir)/etc/c-compile.sh boot-root/bin/mit-scheme-c \
901	    --library boot-root/lib/mit-scheme-c --band boot-compiler.com
902	echo "done" > $@
903
904stamp_compile-liarc-bundles: stamp_liarc-compile-scheme compile-liarc-bundles
905	echo "done" > $@
906
907compile-liarc-bundles: compile-microcode
908	etc/make-in-subdirs.sh compile-liarc-bundle $(LIARC_BUNDLES)
909
910install-liarc-bundles:
911	etc/make-in-subdirs.sh install-liarc-bundle $(LIARC_BUNDLES)
912
913# **** Build native from liarc ****
914
915stamp_build-native-boot-compiler: stamp_install-microcode
916	@$(top_srcdir)/etc/build-boot-compiler.sh
917	echo "done" > $@
918
919stamp_install-native-boot-compiler: stamp_build-native-boot-compiler
920	$(MAKE) install-auxdir-top
921	echo "done" > $@
922
923stamp_native-compile-scheme: compile-microcode
924	@$(top_srcdir)/etc/compile.sh boot-root/bin/mit-scheme \
925	    --library boot-root/lib/$(AUXDIR_NAME) --band boot-compiler.com
926	echo "done" > $@
927
928
929mostlyclean clean distclean maintainer-clean c-clean:
930	$(top_srcdir)/Clean.sh $@ $(SUBDIRS)
931
932clean-boot-root:
933	rm -rf boot-root
934	rm -f stamp_*
935
936tags TAGS:
937	$(top_srcdir)/Tags.sh $(SUBDIRS)
938
939subdir-list:
940	@for D in $(SUBDIRS); do echo $$D; done
941
942install: install-standard
943
944install-standard: install-auxdir-top
945	etc/make-in-subdirs.sh install $(INSTALLED_SUBDIRS)
946	$(mkinstalldirs) $(DESTDIR)$(EDDIR)
947	$(INSTALL_DATA) $(top_srcdir)/etc/TUTORIAL $(DESTDIR)$(EDDIR)/.
948
949install-auxdir-top:
950	$(mkinstalldirs) $(DESTDIR)$(AUXDIR)
951	$(INSTALL_DATA) $(top_srcdir)/etc/optiondb.scm $(DESTDIR)$(AUXDIR)/.
952	$(INSTALL_DATA) lib/*.com $(DESTDIR)$(AUXDIR)/.
953
954.PHONY: default-target all all-native all-liarc all-svm macosx-app
955.PHONY: compile-microcode build-bands
956.PHONY: liarc-dist compile-liarc-bundles install-liarc-bundles
957.PHONY: mostlyclean clean distclean maintainer-clean c-clean clean-boot-root
958.PHONY: tags TAGS subdir-list install install-standard install-auxdir-top
959