added a function to get the command line arguments
[antimony.git] / configure
blobd23fe37e6c91d6e6944baf6d50f1aafc509d620c
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_hash_table
33 test_list
34 test_log
35 test_mod
36 test_mod_voodoo
37 test_readdir
38 test_stat
39 test_stream
40 test_symbol
41 test_symbol_encoder
42 test_tempdir
43 test_to_core
44 test_voodoo_translator
45 test_voodoo_writer
46 xyzzy
49 bootstrap_bintargets="$bintargets"
50 bootstrap_libtargets="$libtargets"
52 libantimony_sources='
53 antimony_reader
54 antimony_writer
55 args
56 array
57 array_sb
58 allocate
59 blob
60 blob_sb
61 block
62 boolean
63 comment
64 condition
65 dynarray
66 env
67 errno
68 errno_c
69 file
70 fixnum
71 gensym
72 hash_table
73 hex
74 init
75 list
76 log
77 module
78 process
79 random
80 readdir_c
81 stat_c
82 stream
83 symbol
84 symbol_encoder
85 symbol_sb
86 tempfile
87 type
90 libvoodoo_translator_sources='
91 anf_transform
92 antimony_symbols
93 compile_module
94 dealias
95 link
96 to_core
97 voodoo_translator
98 voodoo_writer
101 transmute_libs="$_voodoo_translator_libs"
102 test_anf_transform_libs="$_voodoo_translator_libs"
103 test_symbol_encoder_libs="$_voodoo_translator_libs"
104 test_to_core_libs="$_voodoo_translator_libs"
105 test_voodoo_translator_libs="$_voodoo_translator_libs"
106 test_voodoo_writer_libs="$_voodoo_translator_libs"
108 write_makefile() {
109 cat <<EOT
110 CFLAGS = ${CFLAGS}
111 BOOTSTRAP_TRANSMUTE = $bootstrap_transmute
112 BOOTSTRAP_TRANSMUTE_ENV = $bootstrap_transmute_env
113 LDFLAGS = ${LDFLAGS}
114 SRC = "$source_dir"
115 VOODOOC = voodooc
117 makefile_bintargets=''
118 for target in $bintargets
120 makefile_bintargets="$makefile_bintargets bin/${target}"
121 done
122 echo
123 echo "BINTARGETS =$makefile_bintargets"
125 makefile_libtargets=''
126 for target in $libtargets
128 makefile_libtargets="$makefile_libtargets lib/lib${target}.so"
129 done
130 echo "LIBTARGETS =$makefile_libtargets"
132 makefile_testtargets=''
133 for target in $testtargets
135 makefile_testtargets="$makefile_testtargets test/${target}"
136 done
137 echo
138 echo "TESTTARGETS =$makefile_testtargets"
140 makefile_bootstrap_bintargets=''
141 for target in $bootstrap_bintargets
143 makefile_bootstrap_bintargets="$makefile_bootstrap_bintargets bootstrap/bin/${target}"
144 done
145 echo
146 echo "BOOTSTRAP_BINTARGETS =$makefile_bootstrap_bintargets"
148 makefile_bootstrap_libtargets=''
149 for target in $bootstrap_libtargets
151 makefile_bootstrap_libtargets="$makefile_bootstrap_libtargets bootstrap/lib/${target}"
152 done
153 echo "BOOTSTRAP_LIBTARGETS =$makefile_bootstrap_libtargets"
155 for target in $bintargets
157 eval "libs=\$${target}_libs"
158 [ -n "$libs" ] || libs="$default_libs"
159 lib_depends=''
160 lib_flags=''
161 for lib in $libs
163 lib_depends="${lib_depends} lib/lib${lib}.so"
164 lib_flags="$lib_flags -l${lib}"
165 done
166 eval "sources=\$${target}_sources"
167 [ -n "$sources" ] || sources="$target"
168 srcs=''
169 for source in $sources
171 srcs="$srcs objects/${target}/${source}.o"
172 done
173 echo
174 echo "${target}_lflags =$lib_flags"
175 echo "${target}_libs =$lib_depends"
176 echo "${target}_objects =$srcs"
177 done
179 for target in $bootstrap_bintargets
181 eval "libs=\$${target}_libs"
182 [ -n "$libs" ] || libs="$default_libs"
183 lib_depends=''
184 lib_flags=''
185 for lib in $libs
187 lib_depends="${lib_depends} bootstrap/lib/lib${lib}.so"
188 lib_flags="$lib_flags -l${lib}"
189 done
190 eval "sources=\$${target}_sources"
191 [ -n "$sources" ] || sources="$target"
192 srcs=''
193 for source in $sources
195 srcs="$srcs bootstrap/objects/${target}/${source}.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}_objects) \$(${target}_libs)"
277 printf '\t$(CC) $(CFLAGS) $(%s_objects) -o bin/%s -Llib $(%s_lflags) $(LDFLAGS)\n' "$target" "$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