include ../make.inc

LIBS= ${TLIB} \
      ${CURS_LIB} \
      ${LAPACK_LIB} \
      ${BLAS_LIB} \
      ${MATLAB_LIB} \
      ${ESSL_LIB} \
      ${OP4_LIB} \
      ${X11} \
      ${X11EXT_LIB} \
      ${VMO_LIB} \
      ${XDB_LIB} \
      ${FFTW_LIB} \
      ${DYN_LIB} \
      ${SQLITE_LIB} \
      ${UMFPACK_LIB} \
      ${ARPACK_LIB} \
      ${METIS_LIB} \
      ${SSL_LIB} \
      ${VTPARSE_LIB} \
      ${F_LIB} \
      -lm

INC = ${MATLAB_INC} ${CURS_INC} ${OP4_INC} ${FFTW_INC} ${X11EXT_INC} \
      ${VMO_INC} ${SQLITE_INC} ${UMFPACK_INC} ${METIS_INC} ${SSL_INC} \
      ${VTPARSE_INC}

# Compilations are done in the order of these entries (an observation):
OBJ = ctrl.o exe.o hash.o inpo.o key.o lib.o main.o mat.o math.o  \
      mmath.o matlab.o mem.o prs.o stk.o sys.o term.o tex.o       \
      wapp.o wapp_f.o word.o xterm.o tag.o                        \
      essl.o ordering.o op4.o xdbfetch.o fftw_driver.o sparse.o   \
      lapack.o net.o spadd_rr.o spadd_rc.o spadd_cc.o spadd_cx.o  \
      spmult_rr.o spmult_rc.o spmult_cr.o spmult_cc.o stp.o       \
      vmo.o loadtx.o spsolve.o sql.o speig.o metis.o ssl.o vt.o

HEADERS= ctrl.h essl.h exe.h hash.h inpo.h key.h lib.h   \
         main.h mat.h math1.h matlab.h mem.h mmath.h     \
         op4.h prs.h stk.h stp.h sys.h term.h tex.h      \
         wapp.h  wapp.p word.h word.p lib1.p             \
         ordering.h fftw_driver.h sparse.h               \
         lapack.h net.h sql.h speig.h ssl.h vmo.h vt.h

tops1: ${OBJ} ${HEADERS} ${TLIB}
	${CC} ${LDFLAGS} ${OBJ} ${LIBS} -o $@

# Getting more memory on AIX:
#	${CC} ${OBJ} -bmaxdata:0x80000000 ${LIBS} -o $@
# Puts a load map in the previous directory:
#	${CC} ${OBJ} ${LIBS} -bloadmap:../loadmap -o $@

clean: 
	rm -fr tops1 *.o core

tags:
	ctags *.[chp]

cleantags:
	cd ..; make cleantags

.f.o :
	${FC} ${INC} ${F_COMOPTS} -c $<

.c.o : 
	${CC} ${INC} ${C_COMOPTS} ${UNISTD} -c $<

essl.o:        main.h stk.h ctrl.h inpo.h math1.h mmath.h mem.h tag.h
fftw_driver.o: fftw_driver.h stk.h
lapack.o:      lapack.h stk.h ctrl.h exe.h main.h mat.h mmath.h mem.h \
               ordering.h sys.h tex.h
main.o:        word.h
mat.o:         main.h stk.h ctrl.h inpo.h mat.h mem.h math1.h tex.h
matlab.o:      main.h stk.h matlab.h
mem.o:         main.h stk.h ctrl.h inpo.h mem.h tag.h sparse.h
metis.o:       stk.h main.h inpo.h sparse.h
net.o:         main.h stk.h net.h
ordering.o:    ordering.h main.h stk.h exe.h ctrl.h inpo.h mem.h
sparse.o:      sparse.h main.h stk.h ctrl.h inpo.h mem.h tag.h
spadd_rr.o:    sparse.h main.h stk.h ctrl.h inpo.h mem.h exe.h tag.h
spadd_rc.o:    sparse.h main.h stk.h ctrl.h inpo.h mem.h exe.h tag.h
spadd_cc.o:    sparse.h main.h stk.h ctrl.h inpo.h mem.h exe.h tag.h
spadd_cx.o:    sparse.h main.h stk.h ctrl.h inpo.h mem.h exe.h tag.h
speig.o:       stk.h main.h exe.h sparse.h tag.h speig.h ctrl.h inpo.h \
               mem.h lapack.h
spmult_rr.o:   sparse.h main.h stk.h ctrl.h inpo.h mem.h exe.h mat.h tag.h
spmult_rc.o:   sparse.h main.h stk.h ctrl.h inpo.h mem.h exe.h mat.h tag.h
spmult_cr.o:   sparse.h main.h stk.h ctrl.h inpo.h mem.h exe.h mat.h tag.h
spmult_cc.o:   sparse.h main.h stk.h ctrl.h inpo.h mem.h exe.h mat.h tag.h
spsolve.o:     stk.h main.h exe.h sparse.h tag.h spsolve.h ctrl.h inpo.h mem.h
sql.o:         sql.h stk.h main.h inpo.h tag.h
ssl.o:         net.h ssl.h
stk.o:         main.h stk.h ctrl.h exe.h inpo.h lib.h mem.h sparse.h \
               tex.h
sys.o:         main.h ctrl.h exe.h inpo.h lib.h key.h mat.h math1.h \
               mem.h stk.h tex.h
tag.o:         main.h exe.h ctrl.h inpo.h stk.h tag.h
term.o:        net.h ssl.h
tex.o:         main.h stk.h ctrl.h inpo.h mat.h mem.h tex.h
vmo.o:         main.h stk.h ctrl.h inpo.h lib.h mem.h term.h vmo.h
wapp.o:        main.h stk.h exe.h inpo.h mat.h math1.h mmath.h mem.h \
               wapp.h tag.h
word.o:        word.h word.p wapp.p lib1.p main.h stk.h term.h \
               ctrl.h exe.h hash.h inpo.h key.h lib.h mat.h math1.h \
               mmath.h mem.h sys.h tex.h wapp.h essl.h matlab.h \
               vmo.h ordering.h sparse.h tag.h
xterm.o:       stk.h main.h exe.h inpo.h mat.h math1.h term.h tex.h tag.h
