VERSION=3.3.1
CFLAGS=-XDeriveDataTypeable

PROG_HS  = $(notdir $(basename $(wildcard [_abcdefghijklmnopqrstuvwxyzäöü]*.hs)))
PROG_CHS = $(notdir $(basename $(wildcard [_abcdefghijklmnopqrstuvwxyzäöü]*.chs)))

# Löscht Doppelgänger
PROGS    = $(sort $(PROG_HS) $(PROG_CHS))


% : %.o cteile.o ../dist/build/libHShsshellscript-$(VERSION).a
	ghc -o $@ $^ -package haskell2010 -package unix

%.o : %.hs
	ghc -c $(CFLAGS) $^

%.o : %.c
	gcc -c -o $@ $<

%.hs : %.chs
	-chmod u+w $@
	c2hs -o $@ $<
	chmod u-w $@

clean :: depend
	rm -f *.hi *.o *~ *.bak $(PROGS) *.chi *.chs.h \
	      $(foreach m, $(PROG_CHS), "$(m).hs")

depend :: $(foreach m, $(PROGS), $(m).hs)
	ghc -M $(CFLAGS) -dep-makefile -optdepdepend \
	       $(foreach m, $(PROGS), "$(m).hs")
	make cteile.o

z : z.c
	gcc -o $@ $<

-include depend
