7 _voodoo_translator_libs
='
47 test_voodoo_translator
51 bootstrap_bintargets
="$bintargets"
52 bootstrap_libtargets
="$libtargets"
95 libvoodoo_translator_sources
='
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"
116 BOOTSTRAP_TRANSMUTE = $bootstrap_transmute
117 BOOTSTRAP_TRANSMUTE_ENV = $bootstrap_transmute_env
122 makefile_bintargets
=''
123 for target
in $bintargets
125 makefile_bintargets
="$makefile_bintargets bin/${target}"
128 echo "BINTARGETS =$makefile_bintargets"
130 makefile_libtargets
=''
131 for target
in $libtargets
133 makefile_libtargets
="$makefile_libtargets lib/lib${target}.so"
135 echo "LIBTARGETS =$makefile_libtargets"
137 makefile_testtargets
=''
138 for target
in $testtargets
140 makefile_testtargets
="$makefile_testtargets test/${target}"
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}"
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}"
158 echo "BOOTSTRAP_LIBTARGETS =$makefile_bootstrap_libtargets"
160 for target
in $bintargets
162 eval "libs=\$${target}_libs"
163 [ -n "$libs" ] || libs
="$default_libs"
168 lib_depends
="${lib_depends} lib/lib${lib}.so"
169 lib_flags
="$lib_flags -l${lib}"
171 eval "sources=\$${target}_sources"
172 [ -n "$sources" ] || sources
="$target"
173 srcs
=$
(echo ${target}/*)
175 echo "${target}_lflags =$lib_flags"
176 echo "${target}_libs =$lib_depends"
177 echo "${target}_sources =$srcs"
180 for target
in $bootstrap_bintargets
182 eval "libs=\$${target}_libs"
183 [ -n "$libs" ] || libs
="$default_libs"
188 lib_depends
="${lib_depends} bootstrap/lib/lib${lib}.so"
189 lib_flags
="$lib_flags -l${lib}"
192 for source in bootstrap
/src
/${target}/*.voo
194 base
=$
(basename ${source} .voo
)
195 srcs
="$srcs bootstrap/objects/${target}/${base}.o"
198 echo "bootstrap_${target}_lflags =$lib_flags"
199 echo "bootstrap_${target}_libs =$lib_depends"
200 echo "bootstrap_${target}_objects =$srcs"
203 for target
in $libtargets
205 eval "libs=\$lib${target}_libs"
210 lib_depends
="$lib_depends lib/lib${lib}.so"
211 lib_flags
="$lib_flags -l${lib}"
213 eval "sources=\$lib${target}_sources"
214 [ -n "$sources" ] || sources
="$target"
216 for source in $sources
218 srcs
="$srcs objects/${target}/${source}.o"
221 echo "lib${target}_lflags =$lib_flags"
222 echo "lib${target}_libs =$lib_depends"
223 echo "lib${target}_objects =$srcs"
226 for target
in $bootstrap_libtargets
228 eval "libs=\$lib${target}_libs"
233 lib_depends
="$lib_depends bootstrap/lib/lib${lib}.so"
234 lib_flags
="$lib_flags -l${lib}"
236 eval "sources=\$lib${target}_sources"
237 [ -n "$sources" ] || sources
="$target"
239 for source in $sources
241 srcs
="$srcs bootstrap/objects/${target}/${source}.o"
244 echo "bootstrap_lib${target}_lflags =$lib_flags"
245 echo "bootstrap_lib${target}_libs =$lib_depends"
246 echo "bootstrap_lib${target}_objects =$srcs"
249 for target
in $testtargets
251 eval "libs=\$${target}_libs"
252 [ -n "$libs" ] || libs
="$default_libs"
257 lib_depends
="${lib_depends} lib/lib${lib}.so"
258 lib_flags
="$lib_flags -l${lib}"
260 eval "sources=\$${target}_sources"
261 [ -n "$sources" ] || sources
="$target"
263 echo "${target}_lflags =$lib_flags"
264 echo "${target}_libs =$lib_depends"
267 for target
in $bintargets
270 echo "bin/${target} : \$(${target}_sources) \$(${target}_libs)"
271 if [ "$target" = transmute
]
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"
278 for target
in $bootstrap_bintargets
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"
285 for target
in $libtargets
287 target
="lib${target}"
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"
293 for target
in $bootstrap_libtargets
295 target
="lib${target}"
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"
303 .PHONY : all check clean default distclean
305 default : $(LIBTARGETS) $(BINTARGETS)
307 all : default $(TESTTARGETS)
310 cd test && case $(SRC) in /*) $(SRC)/src/test/test;; *) ../$(SRC)/src/test/test;; esac
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
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"
333 for target
in $bintargets $libtargets
335 for x
in "$source_dir"/src
/${target}/*.sb
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"
350 for x
in $testtargets
352 s
="$source_dir/src/test/$x.sb"
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"
361 for target
in $bintargets $libtargets
363 for x
in "$source_dir"/src
/${target}/*.voo
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" ]
373 printf '\nbootstrap/%s : %s\n' "$t" "$x"
374 printf '\t$(VOODOOC) %s -o bootstrap/%s\n' "$x" "$t"
380 for target
in $bintargets $libtargets
382 for x
in "$source_dir"/src
/${target}/*.c
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"
396 for x
in "$source_dir"/src
/test
/*.voo
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"
408 LDFLAGS
="$LDFLAGS -lgc"
409 bootstrap_transmute
="bootstrap/bin/transmute"
410 bootstrap_transmute_env
="env LD_LIBRARY_PATH=bootstrap/lib"
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}
421 write_makefile
> Makefile