#  Makefile for EXCI shared library 
#  Created Mon May 29 15:06:11 CEST 2006 
#  Configuration: ./config/config.Absoft 
#------------------------------------------------------
#
# directory with source files: 
EXCSRC=exci
SRC=src
# where to put executables and binary files: 
BINDIR=bin
LIBDIR=lib
# directory with include files (headers)
INCLDIR=include
SHEXT=so
DBG=
 
#----------------------------------------------------
# System dependent part of makefile for RESTRAX 
# Absoft Fortran on Linux, ver. 9.0 
#----------------------------------------------------

# command calling Fortran compler 
FC= f90

# Fortran options:
FCFLAGS= -O -W132 -B108 -YEXT_NAMES=LCS -YCOM_NAMES=LCS -YCFRL=1 -YCOM_SFX=_ -YCOM_PFX=

# command calling C compler 
CC= gcc

# Fortran options:
CCFLAGS= -O

# other libraries to link with RESTRAX:
# restrax_LDADD= -L/usr/absoft/lib -lV77 -lU77  -L/usr/X11R6/lib -lX11 -lm -lg2c
restrax_LDADD= -lU77 -lf77math -L/usr/X11R6/lib -lX11 -ldl 

# Command for linking RESTRAX
restrax_LD= $(FC) -X--unresolved-symbols=report-all 

#  -X--cref -X-Map -Xmap.txt -lf77math -lf90math -lfio 

# option passed to the linker
restrax_LDFLAGS=  -X --export-dynamic  

# Compiler for EXCI library
exci_FC= $(FC)

# Compiler options for compiling EXCI subroutine
# EXCFLG= -O -f -B108 -N22 -N34  
exci_FCFLAGS= $(FCFLAGS) -fpic

# Command for linking shared library
exci_LD= $(FC) -X-shared 

# option passed to the linker
exci_LDFLAGS=  

# Define additional system-dependent object files to be linked with RESTRAX
# define file names including object extensions (*.o) 
# they will be created using implicit rules defined in the makefile
src_SYSDEP= 
 
TARGETS=  lib/res_exci_osc.so lib/res_exci_osc1.so lib/res_exci_phon.so lib/res_exci_bcm.so lib/res_exci_incom.so
OBJECTS=  bin/exci/eeigen.o bin/exci/exci_io.o bin/exci/reclat.o
EXCIOBJ=  exci/res_exci_osc.o exci/res_exci_osc1.o exci/res_exci_phon.o exci/res_exci_bcm.o exci/res_exci_incom.o
INCLUDES=  include/exci.inc include/const.inc include/reclat.inc
 
#------ rules and dependences ------------------

all: $(EXCIOBJ) $(OBJECTS) $(TARGETS) 

$(LIBDIR)/%.$(SHEXT): $(EXCSRC)/%.o $(OBJECTS)
	$(exci_LD) $(exci_LDFLAGS)  $< $(OBJECTS) -o $@
	chmod +r+x $@
	@echo Shared library $@ created.

$(EXCSRC)/%.o: $(EXCSRC)/%.f $(INCLUDES) 
	$(exci_FC) $(exci_FCFLAGS) $(DBG) -I$(EXCSRC) -I$(INCLDIR) -c $< -o $@

$(BINDIR)/%.o: $(SRC)/%.f
	$(exci_FC) $(exci_FCFLAGS) $(DBG) -I$(EXCSRC) -I$(INCLDIR) -c $< -o $@

clean: 
	rm -f $(OBJECTS) $(EXCIOBJ)

cleandist:
	rm -f $(OBJECTS) $(EXCIOBJ)
	rm -f $(TARGETS)

