#
# Makefile for xfractint
#

# SRCDIR should be a path to the directory that will hold fractint.hlp
# You will have to copy fractint.hlp to SRCDIR and make it world readable.
# SRCDIR should also hold the .par, .frm, etc. files
SRCDIR = $(pwd)/usr/X11R6/lib/xfractint
# BINDIR is where you put your X11 binaries
BINDIR = /usr/X11R6/bin
# MANDIR is where you put your chapter 1 man pages
MANDIR = /usr/man/man1

#NOBSTRING =
HAVESTRI =
DEBUG =

# For Ultrix, uncomment the NOBSTRING line below.
# For SunOS or Solaris, uncomment the NOBSTRING and HAVESTRI lines below, so
# bstring.h will not be included, and the library stricmp will be used.
# For HPUX, uncomment the NOBSTRING line, change the DEFINES line, the CFLAGS
# line, the CC line, and the LIBS line.
# For AIX or OSF/1, change the DEFINES and LIB lines.
# For Apollo, uncomment the NOBSTRING line.  You must also remove the
#     source references to unistd.h, malloc.h, and alloc.h.
# For 386BSD, uncomment the NOBSTRING line.  Depending on your system, you
#     may have to change the "#elif !defined(__386BSD__)" at the top of
#     prompts2.c to "#else".
#

NOBSTRING = -DNOBSTRING
#HAVESTRI = -DHAVESTRI
#DEBUG adds some sanity checking but will slow xfractint down
#DEBUG = -DEBUG
# If your compiler doesn't handle void *, define -DBADVOID
# If you get SIGFPE errors define -DFPUERR
# For HPUX, add -DSYS5
# and maybe add -DSYSV -D_CLASSIC_ANSI_TYPES
# For AIX, add -DNOBSTRING and -DDIRENT
# AIX may also need -D_POSIX_SOURCE -D_ALL_SOURCE -D_NONSTD_TYPES
# AIX may need -D_ALL_SOURCE -D_NONSTD_TYPES to compile help.c
# For Dec Alpha, add -DFTIME -DNOBSTRING -DDIRENT
# For SGI, you may have to add -DSYSVSGI
DEFINES = -DXFRACT $(NOBSTRING) $(HAVESTRI) $(DEBUG)

#Maybe -D_CONST will fix problems with constant type in include files?
#For HPUX, use CFLAGS = -I. $(DEFINES) -I/usr/include/X11R4 +O3 +Obb1000
#For SGI, add -cckr to CFLAGS
#For 386BSD, add -I/usr/X386/include to CFLAGS
#For Apollo add -I/usr/include/X11 to CFLAGS
#Some systems need -static on the CFLAGS.
#For Linux, add -DLINUX to CFLAGS
#For Solaris, use CFLAGS = -I. -I/usr/openwin/include $(DEFINES) -g

#CFLAGS = -I. -D_CONST $(DEFINES)
CFLAGS = -I. $(DEFINES) -g -DBIG_ANSI_C -DLINUX

# Gcc is often the only compiler that works for this
# For HPUX, use CC = cc -Aa -D_HPUX_SOURCE
# For AIX, maybe use CC = xlc, but other AIX users found cc works, xlc doesn't.
# For Apollo use CC = cc -A cpu,mathlib_sr10  -A systype,bsd4.3 
# For Sun Solaris 2.x w/SparcCompilerC (cc), use CC = cc.
# For Sun Solaris 2.x w/GNU gcc, use CC = gcc
#CC = gcc
CC = cc

# For HPUX, use LIBS = -L/usr/lib/X11R4 -lX11 -lm -lcurses -ltermcap
# For AIX or OSF/1, add -lbsd
# For 386BSD, add -L/usr/X386/lib to LIBS
# For Apollo, change -lX11 to -L/usr/X11/libX11
# For Solaris, add -L/usr/openwin/lib
# For Linux, use  
LIBS = -L/usr/X11R6/lib -lX11 -lm -lncurses
#LIBS = -L/usr/X11R6/lib -lX11 -lm -lcurses -ltermcap
#LIBS = -lX11 -lm -lcurses -ltermcap

# HPUX fixes thanks to David Allport, Bill Broadley, and R. Lloyd.
# AIX fixes thanks to David Sanderson & Elliot Jaffe.
# OSF/1 fixes thanks to Ronald Record.
# 386BSD fixes thanks to Paul Richards and Andreas Gustafsson.
# Apollo fixes thanks to Carl Heidrich
# Linux fixes thanks to Darcy Boese
# Makefile dependency fixes thanks to Paul Roberts.
# Solaris fixes thanks to Darryl House

