#
# Raster3D makefile for Windows using gnu GCC/G77 compiler environment
# contributed by Suhaib Siddiqi for version 2.6c
# See also the notes in the INSTALL file.
# 

#
# Where to put things
#
prefix = G:/cygwn/mingw32/local
bindir = $(prefix)/bin
mandir = $(prefix)/man/manl
#
CC       = gcc
F2       = f2c
#F2      = f77
FC      = g77
RM      = rm -f
#
INSTALL         = /bin/install -o root -g root
#
LDFLAGS  = 
CFLAGS   = -O1 -m486 -fnative-struct
FFLAGS   = -O1

#LDFLAGS = -fast
#CFLAGS = -fast
#FFLAGS = -fast

#
# TIFF support (enabled by default)
#     add -DTIFF_SUPPORT to the DEFINES statement.
#     add -ltiff to the LIBS definition.
# The TIFF_INVERT option is a work-around for broken programs
# (e.g. PhotoShop) that don't properly read the TIFF header.
#
# JPEG support (disabled by default)
#     add -DJPEG_SUPPORT to the DEFINES statement.
#     add -ljpeg to the LIBS definition.
#

LIBS    =	-LG:/cygwin/mingw32/lib -ltiff -ljpeg -lz
DEFINES	=	-DTIFF_SUPPORT -DJPEG_SUPPORT -DLINUX -DWIN32 -D__MSVCRT__
INCLUDES =	-Ic:/gnu/mingw32/include

RIBOBJS  =	ribbon.o ribbon1.o modsubs.o
PROGS    =	balls normal3d rastep rods ribbon render avs2ps rings3d 

all:	$(PROGS)

clean:
	rm -f *.o *.u core
	rm -f $(PROGS)

install: $(PROGS)
	$(INSTALL) -m 755 $(PROGS) $(bindir)
	$(INSTALL) -m 755 stereo3d $(bindir)
	$(INSTALL) -m 755 worms $(bindir)
	$(INSTALL) -m 644 doc/*.l $(mandir)
	@echo "	*******************************************"
	@echo "	* The examples/ subdirectory contains     *"
	@echo "	* files to verify your installation and   *"
	@echo "	* to serve as examples of use.            *"
	@echo "	*******************************************"

tar:
	(cd ..; tar -czvf Raster3D_$(VERSION).tar.gz raster3d)

ribbon:	$(RIBOBJS)
	$(FC) $(LDFLAGS) $(RIBOBJS) -o ribbon

rods:
	$(FC) $(FFLAGS) rods.f $(CFLAGS) $(LDFLAGS) -o rods

balls:
	$(FC) $(FFLAGS) balls.f $(CFLAGS) $(LDFLAGS) -o balls

local.o: local.c
	$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -c local.c

ungz.o:	ungz.c
	$(CC) $(CFLAGS) -DGUNZIP -c ungz.c

quadric.o: quadric.f

render.f.bak:
	mv render.f render.f.bak
	egrep -v '(CARRIAGECONTROL|DISPOSE)' render.f.bak > render.f

render:	render.f.bak local.o quadric.o parse.o r3dtops.o ungz.o
	$(FC) $(FFLAGS) render.f local.o quadric.o parse.o r3dtops.o ungz.o \
	$(LIBS) -o render

normal3d: normal3d.f.bak normal3d.f quadric.o ungz.o
	$(FC) $(FFLAGS) normal3d.f quadric.o ungz.o -o normal3d

normal3d.f.bak:
	mv normal3d.f normal3d.f.bak
	egrep -v '(CARRIAGECONTROL|DISPOSE)' normal3d.f.bak > normal3d.f

avs2ps:	avs2ps.c
	$(CC) $(CFLAGS) $(LDFLAGS) avs2ps.c -o avs2ps -lm


rastep: rastep.f.bak rastep.f quadric.o suv.o
	$(FC) $(FFLAGS) rastep.f quadric.o suv.o -o rastep

rastep.f.bak:
	mv rastep.f rastep.f.bak
	grep -v CARRIAGECONTROL rastep.f.bak > rastep.f



