# 
# ------ MAKEFILE FILE FOR Linux FREALIGN -----------F77
# 
# Using: gnu compiler
#
# Thanks to: Shixin Yang & Dr Edward Egelman at University of Virginia
#    for providing this file
#
# Notes:  To create executable: make -f Makefile_G5_OSX_gnu
#

SHELL  = /bin/sh

FFLAGS = -c -O3 -fno-second-underscore -D_OPENMP -cpp -w -fopenmp -static

CFLAGS = -c -O3 -DPROTOTYPE -D_OPENMP -cpp -w -fopenmp -static

COMP   = gfortran-mp-4.4

CC     = gcc-mp-4.4

LF     = /opt/local/lib/gcc44/libgfortran.a -static-libgcc -fopenmp # -no-c++filt

PGM    = frealign_v9

LIB    = $(PGM)_mp.a

.PRECIOUS :  $(PGM) $(LIB) 

include Makefile.inc

$(PGM) : $(PGM).o $(LIB)
	@echo linking $(PGM)
	$(COMP) $(LF) $(PGM).o $(LIB) /usr/lib/libSystemStubs.a  -ftrace=full -o ../bin/$(PGM)_mp.exe
	$(COMP) $(FFLAGS) -o merge_3d.o  merge_3d.f
	$(COMP) $(LF) merge_3d.o $(LIB) /usr/lib/libSystemStubs.a  -ftrace=full -o ../bin/merge_3d_mp.exe
	@\rm $(PGM).o
	@\rm merge_3d.o

$(PGM).o  : $(PGM).f
	$(COMP) $(FFLAGS) -o $(PGM).o  $(PGM).f
	$(COMP) -static -o ../bin/set_polarity.exe set_polarity.f
	$(COMP) -static -o ../bin/calc_occ.exe calc_occ.f
	$(COMP) -static -o ../bin/rsample.exe rsample.f

ioc.o : ioc.c
	$(CC) $(CFLAGS) -o ioc.o ioc.c
	$(AR) rc $(LIB) ioc.o
	@\rm ioc.o

$(LIB) : ioc.o $(ELEMENTS)
	@echo all object files placed in library

.f.a:
	$(COMP) $(FFLAGS) $<
	$(AR) r $(LIB) $*.o
	@\rm $*.o