OLDSRC = \
3d.c ant.c big.h bigflt.c biginit.c biginit.h bignum.c \
bignumc.c calcfrac.c cmdfiles.c cmplx.h debugfla.doc decoder.c editpal.c \
encoder.c externs.h f16.c fmath.h fracsubr.c fractalb.c fractalp.c \
fractals.c fractint.c fractint.h fractsrc.doc fractype.h framain2.c \
frasetup.c gifview.c hc.c hc.doc hcmplx.c help.c helpcom.h \
intro.c jb.c jiim.c line3d.c loadfdos.c loadfile.c loadmap.c lorenz.c \
lsys.c lsys.h lsysf.c miscfrac.c miscovl.c miscres.c mpmath.h \
mpmath_c.c parser.c parserfp.c plot3d.c port.h printer.c prompts1.c \
prompts2.c prototyp.h realdos.c rotate.c slideshw.c stereo.c targa.c \
targa.h targa_lc.h testpt.c tgaview.c tplus.c tplus.h zoom.c  

NEWSRC = calcmand.c calmanfp.c diskvidu.c fpu087.c fracsuba.c general.c \
tplus_a.c video.c unix.c unixscr.c unix.h Makefile versions

HELPFILES = help.src help2.src help3.src help4.src help5.src

SRCFILES = $(OLDSRC) $(NEWSRC) $(HELPFILES)

PARFILES = \
cellular.par demo.par fract18.par fract19.par fractint.par \
icons.par lyapunov.par music.par phoenix.par

FRMFILES = fractint.frm phctutor.frm

IFSFILES = fractint.ifs

LFILES = fractint.l penrose.l tiling.l

MAPFILES = \
altern.map blues.map chroma.map default.map firestrm.map froth3.map \
froth316.map froth6.map froth616.map gamma1.map gamma2.map glasses1.map \
glasses2.map goodega.map green.map grey.map grid.map headache.map \
landscap.map lyapunov.map neon.map paintjet.map royal.map topo.map \
volcano.map

OLDRUN = $(PARFILES) $(FRMFILES) $(IFSFILES) $(LFILES) \
$(MAPFILES) demo.key advanced.key basic.key new19-4.key new19-5.key new19.key phctutor.txt if_else.txt  

NEWRUN = fractint.doc README xfractint.man 

NEWFILES = $(NEWSRC) $(NEWRUN)

RUNFILES = $(OLDRUN) $(NEWRUN)

FILES = $(SRCFILES) $(RUNFILES)

OBJS = \
3d.o ant.o bigflt.o  biginit.o bignum.o bignumc.o calcfrac.o \
calcmand.o calmanfp.o cmdfiles.o decoder.o diskvidu.o editpal.o encoder.o \
f16.o fpu087.o fracsuba.o fracsubr.o fractalb.o fractalp.o fractals.o \
fractint.o framain2.o frasetup.o general.o gifview.o hcmplx.o help.o \
intro.o jb.o jiim.o line3d.o loadfdos.o loadfile.o loadmap.o lorenz.o \
lsys.o lsysf.o miscfrac.o miscovl.o miscres.o mpmath_c.o parser.o \
parserfp.o plot3d.o printer.o prompts1.o prompts2.o \
realdos.o rotate.o slideshw.o stereo.o targa.o testpt.o tgaview.o \
tplus.o tplus_a.o unix.o unixscr.o video.o zoom.o  

HOBJS = hc.o unix.o

HELP = help.src help2.src help3.src help4.src help5.src

#Need to prevent lex from doing fractint.l -> fractint.c
.SUFFIXES:
.SUFFIXES: .o .c .s .h

xfractint: fractint.hlp .WAIT $(OBJS)
	$(CC) -o xfractint $(CFLAGS) $(OBJS) $(LIBS)
#	strip xfractint

tar:	$(FILES)
	tar cfh xfractint.tar $(FILES)

tidy:
	rm -f $(OBJS) $(HOBJS)

clean:
	rm -f $(OBJS) $(HOBJS) fractint.doc fractint.hlp hc xfractint helpdefs.h

install: xfractint fractint.hlp
	cp xfractint $(BINDIR)/xfractint
	strip $(BINDIR)/xfractint
	chmod a+x $(BINDIR)/xfractint
	cp fractint.hlp $(PARFILES) $(FRMFILES) $(IFSFILES) $(LFILES) $(MAPFILES) $(SRCDIR)
	(cd $(SRCDIR); chmod a+r fractint.hlp $(PARFILES) $(FRMFILES) $(IFSFILES) $(LFILES) $(MAPFILES) )
	cp xfractint.man $(MANDIR)/xfractint.1
	chmod a+r $(MANDIR)/xfractint.1

