Skip to content
This repository was archived by the owner on Sep 13, 2019. It is now read-only.

Commit 499328e

Browse files
committed
cs: restructure makefile dependencies
Make a build directory for "cs/c" drive other makefiles in a way that tracks dependencies well and keeps all built files in the build directory.
1 parent a403744 commit 499328e

20 files changed

+419
-146
lines changed

racket/collects/setup/main.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
(if (and (pair? (cdr flags))
149149
(pair? (cddr flags)))
150150
(begin
151-
(set! go-module (cadr flags))
151+
(set! go-module (list 'file (cadr flags)))
152152
(set! print-loading-sources? #t)
153153
(let ([root (path->complete-path (caddr flags))])
154154
(current-compiled-file-roots (list root)))

racket/src/README

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ To build the experimental variant of Racket that runs on Chez Scheme
2727
see "cs/c/README.txt".
2828

2929
The rest of the instructions below are about building the traditional
30-
Racket implementation.
30+
Racket implementation, but a general "Implementation Organization"
31+
note at the end applies to both variants.
3132

3233
========================================================================
3334
Compiling for Windows
@@ -107,10 +108,10 @@ Quick instructions:
107108
make
108109
make install
109110

110-
This will create an in-place installation of Racket and store the
111-
results of C compilation in a separate "build" subdirectory, which
112-
is useful if you need to update your sources, delete the build, and
113-
start from scratch.
111+
Those commands will create an in-place installation of Racket and
112+
store the results of C compilation in a separate "build"
113+
subdirectory, which is useful if you need to update your sources,
114+
delete the build, and start from scratch.
114115

115116
You can also run the typical `./configure && make && make install` if
116117
you don't anticipate updating/rebuilding, but it will be harder to
@@ -479,3 +480,61 @@ of built-in identifiers, be sure to update the version number in
479480
"racket/src/schvers.h", so that various tools know to rebuild
480481
bytecode. If you add or remove primitives, you'll also need to adjust
481482
the counter in "racket/src/schminc.h" .
483+
484+
========================================================================
485+
Implementation Organization
486+
========================================================================
487+
488+
Everything in this "src" directory contributes to the implementation
489+
of the `racket` executable (and variants), while "../collects"
490+
contains the additional Racket libraries that are included in a
491+
minimal Racket distribution.
492+
493+
Directories in "src":
494+
495+
"racket" --- starting point for the traditional Racket implementation
496+
497+
"cs" --- starting point for the Racket-on-Chez implementation
498+
499+
"rktio" --- portability layer for low-level I/O, used by "racket" and
500+
"cs"
501+
502+
"start" --- main-executable wrapper, used by "racket" and "cs"
503+
504+
"foreign" --- the FFI implementation for "racket", including "libffi"
505+
(as needed for some platforms)
506+
507+
"expander" --- the macro expander's implementation, used by "racket"
508+
and "cs"; doubles as the "expander" package
509+
510+
"thread" --- the thread scheduler's implementation, used by "cs"
511+
512+
"io" --- the Racket I/O implementation, used by "cs"
513+
514+
"regexp" --- the regexp matcher's implementation, used by "cs"
515+
516+
"schemify" --- a Racket-to-Scheme compiler, used by "cs" and "cify"
517+
518+
"cify" --- a Racket-to-C compiler, used by "racket" when embedding
519+
the expander as C code instead of Racket bytecode
520+
521+
"common" --- Racket libraries used by "thread", "io", etc.
522+
523+
"gracket" --- implementation of the GRacket layer
524+
525+
"mzcom" --- implementation of the MzCOM layer (for Windows)
526+
527+
"mysink" --- `ffi/unsafe/com` helper DLL implementation (for Windows)
528+
529+
"mac" --- scripts for Mac OS ".app"s, used by "gracket"
530+
531+
"worksp" --- Windows projects and build scripts for "racket"
532+
533+
"native-libs" --- build scripts for some native-library packages
534+
535+
"lt" --- libtool/configure support
536+
537+
"utils" --- miscellaneous
538+
539+
"setup-go.rkt" --- helper script used by parts of the build that need
540+
to run substantial Racket programs

racket/src/cs/Makefile

Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ DEBUG_COMP = # --debug
1010
# Controls whether Rumble is built as unsafe:
1111
RUMBLE_UNSAFE_COMP = --unsafe
1212

13-
COMPILE_FILE = $(SCHEME) --script compile-file.ss $(UNSAFE_COMP) $(DEBUG_COMP)
14-
COMPILE_FILE_DEPS = compile-file.ss
13+
COMPILE_FILE = $(SCHEME) --script compile-file.ss $(UNSAFE_COMP) $(DEBUG_COMP) --dest "$(BUILDDIR)"
14+
COMPILE_FILE_DEPS = compile-file.ss include.ss
1515

1616
RACKET_SETUP_ARGS = ../../bin/racket ../collects ../etc 0 false
1717

@@ -20,46 +20,51 @@ PRIMITIVES_TABLES = primitive/kernel.ss primitive/unsafe.ss primitive/flfxnum.ss
2020
primitive/futures.ss primitive/foreign.ss primitive/place.ss \
2121
primitive/linklet.ss primitive/internal.ss
2222

23+
# Set by the makefile in the "c" directory when driving this one
24+
BUILDDIR =
25+
2326
CONVERT_DEPS = convert.rkt $(PRIMITIVES_TABLES)
2427

25-
CONVERT = $(RACKET) -l- raco make convert.rkt && $(RACKET) convert.rkt $(UNSAFE_COMP)
28+
CONVERT_RACKET = $(RACKET) -l- raco make convert.rkt && $(RACKET)
29+
CONVERT = $(CONVERT_RACKET) convert.rkt $(UNSAFE_COMP)
2630

27-
THREAD_DEPS = chezpart.so rumble.so
28-
IO_DEPS = $(THREAD_DEPS) thread.so
29-
REGEXP_DEPS = $(IO_DEPS) io.so
30-
SCHEMIFY_DEPS = $(REGEXP_DEPS) regexp.so
31-
LINKLET_DEPS = $(SCHEMIFY_DEPS) schemify.so
32-
EXPANDER_DEPS = $(LINKLET_DEPS) linklet.so
33-
MAIN_DEPS = $(EXPANDER_DEPS) expander.so
31+
RUMBLE_DEPS = $(BUILDDIR)chezpart.so
32+
THREAD_DEPS = $(RUMBLE_DEPS) $(BUILDDIR)rumble.so
33+
IO_DEPS = $(THREAD_DEPS) $(BUILDDIR)thread.so
34+
REGEXP_DEPS = $(IO_DEPS) $(BUILDDIR)io.so
35+
SCHEMIFY_DEPS = $(REGEXP_DEPS) $(BUILDDIR)regexp.so
36+
LINKLET_DEPS = $(SCHEMIFY_DEPS) $(BUILDDIR)schemify.so
37+
EXPANDER_DEPS = $(LINKLET_DEPS) $(BUILDDIR)linklet.so
38+
MAIN_DEPS = $(EXPANDER_DEPS) $(BUILDDIR)expander.so
3439

3540
all:
3641
$(MAKE) rktio
3742
$(MAKE) rktl
38-
$(MAKE) racket.so
43+
$(MAKE) $(BUILDDIR)racket.so
3944

40-
expander-demo: expander.so demo/expander.ss
41-
$(SCHEME) $(EXPANDER_DEPS) expander.so demo/expander.ss
45+
expander-demo: $(BUILDDIR)expander.so demo/expander.ss
46+
$(SCHEME) $(EXPANDER_DEPS) $(BUILDDIR)expander.so demo/expander.ss
4247

43-
run: main.so ../../bin/racket
44-
$(SCHEME) --script main.so $(RACKET_SETUP_ARGS) $(ARGS)
48+
run: $(BUILDDIR)main.so ../../bin/racket
49+
$(SCHEME) --script $(BUILDDIR)main.so $(RACKET_SETUP_ARGS) $(ARGS)
4550

4651
setup:
4752
$(MAKE) run ARGS="-l- setup $(ARGS)"
4853

4954
setup-v:
5055
$(MAKE) run ARGS="-W 'info@compiler/cm info@linklet debug@GC:major error' -l- setup $(ARGS)"
5156

52-
run-wpo: racket.so ../../bin/racket
53-
$(SCHEME) --script racket.so $(RACKET_SETUP_ARGS) $(ARGS)
57+
run-wpo: $(BUILDDIR)racket.so ../../bin/racket
58+
$(SCHEME) --script $(BUILDDIR)racket.so $(RACKET_SETUP_ARGS) $(ARGS)
5459

55-
racket.so: main.so $(COMPILE_FILE_DEPS)
56-
$(COMPILE_FILE) --whole-program racket.so main.wpo
60+
$(BUILDDIR)racket.so: $(BUILDDIR)main.so $(COMPILE_FILE_DEPS)
61+
$(COMPILE_FILE) --whole-program $(BUILDDIR)racket.so $(BUILDDIR)main.wpo
5762

58-
main.so: $(MAIN_DEPS) main.sps $(COMPILE_FILE_DEPS)
63+
$(BUILDDIR)main.so: $(MAIN_DEPS) main.sps $(COMPILE_FILE_DEPS)
5964
$(COMPILE_FILE) main.sps $(MAIN_DEPS)
6065

6166
strip:
62-
${SCHEME} --script strip.ss $(MAIN_DEPS) racket.so
67+
${SCHEME} --script strip.ss $(MAIN_DEPS) $(BUILDDIR)racket.so
6368

6469
rktl:
6570
$(MAKE) thread-rktl
@@ -73,106 +78,101 @@ rktl:
7378
mkdir -p ../../bin
7479
touch ../../bin/racket
7580

76-
expander.so: expander.sls compiled/expander.scm $(PRIMITIVES_TABLES) $(EXPANDER_DEPS) $(COMPILE_FILE_DEPS)
81+
$(BUILDDIR)expander.so: expander.sls $(BUILDDIR)compiled/expander.scm $(PRIMITIVES_TABLES) $(EXPANDER_DEPS) $(COMPILE_FILE_DEPS)
7782
$(COMPILE_FILE) expander.sls $(EXPANDER_DEPS)
7883

79-
compiled/expander.scm: ../expander/compiled/expander.rktl $(CONVERT_DEPS)
80-
$(CONVERT) ../expander/compiled/expander.rktl compiled/expander.scm
84+
$(BUILDDIR)compiled/expander.scm: $(BUILDDIR)compiled/expander.rktl $(CONVERT_DEPS)
85+
$(CONVERT) $(BUILDDIR)compiled/expander.rktl $(BUILDDIR)compiled/expander.scm
8186

82-
..expander/compiled/expander.rktl:
83-
$(MAKE) expander-rktl
87+
$(BUILDDIR)compiled/expander.rktl:
88+
$(MAKE) expander-rktl BUILDDIR="../cs/"
8489

8590
expander-rktl:
8691
$(MAKE) bounce BOUNCE_DIR=../expander BOUNCE_TARGET=expander-src
8792

88-
linklet-demo: linklet.so
89-
$(SCHEME) $(LINKLET_DEPS) linklet.so demo/linklet.ss
93+
linklet-demo: $(BUILDDIR)linklet.so
94+
$(SCHEME) $(LINKLET_DEPS) $(BUILDDIR)linklet.so demo/linklet.ss
9095

91-
linklet.so: linklet.sls $(LINKLET_DEPS) $(COMPILE_FILE_DEPS)
96+
$(BUILDDIR)linklet.so: linklet.sls $(LINKLET_DEPS) $(COMPILE_FILE_DEPS)
9297
$(COMPILE_FILE) linklet.sls $(LINKLET_DEPS)
9398

9499

95-
schemify.so: schemify.sls compiled/schemify.scm compiled/known.scm $(SCHEMIFY_DEPS) $(COMPILE_FILE_DEPS)
100+
$(BUILDDIR)schemify.so: schemify.sls $(BUILDDIR)compiled/schemify.scm $(BUILDDIR)compiled/known.scm $(SCHEMIFY_DEPS) $(COMPILE_FILE_DEPS)
96101
$(COMPILE_FILE) schemify.sls $(SCHEMIFY_DEPS)
97102

98-
compiled/schemify.scm: compiled/schemify.rktl $(CONVERT_DEPS)
99-
$(CONVERT) --skip-export compiled/schemify.rktl compiled/schemify.scm
103+
$(BUILDDIR)compiled/schemify.scm: $(BUILDDIR)compiled/schemify.rktl $(CONVERT_DEPS)
104+
$(CONVERT) --skip-export $(BUILDDIR)compiled/schemify.rktl $(BUILDDIR)compiled/schemify.scm
100105

101-
# Ignoring functions from `#%read` works beause they won't appear in
102-
# the simplified expansion. Make annotation references direct to
103-
# improve performance. Declaring "collect.rkt" pure works around a
104-
# limitation of the flattener.
105-
IGNORE = ++knot read - ++direct kernel ++pure ../../collects/racket/private/collect.rkt
106-
107-
compiled/schemify.rktl:
106+
$(BUILDDIR)compiled/schemify.rktl:
108107
$(MAKE) schemify-rktl
109108

110109
schemify-rktl:
111-
$(RACKET) -N raco -l- raco make ../expander/bootstrap-run.rkt
112-
$(RACKET) ../expander/bootstrap-run.rkt -t ../schemify/main.rkt -c compiled/cache-src -k ../.. $(IGNORE) -s -x -o compiled/schemify.rktl
110+
$(MAKE) bounce BOUNCE_DIR=../schemify BOUNCE_TARGET=schemify-src BUILDDIR="../cs/"
113111

114112

115113
# Used by schemify.sls at compile time
116-
compiled/known.scm: compiled/known.rktl $(CONVERT_DEPS)
117-
$(CONVERT) --skip-export compiled/known.rktl compiled/known.scm
114+
$(BUILDDIR)compiled/known.scm: $(BUILDDIR)compiled/known.rktl $(CONVERT_DEPS)
115+
$(CONVERT) --skip-export $(BUILDDIR)compiled/known.rktl $(BUILDDIR)compiled/known.scm
116+
117+
$(BUILDDIR)compiled/known.rktl:
118+
$(MAKE) known-rktl
118119

119-
compiled/known.rktl: ../schemify/known.rkt
120-
$(RACKET) -N raco -l- raco make ../expander/bootstrap-run.rkt
121-
$(RACKET) ../expander/bootstrap-run.rkt -t ../schemify/known.rkt -c compiled/cache-src -k ../.. $(IGNORE) -s -x -o compiled/known.rktl
120+
known-rktl:
121+
$(MAKE) bounce BOUNCE_DIR=../schemify BOUNCE_TARGET=known-src BUILDDIR="../cs/"
122122

123123

124-
regexp-demo: regexp.so
125-
$(SCHEME) $(REGEXP_DEPS) regexp.so demo/regexp.ss
124+
regexp-demo: $(BUILDDIR)regexp.so
125+
$(SCHEME) $(REGEXP_DEPS) $(BUILDDIR)regexp.so demo/regexp.ss
126126

127-
regexp.so: compiled/regexp.scm regexp.sls $(REGEXP_DEPS) $(COMPILE_FILE_DEPS)
127+
$(BUILDDIR)regexp.so: $(BUILDDIR)compiled/regexp.scm regexp.sls $(REGEXP_DEPS) $(COMPILE_FILE_DEPS)
128128
$(COMPILE_FILE) regexp.sls $(REGEXP_DEPS)
129129

130-
compiled/regexp.scm: ../regexp/compiled/regexp.rktl $(CONVERT_DEPS)
131-
$(CONVERT) ../regexp/compiled/regexp.rktl compiled/regexp.scm
130+
$(BUILDDIR)compiled/regexp.scm: $(BUILDDIR)compiled/regexp.rktl $(CONVERT_DEPS)
131+
$(CONVERT) $(BUILDDIR)compiled/regexp.rktl $(BUILDDIR)compiled/regexp.scm
132132

133-
../regexp/compiled/regexp.rktl:
133+
$(BUILDDIR)compiled/regexp.rktl:
134134
$(MAKE) regexp-rktl
135135

136136
regexp-rktl:
137-
$(MAKE) bounce BOUNCE_DIR=../regexp BOUNCE_TARGET=regexp-src
137+
$(MAKE) bounce BOUNCE_DIR=../regexp BOUNCE_TARGET=regexp-src BUILDDIR="../cs/"
138138

139139

140-
io-demo: io.so
141-
$(SCHEME) $(IO_DEPS) io.so demo/io.ss
140+
io-demo: $(BUILDDIR)io.so
141+
$(SCHEME) $(IO_DEPS) $(BUILDDIR)io.so demo/io.ss
142142

143-
io.so: compiled/io.scm io.sls $(IO_DEPS) ../io/compiled/rktio.rktl $(COMPILE_FILE_DEPS)
143+
$(BUILDDIR)io.so: $(BUILDDIR)compiled/io.scm io.sls $(IO_DEPS) $(BUILDDIR)compiled/rktio.rktl $(COMPILE_FILE_DEPS)
144144
$(COMPILE_FILE) io.sls $(IO_DEPS)
145145

146-
compiled/io.scm: ../io/compiled/io.rktl $(CONVERT_DEPS)
147-
$(CONVERT) ../io/compiled/io.rktl compiled/io.scm
146+
$(BUILDDIR)compiled/io.scm: $(BUILDDIR)compiled/io.rktl $(CONVERT_DEPS)
147+
$(CONVERT) $(BUILDDIR)compiled/io.rktl $(BUILDDIR)compiled/io.scm
148148

149-
../io/compiled/io.rktl:
149+
$(BUILDDIR)compiled/io.rktl:
150150
$(MAKE) io-rktl
151151

152-
../io/compiled/rktio.rktl:
152+
$(BUILDDIR)compiled/rktio.rktl:
153153
$(MAKE) io-rktl
154154

155155
io-rktl:
156-
$(MAKE) bounce BOUNCE_DIR=../io BOUNCE_TARGET=io-src
156+
$(MAKE) bounce BOUNCE_DIR=../io BOUNCE_TARGET=io-src BUILDDIR="../cs/"
157157

158158
rktio:
159159
$(MAKE) bounce BOUNCE_DIR=../io BOUNCE_TARGET=rktio
160160

161161

162-
thread-demo: thread.so
163-
$(SCHEME) $(THREAD_DEPS) thread.so demo/thread.ss
162+
thread-demo: $(BUILDDIR)thread.so
163+
$(SCHEME) $(THREAD_DEPS) $(BUILDDIR)thread.so demo/thread.ss
164164

165-
thread.so: compiled/thread.scm thread.sls $(THREAD_DEPS) $(COMPILE_FILE_DEPS)
165+
$(BUILDDIR)thread.so: $(BUILDDIR)compiled/thread.scm thread.sls $(THREAD_DEPS) $(COMPILE_FILE_DEPS)
166166
$(COMPILE_FILE) thread.sls $(THREAD_DEPS)
167167

168-
compiled/thread.scm: ../thread/compiled/thread.rktl $(CONVERT_DEPS)
169-
$(CONVERT) ../thread/compiled/thread.rktl compiled/thread.scm
168+
$(BUILDDIR)compiled/thread.scm: $(BUILDDIR)compiled/thread.rktl $(CONVERT_DEPS)
169+
$(CONVERT) $(BUILDDIR)compiled/thread.rktl $(BUILDDIR)compiled/thread.scm
170170

171-
../thread/compiled/thread.rktl:
171+
$(BUILDDIR)compiled/thread.rktl:
172172
$(MAKE) thread-rktl
173173

174174
thread-rktl:
175-
$(MAKE) bounce BOUNCE_DIR=../thread BOUNCE_TARGET=thread-src
175+
$(MAKE) bounce BOUNCE_DIR=../thread BOUNCE_TARGET=thread-src BUILDDIR="../cs/"
176176

177177

178178
bounce:
@@ -182,29 +182,29 @@ bounce-go:
182182
cd $(BOUNCE_DIR); $(MAKE) RACO="$(RACKET) -N raco -l- raco" $(BOUNCE_TARGET)
183183

184184

185-
chaperone-demo: rumble.so
186-
$(SCHEME) chezpart.so rumble.so demo/chaperone.ss
185+
chaperone-demo: $(BUILDDIR)rumble.so
186+
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/chaperone.ss
187187

188-
hash-demo: rumble.so
189-
$(SCHEME) chezpart.so rumble.so demo/hash.ss
188+
hash-demo: $(BUILDDIR)rumble.so
189+
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/hash.ss
190190

191-
struct-demo: rumble.so
192-
$(SCHEME) chezpart.so rumble.so demo/struct.ss
191+
struct-demo: $(BUILDDIR)rumble.so
192+
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/struct.ss
193193

194-
control-demo: rumble.so
195-
$(SCHEME) chezpart.so rumble.so demo/control.ss
194+
control-demo: $(BUILDDIR)rumble.so
195+
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/control.ss
196196

197-
foreign-demo: rumble.so
198-
$(SCHEME) chezpart.so rumble.so demo/foreign.ss
197+
foreign-demo: $(BUILDDIR)rumble.so
198+
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/foreign.ss
199199

200-
will-demo: rumble.so
201-
$(SCHEME) chezpart.so rumble.so demo/will.ss
200+
will-demo: $(BUILDDIR)rumble.so
201+
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/will.ss
202202

203-
future-demo: rumble.so
204-
$(SCHEME) chezpart.so rumble.so demo/future.ss
203+
future-demo: $(BUILDDIR)rumble.so
204+
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/future.ss
205205

206-
future2-demo: rumble.so
207-
$(SCHEME) chezpart.so rumble.so demo/future2.ss
206+
future2-demo: $(BUILDDIR)rumble.so
207+
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/future2.ss
208208

209209
RUMBLE_SRCS = rumble/define.ss \
210210
rumble/virtual-register.ss \
@@ -262,10 +262,10 @@ RUMBLE_SRCS = rumble/define.ss \
262262
rumble/inline.ss \
263263
../racket/src/schvers.h
264264

265-
rumble.so: chezpart.so rumble.sls $(RUMBLE_SRCS) $(COMPILE_FILE_DEPS)
266-
$(COMPILE_FILE) $(RUMBLE_UNSAFE_COMP) rumble.sls
265+
$(BUILDDIR)rumble.so: $(RUMBLE_DEPS) rumble.sls $(RUMBLE_SRCS) $(COMPILE_FILE_DEPS)
266+
$(COMPILE_FILE) $(RUMBLE_UNSAFE_COMP) rumble.sls $(RUMBLE_DEPS)
267267

268-
chezpart.so: chezpart.sls $(COMPILE_FILE_DEPS)
268+
$(BUILDDIR)chezpart.so: chezpart.sls $(COMPILE_FILE_DEPS)
269269
$(COMPILE_FILE) chezpart.sls
270270

271271
clean:

0 commit comments

Comments
 (0)