#
# Makefile for xfractint
# !! Note: I haven't bothered to work out all the include file dependencies,
# so don't expect the right things to get recompiled if you change files.
#

# 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 = .
# BINDIR is where you put your X11 binaries
BINDIR = /vol/X11/bin
# MANDIR is where you put your chapter 1 man pages
MANDIR = /vol/X11/man/manl

NOBSTRING =
HAVESTRI =

# 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.
#
# (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)

#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
DEFINES = -DXFRACT $(NOBSTRING) $(HAVESTRI) $(DEBUG) -DDIRENT

#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
#CFLAGS = -I. -g -D_CONST $(DEFINES)
CFLAGS = -I. -I/vol/X11/include -O2 $(DEFINES) -DSVR4

# 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.
CC = gcc

# For HPUX, use LIBS =  -L /usr/lib/X11R4 -lX11 -lm -lcurses -ltermcap
# For AIX or OSF/1, add -lbsd
LIBS = -L/vol/X11/lib -R/vol/X11/lib -lX11 -lm -lcurses

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 help.c intro.c jb.c jiim.c\
line3d.c loadfdos.c loadfile.c loadmap.c lorenz.c lsys.c miscovl.c \
miscres.c mpmath_c.c parser.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

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

SRCFILES = $(OLDSRC) $(NEWSRC)

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

PARFILES = best_one.par dan.par dan1.par dan2.par dcontpot.par \
dcontpt2.par dgeneral.par dmore.par eli.par fracti.par fractint.par \
klaus.par mosaic.par new.par newfract.par pete-1.par plasma.par purple.par \
radar.par tchebych.par test.par testmos.par tetsuo.par trek.par uli.par \
wohlers.par

FRMFILES = eli.frm fractint.frm improved.frm sam.frm tchebych.frm uli.frm

IFSFILES = binary.ifs coral.ifs crystal.ifs dragon.ifs fern.ifs floor.ifs \
fractint.ifs koch3.ifs spiral.ifs swirl5.ifs tree.ifs triangle.ifs zigzag2.ifs

LFILES = fractint.l penrose.l tiling.l

MAPFILES = 2.map 23.map 3.map 4.map 4zebbow.map 4zebbowx.map 8rain.map \
8rain2.map 8temp.map 8zebbow2.map altern.map bandbow1.map black.map \
blakwhit.map blakwht.map blend.map blend1.map blend2.map blend3.map \
blend4.map blend8.map blendfff.map blengbyg.map blues.map chroma.map \
chroma2.map clouds.map default.map defaultw.map fire2.map firestrm.map \
fourain.map fourain2.map gamma1.map gamma2.map glasses1.map \
glasses2.map glasses5.map goodega.map grayish.map green.map grey.map \
grid.map headache.map hybrid.map indigo.map landscap.map laser.map \
litnin1.map lyapunov.map n.map neon.map new.map newmap.map paintjet.map \
pvland.map rain4.map rain4g1.map rain4x.map rainbow.map rainbow2.map \
rainbow3.map rainbow4.map rainbow5.map rainhyb.map rby.map royal.map \
roygbv.map smooth.map smooth2.map smooth4.map star.map topo.map \
tworain.map tworain2.map twowhite.map volcano.map volcano3.map \
volcano4.map volcano5.map volcano6.map white.map whiteblk.map worms.map \
yelpurp1.map zebbow2.map 

OLDOTHER = $(HELPFILES) $(PARFILES) $(FRMFILES) $(IFSFILES) $(LFILES) \
$(MAPFILES) demo.key fractsrc.doc debugfla.doc hc.doc

NEWOTHER = fractint0.doc README Makefile  xfractint.man versions

NEWFILES = $(NEWSRC) $(NEWOTHER)

FILES = $(OLDSRC) $(NEWSRC) $(OLDOTHER) $(NEWOTHER)

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 help.o intro.o jb.o jiim.o \
line3d.o loadfdos.o loadfile.o loadmap.o lorenz.o lsys.o miscovl.o \
miscres.o mpmath_c.o parser.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)
	strip xfractint

fractals.o fractint.o help.o intro.o jb.o: helpdefs.h
loadfdos.o miscovl.o miscres.o prompts.o realdos.o rotate.o: helpdefs.h
unixscr.o: helpdefs.h

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
	strip xfractint
	cp xfractint $(BINDIR)
	chmod +x $(BINDIR)/xfractint
	if [ ! -d $(SRCDIR) ]; then mkdir $(SRCDIR); fi 
	cp fractint.hlp $(SRCDIR)
	chmod +r $(SRCDIR)/fractint.hlp
	cp xfractint.man $(MANDIR)/xfractint.1
	chmod +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)

hc.o:	hc.c helpcom.h

help.o:	help.c helpcom.h

calcfrac.o fpu087.o fracsubr.o fractalp.o fractals.o: mpmath.h
fractint.o jb.o lorenz.o mpmath_a.o mpmath_c.o: mpmath.h
parse.o tmp3d.o: mpmath.h

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

sharsrc:	$(SRCFILES)
	shar -s shirriff@sprite.Berkeley.EDU $(SRCFILES) > source.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
