# This is the makefile for creating the program that builds the opacities tables

PACKAGE_DIR = ../..
MESA_DIR = ../../..

#################################################################

# STEP 1: get the standard compiler setup

include $(MESA_DIR)/utils/makefile_header

#################################################################

# STEP 2: info about the libraries

OTHER_LIBS_DIR = $(MESA_DIR)/lib
INCLUDES = -I$(MESA_DIR)/include
LOAD_OTHER_LIBS = -L$(OTHER_LIBS_DIR) -leos -lchem $(LOAD_MESA_NUMERICS)

#################################################################

# STEP 3: build it

OBJS = ferguson.o freedman.o \
   opal_type1.o opal_type2.o \
   kap_support.o fixed_metal.o co_enhanced.o

CKAP = ckap
PLOTTER = plotter

all : $(CKAP) $(PLOTTER)

$(CKAP) : $(OBJS) create_tables.o
	$(LOADER) $(FCopenmp) -o ../$(CKAP) $(OBJS) create_tables.o \
	$(LOAD_OTHER_LIBS)

$(PLOTTER) : $(OBJS) plot.o
	$(LOADER) $(FCopenmp) -o ../$(PLOTTER) $(OBJS) plot.o \
	$(LOAD_OTHER_LIBS)

	
#################################################################

SRC_DIR = ../src

#COMPILE = $(COMPILE_NO_CHECKS)
COMPILE = $(COMPILE_TO_TEST)

%.o: $(SRC_DIR)/%.f
	$(COMPILE) $(FCfree) $<

COMPILE_OPAL = $(COMPILE_BASIC) $(FCopt) $(FCchecks) $(FCdebug) -c

opal_type1.o: $(SRC_DIR)/opal_type1.f
	$(COMPILE_OPAL) $(FCfixed) -g $<

opal_type2.o: $(SRC_DIR)/opal_type2.f
	$(COMPILE_OPAL) $(FCfixed) -g $<

clean:
	-@rm -f *.o *.mod ../$(CKAP)

