############;-*-fundamental-*-###############################################
# 
# Makefile for quaternion library
#
#
#
#############################################################################


# These are the names of various programs used during "making".
# Pick whichever flavor of C you like with the CC variable.

CC	= gcc
RM	= /bin/rm
CO	= co
YACC    = yacc
LEX     = lex
RANLIB  = ranlib $@
#RANLIB = 

# Useful paths
PROJ_DIR        = ..

# Name of the makefile
MAKEFILE	= Makefile

# INCLUDE supplies paths to header files.
INCLUDE		= -I. -I$(PROJ_DIR)/include

# optimization flags 
OPTIMIZE	= -O
#OPTIMIZE       = -g

# DBFLAGS contains flags for debugging code
DBFLAGS         =

# CFLAGS is all of the compiler options.  Put any extras here.
CFLAGS		= $(OPTIMIZE) $(INCLUDE) $(DBFLAGS)

# LDFLAGS contains all linker flags, which is mostly just paths to libraries.
LDFLAGS		= 

# These are the libraries linked to the program.  example: -lm
LIBS		= 

# Flags used during the header file dependency generating stage.
DEPENDFLAGS	= $(CFLAGS) -Em

#------------------------------ Lists of Files -------------------------------#

#The compiled library
LIB = libquat.a

SOURCES = matrix.c quat.c vector.c xyzquat.c
HEADERS = pdefs.h quat.h
OBJECTS = $(SOURCES:.c=.o)

LIB_DIR = $(PROJ_DIR)/lib
PUBLIC_INCLUDES = $(HEADERS)
INCLUDE_DIR = $(PROJ_DIR)/include

#--------------------------------- Main Rules --------------------------------#

#IMPORTANT - the object files must come BEFORE the libraries!!!


$(LIB): $(OBJECTS)
	/bin/rm -f $@
	ar ruv $@ $(OBJECTS)
	$(RANLIB)

# All programs in this directory.
all: $(LIB)


.c :
	/bin/rm -f $@; $(CC) -o  $@  $< 


#--------------------------------- Handy Rules -------------------------------#

# Run lint on all of the source files.
lint : 
	lint $(LINT_FLAGS) $(ALL_SOURCES)

# Remove any intermediate files.
clean :
	$(RM) -f *.o *~ *% $(LIB)

install:
	/bin/cp $(LIB) $(LIB_DIR)
	/bin/cp $(PUBLIC_INCLUDES) $(INCLUDE_DIR)

# Empty Rule
dummy:


#-----------------------------Dependency Rules--------------------------------#

# This one's from the pxpl5 makefiles
# It tacks dependencies for header files and RCS onto the end of the makefile.

depend: Makefile $(ALL_SOURCES) $(ALL_HEADERS)
	makedepend -- $(CFLAGS) -- $(ALL_SOURCES)
	-if [ -d RCS ] ; then \
	  echo ; echo '# RCS dependencies' ; echo '.PRECIOUS: \' ; \
	  for f in RCS/*,v ; do \
	    echo `basename $$f ,v` ; \
	  done | awk  '{if (length(line $$1) < 65) \
			  line = line $$1 " "; \
			else {print line,"\\"; line = $$1 " "}} \
		      END {print line}' ; echo ; \
	  for f in RCS/*,v ; do \
	    echo "`basename $$f ,v`: $$f ; \$$(CO) \$$?" ; \
	  done ; \
	fi >> Makefile

# DO NOT DELETE THIS LINE -- make depend depends on it.
