added hash table key iterator
[antimony.git] / configure
blob5727090013ad2e941deb27c155f8eaa6dc3bc320
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_list
35 test_log
36 test_mod
37 test_mod_voodoo
38 test_readdir
39 test_stat
40 test_stream
41 test_symbol
42 test_symbol_encoder
43 test_tempdir
44 test_to_core
45 test_voodoo_translator
46 test_voodoo_writer
47 xyzzy
50 bootstrap_bintargets="$bintargets"
51 bootstrap_libtargets="$libtargets"
53 libantimony_sources='
54 antimony_reader
55 antimony_writer
56 args
57 array
58 array_sb
59 allocate
60 blob
61 blob_sb
62 block
63 boolean
64 comment
65 condition
66 dynarray
67 env
68 errno
69 errno_c
70 file
71 fixnum
72 gensym
73 hash_table
74 hex
75 init
76 iterator
77 list
78 log
79 module
80 process
81 random
82 readdir_c
83 stat_c
84 stream
85 symbol
86 symbol_encoder
87 symbol_sb
88 tempfile
89 type
92 libvoodoo_translator_sources='
93 anf_transform
94 antimony_symbols
95 compile_module
96 dealias
97 link
98 to_core
99 voodoo_translator
100 voodoo_writer
103 transmute_libs="$_voodoo_translator_libs"
104 test_anf_transform_libs="$_voodoo_translator_libs"
105 test_symbol_encoder_libs="$_voodoo_translator_libs"
106 test_to_core_libs="$_voodoo_translator_libs"
107 test_voodoo_translator_libs="$_voodoo_translator_libs"
108 test_voodoo_writer_libs="$_voodoo_translator_libs"
110 write_makefile() {
111 cat <<EOT
112 CFLAGS = ${CFLAGS}
113 BOOTSTRAP_TRANSMUTE = $bootstrap_transmute
114 BOOTSTRAP_TRANSMUTE_ENV = $bootstrap_transmute_env
115 LDFLAGS = ${LDFLAGS}
116 SRC = "$source_dir"
117 VOODOOC = voodooc
119 makefile_bintargets=''
120 for target in $bintargets
122 makefile_bintargets="$makefile_bintargets bin/${target}"
123 done
124 echo
125 echo "BINTARGETS =$makefile_bintargets"
127 makefile_libtargets=''
128 for target in $libtargets
130 makefile_libtargets="$makefile_libtargets lib/lib${target}.so"
131 done
132 echo "LIBTARGETS =$makefile_libtargets"
134 makefile_testtargets=''
135 for target in $testtargets
137 makefile_testtargets="$makefile_testtargets test/${target}"
138 done
139 echo
140 echo "TESTTARGETS =$makefile_testtargets"
142 makefile_bootstrap_bintargets=''
143 for target in $bootstrap_bintargets
145 makefile_bootstrap_bintargets="$makefile_bootstrap_bintargets bootstrap/bin/${target}"
146 done
147 echo
148 echo "BOOTSTRAP_BINTARGETS =$makefile_bootstrap_bintargets"
150 makefile_bootstrap_libtargets=''
151 for target in $bootstrap_libtargets
153 makefile_bootstrap_libtargets="$makefile_bootstrap_libtargets bootstrap/lib/${target}"
154 done
155 echo "BOOTSTRAP_LIBTARGETS =$makefile_bootstrap_libtargets"
157 for target in $bintargets
159 eval "libs=\$${target}_libs"
160 [ -n "$libs" ] || libs="$default_libs"
161 lib_depends=''
162 lib_flags=''
163 for lib in $libs
165 lib_depends="${lib_depends} lib/lib${lib}.so"
166 lib_flags="$lib_flags -l${lib}"
167 done
168 eval "sources=\$${target}_sources"
169 [ -n "$sources" ] || sources="$target"
170 srcs=$(echo ${target}/*)
171 echo
172 echo "${target}_lflags =$lib_flags"
173 echo "${target}_libs =$lib_depends"
174 echo "${target}_sources =$srcs"
175 done
177 for target in $bootstrap_bintargets
179 eval "libs=\$${target}_libs"
180 [ -n "$libs" ] || libs="$default_libs"
181 lib_depends=''
182 lib_flags=''
183 for lib in $libs
185 lib_depends="${lib_depends} bootstrap/lib/lib${lib}.so"
186 lib_flags="$lib_flags -l${lib}"
187 done
188 srcs=''
189 for source in bootstrap/src/${target}/*.voo
191 base=$(basename ${source} .voo)
192 srcs="$srcs bootstrap/objects/${target}/${base}.o"
193 done
194 echo
195 echo "bootstrap_${target}_lflags =$lib_flags"
196 echo "bootstrap_${target}_libs =$lib_depends"
197 echo "bootstrap_${target}_objects =$srcs"
198 done
200 for target in $libtargets
202 eval "libs=\$lib${target}_libs"
203 lib_depends=''
204 lib_flags=''
205 for lib in $libs
207 lib_depends="$lib_depends lib/lib${lib}.so"
208 lib_flags="$lib_flags -l${lib}"
209 done
210 eval "sources=\$lib${target}_sources"
211 [ -n "$sources" ] || sources="$target"
212 srcs=''
213 for source in $sources
215 srcs="$srcs objects/${target}/${source}.o"
216 done
217 echo
218 echo "lib${target}_lflags =$lib_flags"
219 echo "lib${target}_libs =$lib_depends"
220 echo "lib${target}_objects =$srcs"
221 done
223 for target in $bootstrap_libtargets
225 eval "libs=\$lib${target}_libs"
226 lib_depends=''
227 lib_flags=''
228 for lib in $libs
230 lib_depends="$lib_depends bootstrap/lib/lib${lib}.so"
231 lib_flags="$lib_flags -l${lib}"
232 done
233 eval "sources=\$lib${target}_sources"
234 [ -n "$sources" ] || sources="$target"
235 srcs=''
236 for source in $sources
238 srcs="$srcs bootstrap/objects/${target}/${source}.o"
239 done
240 echo
241 echo "bootstrap_lib${target}_lflags =$lib_flags"
242 echo "bootstrap_lib${target}_libs =$lib_depends"
243 echo "bootstrap_lib${target}_objects =$srcs"
244 done
246 for target in $testtargets
248 eval "libs=\$${target}_libs"
249 [ -n "$libs" ] || libs="$default_libs"
250 lib_depends=''
251 lib_flags=''
252 for lib in $libs
254 lib_depends="${lib_depends} lib/lib${lib}.so"
255 lib_flags="$lib_flags -l${lib}"
256 done
257 eval "sources=\$${target}_sources"
258 [ -n "$sources" ] || sources="$target"
259 srcs=''
260 for source in $sources
262 srcs="$srcs objects/test/${source}.o"
263 done
264 echo
265 echo "${target}_lflags =$lib_flags"
266 echo "${target}_libs =$lib_depends"
267 echo "${target}_objects =$srcs"
268 done
270 for target in $bintargets
272 echo
273 echo "bin/${target} : \$(${target}_sources) \$(${target}_libs)"
274 if [ "$target" = transmute ]
275 then
276 printf '\tenv LD_LIBRARY_PATH=bootstrap/lib bootstrap/bin/transmute -t exe -L lib -o bin/%s %s\n' "$target" "$target"
278 printf '\tenv LD_LIBRARY_PATH=lib bin/transmute -t exe -L lib -o bin/%s %s\n' "$target" "$target"
279 done
281 for target in $bootstrap_bintargets
283 echo
284 echo "bootstrap/bin/${target} : \$(bootstrap_${target}_objects) \$(bootstrap_${target}_libs)"
285 printf '\t$(CC) $(CFLAGS) $(bootstrap_%s_objects) -o bootstrap/bin/%s -Lbootstrap/lib $(bootstrap_%s_lflags) $(LDFLAGS)\n' "$target" "$target" "$target"
286 done
288 for target in $libtargets
290 target="lib${target}"
291 echo
292 echo "lib/${target}.so : \$(${target}_objects) \$(${target}_libs)"
293 printf '\t$(CC) $(CFLAGS) -shared $(%s_objects) -o lib/%s.so -Llib $(%s_lflags)\n' "$target" "$target" "$target"
294 done
296 for target in $bootstrap_libtargets
298 target="lib${target}"
299 echo
300 echo "bootstrap/lib/${target}.so : \$(bootstrap_${target}_objects) \$(bootstrap_${target}_libs)"
301 printf '\t$(CC) $(CFLAGS) -shared $(bootstrap_%s_objects) -o bootstrap/lib/%s.so -Lbootstrap/lib $(bootsrap_%s_lflags)\n' "$target" "$target" "$target"
302 done
304 for target in $testtargets
306 echo
307 echo "test/${target} : \$(${target}_objects) \$(${target}_libs)"
308 printf '\t$(CC) $(CFLAGS) $(%s_objects) -o test/%s -Llib $(%s_lflags) $(LDFLAGS)\n' "$target" "$target" "$target"
309 done
311 cat <<'EOT'
313 .PHONY : all check clean default distclean
315 default : $(LIBTARGETS) $(BINTARGETS)
317 all : default $(TESTTARGETS)
319 check : all
320 cd test && case $(SRC) in /*) $(SRC)/src/test/test;; *) ../$(SRC)/src/test/test;; esac
322 clean :
324 distclean :
325 -rm -r bin generated lib bootstrap/bin bootstrap/lib bootstrap/objects objects test Makefile
327 bootstrap : bootstrap/bin/transmute
330 for target in $bintargets $libtargets
332 for x in "$source_dir"/bootstrap/src/${target}/*.voo
334 if [ -e "$x" ]
335 then
336 t="bootstrap/objects/${target}/$(basename "$x" .voo).o"
337 printf '\n%s : %s\n' "$t" "$x"
338 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
340 done
341 done
343 for target in $bintargets $libtargets
345 for x in "$source_dir"/src/${target}/*.sb
347 if [ -e "$x" ]
348 then
349 b=$(basename "$x" .sb)
350 g="generated/${target}/${b}.voo"
351 t="objects/${target}/${b}.o"
352 printf '\n%s : %s\n' "$t" "$g"
353 printf '\t$(VOODOOC) %s -o %s\n' "$g" "$t"
354 printf '\n%s : $(BOOTSTRAP_TRANSMUTE) %s\n' "$g" "$x"
355 printf '\t$(BOOTSTRAP_TRANSMUTE_ENV) $(BOOTSTRAP_TRANSMUTE) < %s > %s\n' "$x" "$g"
357 done
358 done
360 for x in "$source_dir"/src/test/*.sb
362 if [ -e "$x" ]
363 then
364 b=$(basename "$x" .sb)
365 g="generated/test/${b}.voo"
366 t="objects/test/${b}.o"
367 printf '\n%s : %s\n' "$t" "$g"
368 printf '\t$(VOODOOC) %s -o %s\n' "$g" "$t"
369 printf '\n%s : bin/transmute %s\n' "$g" "$x"
370 printf '\tenv LD_LIBRARY_PATH=lib bin/transmute < %s > %s\n' "$x" "$g"
372 done
374 for target in $bintargets $libtargets
376 for x in "$source_dir"/src/${target}/*.voo
378 if [ -e "$x" ]
379 then
380 b=$(basename "$x" .voo)
381 t="objects/${target}/${b}.o"
382 printf '\n%s : %s\n' "$t" "$x"
383 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
384 if [ \! -f "$source_dir/bootstrap/src/${target}/$b.voo" ]
385 then
386 printf '\nbootstrap/%s : %s\n' "$t" "$x"
387 printf '\t$(VOODOOC) %s -o bootstrap/%s\n' "$x" "$t"
390 done
391 done
393 for target in $bintargets $libtargets
395 for x in "$source_dir"/src/${target}/*.c
397 if [ -e "$x" ]
398 then
399 b=$(basename "$x" .c)
400 t="objects/${target}/${b}.o"
401 printf '\n%s : %s\n' "$t" "$x"
402 printf '\t$(CC) $(CFLAGS) -I$(SRC)/include -fPIC -c %s -o %s\n' "$x" "$t"
403 printf '\nbootstrap/%s : %s\n' "$t" "$x"
404 printf '\t$(CC) $(CFLAGS) -I$(SRC)/include -fPIC -c %s -o bootstrap/%s\n' "$x" "$t"
406 done
407 done
409 for x in "$source_dir"/src/test/*.voo
411 if [ -e "$x" ]
412 then
413 b=$(basename "$x" .voo)
414 t="objects/test/${b}.o"
415 printf '\n%s : %s\n' "$t" "$x"
416 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
418 done
421 LDFLAGS="$LDFLAGS -lgc"
422 bootstrap_transmute="bootstrap/bin/transmute"
423 bootstrap_transmute_env="env LD_LIBRARY_PATH=bootstrap/lib"
424 make_bootstrap=true
425 source_dir="$(dirname "$0")"
427 mkdir -p bin bootstrap/bin bootstrap/lib bootstrap/objects generated \
428 generated/test lib objects objects/test test
429 for target in $bintargets $libtargets
431 mkdir -p bootstrap/objects/${target} generated/${target} objects/${target}
432 done
434 write_makefile > Makefile