# The path to the tcl.h header file

TCL_INCPATH = @TCL_SRC_DIR@/generic

# The path to the tk.h header file

TK_INCPATH  = @TK_SRC_DIR@/generic

# The path to the X11 include files

XINCLUDES   = @XINCLUDES@

# Install SNACK package here

SNACK_INSTALL_PATH = @SNACK_INSTALL_PATH@

# Install SNACK plug-in add-on here

MOZILLA_DIR = @MOZILLA_DIR@

VERSION = 1.6

TCL_VERSION = @TCLVER@

CC        = @CC@

INCLUDES  = ${XINCLUDES} -I${TCL_INCPATH} -I${TK_INCPATH} @AINC@ @NISTINC@

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

LIBSO     = -lc @ALIB@ @TCL_LIB_SPEC@

LIBSN     = -lc @TK_LIBS@ @ALIB@ @TCL_LIB_SPEC@ @TK_LIB_SPEC@

SHLIB_LD     = @SHLIB_LD@
SHLIB_SUFFIX = @SHLIB_SUFFIX@

all: libsound${SHLIB_SUFFIX} libsnack${SHLIB_SUFFIX} @LIBNIST@ @DOSTUBLIB@ editversion

OBJSO = sound.o jkSound.o jkSoundEdit.o jkSoundFile.o g711.o @AOBJ@ SnackMP3amp.o jkSoundProc.o ffa.o @STUBINITOBJ@

OBJSN = snack.o jkSound.o jkSoundEdit.o jkSoundFile.o jkCanvSpeg.o jkCanvWave.o jkCanvSect.o ffa.o g711.o @AOBJ@ SnackMP3amp.o jkSoundProc.o @STUBINITOBJ@

OBJSNST = snackStubLib.o

libsound${SHLIB_SUFFIX}: ${OBJSO}
	${SHLIB_LD} ${OBJSO} ${LIBSO} -o libsound${SHLIB_SUFFIX} 
	sed s/.dll/${SHLIB_SUFFIX}/ < pkgIndex.tcl.dll > pkgIndex.tcl

libsnack${SHLIB_SUFFIX}: ${OBJSN}
	${SHLIB_LD} ${OBJSN} ${LIBSN} -o libsnack${SHLIB_SUFFIX} 
	sed s/.dll/${SHLIB_SUFFIX}/ < pkgIndex.tcl.dll > pkgIndex.tcl

stublib: ${OBJSNST}
	ar cr libsnackstub${VERSION}.a ${OBJSNST}

editversion: ${OBJSN}
	if test "$(TCL_VERSION)" != "8.1"; then\
	    cd ../demos/ ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ MinSect.tcl > tmp ;\
	    mv -f tmp MinSect.tcl ;\
	    chmod 755 MinSect.tcl ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ MinSpeg.tcl > tmp ;\
	    mv -f tmp MinSpeg.tcl ;\
	    chmod 755 MinSpeg.tcl ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ MinWave.tcl > tmp ;\
	    mv -f tmp MinWave.tcl ;\
	    chmod 755 MinWave.tcl ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ Section.tcl > tmp ;\
	    mv -f tmp Section.tcl ;\
	    chmod 755 Section.tcl ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ Spectrogram.tcl > tmp ;\
	    mv -f tmp Spectrogram.tcl ;\
	    chmod 755 Spectrogram.tcl ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ Waveform.tcl > tmp ;\
	    mv -f tmp Waveform.tcl ;\
	    chmod 755 Waveform.tcl ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ aserver.tcl > tmp ;\
	    mv -f tmp aserver.tcl ;\
	    chmod 755 aserver.tcl ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ mixer.tcl > tmp ;\
	    mv -f tmp mixer.tcl ;\
	    chmod 755 mixer.tcl ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ record.tcl > tmp ;\
	    mv -f tmp record.tcl ;\
	    chmod 755 record.tcl ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ snamp.tcl > tmp ;\
	    mv -f tmp snamp.tcl ;\
	    chmod 755 snamp.tcl ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ widget.tcl > tmp ;\
	    mv -f tmp widget.tcl ;\
	    chmod 755 widget.tcl ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ xs.tcl > tmp ;\
	    mv -f tmp xs.tcl ;\
	    chmod 755 xs.tcl ;\
	    sed s/wish8.1/wish${TCL_VERSION}/ cool.tcl > tmp ;\
	    mv -f tmp cool.tcl ;\
	    chmod 755 cool.tcl ;\
	    cd ../src ;\
	fi
LIBNIST = @NISTLIBS@ -lc @TCL_LIB_SPEC@
OBJNIST = SphereFile.o

libsnsphere${SHLIB_SUFFIX}: ${OBJNIST}
	${SHLIB_LD} ${OBJNIST} ${LIBNIST} -o libsnsphere${SHLIB_SUFFIX}

install:
	@if [ ! -d ${SNACK_INSTALL_PATH}/snack${VERSION} ] ; then \
	    echo "Making directory ${SNACK_INSTALL_PATH}/snack${VERSION}"; \
	    mkdir ${SNACK_INSTALL_PATH}/snack${VERSION}; \
	    chmod 755 ${SNACK_INSTALL_PATH}/snack${VERSION}; \
        else true; \
        fi;
	cp -f libsound${SHLIB_SUFFIX} ${SNACK_INSTALL_PATH}/snack${VERSION}/
	cp -f libsnack${SHLIB_SUFFIX} ${SNACK_INSTALL_PATH}/snack${VERSION}/
	if test -f libsnsphere${SHLIB_SUFFIX}; then cp -f libsnsphere${SHLIB_SUFFIX} ${SNACK_INSTALL_PATH}/snack${VERSION}/; fi
	cp -f snack.tcl ${SNACK_INSTALL_PATH}/snack${VERSION}/
	cp -f pkgIndex.tcl ${SNACK_INSTALL_PATH}/snack${VERSION}/
	@if [ -d "@MOZILLA_DIR@" ] ; then \
	    cp -rf ${SNACK_INSTALL_PATH}/snack${VERSION} ${MOZILLA_DIR}/tclplug/2.0/; \
	fi;

clean:
	rm -f *.o libsound${SHLIB_SUFFIX} libsnack${SHLIB_SUFFIX} libsnsphere${SHLIB_SUFFIX}

distclean: clean
	rm -f Makefile config.status config.cache config.log
