##############################
# OSF1 Makefile for FUDGIT
###############################
#
# macro definitions
LDFLAGS = -lm -Lreadline/ -lreadline -ltermcap -lsys5 # -lmalloc 
# C compiling flags
# OSF compiler supports 'const' declarator and
# have the \a sequence for a bell
CFLAGS = $(OPT) -DVOID_SIGHANDLER -DRESTART_SIGHANDLER -DOSF -verbose 
# Final compiling flags
FCFLAGS =  $(OPT) 
# READLINE CFLAGS for OSF
# Loading <stdlib.h> ... crashes the compiler! So define NOSTDLIB_H
READLINE = USG="-DUSG" \
 OTH_CFLAGS="-DVOID_SIGHANDLER -DRESTART_SIGHANDLER -DNOSTDLIB_H \
 $(VI_MODE) -verbose"
DLDFLAGS = CFLAGS="-g -I."
DLFLAGS = CFLAGS="-g -I.."

# You should not need to edit anything below that line (except for sunos 3.5)
# Compiler: Use gcc if you want dynamic loader to work.
OBJECTS = mathparse.o fudgit.o alloc.o setshow.o vgetargp.o plot.o \
	fits.o fit.o svdfit.o medfit.o help.o mrqmin.o \
	command.o code.o math.o lexi.o init.o fft.o macro.o minit.o \
	spline.o readline2.o chd.o if.o strings.o

# Guess
SHELL = /bin/sh
# Default compiler
CC = cc
YFLAGS = -d
DATE = `cat ../Date`
VERSION = `cat ../Version`

all: 
	(cd readline; $(MAKE) CC="$(CC)" $(READLINE))
	$(MAKE) -f Makefile.osf CC="$(CC)" ../fudgit

../fudgit: $(OBJECTS) fudgit.h setshow.h readline/libreadline.a
	$(CC) $(FCFLAGS) -o ../fudgit $(OBJECTS) $(LDFLAGS)

code.o: code.h math.tab.h symbol.h
	$(CC) $(CFLAGS) $(POP) -c code.c

command.o: symbol.h code.h macro.h fudgit.h math.tab.h setshow.h help.h \
	install.dummy.c

fft.o: math.tab.h code.h symbol.h fudgit.h setshow.h dalloca.h

fits.o: symbol.h code.h fudgit.h math.tab.h setshow.h

fudgit.o: fudgit.h macro.h ../Date fudgit.c ../Version
	$(CC) $(CFLAGS) -DDATE="\"$(DATE)\"" -DVERSION="\"$(VERSION)\"" -c fudgit.c

help.o: help.h fudgit.h help.c
	$(CC) $(CFLAGS) -DHELPFILE="\"$(LIBDIR)/fudgit.help\"" -c help.c

if.o: fudgit.h

init.o: symbol.h code.h math.tab.h fudgit.h

lexi.o: symbol.h code.h fudgit.h math.tab.h

macro.o: macro.h fudgit.h setshow.h

math.o: fudgit.h 

mathparse.o: symbol.h code.h parse.y
	yacc $(YFLAGS) parse.y
	cat y.tab.c | sed s/yy/Ft_mathyy/g > mathparse.c
	rm y.tab.c 
	$(CC) $(CFLAGS) -Olimit 1000 -c mathparse.c

medfit.o: dalloca.h

minit.o: macro.h setshow.h

mrqmin.o: dalloca.h

chd.o: fudgit.h

plot.o: fudgit.h setshow.h macro.h

setshow.o: symbol.h code.h fudgit.h math.tab.h setshow.h macro.h functions.h

spline.o: symbol.h code.h fudgit.h math.tab.h command.h dalloca.h

svdfit.o: dalloca.h

vgetarg.o: fudgit.h macro.h

math.tab.h: y.tab.h
	cat y.tab.h | sed s/yy/Ft_mathyy/g > math.tab.h

y.tab.h: mathparse.o

