# Makefile for pstoedit. 

BINDIR=debian-tmp/usr/bin
LIBDIR=debian-tmp/usr/lib/pstoedit
MANDIR=debian-tmp/usr/man

#CC=SCC4 +w
#CC=clCC +w
CC=g++ -Wall
CFLAGS=-g 

# No changes should be necessary below this line

VERSION=2.3.3
CPPSOURCES=drvMIF.c drvTGIF.c drvFIG.c drvbase.c drvexample.c lex.yy.c
OTHERSOURCES=makeedit.l pstoedit pstoedit.pro
HEADERS=drvMIF.h drvTGIF.h drvFIG.h drvbase.h drvexample.h drvgeneral.h 
EXAMPLES=illusion.ps escher.triang.ps spiral.ps

SHAROBJECTS=COPYING README HISTORY PROBLEMS Makefile pstoedit.man $(CPPSOURCES) $(HEADERS) $(OTHERSOURCES) $(EXAMPLES)

#OBJECTS=lex.yy.o drvbase.o drvTGIF.o drvMIF.o drvFIG.o drvCGM.o drvPDF.o 
OBJECTS=lex.yy.o drvbase.o drvTGIF.o drvMIF.o drvFIG.o 

# this does not work with GNU make
#OBJECTS:sh =ls drv*.c | sed 's/\.c/\.o/'
#OBJECTS += lex.yy.o

makeedit: $(OBJECTS)
	$(CC) -o makeedit $(CFLAGS) $(OBJECTS) -ll

lex.yy.c: makeedit.l 
	flex  -8 makeedit.l 

config.h: Makefile
	@echo "// generated by pstoedit makefile " > config.h
	if [ -f drvCGM.c ] ; then \
		echo "#define WITHCGM 1" > config.h ;\
	fi
	if [ -f drvPDF.c ] ; then \
		echo "#define WITHPDF 1" > config.h ;\
	fi
clean:
	rm -f core makeedit $(OBJECTS)

test: makeedit
	pstoedit -f tgif illusion.ps 
	tgif illusion.ps.obj
	pstoedit -m 2 -f tgif illusion.ps 
	tgif illusion.ps.obj
	pstoedit -dt -f tgif illusion.ps 
	tgif illusion.ps.obj
	pstoedit -f tgif escher.triang.ps 
	tgif escher.triang.ps.obj
	pstoedit -f fig spiral.ps
	xfig spiral.ps.fig
	groff -man pstoedit.man > pstoedit.man.ps
	pstoedit -f ps pstoedit.man.ps
	gs pstoedit.man.ps.ps
	pstoedit -f mif illusion.ps
	pstoedit -f mif escher.triang.ps


install: makeedit pstoedit.pro pstoedit pstoedit.man
	install makeedit pstoedit $(BINDIR)
	install pstoedit.pro $(LIBDIR)
	install pstoedit.man $(MANDIR)/man1/pstoedit.1

shar: pstoedit.shar
tar : pstoedit.$(VERSION).tar.gz pstoedit.$(VERSION).tar.gz.uu

pstoedit.shar: $(SHAROBJECTS)
	shar $(SHAROBJECTS) > pstoedit.shar

pstoedit.$(VERSION).tar.gz : $(SHAROBJECTS)
	if [ ! -d pstoedit_$(VERSION) ] ; then \
		mkdir pstoedit_$(VERSION);\
	fi
	cp $(SHAROBJECTS) pstoedit_$(VERSION);
	tar cvf - pstoedit_$(VERSION) | gzip >  pstoedit.$(VERSION).tar.gz 

pstoedit.$(VERSION).tar.gz.uu: pstoedit.$(VERSION).tar.gz
	uuencode pstoedit.$(VERSION).tar.gz pstoedit.$(VERSION).tar.gz > pstoedit.$(VERSION).tar.gz.uu

mtest:	
	echo $(OBJECTS)
depend: 
	makedepend $(CPPSOURCES)
# DO NOT DELETE

# drvCGM.o: drvCGM.h drvbase.h drvgeneral.h
# drvPDF.o: drvPDF.h drvbase.h drvgeneral.h
drvFIG.o: drvFIG.h drvbase.h drvgeneral.h
drvMIF.o: drvMIF.h drvbase.h drvgeneral.h
drvTGIF.o: drvTGIF.h drvbase.h drvgeneral.h
drvbase.o: drvbase.h
drvexample.o: drvbase.h drvexample.h drvgeneral.h
lex.yy.o: drvFIG.h drvMIF.h drvTGIF.h drvbase.h config.h
lex.yy.o: drvgeneral.h makeedit.l