fractint.hlp: hc $(HELP)
	./hc /c

.WAIT:

fractint.doc: doc

doc: hc $(HELP)
	./hc /p

hc:	$(HOBJS)
	$(CC) -o hc $(CFLAGS) $(HOBJS)

unix.o:	unix.c
	$(CC) $(CFLAGS) -DSRCDIR=\"$(SRCDIR)\" -c unix.c

fractint.o: fractint.c
	$(CC) $(CFLAGS) -DSRCDIR=\"$(SRCDIR)\" -c fractint.c

help.o: help.c
	$(CC) $(CFLAGS) -DSRCDIR=\"$(SRCDIR)\" -c help.c

sharsrc:	$(SRCFILES)
	shar -s shirriff@eng.sun.com $(SRCFILES) > xfsrc.shar

sharrun:	$(RUNFILES)
	shar $(RUNFILES) > xfrun.shar

shar:	$(FILES)
	shar $(FILES) > xfract.shar

sharc:	$(FILES)
	shar $(FILES) > xfract.shr; gzip xfract.shr

shartw: $(OLDSRC) $(HELPFILES)
	shar -s shirriff@sprite.Berkeley.EDU $(OLDSRC) $(HELPFILES)> source.tw;compress \
	source.tw

create:
	sccs create -r3.0 $(FILES)

checkout:
	for i in $(FILES) ; do \
	    sccs edit $$i; \
	done

checkin: $(OLDRUN) $(OLDSRC)
	for i in $(FILES) ; do \
	    sccs delget  -y"released 3.02" $$i; \
	done

unlock: $(FILES)
	co -u -f $(FILES)

outdate: $(FILES)
	rcs -o3.5 $(FILES)

merge: $(SRCFILES) $(HELPFILES)
	for i in $(SRCFILES) ; do \
	    rcsmerge -r3.1 -r3.1.1.1 $$i; \
	done

tags: $(SRCFILES)
	ctags $(SRCFILES)

rcsdiff:
	cp /dev/null diffs.out ; \
	for i in $(OLDSRC) ; do \
	    rcsdiff -c $$i >> diffs.out; \
	done
diff:
	echo "use make -i"; \
	for i in $(FILES) ; do \
	    (diff -c $$i v18 > diffs/$$i; true;); \
	    true; \
	done

copy: $(FILES)
	mv $(FILES) backup

# DO NOT DELETE THIS LINE -- make depend depends on it.

3d.o: 3d.c fractint.h port.h prototyp.h mpmath.h helpcom.h

ant.o: ant.c fractint.h port.h prototyp.h mpmath.h helpcom.h helpdefs.h

bigflt.o: bigflt.c big.h biginit.h

biginit.o: biginit.c fractint.h port.h prototyp.h mpmath.h helpcom.h \
big.h 

bignum.o: bignum.c fractint.h port.h prototyp.h mpmath.h helpcom.h 

bignumc.o: bignumc.c fractint.h port.h prototyp.h mpmath.h helpcom.h 

calcfrac.o: calcfrac.c fractint.h port.h fractype.h mpmath.h targa_lc.h \
			prototyp.h helpcom.h

calcmand.o: calcmand.c fractint.h port.h

calmanfp.o: calmanfp.c fractint.h port.h fractype.h

cmdfiles.o: cmdfiles.c fractint.h port.h fractype.h prototyp.h mpmath.h \
			helpcom.h

decoder.o: decoder.c prototyp.h mpmath.h port.h fractint.h helpcom.h

diskvidu.o: diskvidu.c fractint.h port.h

editpal.o: editpal.c fractint.h port.h prototyp.h mpmath.h helpcom.h

encoder.o: encoder.c fractint.h port.h fractype.h prototyp.h mpmath.h helpcom.h

f16.o: f16.c targa_lc.h prototyp.h mpmath.h port.h fractint.h helpcom.h

fpu087.o: fpu087.c fractint.h port.h mpmath.h

fracsuba.o: fracsuba.c fractint.h port.h

fracsubr.o: fracsubr.c fractint.h port.h fractype.h mpmath.h prototyp.h \
			helpcom.h

fractalb.o: fractalb.c fractint.h port.h prototyp.h mpmath.h helpcom.h \
helpdefs.h fractype.h

fractalp.o: fractalp.c fractint.h port.h mpmath.h helpdefs.h fractype.h \
			prototyp.h helpcom.h

