#########################################################################
# For TESTING HiOp only. Not intended for any kind of production use
#
# Makefile for HiOp's example driver for IpoptAdapter 
# Based on IPOPT_DIR/Ipopt/examples/Cpp_example/Makefile
#
# This file needs manual adaptations to your specific OS 
# The easiest way to do this is to copy Makefile generated
# by Ipopt on your system and update the CHANGEME entries
# HiOp include/ and lib/ directories need to be appended
# to ADDINCFLAGS and LIBS, see below

# Use as
# > make -f Makefile_IpoptAdapter
#
# Remark that does not have 'clean' target :)
# > rm IpoptAdapterDriver.o
#########################################################################

# Copyright (C) 2003, 2010 International Business Machines and others.
# All Rights Reserved.
# This file is distributed under the Eclipse Public License.

# $Id$

##########################################################################
#    You can modify this example makefile to fit for your own program.   #
#    Usually, you only need to change the five CHANGEME entries below.   #
##########################################################################

# CHANGEME: This should be the name of your executable
EXE = IpoptAdapterDriverEx2.exe

# CHANGEME: Here is the name of all object files corresponding to the source
#           code that you wrote in order to define the problem statement
OBJS =  IpoptAdapterDriverEx2.o NlpSparseEx1.o 

# CHANGEME: Additional libraries
ADDLIBS = -L/g/g90/wang125/software/magma/lib /g/g90/wang125/software/coinhsl/lib/libcoinhsl.so 
#ADDLIBS = -shared -L/usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-rolling-release/lib:/usr/tce/packages/cuda/cuda-11.0.2/lib64:/g/g90/wang125/software/magma/lib:/g/g90/wang125/software/coinhsl/lib -llapack /usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-rolling-release/lib/libmpiprofilesupport.so /usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-rolling-release/lib/libmpi_ibm.so /usr/tce/packages/cuda/cuda-11.0.2/lib64/libcublas.so /usr/tce/packages/cuda/cuda-11.0.2/lib64/libcudart.so /usr/tce/packages/cuda/cuda-11.0.2/lib64/libcudadevrt.a /usr/tce/packages/cuda/cuda-11.0.2/lib64/libcusparse.so /usr/lib64/libcublasLt.so /usr/tce/packages/cuda/cuda-11.0.2/lib64/libculibos.a /g/g90/wang125/software/magma/lib/libmagma.so -lgomp -lpthread /usr/lib64/libessl.so /usr/lib64/libblas.so /usr/lib64/libessl.so /usr/lib64/libblas.so /g/g90/wang125/software/metis/lib/libmetis.a /g/g90/wang125/software/coinhsl/lib/libcoinhsl.so 


# CHANGEME: Additional flags for compilation (e.g., include flags)
ADDINCFLAGS = -I/g/g90/wang125/software/hiop/include/
#ADDINCFLAGS = -I/Users/petra1/work/projects/hiop/_dist-DEBUG/include/
##########################################################################
#  Usually, you don't have to change anything below.  Note that if you   #
#  change certain compiler options, you might have to recompile Ipopt.   #
##########################################################################

# C++ Compiler command
CXX = mpig++

# C++ Compiler options
CXXFLAGS = -g -pipe -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long -m64 -fopenmp -fPIC -lgomp  -DIPOPT_BUILD
# mac
#CXXFLAGS = -g -pipe -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long -m64 -I/home/petra1/intel_mkl2019/compilers_and_libraries_2019.2.187/linux/mkl/include -fPIC -DIPOPT_BUILD 

# additional C++ Compiler options for linking
CXXLINKFLAGS = -Wl,--rpath -Wl,/g/g90/wang125/software/lassen/Ipopt/lib/
#mac
#CXXLINKFLAGS =  -Wl,-rpath -Wl,/Users/petra1/work/projects/go-compet/Ipopt-gollnlp/build/lib/

# Include directories (we use the CYGPATH_W variables to allow compilation with Windows compilers)
INCL = `PKG_CONFIG_PATH=/g/g90/wang125/software/lib/pkgconfig pkg-config --cflags ipopt` $(ADDINCFLAGS)
#mac
#INCL = -I`$(CYGPATH_W) /Users/petra1/work/projects/go-compet/Ipopt-gollnlp/build/include/coin`  -I/Users/petra1/work/projects/go-compet/Ipopt-gollnlp/build/include/coin/ThirdParty  -I/Users/petra1/work/projects/go-compet/Ipopt-gollnlp/build/include/coin/ThirdParty   $(ADDINCFLAGS)

# Linker flags
LIBS = `PKG_CONFIG_PATH=/g/g90/wang125/software/lassen/Ipopt/lib/pkgconfig pkg-config --libs ipopt` -llapack -lblas  -ldl -lm /g/g90/wang125/software/hiop/lib/libhiop.a

#mac
#LIBS = -L/Users/petra1/work/projects/go-compet/Ipopt-gollnlp/build/lib -lipopt  -L/Users/petra1/work/projects/go-compet/Ipopt-gollnlp/build/lib -lcoinhsl -framework Accelerate -framework Accelerate -L/usr/local/Cellar/gcc/9.2.0_1/lib/gcc/9/gcc/x86_64-apple-darwin18/9.2.0 -L/usr/local/Cellar/gcc/9.2.0_1/lib/gcc/9/gcc/x86_64-apple-darwin18/9.2.0/../../.. -lgfortran -lSystem -lquadmath -lm  -L/Users/petra1/work/projects/go-compet/Ipopt-gollnlp/build/lib -lcoinmetis  -framework Accelerate -framework Accelerate -lm  -ldl /Users/petra1/work/projects/hiop/_dist-DEBUG/lib/libhiop.a

# The following is necessary under cygwin, if native compilers are used
CYGPATH_W = echo

all: $(EXE)

.SUFFIXES: .cpp .c .o .obj

$(EXE): $(OBJS)
	bla=;\
	for file in $(OBJS); do bla="$$bla `$(CYGPATH_W) $$file`"; done; \
	$(CXX) $(CXXLINKFLAGS) $(CXXFLAGS) -o $@ $$bla $(LIBS) $(ADDLIBS)

clean:
	rm -rf $(EXE) $(OBJS)

.cpp.o:
	$(CXX) $(CXXFLAGS) $(INCL) -c -o $@ $<


.cpp.obj:
	$(CXX) $(CXXFLAGS) $(INCL) -c -o $@ `$(CYGPATH_W) '$<'`
