made hash tables work with hash functions returning negative values
[antimony.git] / configure
blob1ab8a047892f5b79d503be1aa47d0d782c57fd78
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 list
77 log
78 module
79 process
80 random
81 readdir_c
82 stat_c
83 stream
84 symbol
85 symbol_encoder
86 symbol_sb
87 tempfile
88 type
91 libvoodoo_translator_sources='
92 anf_transform
93 antimony_symbols
94 compile_module
95 dealias
96 link
97 to_core
98 voodoo_translator
99 voodoo_writer
102 transmute_libs="$_voodoo_translator_libs"
103 test_anf_transform_libs="$_voodoo_translator_libs"
104 test_symbol_encoder_libs="$_voodoo_translator_libs"
105 test_to_core_libs="$_voodoo_translator_libs"
106 test_voodoo_translator_libs="$_voodoo_translator_libs"
107 test_voodoo_writer_libs="$_voodoo_translator_libs"
109 write_makefile() {
110 cat <<EOT
111 CFLAGS = ${CFLAGS}
112 BOOTSTRAP_TRANSMUTE = $bootstrap_transmute
113 BOOTSTRAP_TRANSMUTE_ENV = $bootstrap_transmute_env
114 LDFLAGS = ${LDFLAGS}
115 SRC = "$source_dir"
116 VOODOOC = voodooc
118 makefile_bintargets=''
119 for target in $bintargets
121 makefile_bintargets="$makefile_bintargets bin/${target}"
122 done
123 echo
124 echo "BINTARGETS =$makefile_bintargets"
126 makefile_libtargets=''
127 for target in $libtargets
129 makefile_libtargets="$makefile_libtargets lib/lib${target}.so"
130 done
131 echo "LIBTARGETS =$makefile_libtargets"
133 makefile_testtargets=''
134 for target in $testtargets
136 makefile_testtargets="$makefile_testtargets test/${target}"
137 done
138 echo
139 echo "TESTTARGETS =$makefile_testtargets"
141 makefile_bootstrap_bintargets=''
142 for target in $bootstrap_bintargets
144 makefile_bootstrap_bintargets="$makefile_bootstrap_bintargets bootstrap/bin/${target}"
145 done
146 echo
147 echo "BOOTSTRAP_BINTARGETS =$makefile_bootstrap_bintargets"
149 makefile_bootstrap_libtargets=''
150 for target in $bootstrap_libtargets
152 makefile_bootstrap_libtargets="$makefile_bootstrap_libtargets bootstrap/lib/${target}"
153 done
154 echo "BOOTSTRAP_LIBTARGETS =$makefile_bootstrap_libtargets"
156 for target in $bintargets
158 eval "libs=\$${target}_libs"
159 [ -n "$libs" ] || libs="$default_libs"
160 lib_depends=''
161 lib_flags=''
162 for lib in $libs
164 lib_depends="${lib_depends} lib/lib${lib}.so"
165 lib_flags="$lib_flags -l${lib}"
166 done
167 eval "sources=\$${target}_sources"
168 [ -n "$sources" ] || sources="$target"
169 srcs=$(echo ${target}/*)
170 echo
171 echo "${target}_lflags =$lib_flags"
172 echo "${target}_libs =$lib_depends"
173 echo "${target}_sources =$srcs"
174 done
176 for target in $bootstrap_bintargets
178 eval "libs=\$${target}_libs"
179 [ -n "$libs" ] || libs="$default_libs"
180 lib_depends=''
181 lib_flags=''
182 for lib in $libs
184 lib_depends="${lib_depends} bootstrap/lib/lib${lib}.so"
185 lib_flags="$lib_flags -l${lib}"
186 done
187 srcs=''
188 for source in bootstrap/src/${target}/*.voo
190 base=$(basename ${source} .voo)
191 srcs="$srcs bootstrap/objects/${target}/${base}.o"
192 done
193 echo
194 echo "bootstrap_${target}_lflags =$lib_flags"
195 echo "bootstrap_${target}_libs =$lib_depends"
196 echo "bootstrap_${target}_objects =$srcs"
197 done
199 for target in $libtargets
201 eval "libs=\$lib${target}_libs"
202 lib_depends=''
203 lib_flags=''
204 for lib in $libs
206 lib_depends="$lib_depends lib/lib${lib}.so"
207 lib_flags="$lib_flags -l${lib}"
208 done
209 eval "sources=\$lib${target}_sources"
210 [ -n "$sources" ] || sources="$target"
211 srcs=''
212 for source in $sources
214 srcs="$srcs objects/${target}/${source}.o"
215 done
216 echo
217 echo "lib${target}_lflags =$lib_flags"
218 echo "lib${target}_libs =$lib_depends"
219 echo "lib${target}_objects =$srcs"
220 done
222 for target in $bootstrap_libtargets
224 eval "libs=\$lib${target}_libs"
225 lib_depends=''
226 lib_flags=''
227 for lib in $libs
229 lib_depends="$lib_depends bootstrap/lib/lib${lib}.so"
230 lib_flags="$lib_flags -l${lib}"
231 done
232 eval "sources=\$lib${target}_sources"
233 [ -n "$sources" ] || sources="$target"
234 srcs=''
235 for source in $sources
237 srcs="$srcs bootstrap/objects/${target}/${source}.o"
238 done
239 echo
240 echo "bootstrap_lib${target}_lflags =$lib_flags"
241 echo "bootstrap_lib${target}_libs =$lib_depends"
242 echo "bootstrap_lib${target}_objects =$srcs"
243 done
245 for target in $testtargets
247 eval "libs=\$${target}_libs"
248 [ -n "$libs" ] || libs="$default_libs"
249 lib_depends=''
250 lib_flags=''
251 for lib in $libs
253 lib_depends="${lib_depends} lib/lib${lib}.so"
254 lib_flags="$lib_flags -l${lib}"
255 done
256 eval "sources=\$${target}_sources"
257 [ -n "$sources" ] || sources="$target"
258 srcs=''
259 for source in $sources
261 srcs="$srcs objects/test/${source}.o"
262 done
263 echo
264 echo "${target}_lflags =$lib_flags"
265 echo "${target}_libs =$lib_depends"
266 echo "${target}_objects =$srcs"
267 done
269 for target in $bintargets
271 echo
272 echo "bin/${target} : \$(${target}_sources) \$(${target}_libs)"
273 if [ "$target" = transmute ]
274 then
275 printf '\tenv LD_LIBRARY_PATH=bootstrap/lib bootstrap/bin/transmute -t exe -L lib -o bin/%s %s\n' "$target" "$target"
277 printf '\tenv LD_LIBRARY_PATH=lib bin/transmute -t exe -L lib -o bin/%s %s\n' "$target" "$target"
278 done
280 for target in $bootstrap_bintargets
282 echo
283 echo "bootstrap/bin/${target} : \$(bootstrap_${target}_objects) \$(bootstrap_${target}_libs)"
284 printf '\t$(CC) $(CFLAGS) $(bootstrap_%s_objects) -o bootstrap/bin/%s -Lbootstrap/lib $(bootstrap_%s_lflags) $(LDFLAGS)\n' "$target" "$target" "$target"
285 done
287 for target in $libtargets
289 target="lib${target}"
290 echo
291 echo "lib/${target}.so : \$(${target}_objects) \$(${target}_libs)"
292 printf '\t$(CC) $(CFLAGS) -shared $(%s_objects) -o lib/%s.so -Llib $(%s_lflags)\n' "$target" "$target" "$target"
293 done
295 for target in $bootstrap_libtargets
297 target="lib${target}"
298 echo
299 echo "bootstrap/lib/${target}.so : \$(bootstrap_${target}_objects) \$(bootstrap_${target}_libs)"
300 printf '\t$(CC) $(CFLAGS) -shared $(bootstrap_%s_objects) -o bootstrap/lib/%s.so -Lbootstrap/lib $(bootsrap_%s_lflags)\n' "$target" "$target" "$target"
301 done
303 for target in $testtargets
305 echo
306 echo "test/${target} : \$(${target}_objects) \$(${target}_libs)"
307 printf '\t$(CC) $(CFLAGS) $(%s_objects) -o test/%s -Llib $(%s_lflags) $(LDFLAGS)\n' "$target" "$target" "$target"
308 done
310 cat <<'EOT'
312 .PHONY : all check clean default distclean
314 default : $(LIBTARGETS) $(BINTARGETS)
316 all : default $(TESTTARGETS)
318 check : all
319 cd test && case $(SRC) in /*) $(SRC)/src/test/test;; *) ../$(SRC)/src/test/test;; esac
321 clean :
323 distclean :
324 -rm -r bin generated lib bootstrap/bin bootstrap/lib bootstrap/objects objects test Makefile
326 bootstrap : bootstrap/bin/transmute
329 for target in $bintargets $libtargets
331 for x in "$source_dir"/bootstrap/src/${target}/*.voo
333 if [ -e "$x" ]
334 then
335 t="bootstrap/objects/${target}/$(basename "$x" .voo).o"
336 printf '\n%s : %s\n' "$t" "$x"
337 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
339 done
340 done
342 for target in $bintargets $libtargets
344 for x in "$source_dir"/src/${target}/*.sb
346 if [ -e "$x" ]
347 then
348 b=$(basename "$x" .sb)
349 g="generated/${target}/${b}.voo"
350 t="objects/${target}/${b}.o"
351 printf '\n%s : %s\n' "$t" "$g"
352 printf '\t$(VOODOOC) %s -o %s\n' "$g" "$t"
353 printf '\n%s : $(BOOTSTRAP_TRANSMUTE) %s\n' "$g" "$x"
354 printf '\t$(BOOTSTRAP_TRANSMUTE_ENV) $(BOOTSTRAP_TRANSMUTE) < %s > %s\n' "$x" "$g"
356 done
357 done
359 for x in "$source_dir"/src/test/*.sb
361 if [ -e "$x" ]
362 then
363 b=$(basename "$x" .sb)
364 g="generated/test/${b}.voo"
365 t="objects/test/${b}.o"
366 printf '\n%s : %s\n' "$t" "$g"
367 printf '\t$(VOODOOC) %s -o %s\n' "$g" "$t"
368 printf '\n%s : bin/transmute %s\n' "$g" "$x"
369 printf '\tenv LD_LIBRARY_PATH=lib bin/transmute < %s > %s\n' "$x" "$g"
371 done
373 for target in $bintargets $libtargets
375 for x in "$source_dir"/src/${target}/*.voo
377 if [ -e "$x" ]
378 then
379 b=$(basename "$x" .voo)
380 t="objects/${target}/${b}.o"
381 printf '\n%s : %s\n' "$t" "$x"
382 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
383 if [ \! -f "$source_dir/bootstrap/src/${target}/$b.voo" ]
384 then
385 printf '\nbootstrap/%s : %s\n' "$t" "$x"
386 printf '\t$(VOODOOC) %s -o bootstrap/%s\n' "$x" "$t"
389 done
390 done
392 for target in $bintargets $libtargets
394 for x in "$source_dir"/src/${target}/*.c
396 if [ -e "$x" ]
397 then
398 b=$(basename "$x" .c)
399 t="objects/${target}/${b}.o"
400 printf '\n%s : %s\n' "$t" "$x"
401 printf '\t$(CC) $(CFLAGS) -I$(SRC)/include -fPIC -c %s -o %s\n' "$x" "$t"
402 printf '\nbootstrap/%s : %s\n' "$t" "$x"
403 printf '\t$(CC) $(CFLAGS) -I$(SRC)/include -fPIC -c %s -o bootstrap/%s\n' "$x" "$t"
405 done
406 done
408 for x in "$source_dir"/src/test/*.voo
410 if [ -e "$x" ]
411 then
412 b=$(basename "$x" .voo)
413 t="objects/test/${b}.o"
414 printf '\n%s : %s\n' "$t" "$x"
415 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
417 done
420 LDFLAGS="$LDFLAGS -lgc"
421 bootstrap_transmute="bootstrap/bin/transmute"
422 bootstrap_transmute_env="env LD_LIBRARY_PATH=bootstrap/lib"
423 make_bootstrap=true
424 source_dir="$(dirname "$0")"
426 mkdir -p bin bootstrap/bin bootstrap/lib bootstrap/objects generated \
427 generated/test lib objects objects/test test
428 for target in $bintargets $libtargets
430 mkdir -p bootstrap/objects/${target} generated/${target} objects/${target}
431 done
433 write_makefile > Makefile