support dealiasing @-prefixed symbols
[antimony.git] / configure
blob8113b7f159d4e91228e0e1f72eb8f0cc88eb091c
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_set
34 test_hash_table
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_translator
47 test_voodoo_writer
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 srcs=''
263 for source in $sources
265 srcs="$srcs objects/test/${source}.o"
266 done
267 echo
268 echo "${target}_lflags =$lib_flags"
269 echo "${target}_libs =$lib_depends"
270 echo "${target}_objects =$srcs"
271 done
273 for target in $bintargets
275 echo
276 echo "bin/${target} : \$(${target}_sources) \$(${target}_libs)"
277 if [ "$target" = transmute ]
278 then
279 printf '\tenv LD_LIBRARY_PATH=bootstrap/lib bootstrap/bin/transmute -t exe -L lib -o bin/%s %s\n' "$target" "$target"
281 printf '\tenv LD_LIBRARY_PATH=lib bin/transmute -t exe -L lib -o bin/%s %s\n' "$target" "$target"
282 done
284 for target in $bootstrap_bintargets
286 echo
287 echo "bootstrap/bin/${target} : \$(bootstrap_${target}_objects) \$(bootstrap_${target}_libs)"
288 printf '\t$(CC) $(CFLAGS) $(bootstrap_%s_objects) -o bootstrap/bin/%s -Lbootstrap/lib $(bootstrap_%s_lflags) $(LDFLAGS)\n' "$target" "$target" "$target"
289 done
291 for target in $libtargets
293 target="lib${target}"
294 echo
295 echo "lib/${target}.so : \$(${target}_objects) \$(${target}_libs)"
296 printf '\t$(CC) $(CFLAGS) -shared $(%s_objects) -o lib/%s.so -Llib $(%s_lflags)\n' "$target" "$target" "$target"
297 done
299 for target in $bootstrap_libtargets
301 target="lib${target}"
302 echo
303 echo "bootstrap/lib/${target}.so : \$(bootstrap_${target}_objects) \$(bootstrap_${target}_libs)"
304 printf '\t$(CC) $(CFLAGS) -shared $(bootstrap_%s_objects) -o bootstrap/lib/%s.so -Lbootstrap/lib $(bootsrap_%s_lflags)\n' "$target" "$target" "$target"
305 done
307 for target in $testtargets
309 echo
310 echo "test/${target} : \$(${target}_objects) \$(${target}_libs)"
311 printf '\t$(CC) $(CFLAGS) $(%s_objects) -o test/%s -Llib $(%s_lflags) $(LDFLAGS)\n' "$target" "$target" "$target"
312 done
314 cat <<'EOT'
316 .PHONY : all check clean default distclean
318 default : $(LIBTARGETS) $(BINTARGETS)
320 all : default $(TESTTARGETS)
322 check : all
323 cd test && case $(SRC) in /*) $(SRC)/src/test/test;; *) ../$(SRC)/src/test/test;; esac
325 clean :
327 distclean :
328 -rm -r bin generated lib bootstrap/bin bootstrap/lib bootstrap/objects objects test Makefile
330 bootstrap : bootstrap/bin/transmute
333 for target in $bintargets $libtargets
335 for x in "$source_dir"/bootstrap/src/${target}/*.voo
337 if [ -e "$x" ]
338 then
339 t="bootstrap/objects/${target}/$(basename "$x" .voo).o"
340 printf '\n%s : %s\n' "$t" "$x"
341 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
343 done
344 done
346 for target in $bintargets $libtargets
348 for x in "$source_dir"/src/${target}/*.sb
350 if [ -e "$x" ]
351 then
352 b=$(basename "$x" .sb)
353 g="generated/${target}/${b}.voo"
354 t="objects/${target}/${b}.o"
355 printf '\n%s : %s\n' "$t" "$g"
356 printf '\t$(VOODOOC) %s -o %s\n' "$g" "$t"
357 printf '\n%s : $(BOOTSTRAP_TRANSMUTE) %s\n' "$g" "$x"
358 printf '\t$(BOOTSTRAP_TRANSMUTE_ENV) $(BOOTSTRAP_TRANSMUTE) < %s > %s\n' "$x" "$g"
360 done
361 done
363 for x in "$source_dir"/src/test/*.sb
365 if [ -e "$x" ]
366 then
367 b=$(basename "$x" .sb)
368 g="generated/test/${b}.voo"
369 t="objects/test/${b}.o"
370 printf '\n%s : %s\n' "$t" "$g"
371 printf '\t$(VOODOOC) %s -o %s\n' "$g" "$t"
372 printf '\n%s : bin/transmute %s\n' "$g" "$x"
373 printf '\tenv LD_LIBRARY_PATH=lib bin/transmute < %s > %s\n' "$x" "$g"
375 done
377 for target in $bintargets $libtargets
379 for x in "$source_dir"/src/${target}/*.voo
381 if [ -e "$x" ]
382 then
383 b=$(basename "$x" .voo)
384 t="objects/${target}/${b}.o"
385 printf '\n%s : %s\n' "$t" "$x"
386 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
387 if [ \! -f "$source_dir/bootstrap/src/${target}/$b.voo" ]
388 then
389 printf '\nbootstrap/%s : %s\n' "$t" "$x"
390 printf '\t$(VOODOOC) %s -o bootstrap/%s\n' "$x" "$t"
393 done
394 done
396 for target in $bintargets $libtargets
398 for x in "$source_dir"/src/${target}/*.c
400 if [ -e "$x" ]
401 then
402 b=$(basename "$x" .c)
403 t="objects/${target}/${b}.o"
404 printf '\n%s : %s\n' "$t" "$x"
405 printf '\t$(CC) $(CFLAGS) -I$(SRC)/include -fPIC -c %s -o %s\n' "$x" "$t"
406 printf '\nbootstrap/%s : %s\n' "$t" "$x"
407 printf '\t$(CC) $(CFLAGS) -I$(SRC)/include -fPIC -c %s -o bootstrap/%s\n' "$x" "$t"
409 done
410 done
412 for x in "$source_dir"/src/test/*.voo
414 if [ -e "$x" ]
415 then
416 b=$(basename "$x" .voo)
417 t="objects/test/${b}.o"
418 printf '\n%s : %s\n' "$t" "$x"
419 printf '\t$(VOODOOC) %s -o %s\n' "$x" "$t"
421 done
424 LDFLAGS="$LDFLAGS -lgc"
425 bootstrap_transmute="bootstrap/bin/transmute"
426 bootstrap_transmute_env="env LD_LIBRARY_PATH=bootstrap/lib"
427 make_bootstrap=true
428 source_dir="$(dirname "$0")"
430 mkdir -p bin bootstrap/bin bootstrap/lib bootstrap/objects generated \
431 generated/test lib objects objects/test test
432 for target in $bintargets $libtargets
434 mkdir -p bootstrap/objects/${target} generated/${target} objects/${target}
435 done
437 write_makefile > Makefile