##########################
# AIX Makefile for FUDGIT
##########################
#
# macro definitions
# Linker flags
LDFLAGS = -lm -Lreadline/ -lreadline -ltermcap
# Final compiling flags
FCFLAGS = $(OPT)
# The following is for RS 6000 AIX 3.2
# Define -DNODRAND48 if AIX 3.1 (no drand48() function)
CFLAGS = -DAIX $(OPT) -DVOID_SIGHANDLER -DSIGHANDLER_1 \
	-DRESTART_SIGHANDLER -D_POSIX_SOURCE -D_XOPEN_SOURCE
# READLINE CFLAGS for AIX
READLINE = OTH_CFLAGS="-DAIX -DVOID_SIGHANDLER \
	-DRESTART_SIGHANDLER -DSIGHANDLER_1 $(VI_MODE) -D_POSIX_SOURCE"

# You should not need to edit anything below that line
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 alloca.o if.o strings.o

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

all: readline/libreadline.a ../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.c help.h fudgit.h ../Makefile
	$(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) -c mathparse.c

medfit.o: dalloca.h

mrqmin.o: dalloca.h

minit.o: macro.h setshow.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

readline/libreadline.a: readline/readline.c readline/readline.h
	(cd readline; $(MAKE) CC="$(CC)" $(READLINE) )
 
