include ../../make.include
include ../../make.pkgs

CXXFLAGS = $(CXXOPT) -w \
	-I. -I.. -I../widget -I../vector -I../list -I../fitsy++ -I../util \
	-I../../include -I$(X11INCLUDE) \
	-I../../$(FUNTOOLSDIR)/util \
	-I/usr/include/libxml2 \
	-I../../$(ASTDIR)

SS	= \
	annulus.C \
	base.C \
	basecommand.C \
	basebox.C \
	baseellipse.C \
	baseline.C \
	basemarker.C \
	basepanda.C \
	box.C \
	boxannulus.C \
	bpanda.C \
	callback.C \
	circle.C \
	colorscale.C \
	colorscalergb.C \
	colorscaletrue8.C \
	colorscaletrue16.C \
	colorscaletrue24.C \
	colorscaletrue32.C \
	compass.C \
	composite.C \
	context.C \
	contour.C \
	coord.C \
	cpanda.C \
	ellipse.C \
	ellipseannulus.C \
	epanda.C \
	fitsanalysis.C \
	fitsbin.C \
	fitscompress.C \
	fitsdata.C \
	fitshealpix.C \
	fitsimage.C \
	fitsmask.C \
	fitsmap.C \
	frame.C \
	frame3d.C \
	framebase.C \
	frame3dbase.C \
	framergb.C \
	framergbtruecolor.C \
	framergbtruecolor8.C \
	framergbtruecolor16.C \
	framergbtruecolor24.C \
	frametrue.C \
	frame3dtrue.C \
	frametruecolor.C \
	frame3dtruecolor.C \
	frametruecolor8.C \
	frametruecolor16.C \
	frametruecolor24.C \
	frame3dtruecolor8.C \
	frame3dtruecolor16.C \
	frame3dtruecolor24.C \
	frblt.C \
	frcommand.C \
	fr3dcommand.C \
	frload.C \
	frmap.C \
	fr3dmap.C \
	frmarker.C \
	frmarkerxml.C \
	frsave.C \
	frscale.C \
	fvcontour.C \
	grid.C \
	grid2d.C \
	grid25d.C \
	grid3d.C \
	inversescale.C \
	line.C \
	marker.C \
	point.C \
	polygon.C \
	projection.C \
	ruler.C \
	tag.C \
	text.C \
	vect.C

ifeq ($(OS),unix)
SSP =	\
	colorscalepseudo8.C \
	framepseudo.C \
	framepseudocolor.C \
	framepseudocolor8.C
endif

SRC	= $(SS) $(SSP) \
	ciaoparser.C \
	ciaolex.C \
	ds9parser.C \
	ds9lex.C \
	parser.C \
	lex.C \
	prosparser.C \
	proslex.C \
	saoparser.C \
	saolex.C \
	tngparser.C \
	tnglex.C \
	xyparser.C \
	xylex.C

INCLS	= $(wildcard *.h)
OBJS	= $(SRC:%.C=%.o)

all	: $(OBJS) TAGS

clean	: FORCE
	rm -f core *~ *#

distclean : clean
	rm -f TAGS *.o parser.output ds9parser.output ciaoparser.output prosparser.output tngparser.output saoparser.output xyparser.output

ifdef DEPENDS
TAGS	: $(SS) $(INCLS)
	etags $+
else
TAGS	: FORCE
endif

parsers	: ciaoparser ds9parser parser prosparser saoparser tngparser xyparser

ciaoparser : FORCE
	bison -d -p ciao -o ciaoparser.C ciaoparser.Y
	flex -Pciao -ociaolex.C ciaolex.L

ds9parser : FORCE
	bison -d -p mk -o ds9parser.C ds9parser.Y
	flex -Pmk -ods9lex.C ds9lex.L

parser : FORCE
	bison -d -p fr -o parser.C parser.Y
	flex -Pfr -olex.C lex.L

prosparser : FORCE
	bison -d -p pros -o prosparser.C prosparser.Y
	flex -Ppros -oproslex.C proslex.L

saoparser : FORCE
	bison -d -p sao -o saoparser.C saoparser.Y
	flex -Psao -osaolex.C saolex.L

tngparser : FORCE
	bison -d -p tng -o tngparser.C tngparser.Y
	flex -Ptng -otnglex.C tnglex.L

xyparser : FORCE
	bison -d -p xy -o xyparser.C xyparser.Y
	flex -Pxy -oxylex.C xylex.L

FORCE	:

ifdef DEPENDS
%.d: %.C
	set -e; $(CXX) -MM $(CXXFLAGS) $< \
	| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
	[ -s $@ ] || rm -f $@

include $(SS:.C=.d)
endif
