converted more tests to new executable support
[antimony.git] / configure
blob11ead53239d0fa44d632cd83fe39f6c3e49ca20a
1 #! /bin/sh
3 default_libs='
4 antimony
7 _voodoo_translator_libs='
8 antimony
9 voodoo_translator
12 bintargets='
13 transmute
16 libtargets='
17 antimony
18 voodoo_translator
21 legacy_testtargets='
22 test_antimony_reader
23 test_antimony_writer
24 test_blob
25 test_dynarray
26 test_list
27 test_stream
28 test_symbol
29 test_voodoo_translator
30 test_voodoo_writer
33 testtargets='
34 test_anf_transform
35 test_array
36 test_block
37 test_condition
38 test_empty_module
39 test_exe
40 test_exe_voodoo
41 test_hash_table
42 test_hash_set
43 test_log
44 test_mod
45 test_mod_voodoo
46 test_readdir
47 test_stat
48 test_symbol_encoder
49 test_tempdir
50 test_to_core
51 xyzzy
54 bootstrap_bintargets="$bintargets"
55 bootstrap_libtargets="$libtargets"
57 libantimony_sources='
58 antimony_reader
59 antimony_writer
60 args
61 array
62 array_sb
63 allocate
64 blob
65 blob_sb
66 block
67 block_sb
68 boolean
69 comment
70 condition
71 dynarray
72 env
73 errno
74 errno_c
75 file
76 fixnum
77 gensym
78 hash_set
79 hash_table
80 hex
81 init
82 iterator
83 list
84 log
85 module
86 process
87 random
88 readdir_c
89 stat_c
90 stream
91 symbol
92 symbol_encoder
93 symbol_sb
94 tempfile
95 type
98 libvoodoo_translator_sources='
99 anf_transform
100 antimony_symbols
101 compile_module
102 dealias
103 link
104 to_core
105 voodoo_translator
106 voodoo_writer
109 transmute_libs="$_voodoo_translator_libs"
110 test_anf_transform_libs="$_voodoo_translator_libs"
111 test_symbol_encoder_libs="$_voodoo_translator_libs"
112 test_to_core_libs="$_voodoo_translator_libs"
113 test_voodoo_translator_libs="$_voodoo_translator_libs"
114 test_voodoo_writer_libs="$_voodoo_translator_libs"
116 write_makefile() {
117 cat <<EOT
118 CFLAGS = ${CFLAGS}
119 BOOTSTRAP_TRANSMUTE = $bootstrap_transmute
120 BOOTSTRAP_TRANSMUTE_ENV = $bootstrap_transmute_env
121 LDFLAGS = ${LDFLAGS}
122 SRC = "$source_dir"
123 VOODOOC = voodooc
125 makefile_bintargets=''
126 for target in $bintargets
128 makefile_bintargets="$makefile_bintargets bin/${target}"
129 done
130 echo
131 echo "BINTARGETS =$makefile_bintargets"
133 makefile_libtargets=''
134 for target in $libtargets
136 makefile_libtargets="$makefile_libtargets lib/lib${target}.so"
137 done
138 echo "LIBTARGETS =$makefile_libtargets"
140 makefile_testtargets=''
141 for target in $legacy_testtargets $testtargets
143 makefile_testtargets="$makefile_testtargets test/${target}"
144 done
145 echo
146 echo "TESTTARGETS =$makefile_testtargets"
148 makefile_bootstrap_bintargets=''
149 for target in $bootstrap_bintargets
151 makefile_bootstrap_bintargets="$makefile_bootstrap_bintargets bootstrap/bin/${target}"
152 done
153 echo
154 echo "BOOTSTRAP_BINTARGETS =$makefile_bootstrap_bintargets"
156 makefile_bootstrap_libtargets=''
157 for target in $bootstrap_libtargets
159 makefile_bootstrap_libtargets="$makefile_bootstrap_libtargets bootstrap/lib/${target}"
160 done
161 echo "BOOTSTRAP_LIBTARGETS =$makefile_bootstrap_libtargets"
163 for target in $bintargets
165 eval "libs=\$${target}_libs"
166 [ -n "$libs" ] || libs="$default_libs"
167 lib_depends=''
168 lib_flags=''
169 for lib in $libs
171 lib_depends="${lib_depends} lib/lib${lib}.so"
172 lib_flags="$lib_flags -l${lib}"
173 done
174 eval "sources=\$${target}_sources"
175 [ -n "$sources" ] || sources="$target"
176 srcs=$(echo ${target}/*)
177 echo
178 echo "${target}_lflags =$lib_flags"
179 echo "${target}_libs =$lib_depends"
180 echo "${target}_sources =$srcs"
181 done
183 for target in $bootstrap_bintargets
185 eval "libs=\$${target}_libs"
186 [ -n "$libs" ] || libs="$default_libs"
187 lib_depends=''
188 lib_flags=''
189 for lib in $libs
191 lib_depends="${lib_depends} bootstrap/lib/lib${lib}.so"
192 lib_flags="$lib_flags -l${lib}"
193 done
194 srcs=''
195 for source in bootstrap/src/${target}/*.voo
197 base=$(basename ${source} .voo)
198 srcs="$srcs bootstrap/objects/${target}/${base}.o"
199 done
200 echo
201 echo "bootstrap_${target}_lflags =$lib_flags"
202 echo "bootstrap_${target}_libs =$lib_depends"
203 echo "bootstrap_${target}_objects =$srcs"
204 done
206 for target in $libtargets
208 eval "libs=\$lib${target}_libs"
209 lib_depends=''
210 lib_flags=''
211 for lib in $libs
213 lib_depends="$lib_depends lib/lib${lib}.so"
214 lib_flags="$lib_flags -l${lib}"
215 done
216 eval "sources=\$lib${target}_sources"
217 [ -n "$sources" ] || sources="$target"
218 srcs=''
219 for source in $sources
221 srcs="$srcs objects/${target}/${source}.o"
222 done
223 echo
224 echo "lib${target}_lflags =$lib_flags"
225 echo "lib${target}_libs =$lib_depends"
226 echo "lib${target}_objects =$srcs"
227 done
229 for target in $bootstrap_libtargets
231 eval "libs=\$lib${target}_libs"
232 lib_depends=''
233 lib_flags=''
234 for lib in $libs
236 lib_depends="$lib_depends bootstrap/lib/lib${lib}.so"
237 lib_flags="$lib_flags -l${lib}"
238 done
239 eval "sources=\$lib${target}_sources"
240 [ -n "$sources" ] || sources="$target"
241 srcs=''
242 for source in $sources
244 srcs="$srcs bootstrap/objects/${target}/${source}.o"
245 done
246 echo
247 echo "bootstrap_lib${target}_lflags =$lib_flags"
248 echo "bootstrap_lib${target}_libs =$lib_depends"
249 echo "bootstrap_lib${target}_objects =$srcs"
250 done
252 for target in $legacy_testtargets
254 eval "libs=\$${target}_libs"
255 [ -n "$libs" ] || libs="$default_libs"
256 lib_depends=''
257 lib_flags=''
258 for lib in $libs
260 lib_depends="${lib_depends} lib/lib${lib}.so"
261 lib_flags="$lib_flags -l${lib}"
262 done
263 eval "sources=\$${target}_sources"
264 [ -n "$sources" ] || sources="$target"
265 srcs=''
266 for source in $sources
268 srcs="$srcs objects/test/${source}.o"
269 done
270 echo
271 echo "${target}_lflags =$lib_flags"
272 echo "${target}_libs =$lib_depends"
273 echo "${target}_objects =$srcs"
274 done
276 for target in $testtargets
278 eval "libs=\$${target}_libs"
279 [ -n "$libs" ] || libs="$default_libs"
280 lib_depends=''
281 lib_flags=''
282 for lib in $libs
284 lib_depends="${lib_depends} lib/lib${lib}.so"
285 lib_flags="$lib_flags -l${lib}"
286 done
287 eval "sources=\$${target}_sources"
288 [ -n "$sources" ] || sources="$target"
289 echo
290 echo "${target}_lflags =$lib_flags"
291 echo "${target}_libs =$lib_depends"
292 done
294 for target in $bintargets
296 echo
297 echo "bin/${target} : \$(${target}_sources) \$(${target}_libs)"
298 if [ "$target" = transmute ]
299 then
300 printf '\tenv LD_LIBRARY_PATH=bootstrap/lib bootstrap/bin/transmute -t exe -L lib -o bin/%s %s\n' "$target" "$target"
302 printf '\tenv LD_LIBRARY_PATH=lib bin/transmute -t exe -L lib -o bin/%s %s\n' "$target" "$target"
303 done
305 for target in $bootstrap_bintargets
307 echo
308 echo "bootstrap/bin/${target} : \$(bootstrap_${target}_objects) \$(bootstrap_${target}_libs)"
309 printf '\t$(CC) $(CFLAGS) $(bootstrap_%s_objects) -o bootstrap/bin/%s -Lbootstrap/lib $(bootstrap_%s_lflags) $(LDFLAGS)\n' "$target" "$target" "$target"
310 done
312 for target in $libtargets
314 target="lib${target}"
315 echo
316 echo "lib/${target}.so : \$(${target}_objects) \$(${target}_libs)"
317 printf '\t$(CC) $(CFLAGS) -shared $(%s_objects) -o lib/%s.so -Llib $(%s_lflags)\n' "$target" "$target" "$target"
318 done
320 for target in $bootstrap_libtargets
322 target="lib${target}"
323 echo
324 echo "bootstrap/lib/${target}.so : \$(bootstrap_${target}_objects) \$(bootstrap_${target}_libs)"
325 printf '\t$(CC) $(CFLAGS) -shared $(bootstrap_%s_objects) -o bootstrap/lib/%s.so -Lbootstrap/lib $(bootsrap_%s_lflags)\n' "$target" "$target" "$target"
326 done
328 for target in $legacy_testtargets
330 echo
331 echo "test/${target} : \$(${target}_objects) \$(${target}_libs)"
332 printf '\t$(CC) $(CFLAGS) $(%s_objects) -o test/%s -Llib $(%s_lflags) $(LDFLAGS)\n' "$target" "$target" "$target"
333 done
335 cat <<'EOT'
337 .PHONY : all check clean default distclean
339 default : $(LIBTARGETS) $(BINTARGETS)
341 all : default $(TESTTARGETS)
343 check : all
344 cd test && case $(SRC) in /*) $(SRC)/src/test/test;; *) ../$(SRC)/src/test/test;; esac
346 clean :
348 distclean :
349 -rm -r bin generated lib bootstrap/bin bootstrap/lib bootstrap/objects objects test Makefile
351 bootstrap : bootstrap/bin/transmute
354 for target in $bintargets $libtargets
356 for x in "$source_dir"/bootstrap/src/${target}/*.voo
358 if [ -e "$x" ]
359 then
360 t="bootstrap/objects/${target}/$(basename "$x" .voo).o"
361 printf '\n%s : %s\n' "$t" "$x"
362 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
364 done
365 done
367 for target in $bintargets $libtargets
369 for x in "$source_dir"/src/${target}/*.sb
371 if [ -e "$x" ]
372 then
373 b=$(basename "$x" .sb)
374 g="generated/${target}/${b}.voo"
375 t="objects/${target}/${b}.o"
376 printf '\n%s : %s\n' "$t" "$g"
377 printf '\t$(VOODOOC) %s -o %s\n' "$g" "$t"
378 printf '\n%s : $(BOOTSTRAP_TRANSMUTE) %s\n' "$g" "$x"
379 printf '\t$(BOOTSTRAP_TRANSMUTE_ENV) $(BOOTSTRAP_TRANSMUTE) < %s > %s\n' "$x" "$g"
381 done
382 done
384 for x in $legacy_testtargets
386 s="$source_dir/src/test/$x.sb"
387 if [ -e "$s" ]
388 then
389 g="generated/test/${x}.voo"
390 t="objects/test/${x}.o"
391 printf '\n%s : %s\n' "$t" "$g"
392 printf '\t$(VOODOOC) %s -o %s\n' "$g" "$t"
393 printf '\n%s : bin/transmute %s\n' "$g" "$s"
394 printf '\tenv LD_LIBRARY_PATH=lib bin/transmute < %s > %s\n' "$s" "$g"
396 done
398 for x in $testtargets
400 s="$source_dir/src/test/$x.sb"
401 t="test/$x"
402 if [ -e "$s" ]
403 then
404 printf '\n%s : bin/transmute %s\n' "$t" "$s"
405 printf '\tenv LD_LIBRARY_PATH=lib bin/transmute -t exe -o %s -L lib -b %s/src/test %s\n' "$t" "$source_dir" "$s"
407 done
409 for target in $bintargets $libtargets
411 for x in "$source_dir"/src/${target}/*.voo
413 if [ -e "$x" ]
414 then
415 b=$(basename "$x" .voo)
416 t="objects/${target}/${b}.o"
417 printf '\n%s : %s\n' "$t" "$x"
418 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
419 if [ \! -f "$source_dir/bootstrap/src/${target}/$b.voo" ]
420 then
421 printf '\nbootstrap/%s : %s\n' "$t" "$x"
422 printf '\t$(VOODOOC) %s -o bootstrap/%s\n' "$x" "$t"
425 done
426 done
428 for target in $bintargets $libtargets
430 for x in "$source_dir"/src/${target}/*.c
432 if [ -e "$x" ]
433 then
434 b=$(basename "$x" .c)
435 t="objects/${target}/${b}.o"
436 printf '\n%s : %s\n' "$t" "$x"
437 printf '\t$(CC) $(CFLAGS) -I$(SRC)/include -fPIC -c %s -o %s\n' "$x" "$t"
438 printf '\nbootstrap/%s : %s\n' "$t" "$x"
439 printf '\t$(CC) $(CFLAGS) -I$(SRC)/include -fPIC -c %s -o bootstrap/%s\n' "$x" "$t"
441 done
442 done
444 for x in "$source_dir"/src/test/*.voo
446 if [ -e "$x" ]
447 then
448 b=$(basename "$x" .voo)
449 t="objects/test/${b}.o"
450 printf '\n%s : %s\n' "$t" "$x"
451 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
453 done
456 LDFLAGS="$LDFLAGS -lgc"
457 bootstrap_transmute="bootstrap/bin/transmute"
458 bootstrap_transmute_env="env LD_LIBRARY_PATH=bootstrap/lib"
459 make_bootstrap=true
460 source_dir="$(dirname "$0")"
462 mkdir -p bin bootstrap/bin bootstrap/lib bootstrap/objects generated \
463 generated/test lib objects objects/test test
464 for target in $bintargets $libtargets
466 mkdir -p bootstrap/objects/${target} generated/${target} objects/${target}
467 done
469 write_makefile > Makefile