# This is the Makefile for the MathArray objects
#
# The file Makefile.in should be processed by configure to generate
# Makefile.  If you want to generate Makefile by hand, you must find
# all variables surrounded by @ and replace them with the correct
# value (e.g. @CC@ must be replaced by something like cc or gcc).
#
# Once you have done that, you should check the definitions at the top
# of this file to make sure that they are reasonable for your system.

SHELL = /bin/sh
MATHARRAY_VERSION = 0.33
MATHARRAY_SCORE_VERSION = `echo $(MATHARRAY_VERSION) | tr . _`

# Prefix directory for installation directories.
prefix = @prefix@

# Where to install executables
libdir = @exec_prefix@/lib

# Where to install the headers (will go in MathArray subdir).
incdir = $(prefix)/include

#
# The next few lines are set up by the configuration script.  You may
# want to look them over.
#

# Source directory
srcdir = @srcdir@
VPATH = @srcdir@

# Define programs and flags
CC = @CC@
CFLAGS = @CFLAGS@ 
LDFLAGS =@LDFLAGS@ -ObjC
OBJCFLAGS = -Wno-import
LIBS = @LIBS@
DEFS = @DEFS@ -DMATH_CHECK_FPE
ARFLAGS = rc
RANLIB = @RANLIB@

OPENSTEP_INCLUDE = @OPENSTEP_INCLUDE@
OTHER_CFLAGS = -Wall -I$(srcdir) $(OPENSTEP_INCLUDE) $(DEFS)

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

#----------------------------end of user config-------------------------------
NAME = libMathArray.a 

MDEFINES = CC='$(CC)' CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFGLAS)' \
	OBJCFLAGS='$(OBJCFLAGS)' 

# Source files
CLASSES = \
MANumber.m \
MaskedException.m \
MathArray.m \
MathArrayExtensions.m \
MAValueData.m

HFILES = \
MathArray/MaskedException.h \
MathArray/MathArray.h \
MathArray/MathArrayExtensions.h \
MathArray/MAValue.h \
MathArray/MAValueData.h \
MathArray/NSObjectExtra.h \
MathArray/array_encoding.h \
MathArray/complex.h @EXTRA_HFILES@

PRIVATE_HFILES = \
MathArrayPrivate.h \
MathComplexArrayPrivate.h \
MAConcreteNumber.h \
MathTemplateArray.h

MFILES = \
array_functions.m \
MathComplexArrayPrivate.m \
NSObjectExtra.m @EXTRA_MFILES@

CFILES = \
array_encoding.c \
complex.c 

MANUMBER_CLUSTER = 0 1
MANUMBER_OFILES  = \
	MAConcreteNumber0.o \
	MAConcreteNumber1.o

MATHTEMPLATE_CLUSTER = 1 2 3 4 5 6 7 8 9 10 11 12
MATHTEMPLATE_OFILES  = \
	MathTemplateArray1.o \
	MathTemplateArray2.o \
	MathTemplateArray3.o \
	MathTemplateArray4.o \
	MathTemplateArray5.o \
	MathTemplateArray6.o \
	MathTemplateArray7.o \
	MathTemplateArray8.o \
	MathTemplateArray9.o \
	MathTemplateArray10.o \
	MathTemplateArray11.o \
	MathTemplateArray12.o
MATHCOMPLEX_CLUSTER = 1 2
MATHCOMPLEX_OFILES  = MathComplexArray1.o MathComplexArray2.o 

OBJECT_FILES = $(OFILES) $(MANUMBER_OFILES) $(MATHTEMPLATE_OFILES) \
	$(MATHCOMPLEX_OFILES)

OTHER_SOURCES = README NEWS Makefile.in TODO INSTALL conf.h.in configure.in \
	common.make MAConcreteNumber.m MATemplateArray.m MAComplexArray.m

MAKEFILEDIR = .
include $(MAKEFILEDIR)/common.make

all:: ${NAME}

$(NAME): $(OBJECT_FILES)
	$(AR) $(ARFLAGS) $(NAME) $(OBJECT_FILES)
	$(RANLIB) $(NAME)

# Compilation of class clusters
$(MANUMBER_OFILES) : MAConcreteNumber.m MAConcreteNumber.h MathArray/MAValue.h
	for i in ${MANUMBER_CLUSTER}; do \
	    cp MAConcreteNumber.m MAConcreteNumber$$i.m; \
	    $(CC) -c $(ALL_CFLAGS) $(DEFS) $(ALL_OBJCFLAGS) \
	    -DMATH_ORDER=$$i MAConcreteNumber$$i.m -o MAConcreteNumber$$i.o;\
	    rm -f MAConcreteNumber$$i.m; \
	done

$(MATHTEMPLATE_OFILES) : MathTemplateArray.m  MathArrayPrivate.h $(HFILES)
	for i in ${MATHTEMPLATE_CLUSTER}; do \
	    cp MathTemplateArray.m MathTemplateArray$$i.m; \
	    $(CC) -c $(ALL_CFLAGS) $(ALL_OBJCFLAGS) \
	    -DMATH_ORDER=$$i MathTemplateArray$$i.m -o MathTemplateArray$$i.o;\
	    rm -f MathTemplateArray$$i.m; \
	done

$(MATHCOMPLEX_OFILES) : MathComplexArray.m  MathArrayPrivate.h \
		MathComplexArrayPrivate.h $(HFILES)
	for i in ${MATHCOMPLEX_CLUSTER}; do \
	    cp MathComplexArray.m MathComplexArray$$i.m; \
	    $(CC) -c $(ALL_CFLAGS) $(ALL_OBJCFLAGS) \
	    -DMATH_ORDER=$$i MathComplexArray$$i.m -o MathComplexArray$$i.o;\
	    rm -f MathComplexArray$$i.m; \
	done

check: $(NAME)
	cd checks; $(MAKE) -$(MAKEFLAGS) $(MDEFINES)

checks: check

install: all
	$(INSTALL) $(NAME) $(libdir)
	-mkdir $(incdir)/MathArray
	for file in ${HFILES}; do \
	    $(INSTALL_DATA) $$file $(incdir)/$$file; \
	done

dist:
	-mkdir matharray-dist
	cd matharray-dist; \
	cvs export -rMATHARRAY_$(MATHARRAY_SCORE_VERSION) MathArray; \
	mv MathArray ../MathArray-$(MATHARRAY_VERSION)
	rmdir matharray-dist
	tar -cf MathArray-$(MATHARRAY_VERSION).s.tar \
		MathArray-$(MATHARRAY_VERSION)
	gzip MathArray-$(MATHARRAY_VERSION).s.tar
	rm -rf MathArray-$(MATHARRAY_VERSION)

cvstag:
	cvs rtag MATHARRAY_$(MATHARRAY_SCORE_VERSION) MathArray

clean::
	cd checks; $(MAKE) clean

distclean:: clean
	$(RM) Makefile conf.h config.status config.log config.cache
	cd checks; $(MAKE) distclean

realclean:: distclean

include Makefile.dependencies
