# Copyright (c) 2013-2020, SIB - Swiss Institute of Bioinformatics and
#                          Biozentrum - University of Basel
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#   http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


########
# SETUP
########
# path to OST and ProMod3 stage
OST_ROOT = $(EBROOTOPENSTRUCTURE)
PROMOD3_ROOT = $(EBROOTPROMOD3)

# sources to compile
SOURCES = test_cpp.cc

# target filename
TARGET = test_cpp

# choose C++ compiler
CC = g++
LD = $(CC)

# set extra flags
CFLAGS = 
LDFLAGS = 
########

# set include paths
INCLUDES = -I$(OST_ROOT)/include -I$(PROMOD3_ROOT)/include
# collect libraries
LIB_DIRS = -L$(OST_ROOT)/lib -L$(PROMOD3_ROOT)/lib
LIBS = -lpromod3_core -lpromod3_loop -lpromod3_modelling -lpromod3_sidechain
LIBS += -lost_io -lost_mol -lost_seq -lost_seq_alg -lost_mol_alg -lost_conop
LIBS += -lost_base -lost_geom -lost_mol_mm -lboost_system

# add rpath to find shared objects (req. gcc)
LDFLAGS += "-Wl,-rpath,$(PROMOD3_ROOT)/lib:$(OST_ROOT)/lib"

# setup compilation
OBJECTS := $(SOURCES:%.cc=%.o)

.DEFAULT: all;

# Default target is to compile everything
all: $(TARGET)

# run it
run: $(TARGET)
	@echo "------ RUNNING $(TARGET) ------"
	@./$(TARGET)

# final linking
$(TARGET): $(OBJECTS)
	@echo "PRODUCING $@"
	@#echo "SOURCES = $(SOURCES)"
	@#echo "OBJECTS = $(OBJECTS)"
	@#echo "---------------------"
	@$(LD) $(OBJECTS) -o $@ $(LIB_DIRS) $(LDFLAGS) $(LIBS)
	@#echo "---------------------"

%.o: %.cc
	@echo "PRODUCING $@"
	@$(CC) ${INCLUDES} $(CFLAGS) -c -o $@ $<

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