# ********** 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, HP-UX,
# or SOL. 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.


# 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 = Linux
#OS = SOL


# 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

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


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

OBJS_CBP = $(LP)/allocate.o $(LP)/A_comp_iupui.o $(LP)/cti_io.o $(LP)/cti_byte_io.o $(LP)/cti_structs.o  $(LP)/fft.o  read_cfg_file.o iu_utils.o

all: cbp

clean:
	/bin/rm -f *.o ../cbp  $(OBJS_CBP)

cleanup:
	 /bin/rm -f *.o  $(OBJS_CBP)

cbp: cbp.c $(OBJS_CBP) $(LP)/io_mat_dbl.c defs.h
	$(CC) $(CFLAGS) $(INCLUDE) -o cbp cbp.c $(LP)/io_mat_dbl.c $(OBJS_CBP) $(LIBS) 
	mv cbp ../


$(LP)/cti_io.o : $(LP)/cti_io.c $(LP)/cti_io.h $(OBJS_RIDL)
	$(CC) $(CFLAGS) $(INCLUDE) -c  $< -o $@

$(LP)/cti_byte_io.o : $(LP)/cti_byte_io.c $(LP)/cti_byte_io.h $(LP)/allocate.o
	$(CC) $(CFLAGS) $(INCLUDE) -c  $< -o $@

$(LP)/cti_structs.o : $(LP)/cti_structs.c $(LP)/cti_structs.h $(LP)/allocate.o $(LP)/cti_byte_io.o
	$(CC) $(CFLAGS) $(INCLUDE) -c  $< -o $@

$(LP)/allocate.o : $(LP)/allocate.c $(LP)/allocate.h
	$(CC) $(CFLAGS) $(INCLUDE) -c  $< -o $@

$(LP)/A_comp_iupui.o : $(LP)/A_comp_iupui.c $(LP)/A_comp_iupui.h $(LP)/allocate.o
	$(CC) $(CFLAGS) $(INCLUDE) -c  $< -o $@

$(LP)/fft.o : $(LP)/fft.c $(LP)/fft.h
	$(CC) $(CFLAGS) $(INCLUDE) -c  $< -o $@


read_cfg_file.o: read_cfg_file.c read_cfg_file.h $(LP)/allocate.o
	$(CC) $(CFLAGS) $(INCLUDE) -c  $< -o $@

iu_utils.o: iu_utils.c iu_utils.h $(LP)/allocate.o $(LP)/A_comp_iupui.o defs.h
	$(CC) $(CFLAGS) $(INCLUDE) -c  $< -o $@

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


