#
# Makefile for formfactor library
#
# $Id: Makefile,v 1000.2 94/02/24 14:18:34 ps Exp $
# $Source: /usr/graphics/project/ff/Makefile,v $
# $Log:	Makefile,v $
# Revision 1000.2  94/02/24  14:18:34  ps
# fixed come mathematica complaints
# 
# Revision 1000.1  93/12/05  15:03:37  ps
# replaced plane test with a new one and made all mach[] tests much tighter.
# Also fixed a but in evalint{m|p}()
# 
# Revision 1000.1  93/06/18  06:56:10  ps
# Bump to release, no file changes
# 
# Revision 1.2  93/06/18  06:53:49  ps
# release procedures fixed
# 
# Revision 1.1  93/04/14  22:04:25  ps
# Initial revision
# 
#
SRC=ffp.c claussenp.c
OBJ=claussens.o claussend.o ffd.o ffs.o
HDR=claussen.h ff.h
DOC=
TARGET=libff.a
TARGET_COMPILER=ar
TARGET_COMPILER_FLAGS=rv
RANLIB=
INC=-I.
DEF=
DEBUG=-O2 -sopt
#DEBUG=-g
CC=cc
RCSFILES=$(SRC) $(HDR) $(DOC) Makefile
SGI_FLAGS=-ansi -fullwarn -woff 269,151 -Wf,-XNh1500
GCC_FLAGS=-ansi -pedantic -Wall
LCC_FLAGS=-A -A -b
CFLAGS=$(INC) $(DEF) $(DEBUG) $(SGI_FLAGS)

PRODUCT_NAME=FF
INTERNAL_VERSION=0
RELNUM=$(VERSION)
RELNAME=$(VERSION)

all: $(TARGET)

$(TARGET): $(OBJ)
	$(TARGET_COMPILER) $(TARGET_COMPILER_FLAGS) $(TARGET) $(OBJ)
	@echo $@ is made.

ffd.o: ff.h ffp.c
	$(CC) $(CFLAGS) -c ffp.c -o ffd.o -DDOUBLE
ffs.o: ff.h ffp.c
	$(CC) $(CFLAGS) -c ffp.c -o ffs.o -DSINGLE
claussend.o: claussen.h claussenp.c
	$(CC) $(CFLAGS) -c claussenp.c -o claussend.o -DDOUBLE
claussens.o: claussen.h claussenp.c
	$(CC) $(CFLAGS) -c claussenp.c -o claussens.o -DSINGLE

tags:
	etags $(SRC) $(HDR)

clean::
	rm -f $(TARGET) $(OBJ) *.o *~ *.a core a.out \#* *.bak

# Perform an ordinary RCS checkin
checkin:
	@sh -c "if test ! -d RCS; then mkdir RCS ; \
		echo Making RCS directory... ; else true; fi;"
	@echo ====== Ignore any messages about "\"no lock set by <your name>\""...
	@echo ====== These refer to files which are already checked in.
	-ci -u $(RCSFILES)

# Make checkout
#   Get out the latest version of everything in the source tree
#
checkout:
	co -u $(RCSFILES)

# show what RCS files are out for editing:
whatsout:
	rlog -L -R $(RCSFILES)

# show current version numbers:
ident:
	ident $(RCSFILES)

# Make version
#   Makes a new release by checking in all files, giving them a new RCS
#   revision and a symbolic name derived from the product name and the
#   release name.
#   By default the RCS revision is mnxy, where m and n are the major and
#   minor release numbers, and x and y are file set rev.
#   The release symbolic name is Product_Rel_mnxy, where Product is the
#   product name, and Rel is the constant string "Rel".
#   To back out a release, use make oops.  That obliterates
#   the entire release delta; the top level will be back the way it was.
#
# To make a version, you must say:
#   make version VERSION=mnxy.
#   VERSION *must* be an integer (due to RCS).
#   (may also be specified in your environment)
version:
	@sh -c "if test X$(VERSION) = X; then \
	   echo You must specify VERSION to make. ; \
	   exit 1 ; else exit 0; \
	   fi"
	@sh -c "if rlog -L -R $(RCSFILES) > /dev/null 2>&1 ; then \
	   exit 0; \
	  else \
	   echo ERROR: The RCS directory must exist and all files must be ; \
	   echo checked in to RCS before making new a version. ; \
	   exit 1 ; \
	  fi"
	@sh -c "if test X`rlog -L -R $(RCSFILES) 2>& 1` != X ; then \
	   echo ERROR: Some files are still checked out of RCS. ; \
	   echo All files must be checked in before making new a version. ; \
	   exit 1; else exit 0; \
	  fi"
	co -l $(RCSFILES)
	ci -u -f -r$(RELNUM).1 -sRel -N"$(PRODUCT_NAME)_Rel_$(RELNAME)" \
		-m"Bump to release, no file changes" \
		$(RCSFILES)

# This deletes the rev and also deletes the symbolic name.
oops:
	@sh -c "if test X$(VERSION) = X; then \
	   echo You must specify VERSION to oops. ; \
	   exit 1 ; else exit 0; \
	   fi"
	rcs -o$(RELNUM).1 -n$(PRODUCT_NAME)_Rel_$(RELNAME) $(RCSFILES)
	co -u $(RCSFILES)

# Make release
#   copies all files from a specified release number into the destination
#   release area.
#
# To do a release, you must say:
#   make release VERSION=mnxy DESTDIR=dir
#   VERSION *must* be an integer (due to RCS).
#   (May also be specified in your environment.)
release:
	@sh -c "if test X$(VERSION) = X \
	   || test X$(DESTDIR) = X ; then \
	   echo You must specify VERSION and DESTDIR. ; \
	   exit 1 ; else exit 0; \
	   fi"
	@sh -c "if test ! -d $(DESTDIR); then mkdir $(DESTDIR) ; \
		echo Making destination directory $(DESTDIR)... ; \
		else exit 0; fi;"
	@srcdir=`pwd`; cd $(DESTDIR); \
	echo cd $(DESTDIR); \
	for file in $(RCSFILES) ; do \
	  co -u -r$(RELNUM) $$srcdir/RCS/$${file},v ; \
	  rlog $$srcdir/RCS/$${file},v | awk ' \
		/^head:/ {rev=$$2} \
		$$1 == "revision" && $$2 == rev {line=NR+1} \
		NR == line {date = $$2; time = $$3; \
			split(date, dates, "/"); \
			time = substr(time, 1, index(time, ";")); \
			split(time, times, ":"); \
			} \
		END {printf "%02d%02d%02d%02d%02d\n", dates[2],dates[3],times[1],times[2],dates[1] }' \
		> /tmp/$$$$touch ; \
	  echo -n Resetting date of $${file}... ; \
	  chmod u+w $${file} ; \
	  if vax; then \
	     touch `cat /tmp/$$$$touch` $${file} ; else \
	     /usr/bin/touch `cat /tmp/$$$$touch` $${file} ; fi ; \
	  chmod u-w $${file} ; \
	  echo done. ; \
	done ;
