# Install Trans package here

TRANS_LIB = @TRANS_LIB@
TRANS_LIB_DIR = @TRANS_LIB@/@TRANS_DIR@

TRANS_BIN = @TRANS_BIN@

#----------------------------------------------------------------
OS 	= @OS@
CC      = @CC@
#INCLUDES  = @XINCLUDES@ -I@TCL_SRC_DIR@/generic -I@TK_SRC_DIR@/generic -I@TCL_PREFIX@/include -I@TK_PREFIX@/include
INCLUDES = @INCLUDES@

CFLAGS    = -O @CFLAGS@ ${INCLUDES} @TCLAPI@
#CFLAGS    = -O -Wall @CFLAGS@ @AFLAG@ ${INCLUDES}

#LIBS      = -lc @TK_LIBS@ @TCL_LIB_SPEC@ @TK_LIB_SPEC@
LIBS      = @LIBS@

SHLIB_LD     = @SHLIB_LD@
SHLIB_SUFFIX = @LIB_SUFFIX@

all: libtrans${SHLIB_SUFFIX}

OBJS =  axis.o wavfm.o segmt.o trans.o

libtrans${SHLIB_SUFFIX}: ${OBJS}
	${SHLIB_LD} ${OBJS} ${LIBS} -o libtrans${SHLIB_SUFFIX} 
	sed s/.dll/${SHLIB_SUFFIX}/ < pkgIndex.tcl.dll > pkgIndex.tcl

install:
	@if [ ! -d ${TRANS_LIB} ] ; then \
            echo Creating ${TRANS_LIB} directory ; \
	    mkdir ${TRANS_LIB}  ; \
	fi; 
	if [ ! -d ${TRANS_BIN} ] && [ ${OS} = UnixLike ] ; then \
            echo Creating ${TRANS_BIN} directory ; \
	    mkdir ${TRANS_BIN} ; \
	fi;
	@if [ ! -d ${TRANS_LIB_DIR} ] ; then \
	    mkdir ${TRANS_LIB_DIR} ${TRANS_LIB_DIR}/tcl ${TRANS_LIB_DIR}/convert; \
	    chmod 755 ${TRANS_LIB_DIR} ${TRANS_LIB_DIR}/tcl ${TRANS_LIB_DIR}/convert; \
	else true; \
	fi;
	cp -f libtrans${SHLIB_SUFFIX} ${TRANS_LIB_DIR}/
	cp -f pkgIndex.tcl ${TRANS_LIB_DIR}/
	cp -f ../tcl/*.tcl ${TRANS_LIB_DIR}/tcl
	cp -f ../convert/*.tcl ../convert/README ${TRANS_LIB_DIR}/convert
	cp -rf ../img ../doc ../etc ../demo ../COPYING ${TRANS_LIB_DIR}/

	@if [ ${OS} = UnixLike ] ; then \
		cp -f trans ${TRANS_BIN}/trans; \
		chmod ugo+x ${TRANS_BIN}/trans; \
		cp ../README_UNIX ${TRANS_LIB_DIR} ; \
	else \
		cp ../README_WINDOWS.txt ${TRANS_LIB_DIR}; \
	fi ;

distrib-bin:
	make install
	cd ../..; tar cf - -C ${TRANS_LIB}/.. lib/@TRANS_DIR@ lib/snack1.7 lib/tcLex1.2 bin/trans | gzip -c > Transcriber-bin.tar.gz

clean:
	rm -f *.o libtrans${SHLIB_SUFFIX} pkgIndex.tcl

distclean: clean
	@if [ ${OS} = Windows ] ; then \
		rm -f Makefile config.status config.cache config.log; \
	else \
		rm -f trans Makefile config.status config.cache config.log; \
	fi;
