rewrote tests written in voodoo in antimony
[antimony.git] / configure
blob775794fa279ae7636e2d92799c5baebcd5e71811
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 testtargets='
22 test_anf_transform
23 test_antimony_reader
24 test_antimony_writer
25 test_array
26 test_blob
27 test_block
28 test_condition
29 test_dynarray
30 test_empty_module
31 test_exe
32 test_exe_voodoo
33 test_hash_table
34 test_hash_set
35 test_list
36 test_log
37 test_mod
38 test_mod_voodoo
39 test_readdir
40 test_stat
41 test_stream
42 test_symbol
43 test_symbol_encoder
44 test_tempdir
45 test_to_core
46 test_voodoo_writer
47 test_voodoo_translator
48 xyzzy
51 bootstrap_bintargets="$bintargets"
52 bootstrap_libtargets="$libtargets"
54 libantimony_sources='
55 antimony_reader
56 antimony_writer
57 args
58 array
59 array_sb
60 allocate
61 blob
62 blob_sb
63 block
64 block_sb
65 boolean
66 comment
67 condition
68 dynarray
69 env
70 errno
71 errno_c
72 file
73 fixnum
74 gensym
75 hash_set
76 hash_table
77 hex
78 init
79 iterator
80 list
81 log
82 module
83 process
84 random
85 readdir_c
86 stat_c
87 stream
88 symbol
89 symbol_encoder
90 symbol_sb
91 tempfile
92 type
95 libvoodoo_translator_sources='
96 anf_transform
97 antimony_symbols
98 compile_module
99 dealias
100 link
101 to_core
102 voodoo_translator
103 voodoo_writer
106 transmute_libs="$_voodoo_translator_libs"
107 test_anf_transform_libs="$_voodoo_translator_libs"
108 test_symbol_encoder_libs="$_voodoo_translator_libs"
109 test_to_core_libs="$_voodoo_translator_libs"
110 test_voodoo_translator_libs="$_voodoo_translator_libs"
111 test_voodoo_writer_libs="$_voodoo_translator_libs"
113 write_makefile() {
114 cat <<EOT
115 CFLAGS = ${CFLAGS}
116 BOOTSTRAP_TRANSMUTE = $bootstrap_transmute
117 BOOTSTRAP_TRANSMUTE_ENV = $bootstrap_transmute_env
118 LDFLAGS = ${LDFLAGS}
119 SRC = "$source_dir"
120 VOODOOC = voodooc
122 makefile_bintargets=''
123 for target in $bintargets
125 makefile_bintargets="$makefile_bintargets bin/${target}"
126 done
127 echo
128 echo "BINTARGETS =$makefile_bintargets"
130 makefile_libtargets=''
131 for target in $libtargets
133 makefile_libtargets="$makefile_libtargets lib/lib${target}.so"
134 done
135 echo "LIBTARGETS =$makefile_libtargets"
137 makefile_testtargets=''
138 for target in $testtargets
140 makefile_testtargets="$makefile_testtargets test/${target}"
141 done
142 echo
143 echo "TESTTARGETS =$makefile_testtargets"
145 makefile_bootstrap_bintargets=''
146 for target in $bootstrap_bintargets
148 makefile_bootstrap_bintargets="$makefile_bootstrap_bintargets bootstrap/bin/${target}"
149 done
150 echo
151 echo "BOOTSTRAP_BINTARGETS =$makefile_bootstrap_bintargets"
153 makefile_bootstrap_libtargets=''
154 for target in $bootstrap_libtargets
156 makefile_bootstrap_libtargets="$makefile_bootstrap_libtargets bootstrap/lib/${target}"
157 done
158 echo "BOOTSTRAP_LIBTARGETS =$makefile_bootstrap_libtargets"
160 for target in $bintargets
162 eval "libs=\$${target}_libs"
163 [ -n "$libs" ] || libs="$default_libs"
164 lib_depends=''
165 lib_flags=''
166 for lib in $libs
168 lib_depends="${lib_depends} lib/lib${lib}.so"
169 lib_flags="$lib_flags -l${lib}"
170 done
171 eval "sources=\$${target}_sources"
172 [ -n "$sources" ] || sources="$target"
173 srcs=$(echo ${target}/*)
174 echo
175 echo "${target}_lflags =$lib_flags"
176 echo "${target}_libs =$lib_depends"
177 echo "${target}_sources =$srcs"
178 done
180 for target in $bootstrap_bintargets
182 eval "libs=\$${target}_libs"
183 [ -n "$libs" ] || libs="$default_libs"
184 lib_depends=''
185 lib_flags=''
186 for lib in $libs
188 lib_depends="${lib_depends} bootstrap/lib/lib${lib}.so"
189 lib_flags="$lib_flags -l${lib}"
190 done
191 srcs=''
192 for source in bootstrap/src/${target}/*.voo
194 base=$(basename ${source} .voo)
195 srcs="$srcs bootstrap/objects/${target}/${base}.o"
196 done
197 echo
198 echo "bootstrap_${target}_lflags =$lib_flags"
199 echo "bootstrap_${target}_libs =$lib_depends"
200 echo "bootstrap_${target}_objects =$srcs"
201 done
203 for target in $libtargets
205 eval "libs=\$lib${target}_libs"
206 lib_depends=''
207 lib_flags=''
208 for lib in $libs
210 lib_depends="$lib_depends lib/lib${lib}.so"
211 lib_flags="$lib_flags -l${lib}"
212 done
213 eval "sources=\$lib${target}_sources"
214 [ -n "$sources" ] || sources="$target"
215 srcs=''
216 for source in $sources
218 srcs="$srcs objects/${target}/${source}.o"
219 done
220 echo
221 echo "lib${target}_lflags =$lib_flags"
222 echo "lib${target}_libs =$lib_depends"
223 echo "lib${target}_objects =$srcs"
224 done
226 for target in $bootstrap_libtargets
228 eval "libs=\$lib${target}_libs"
229 lib_depends=''
230 lib_flags=''
231 for lib in $libs
233 lib_depends="$lib_depends bootstrap/lib/lib${lib}.so"
234 lib_flags="$lib_flags -l${lib}"
235 done
236 eval "sources=\$lib${target}_sources"
237 [ -n "$sources" ] || sources="$target"
238 srcs=''
239 for source in $sources
241 srcs="$srcs bootstrap/objects/${target}/${source}.o"
242 done
243 echo
244 echo "bootstrap_lib${target}_lflags =$lib_flags"
245 echo "bootstrap_lib${target}_libs =$lib_depends"
246 echo "bootstrap_lib${target}_objects =$srcs"
247 done
249 for target in $testtargets
251 eval "libs=\$${target}_libs"
252 [ -n "$libs" ] || libs="$default_libs"
253 lib_depends=''
254 lib_flags=''
255 for lib in $libs
257 lib_depends="${lib_depends} lib/lib${lib}.so"
258 lib_flags="$lib_flags -l${lib}"
259 done
260 eval "sources=\$${target}_sources"
261 [ -n "$sources" ] || sources="$target"
262 echo
263 echo "${target}_lflags =$lib_flags"
264 echo "${target}_libs =$lib_depends"
265 done
267 for target in $bintargets
269 echo
270 echo "bin/${target} : \$(${target}_sources) \$(${target}_libs)"
271 if [ "$target" = transmute ]
272 then
273 printf '\tenv LD_LIBRARY_PATH=bootstrap/lib bootstrap/bin/transmute -t exe -L lib -o bin/%s %s\n' "$target" "$target"
275 printf '\tenv LD_LIBRARY_PATH=lib bin/transmute -t exe -L lib -o bin/%s %s\n' "$target" "$target"
276 done
278 for target in $bootstrap_bintargets
280 echo
281 echo "bootstrap/bin/${target} : \$(bootstrap_${target}_objects) \$(bootstrap_${target}_libs)"
282 printf '\t$(CC) $(CFLAGS) $(bootstrap_%s_objects) -o bootstrap/bin/%s -Lbootstrap/lib $(bootstrap_%s_lflags) $(LDFLAGS)\n' "$target" "$target" "$target"
283 done
285 for target in $libtargets
287 target="lib${target}"
288 echo
289 echo "lib/${target}.so : \$(${target}_objects) \$(${target}_libs)"
290 printf '\t$(CC) $(CFLAGS) -shared $(%s_objects) -o lib/%s.so -Llib $(%s_lflags)\n' "$target" "$target" "$target"
291 done
293 for target in $bootstrap_libtargets
295 target="lib${target}"
296 echo
297 echo "bootstrap/lib/${target}.so : \$(bootstrap_${target}_objects) \$(bootstrap_${target}_libs)"
298 printf '\t$(CC) $(CFLAGS) -shared $(bootstrap_%s_objects) -o bootstrap/lib/%s.so -Lbootstrap/lib $(bootsrap_%s_lflags)\n' "$target" "$target" "$target"
299 done
301 cat <<'EOT'
303 .PHONY : all check clean default distclean
305 default : $(LIBTARGETS) $(BINTARGETS)
307 all : default $(TESTTARGETS)
309 check : all
310 cd test && case $(SRC) in /*) $(SRC)/src/test/test;; *) ../$(SRC)/src/test/test;; esac
312 clean :
314 distclean :
315 -rm -r bin generated lib bootstrap/bin bootstrap/lib bootstrap/objects objects test Makefile
317 bootstrap : bootstrap/bin/transmute
320 for target in $bintargets $libtargets
322 for x in "$source_dir"/bootstrap/src/${target}/*.voo
324 if [ -e "$x" ]
325 then
326 t="bootstrap/objects/${target}/$(basename "$x" .voo).o"
327 printf '\n%s : %s\n' "$t" "$x"
328 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
330 done
331 done
333 for target in $bintargets $libtargets
335 for x in "$source_dir"/src/${target}/*.sb
337 if [ -e "$x" ]
338 then
339 b=$(basename "$x" .sb)
340 g="generated/${target}/${b}.voo"
341 t="objects/${target}/${b}.o"
342 printf '\n%s : %s\n' "$t" "$g"
343 printf '\t$(VOODOOC) %s -o %s\n' "$g" "$t"
344 printf '\n%s : $(BOOTSTRAP_TRANSMUTE) %s\n' "$g" "$x"
345 printf '\t$(BOOTSTRAP_TRANSMUTE_ENV) $(BOOTSTRAP_TRANSMUTE) < %s > %s\n' "$x" "$g"
347 done
348 done
350 for x in $testtargets
352 s="$source_dir/src/test/$x.sb"
353 t="test/$x"
354 if [ -e "$s" ]
355 then
356 printf '\n%s : bin/transmute %s\n' "$t" "$s"
357 printf '\tenv LD_LIBRARY_PATH=lib bin/transmute -t exe -o %s -L lib -b %s/src/test %s\n' "$t" "$source_dir" "$s"
359 done
361 for target in $bintargets $libtargets
363 for x in "$source_dir"/src/${target}/*.voo
365 if [ -e "$x" ]
366 then
367 b=$(basename "$x" .voo)
368 t="objects/${target}/${b}.o"
369 printf '\n%s : %s\n' "$t" "$x"
370 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
371 if [ \! -f "$source_dir/bootstrap/src/${target}/$b.voo" ]
372 then
373 printf '\nbootstrap/%s : %s\n' "$t" "$x"
374 printf '\t$(VOODOOC) %s -o bootstrap/%s\n' "$x" "$t"
377 done
378 done
380 for target in $bintargets $libtargets
382 for x in "$source_dir"/src/${target}/*.c
384 if [ -e "$x" ]
385 then
386 b=$(basename "$x" .c)
387 t="objects/${target}/${b}.o"
388 printf '\n%s : %s\n' "$t" "$x"
389 printf '\t$(CC) $(CFLAGS) -I$(SRC)/include -fPIC -c %s -o %s\n' "$x" "$t"
390 printf '\nbootstrap/%s : %s\n' "$t" "$x"
391 printf '\t$(CC) $(CFLAGS) -I$(SRC)/include -fPIC -c %s -o bootstrap/%s\n' "$x" "$t"
393 done
394 done
396 for x in "$source_dir"/src/test/*.voo
398 if [ -e "$x" ]
399 then
400 b=$(basename "$x" .voo)
401 t="objects/test/${b}.o"
402 printf '\n%s : %s\n' "$t" "$x"
403 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
405 done
408 LDFLAGS="$LDFLAGS -lgc"
409 bootstrap_transmute="bootstrap/bin/transmute"
410 bootstrap_transmute_env="env LD_LIBRARY_PATH=bootstrap/lib"
411 make_bootstrap=true
412 source_dir="$(dirname "$0")"
414 mkdir -p bin bootstrap/bin bootstrap/lib bootstrap/objects generated \
415 generated/test lib objects objects/test test
416 for target in $bintargets $libtargets
418 mkdir -p bootstrap/objects/${target} generated/${target} objects/${target}
419 done
421 write_makefile > Makefile