# dxy2ps and hpgl2ps (Copyright) D McCormick
# Commercial reproduction prohibited.
#
# Obtained from UUCP Newsgroup comp.sources.unix
# Spring 1988
#
# Modified by Gordon Jacobs, July 1989
#
# Modified by Michael L. Brown, June, 1990
#
# Modified by Jeffrey A. Stern, Nov, 1994. Called v2.1.
#
# UNIX and DOS/DJGPP Makefile
# SETUP:
#
# 1) Check that you have the 'ar' and 'install' commands on your
# system, and that CC, INSTALLFLAGS, INSTALLMANFLAGS are set to your
# compiler/preferences.  

CC=		gcc
SHELL=		/bin/sh
FILTER1=	dxy2ps.in
FILTER2=	hpgl2ps.in
FILTER1.C=	dxy2ps.c
FILTER2.C=	hpgl2ps.c
INSTALLFLAGS=	-s -o root -g root -m 755
MANFILTER1=	dxy2ps.1
MANFILTER2=	hpgl2ps.1
INSTALLMANFLAGS=-o root -g root -m 644
TESTFILES=	test1h.ps test2h.ps test3h.ps test1d.ps



# 3) Make sure this is where you want the man pages to go.
# This complies with the Linux FSSTND (File System Standard).

INSDIR=		/usr/local/bin
INSMANDIR=	/usr/local/man/man1


# 4) Find your system below and uncomment the lines.  Default is
# Linux.  So far, Sun, MIPS, Linux supported, but it 'shouldn't"
# be much to adapt these variables to your system.
#
# For the CFLAGS variable below:
#
# Add -DNOTIMP to list the non-implemented HPGL commands out to the stderr.
#
# Add -DDEBUG for listing the HPGL implemented commands and the PostScript
# output that goes with it.
#

# For Sun using GNU, activate the following lines, and deactivate the
# other machines'.

# LOADLIBES=	-lieee -lm 
# CFLAGS=	-O -Wall -DNOTIMP -ansi -pedantic
# FILTER1A=	dxy2ps
# FILTER2A=	hpgl2ps
# ACONVERT1=	cp $(FILTER1) $(FILTER1A); strip $(FILTER1A)
# ACONVERT2=	cp $(FILTER2) $(FILTER2A); strip $(FILTER2A)

# For MIPS or Linux, activate the following lines, and deactivate the
# other machines'.
# I originally needed the -lieee flag for the libraries.  I kept
# getting 'Floating Exception' when I ran hpgl2ps. This was reputedly
# caused by a bug in strtod or floatconv.c (which manifests as _IO_dtoa
# in gdb output).  Apparently strtod will die after too many calls to
# itself, or something like that.  Later, I found that with a lot of
# cleanup using 'gcc -Wall', and no dependence up math.h for rint, and
# a bunch of other stuff to get the programs into strict ANSI
# compliance and compile without error, the -lieee was not needed.  A
# phantom, I guess.  But one heck of an ugly one. :) Anyway, if you get
# the error mentioned above and you're compiling on linux, try adding
# the -lieee back into LOADLIBES.  For reference, I have libc 4.5.26,
# and gcc 2.5.8. -jas. 

CC=		egcs
LOADLIBES=	-lm
CFLAGS=	-O -Wall -DNOTIMP
FILTER1A=	dxy2ps
FILTER2A=	hpgl2ps
ACONVERT1=	cp $(FILTER1) $(FILTER1A); strip $(FILTER1A)
ACONVERT2=	cp $(FILTER2) $(FILTER2A); strip $(FILTER2A)

# For MS-DOS using djgpp compiler, activate these lines and deactivate
# the other machines'. Leave SHELL= /bin/sh as it is above. The linker 
# bombed when I had SHELL=c:\dos\command.com and I don't know what
# blanking it out entirely would do, either.  Also note: There is no
# 'make install': Instead, just copy the *.exe's and *.man's where you want. 
# The 32-bit djgpp compiler (source and bins) can be ftp'd from either
# omnigate.clarkson.edu or oak.oakland.edu.  In both places it's found
# in the directory /pub/msdos/djgpp.  Or, you can send email to the
# FSF (Free Software Foundation) at gnu@prep.ai.mit.edu for information
# on obtaining djgpp on CDROM.
# LOADLIBES=	-lm 
# CFLAGS=		-O -Wall -DNOTIMP -ansi -pedantic
# FILTER1A=	dxy2ps.exe
# FILTER2A=	hpgl2ps.exe
# ACONVERT1=	coff2exe $(FILTER1)
# ACONVERT2=	coff2exe $(FILTER2)

