################################################################################
# TITLE: Makefile_OSOAA.f77
#
# RULE: Makefile to compile OSOAA software (gnu compilation)
#       Solaris Makefile 
#       KSH ou CSH
#	
# AUTHOR: B. LAFRANCE ( CS )
# DATE: 05/05/2011
#
#
# In order to use this Makefile, the following environment variable 
# has to be defined : 
#	OSOAA_ROOT:	root directory of the OSOAA code
#
#	Its definition has to be performed in the global settings file.
#       On KSH cession : .profile
#       On CSH cession : .login

#	For instance :
#           KSH (in the .profile file): export OSOAA_ROOT=~/home/user1/OSOAA
#	    CSH (in the .login file):   setenv OSOAA_ROOT ~/home/user1/OSOAA
#
#       Under the ${OSOAA_ROOT} directory, you find the sub-directories:
#       doc    exe    fic    gen    inc    obj    src
#
# Compilation is performed by the Kshell/Cshell command : make -f Makefile_OSOAA.g77
#
# To compile in debug mode, you have to use the DEBUG following option
# and not use the CCOPTS optimisation option 
#	DEBUG: -g -D_DEBUG
#
#
# MOD:VERSION:1.0: 05/05/2011: Creation  
# MOD:VERSION:1.1: 03/11/2016
#    - The option -w is added to avoid warning messages  
# MOD:VERSION:1.2: 11/01/2019
#    - Adding the creation of the directory obj
#
################################################################################
 

################################
# Initialisation of variables 
################################
mkdir		=	mkdir -p
rm		=	rm
FF		=	f77
###DEBUG		=	-g
CCOPTS  =  -O

########################################
# Definition of includes and libraries
########################################
CFLAGS +=  -DSYSV
LIBS	=  -lm


###########################
# User directories 
###########################
SRC	=	$(OSOAA_ROOT)/src
BIB	=	$(OSOAA_ROOT)/obj
EXE    =      $(OSOAA_ROOT)/exe
NCL	=	$(OSOAA_ROOT)/inc

#############################
# List of object files 
#############################
OBJS_OSOAA     =     $(BIB)/OSOAA_MAIN.o\
			$(BIB)/OSOAA_ANGLES.o\
			$(BIB)/OSOAA_AEROSOLS.o\
			$(BIB)/OSOAA_HYDROSOLS.o\
			$(BIB)/OSOAA_MIE.o\
			$(BIB)/OSOAA_PARTICLES_RAD.o\
			$(BIB)/OSOAA_PROFILE.o\
			$(BIB)/OSOAA_SURFACE.o\
			$(BIB)/OSOAA_SURF_MATRICES.o\
			$(BIB)/OSOAA_SOS.o\
			$(BIB)/OSOAA_SOS_CORE.o\
			$(BIB)/OSOAA_TRPHI.o




###########################################
# List of required include files 
###########################################
DEP	=	$(NCL)/OSOAA.h

all::$(EXE)/OSOAA_MAIN.exe 

#####################
# Links edition
#####################
$(EXE)/OSOAA_MAIN.exe : $(OBJS_OSOAA) 
	@echo "------------> Link of $@"
	@$(FF) $(CCOPTS) -w $(DEBUG) -o $@  $(OBJS_OSOAA) $(LIBS)
	@echo "Copying constantes file used to the software compilation" > $(EXE)/config.txt
	@echo "--> $(NCL)/OSOAA.h \n\n" >> $(EXE)/config.txt
	@cat  $(NCL)/OSOAA.h >> $(EXE)/config.txt
	@echo "------------>ok\n"
	


	
###################################
# Compilation of object files 
###################################
$(BIB)/OSOAA_MAIN.o:$(SRC)/OSOAA_MAIN.F $(DEP) 
	@echo "------------> Compilation of $@"
	@$(mkdir)  $(BIB)
	@$(FF) $(CCOPTS) -w $(DEBUG) -c $(SRC)/OSOAA_MAIN.F -o $@ $(CFLAGS) -I$(NCL)
	
