# vim: ft=make

MC = ocamlopt.opt
mc-opt = 3
mc-flags = $(if $(debug),-g,-O$(mc-opt))
mc = $(MC) $(mc-flags)

SC = chicken-csc
sc-opt = 5
sc-flags = $(if $(debug),-d3,-O$(sc-opt))
sc = $(SC) $(sc-flags)

cc-opt = fast
cc-std = c2x
cc-flags = $(if $(debug),-g,-O$(cc-opt)) -std=$(cc-std)
cc = $(CC) $(cc-flags)

post = $(if $(debug),, && strip $@)
cc-post = $(post)
sc-post = $(post)
mc-post = $(post)

prefix = $(if ${out},${out},/usr)

os = $(shell uname -o)

%: %.c
	$(cc) $< -o$@ $(cc-post)

%: %.ml
	$(mc) $< -o $@ $(mc-post)

%: %.scm
	$(sc) $< -o $@ $(sc-post)

%.proj: %/makefile
	cd $* && make $*

%.proj: %/make.sh
	cd $* && ./make.sh

dep/%:
	make -C dep $*