# 5) You're done.  Now just type 'make' and with any luck...

##############################################################################
# YOU SHOULDN'T HAVE TO EDIT BELOW HERE.
##############################################################################

# .c.o:		$(INCLUDE)
#		$(CC) $(CFLAGS) -c $< -o $@

all:		$(FILTER1A) $(FILTER2A) $(TESTFILES)

$(FILTER1A):	$(FILTER1)
		$(ACONVERT1)

$(FILTER2A):	$(FILTER2)
		$(ACONVERT2)

$(FILTER1):	$(FILTER1.C)
		$(CC) $(CFLAGS) $< -o $@ $(LOADLIBES)

$(FILTER2):	$(FILTER2.C)
		$(CC) $(CFLAGS) $< -o $@ $(LOADLIBES)


test1d.ps: $(FILTER1A) test1d.dxy
	$(FILTER1A) test1d.dxy > test1d.ps

test1h.ps: $(FILTER2A) test1h.hpg
	$(FILTER2A) test1h.hpg > test1h.ps

test2h.ps: $(FILTER2A) test2h.hpg
	$(FILTER2A) test2h.hpg > test2h.ps

test3h.ps: $(FILTER2A) test3h.hpg
	$(FILTER2A) test3h.hpg > test3h.ps

install:	install1 install2 installman

install1:	$(FILTER1A)
		install $(INSTALLFLAGS) $(FILTER1A) $(INSDIR)

install2:	$(FILTER2A)
		install $(INSTALLFLAGS) $(FILTER2A) $(INSDIR)

installman:	$(MANFILTER1) $(MANFILTER2)
		install $(INSTALLMANFLAGS) $(MANFILTER1) $(INSMANDIR)
		install $(INSTALLMANFLAGS) $(MANFILTER2) $(INSMANDIR)

clean:
	rm -f *~* *.o *.ps a.out core hpgl2ps dxy2ps *.in

uninstall:
		rm -f $(INSDIR)/$(FILTER1A)
		rm -f $(INSDIR)/$(FILTER2A)
		rm -f $(INSMANDIR)/$(MANFILTER1)
		rm -f $(INSMANDIR)/$(MANFILTER2)


# To be used on Unix to create manuals for dos users and ps printers
dosman:	dosstuff/hpgl2ps.txt dosstuff/dxy2ps.txt dosstuff/hpgl2ps.ps dosstuff/dxy2ps.ps

dosstuff/hpgl2ps.txt:	hpgl2ps.1
	groff -Tascii -mandoc hpgl2ps.1 > dosstuff/hpgl2ps.txt

dosstuff/dxy2ps.txt:	dxy2ps.1
	groff -Tascii -mandoc dxy2ps.1 > dosstuff/dxy2ps.txt

dosstuff/hpgl2ps.ps:	hpgl2ps.1
	groff -Tps -mandoc hpgl2ps.1 > dosstuff/hpgl2ps.ps

dosstuff/dxy2ps.ps:	dxy2ps.1
	groff -Tps -mandoc dxy2ps.1 > dosstuff/dxy2ps.ps

arcps.obj:	arcps.c
	$(CC) -c $.

changesizes.obj: changesizes.c
	$(CC) -c $.

circle.obj: circle.c
	$(CC) -c $.

dxycom.obj: dxycom.c
	$(CC) -c $.

end_draw.obj: end_draw.c
	$(CC) -c $.

getval.obj: getval.c
	$(CC) -c $.

hpglcom.obj: hpglcom.c
	$(CC) -c $.

linesize.obj: linesize.c
	$(CC) -c $.

linetype.obj: linetype.c
	$(CC) -c $.

manualfeed.obj: manualfeed.c
	$(CC) -c $.

plotdot.obj: plotdot.c
	$(CC) -c $.

plotinit.obj: plotinit.c
	$(CC) -c $.

plotps.obj: plotps.c
	$(CC) -c $.

userdefchar.obj: userdefchar.c
	$(CC) -c $.

ps_macros.obj: ps_macros.c
	$(CC) -c $.

rectangle.obj: rectangle.c
	$(CC) -c $.

textps.obj: textps.c
	$(CC) -c $.

viewport.obj: viewport.c
	$(CC) -c $.

plotcoords.obj: plotcoords.c
	$(CC) -c $.

tick.obj: tick.c
	$(CC) -c $.