$(BIB)/OSOAA_ANGLES.o:$(SRC)/OSOAA_ANGLES.F $(DEP) 
	@echo "------------> Compilation of $@"
	@$(FF) $(CCOPTS) -w $(DEBUG) -c $(SRC)/OSOAA_ANGLES.F -o $@ $(CFLAGS) -I$(NCL)	

$(BIB)/OSOAA_AEROSOLS.o:$(SRC)/OSOAA_AEROSOLS.F $(DEP) 
	@echo "------------> Compilation of $@"
	@$(FF) $(CCOPTS) -w $(DEBUG) -c $(SRC)/OSOAA_AEROSOLS.F -o $@ $(CFLAGS) -I$(NCL)

$(BIB)/OSOAA_HYDROSOLS.o:$(SRC)/OSOAA_HYDROSOLS.F $(DEP) 
	@echo "------------> Compilation of $@"
	@$(FF) $(CCOPTS) -w $(DEBUG) -c $(SRC)/OSOAA_HYDROSOLS.F -o $@ $(CFLAGS) -I$(NCL)

$(BIB)/OSOAA_MIE.o:$(SRC)/OSOAA_MIE.F $(DEP) 
	@echo "------------> Compilation of $@"
	@$(FF) $(CCOPTS) -w $(DEBUG) -c $(SRC)/OSOAA_MIE.F -o $@ $(CFLAGS) -I$(NCL)
	
$(BIB)/OSOAA_PARTICLES_RAD.o:$(SRC)/OSOAA_PARTICLES_RAD.F $(DEP) 
	@echo "------------> Compilation of $@"
	@$(FF) $(CCOPTS) -w $(DEBUG) -c $(SRC)/OSOAA_PARTICLES_RAD.F -o $@ $(CFLAGS) -I$(NCL)	
		
$(BIB)/OSOAA_PROFILE.o:$(SRC)/OSOAA_PROFILE.F $(DEP) 
	@echo "------------> Compilation of $@"
	@$(FF) $(CCOPTS) -w $(DEBUG) -c $(SRC)/OSOAA_PROFILE.F -o $@ $(CFLAGS) -I$(NCL)	

$(BIB)/OSOAA_SURFACE.o:$(SRC)/OSOAA_SURFACE.F $(DEP) 
	@echo "------------> Compilation of $@"
	@$(FF) $(CCOPTS) -w $(DEBUG) -c $(SRC)/OSOAA_SURFACE.F -o $@ $(CFLAGS) -I$(NCL)	

$(BIB)/OSOAA_SURF_MATRICES.o:$(SRC)/OSOAA_SURF_MATRICES.F $(DEP) 
	@echo "------------> Compilation of $@"
	@$(FF) $(CCOPTS) -w $(DEBUG) -c $(SRC)/OSOAA_SURF_MATRICES.F -o $@ $(CFLAGS) -I$(NCL)
	
$(BIB)/OSOAA_SOS.o:$(SRC)/OSOAA_SOS.F $(DEP) 
	@echo "------------> Compilation of $@"
	@$(FF) $(CCOPTS) -w $(DEBUG) -c $(SRC)/OSOAA_SOS.F -o $@ $(CFLAGS) -I$(NCL)	
		
$(BIB)/OSOAA_SOS_CORE.o:$(SRC)/OSOAA_SOS_CORE.F $(DEP) 
	@echo "------------> Compilation of $@"
	@$(FF) $(CCOPTS) -w $(DEBUG) -c $(SRC)/OSOAA_SOS_CORE.F -o $@ $(CFLAGS) -I$(NCL)	

		
$(BIB)/OSOAA_TRPHI.o:$(SRC)/OSOAA_TRPHI.F $(DEP) 
	@echo "------------> Compilation of $@"
	@$(FF) $(CCOPTS) -w $(DEBUG) -c $(SRC)/OSOAA_TRPHI.F -o $@ $(CFLAGS) -I$(NCL)	
