#-----------------------------------------------------------------------------
# Cyclize makefile for the src directory
#
# Notes:
# 1) All optimizations are done during the compiling of the object code.
# 2) The linking must be done with the Fortran compiler, otherwise we have 
#    problems linking against the odrpack.a library.  I would like to change 
#    this behaviour to use the C compiler, any suggestions?
# 3) If you want to use a different odrpack library file (maybe you already 
#    have it installed on your machine?), change the FITLIB variable below 
#    to point to the correct place.
# 4) If you are using the Numerical Recipies library instead of the odrpack 
#    library, change the FITLIB variable to point to your nr.a file.
#
#-----------------------------------------------------------------------------

ALL_PROGS   = generate_chains analyze_chains show_chains
EXTRA_PROGS = cyclize_whole_chains view_chains view_0k
BIN         = ../$(BINDIR)
OBJS        = cyclize_lib.o math_routines.o fit.o odr.o nrutil.o 

#--------------------------------
# Compile the object code with optimizations:
.c.o :
	$(CC) $(OPTS) $(OPTS2) $(CFLAGS) -c $<

# No optimizations for the fitting routines or they break!  Why???  Doesn't
# matter, this is not a high CPU profile routine.
fit.o : fit.c
	$(CC) $(CFLAGS) -c fit.c

#--------------------------------
# Link the final executables:
all: $(ALL_PROGS)

generate_chains: $(OBJS) generate_chains.o
	$(F77) -o generate_chains generate_chains.o $(OBJS) $(LIBS)
	$(MV) $@ $(BIN)

analyze_chains: $(OBJS) analyze_chains.o
	$(F77) -o analyze_chains analyze_chains.o $(OBJS) $(LIBS)
	$(MV) $@ $(BIN)

show_chains: $(OBJS) show_chains.o 
	$(F77) -o show_chains show_chains.o $(OBJS) $(LIBS)
	$(MV) $@ $(BIN)

#--------------------------------
# Extra programs that aren't really part of the cyclization programs...
extra: $(EXTRA_PROGS)

cyclize_whole_chains: $(OBJS) cyclize_whole_chains.o 
	$(F77) -o cyclize_whole_chains cyclize_whole_chains.o $(OBJS) $(LIBS)
	$(MV) $@ $(BIN)

view_chains: $(OBJS) view_chains.o
	$(F77) -o view_chains view_chains.o $(OBJS) $(LIBS)
	$(MV) $@ $(BIN)

view_0k: $(OBJS) view_0k.o
	$(F77) -o view_0k view_0k.o $(OBJS) $(LIBS)
	$(MV) $@ $(BIN)

test: test.o odr.o nrutil.o
	$(F77) -o test test.o odr.o nrutil.o $(LIBS)

clean:
	$(RM) -f *.o
	$(RM) -f $(ALL_PROGS) $(EXTRA_PROGS)
	$(RM) -f test

