#
#  Makefile for program(s) a2fplot analyze dmp2asc jsexpr plot
#   generated automatically
#
#   (C) Joerg Schoen 1994-98
#

#  My preferred optimization flags for some systems:
# --- Silicon Graphics ---
#COPTIMIZE= -O2 -mips2
# --- AIX ---
#COPTIMIZE= -O3 -qstrict -qansialias
# --- AIX PWR2 ---
#COPTIMIZE= -O3 -qstrict -qansialias -qarch=pwrx -qtune=pwrx
# --- Linux ---
#COPTIMIZE= -pipe -O3 -fstrength-reduce -funroll-loops

#  Numerical libraries to use for canned functions
# --- Silicon Graphics ---
#NUMLIB= -lcomplib.sgimath -lftn -lm
# --- AIX ---
#NUMLIB= -lessl -lxlf90 -lxlf -lm -Wl,-bI:/usr/lpp/xlf/lib/lowsys.exp
# --- AIX PWR2 ---
#NUMLIB= -lesslp2 -lxlf90 -lxlf -lm -bI:/usr/lpp/xlf/lib/lowsys.exp
# --- Linux ---
#NUMLIB=

# Default settings for configuration dependent options.
CFLAGS= -I. $(COPTIMIZE) $(CCOPTIONS)
LFLAGS= $(LDOPTIONS)
BINDIR=..

#  Definitions for libraries.
L=libjssubs.a
LSRC=	ErrCodes.c calcderiv.c cfft.c cfftn.c compexpr.c critical.c \
	cstrcompile.c errfkt.c evalstring.c flocks.c fopenpath.c \
	freeexpr.c intpow.c jserror.c jsgetline.c jsgetopt.c \
	jsperror.c jsstrerr.c lcfftn.c logprintf.c mktime2.c \
	permute.c polint.c progopts.c rfft.c ridderiv.c scalprod.c \
	spline.c strcomp.c stricomp.c strtoid.c strtol2.c \
	truncnum.c vaprintf.c 
LOBJ=	$L(ErrCodes.o) $L(calcderiv.o) $L(cfft.o) $L(cfftn.o) \
	$L(compexpr.o) $L(critical.o) $L(cstrcompile.o) \
	$L(errfkt.o) $L(evalstring.o) $L(flocks.o) $L(fopenpath.o) \
	$L(freeexpr.o) $L(intpow.o) $L(jserror.o) $L(jsgetline.o) \
	$L(jsgetopt.o) $L(jsperror.o) $L(jsstrerr.o) $L(lcfftn.o) \
	$L(logprintf.o) $L(mktime2.o) $L(permute.o) $L(polint.o) \
	$L(progopts.o) $L(rfft.o) $L(ridderiv.o) $L(scalprod.o) \
	$L(spline.o) $L(strcomp.o) $L(stricomp.o) $L(strtoid.o) \
	$L(strtol2.o) $L(truncnum.o) $L(vaprintf.o) 
L1=libfplot.a
L1SRC=	fplot.c fplotanalyze.c fplotaxes.c fplotcast.c fplotcopy.c \
	fplotopen.c fplotread.c fplotstensor.c fplotsubs.c \
	fplottensor.c fplottext.c fplottrans.c fplotvector.c 
L1OBJ=	$(L1)(fplot.o) $(L1)(fplotanalyze.o) $(L1)(fplotaxes.o) \
	$(L1)(fplotcast.o) $(L1)(fplotcopy.o) $(L1)(fplotopen.o) \
	$(L1)(fplotread.o) $(L1)(fplotstensor.o) $(L1)(fplotsubs.o) \
	$(L1)(fplottensor.o) $(L1)(fplottext.o) $(L1)(fplottrans.o) \
	$(L1)(fplotvector.o) 

#  Definitions for program "a2fplot"
OBJ1=	a2fplot.o 
EXE1=	$(BINDIR)/a2fplot

#  Definitions for program "analyze"
SRC2=	analyze.c analyze2.c analyze3.c analyze4.c analyze5.c 
OBJ2=	analyze.o analyze2.o analyze3.o analyze4.o analyze5.o 
EXE2=	$(BINDIR)/analyze

#  Definitions for program "dmp2asc"
OBJ3=	dmp2asc.o jtsubs.o 
EXE3=	$(BINDIR)/dmp2asc

#  Definitions for program "jsexpr"
OBJ4=	jsexpr.o 
EXE4=	$(BINDIR)/jsexpr

#  Definitions for program "plot"
SRC5=	plot.c plot2.c plotdev.c plotparse.y 
OBJ5=	plot.o plot2.o plotdev.o plotparse.o 
EXE5=	$(BINDIR)/plot

#  General user targets
all: $(EXE1) $(EXE2) $(EXE3) $(EXE4) $(EXE5)

clean:
	-rm *.o *.a

realclean: clean
	-rm $(EXE1) $(EXE2) $(EXE3) $(EXE4) $(EXE5)

#  How to make the executable(s)
$(EXE1): $(L1) $(L) $(OBJ1)
	$(CC) $(CFLAGS) $(OBJ1) $(L1) $(L) -lm $(LFLAGS) -o $@

$(EXE2): $(L1) $(L) $(OBJ2)
	$(CC) $(CFLAGS) $(OBJ2) $(L1) $(L) -lm $(NUMLIB) $(LFLAGS) -o $@

analyze.h: $(SRC2) analyze.in
	makeproto -i analyze.in $(SRC2) | makedefs -i - $(SRC2) -o $@

$(EXE3): $(L1) $(L) $(OBJ3)
	$(CC) $(CFLAGS) $(OBJ3) $(L1) $(L) -lm $(LFLAGS) -o $@

$(EXE4): $(L1) $(L) $(OBJ4)
	$(CC) $(CFLAGS) $(OBJ4) $(L1) $(L) -lm $(LFLAGS) -o $@

$(EXE5): $(L1) $(L) $(OBJ5)
	$(CC) $(CFLAGS) $(OBJ5) $(L1) $(L) -ltwg -ltwgpost -lftn -lm $(LFLAGS) -o $@

plot.h: $(SRC5) plot.in
	makeproto -i plot.in $(SRC5) | makedefs -i - $(SRC5) -o $@


# These rules should make the library and the library header files
#  and the error definitions if necessary. For the headers you'll
#  need my utilities makeproto, makedefs and makeerror.
$(L): $(LOBJ)
$(L1): $(L1OBJ)

header:  fplot.h jssubs.h

jssubs.h: $(LSRC) jssubs.in
	makeproto -i jssubs.in $(LSRC) | makedefs -i - $(LSRC) -o $@

fplot.h: $(L1SRC) fplot.in
	makeproto -i fplot.in $(L1SRC) | makedefs -i - $(L1SRC) -o $@

errdefs: $(LSRC) $(L1SRC)
	makeerror -o ErrCodes.c -mM Error.txt $(LSRC) $(L1SRC)

# Some platforms need this rule. Remove comments if yacc
#  files get not compiled automatically.
#.y.a:
#	$(YACC) $(YFLAGS) $<
#	$(CC) -c $(CFLAGS) y.tab.c
#	rm y.tab.c
#	mv y.tab.o $*.o
#	$(AR) $(ARFLAGS) $@ $*.o
#	-rm -f $*.o
