####### Please do not forget to read TYA README file #######
#
prefix=@prefix@
exec_prefix=@exec_prefix@
JAVABINDIR=@javabindir@
LIBDIR=@libdir@


# TARGET specific options:
#TARGETFLAGS =-DDEBUG -DJ102
#TARGETFLAGS =-DJ102
#TARGETFLAGS =-DDEBUG

# GCC specific options:
COPTFLAGS=-O3
#COPTFLAGS=-O6 -v


# CPU specific options:
POPTFLAGS=-m486 -malign-loops=4 -malign-functions=4 -malign-jumps=4


#_____________________________________________________________

JAVAINCLDIR=-I$(JAVABINDIR)/../include -I$(JAVABINDIR)/../include/genunix \
	-I$(JAVABINDIR)/../include/freebsd \
	-I$(JAVABINDIR)/../include/linux \
	-I$(JAVABINDIR)/../include-old -I$(JAVABINDIR)/../include-old/linux


TARGET=libtya.so
CSOURCES=tya.c tyarechelp.c tyarecode.c tyautil.c tyaruntime.c tyaexc.c

#
CFLAGS = -Wall -pipe -shared -lc $(COPTFLAGS) $(POPTFLAGS)	$(TARGETFLAGS)

all: $(TARGET)

$(TARGET): tya.h tyaconfig.h Makefile $(CSOURCES) tya.S tyaasm.S tyaasm_FreeBSD.S
	gcc $(CFLAGS) $(JAVAINCLDIR) -o $(TARGET) $(CSOURCES) tya.S

install: $(TARGET)
	install -m 755 $(TARGET) $(LIBDIR)

tya.s: tya.c tya.h tyaconfig.h Makefile $(CSOURCES)
	gcc $(CFLAGS) $(JAVAINCLDIR) -S $(CSOURCES)

tya.list: tya.c tya.h tyaconfig.h Makefile
	gcc -Wa,-a -c -g $(COPTFLAGS) $(POPTFLAGS) $(JAVAINCLDIR) tya.c >tya.list
	
tya.prep: tya.c tya.h tyaconfig.h Makefile
	gcc -E $(COPTFLAGS) $(POPTFLAGS) $(JAVAINCLDIR) tya.c >tya.list

clean:
	rm -f $(TARGET) *.o *.s
distclean: clean
	rm -f Makefile config.h config.cache config.status config.log

test:
	cd demo; make TYA_TEST_JAVA=$(JAVABINDIR)/java $@
