# Generated automatically from Makefile.in by configure.
TOP = ../../..
srcdir = .

include $(TOP)/config/Makedefs

CCINCS = -I. -I$(srcdir) -I$(srcdir)/$(TOP) -I$(TOP) 

TARGETS = libthor.a
LDIRT = th_*.c th_*.h th-typelist.h

GENERATED = th-typelist.h *.h-th

all: libthor.a #libthor-ascii.a

libthor.a: th-typelist.h $(TOP)/fe/boot/specs.pth \
	    ../binary_veneer.h $(TOP)/fe/client/gen-binary-C-veneer.o
	$(RM) th-typelist.h-th
	$(RM) th_*.[ch]
	../../../fe/fe -s 4096 -v builtins
	$(RM) th_combined.c
	echo "typedef float real;" > combined.c
	echo "typedef int null;" >> combined.c
	cat th_*.c >> combined.c 	# for compile speed
	mv combined.c th_combined.c
	$(CC) -c $(CFLAGS) th_combined.c
	$(RM) $@
	$(AR) cq $@ th_*.o
	$(RM) th_*.o th_combined.c
	$(RANLIB) $@

libthor-ascii.a: th-typelist.h $(TOP)/fe/boot/specs.pth ../th-veneer.h
	$(RM) th-typelist.h-th
	../../../fe/fe -v builtins -l C-ascii
	echo "typedef float real;" > combined.c
	cat th_*.c >> combined.c 	# for compile speed
	mv combined.c th_combined.c
	$(RM) th_combined.c
	$(CC) -c $(CFLAGS) th_combined.c
	$(RM) $@
	$(AR) cq $@ th_combined.o
	$(RM) th_*.o th_combined.c
	$(RANLIB) $@


th-typelist.h:
	$(ECHO) "#ifndef _TH_TYPELIST_H"		> $@
	$(ECHO) "#define _TH_TYPELIST_H"		>> $@
	$(ECHO) "#define THOR_TYPE(t) typedef int t"	>> $@
	$(ECHO) "#include \"th-typelist.h-th\""		>> $@
	$(ECHO) "#endif /* _TH_TYPELIST_H */"		>> $@