fractals.o: fractals.c fractint.h port.h mpmath.h helpdefs.h fractype.h \
			prototyp.h helpcom.h

fractint.o: fractint.c prototyp.h mpmath.h port.h fractint.h helpcom.h \
			fractype.h helpdefs.h

framain2.o: framain2.c fractint.h port.h prototyp.h mpmath.h helpcom.h \
fractype.h helpdefs.h

frasetup.o: frasetup.c fractint.h port.h prototyp.h mpmath.h helpcom.h \
mpmath.h helpdefs.h fractype.h

general.o: general.c fractint.h port.h

gifview.o: gifview.c fractint.h port.h prototyp.h mpmath.h helpcom.h

hc.o: hc.c helpcom.h port.h

hcmplx.o: hcmplx.c fractint.h port.h prototyp.h mpmath.h helpcom.h mpmath.h

help.o: help.c fractint.h port.h helpcom.h helpdefs.h prototyp.h mpmath.h

intro.o: intro.c fractint.h port.h helpdefs.h prototyp.h mpmath.h helpcom.h

jb.o: jb.c fractint.h port.h mpmath.h helpdefs.h prototyp.h helpcom.h

jiim.o: jiim.c helpdefs.h fractint.h port.h fractype.h prototyp.h mpmath.h \
		helpcom.h

line3d.o: line3d.c fractint.h port.h prototyp.h mpmath.h helpcom.h

loadfdos.o: loadfdos.c fractint.h port.h helpdefs.h prototyp.h mpmath.h \
			helpcom.h

loadfile.o: loadfile.c fractint.h port.h fractype.h targa_lc.h prototyp.h \
			mpmath.h helpcom.h

loadmap.o: loadmap.c fractint.h port.h prototyp.h mpmath.h helpcom.h

lorenz.o: lorenz.c mpmath.h fractint.h port.h fractype.h prototyp.h helpcom.h

lsys.o: lsys.c fractint.h port.h prototyp.h mpmath.h helpcom.h

lsysf.o: lsysf.c fractint.h port.h prototyp.h mpmath.h helpcom.h lsys.h

miscfrac.o: miscfrac.c fractint.h port.h prototyp.h mpmath.h helpcom.h \
fractype.h targa_lc.h

miscovl.o: miscovl.c fractint.h port.h fractype.h helpdefs.h prototyp.h \
			mpmath.h helpcom.h

miscres.o: miscres.c fractint.h port.h fractype.h helpdefs.h prototyp.h \
			mpmath.h helpcom.h

mpmath_c.o: mpmath_c.c mpmath.h prototyp.h port.h fractint.h helpcom.h

parser.o: parser.c mpmath.h prototyp.h port.h fractint.h helpcom.h

parserfp.o: parserfp.c fractint.h port.h prototyp.h mpmath.h helpcom.h

plot3d.o: plot3d.c fractint.h port.h fractype.h prototyp.h mpmath.h helpcom.h

printer.o: printer.c fractint.h port.h fractype.h prototyp.h mpmath.h helpcom.h

prompts1.o: prompts1.c fractint.h port.h fractype.h helpdefs.h prototyp.h \
			mpmath.h helpcom.h

prompts2.o: prompts2.c fractint.h port.h fractype.h helpdefs.h prototyp.h \
			mpmath.h helpcom.h

realdos.o: realdos.c fractint.h port.h fractype.h helpdefs.h prototyp.h \
			mpmath.h helpcom.h

rotate.o: rotate.c fractint.h port.h helpdefs.h prototyp.h mpmath.h helpcom.h

slideshw.o: slideshw.c fractint.h port.h prototyp.h mpmath.h helpcom.h

stereo.o: stereo.c fractint.h port.h prototyp.h mpmath.h helpcom.h helpdefs.h

targa.o: targa.c targa.h fractint.h port.h prototyp.h mpmath.h helpcom.h

testpt.o: testpt.c

tgaview.o: tgaview.c fractint.h port.h targa_lc.h prototyp.h mpmath.h helpcom.h

tp3d.o: tp3d.c mpmath.h fractint.h port.h prototyp.h helpcom.h

tplus.o: tplus.c port.h tplus.h prototyp.h mpmath.h fractint.h helpcom.h

tplus_a.o: tplus_a.c fractint.h port.h

unix.o: unix.c port.h

unixscr.o: unixscr.c fractint.h port.h prototyp.h mpmath.h helpcom.h helpdefs.h

video.o: video.c fractint.h port.h prototyp.h mpmath.h helpcom.h

zoom.o: zoom.c fractint.h port.h prototyp.h mpmath.h helpcom.h
