# ********** CONFIGURATION INFO ****************

# MAKE SURE YOU HAVE NO SPACES AFTER THE PATH NAMES OR OS's


# For this makefile to work properly, OS must be set to Linux or HP-UX.
# I recommend to set this in your .cshrc or equivalent,
# e.g. as setenv OS "`uname`"
# If it's not set there, then uncomment the appropriate line below.

#OS = HP-UX
#OS = SOL
OS = Linux


# Specify location of Matlab 5 installation directory (need absolute path here)

MATLAB_BASE = /opt/matlab/5.3.1-update

# Specify which compiler to use and which flags
CC_HP-UX = cc
CC_Linux = i486-linuxlibc5-gcc
CC_SOL    = cc

# Use this if you want to store the tomograhic
# projection matrix, if you want to compute
# it on the fly, cut '-DSTORE_A_MATRIX'

CC      = $(CC_$(OS)) -DSTORE_A_MATRIX


CFLAGS_Linux = -V 2.7.2.3 -O -Wall -ansi -Werror -pedantic
CFLAGS_HP-UX = -O -Aa -Wall
CFLAGS_SOL   = -O -Xa


######### END CONFIGURABLE OPTIONS #########

LIBS_HP-UX = -L$(MATLAB_BASE)/extern/lib/hp700 -lmat -lmx -lm -lnsipc -lmi
LIBS_Linux = -L$(MATLAB_BASE)/extern/lib/lnx86 -lm -lut -lmat -lmx
LIBS_SOL   = -L$(MATLAB_BASE)/extern/lib/sol2 -lmat -lmx -lm -lmi -lut


INCLUDE_HP-UX    = -I $(MATLAB_BASE)/extern/include
INCLUDE_Linux = -I $(MATLAB_BASE)/extern/include
INCLUDE_SOL   = -I $(MATLAB_BASE)/extern/include


LIBS    = $(LIBS_$(OS))
INCLUDE = $(INCLUDE_$(OS))
CFLAGS  = $(CFLAGS_$(OS))


LP = ../ansi_lib_loc

LIB_OBJS = $(LP)/allocate.o $(LP)/assort.o $(LP)/randlib.o  \
           $(LP)/A_comp_dbl_storeflt.o
LIB_OBJS_EMIS_OTF =  $(LP)/solve2.o fr_icm.o \
                     fr_paramest.o fr_recon.o

OBJS_FORNRM = $(LP)/allocate.o $(LP)/A_comp_dbl_storeflt.o $(LP)/randlib.o



all: emisnew for

clean:
	/bin/rm -f *.o ../emisnew ../for emisnew for $(OBJS_FORNRM) $(LIB_OBJS) $(LIB_OBJS_EMIS_OTF) 

emisnew: emisnew.c fr_icm.h  fr_paramest.h fr_recon.h $(LIB_OBJS) $(LIB_OBJS_EMIS_OTF) $(LP)/io_mat_dbl.c
	$(CC) $(CFLAGS)  $(INCLUDE) -o emisnew emisnew.c $(LP)/io_mat_dbl.c $(LIB_OBJS) $(LIB_OBJS_EMIS_OTF) $(LIBS) 
	mv emisnew ../

for: for.c fr_icm.h  fr_paramest.h fr_recon.h $(OBJS_FORNRM)  $(LP)/io_mat.c
	$(CC) $(CFLAGS)  $(INCLUDE) -o for for.c  $(LP)/io_mat.c  $(OBJS_FORNRM) $(LIBS)
	mv for ../

.c.o:
	$(CC) $(CFLAGS) $(INCLUDE) -c $*.c -o $*.o


