#
# 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 = /usr/lib/xfractint
# BINDIR is where you put your X11 binaries
BINDIR = /usr/X11/bin
# MANDIR is where you put your chapter 1 man pages
MANDIR = /usr/man/man1

NOBSTRING = -DNOBSTRING
HAVESTRI =
DEBUG =

# For Ultrix, uncomment the NOBSTRING line.
# For SunOS, uncomment the NOBSTRING and HAVESTRI lines, 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".
#
# 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.

#DEBUG adds some sanity checking but will slow xfractint down
#DEBUG = -DEBUG
#NOBSTRING = -DNOBSTRING
#HAVESTRI = -DHAVESTRI
# 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
# For Dec Alpha, add -DFTIME -DNOBSTRING -DDIRENT
# For SGI, you may have to add -DSYSVSGI
DEFINES = -DXFRACT $(NOBSTRING) $(HAVESTRI) $(DEBUG) # -DSYS5

#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

#CFLAGS = -I. -D_CONST $(DEFINES)
#CFLAGS = -I. $(DEFINES) -I/usr/include/X11R5 -I/usr/include/X11R4 +O3 +Obb1000
CFLAGS = -I. $(DEFINES) -O2 -DLINUX -Dlinux

# Gcc is usually 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 
CC = gcc
#CC = cc -Aa -D_HPUX_SOURCE

# 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
LIBS = -lX11 -lm -lcurses -ltermcap -lieee

OLDSRC = 3d.c calcfrac.c cmdfiles.c decoder.c editpal.c encoder.c f16.c \
fracsubr.c fractalp.c fractals.c fractint.c gifview.c hc.c hcmplx.c \
help.c intro.c \
jb.c jiim.c line3d.c loadfdos.c loadfile.c loadmap.c lorenz.c lsys.c \
miscfrac.c miscovl.c miscres.c mpmath_c.c parser.c parserfp.c plot3d.c \
printer.c prompts1.c prompts2.c realdos.c rotate.c slideshw.c targa.c \
testpt.c tgaview.c tp3d.c tplus.c zoom.c fractint.h fractype.h fmath.h port.h \
helpcom.h helpdefs.h mpmath.h targa.h targa_lc.h tplus.h prototyp.h \
fractsrc.doc debugfla.doc hc.doc

NEWSRC = calcmand.c calmanfp.c diskvidu.c fpu087.c fracsuba.c general.c \
printera.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 fractint.par icons.par phoenix.par

FRMFILES = fractint.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

NEWRUN = fractint0.doc README xfractint.man 

NEWFILES = $(NEWSRC) $(NEWRUN)

RUNFILES = $(OLDRUN) $(NEWRUN)

FILES = $(SRCFILES) $(RUNFILES)

OBJS = \
3d.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 fractalp.o \
fractals.o fractint.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 miscfrac.o miscovl.o \
miscres.o mpmath_c.o parser.o parserfp.o plot3d.o  printer.o printera.o \
prompts1.o prompts2.o realdos.o rotate.o slideshw.o targa.o testpt.o \
tgaview.o tp3d.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 $(OBJS)
	$(CC) -o xfractint $(CFLAGS) $(OBJS) $(LIBS)

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
	if [ ! -d $(SRCDIR) ]; then mkdir $(SRCDIR); chmod a+rx $(SRCDIR); fi
	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

makedoc: doc

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@sprite.Berkeley.EDU $(SRCFILES) > xfsrc.shar

sharrun:	$(RUNFILES)
	shar -s shirriff@sprite.Berkeley.EDU $(RUNFILES) > xfrun.shar

shar:	$(FILES)
	shar -s shirriff@sprite.Berkeley.EDU $(FILES) > xfractint.shar

sharc:	$(FILES)
	shar -s shirriff@sprite.Berkeley.EDU $(FILES) > xfractint.shar; compress xfractint.shar

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

checkout:
	co -l -r4.5 -q -f $(FILES)

checkin: $(OLDRUN) $(OLDSRC)
	ci -u -f -r5.2 -m"xfractint 2.1 pre sync" $(FILES)

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)

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

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

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

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

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

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

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

printera.o: printera.c port.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

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

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
