#########################################################################
# 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 = IpoptAdapterDriverEx1.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 =  IpoptAdapterDriverEx1.o NlpSparseEx1.o

# CHANGEME: Additional libraries
ADDLIBS =

# CHANGEME: Additional flags for compilation (e.g., include flags)
#ADDINCFLAGS = -I/g/g92/chiang7/software/hiop_lassen/include/
#ADDINCFLAGS = -I/Users/petra1/work/projects/hiop/_dist-DEBUG/include/
ADDINCFLAGS = -I/Users/chiang7/project/hiop/build_develop/install_db/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 = g++

# C++ Compiler options
# ny VM
#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
# ny mac
CXXFLAGS = -g -std=c++11 -pipe -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long -m64 -fPIC -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
# ny VM
#CXXLINKFLAGS = -Wl,--rpath -Wl,/g/g92/chiang7/software/lassen/COIN-OR/build/lib
# ny mac
CXXLINKFLAGS = -Wl,-rpath -Wl,/Users/chiang7/software/coin-or/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)
# ny VM
#INCL = `PKG_CONFIG_PATH=/g/g92/chiang7/software/lassen/COIN-OR/build/lib/pkgconfig pkg-config --cflags ipopt` $(ADDINCFLAGS)
# ny mac
INCL = `PKG_CONFIG_PATH=/Users/chiang7/software/coin-or/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
# ny VM
#LIBS = `PKG_CONFIG_PATH=/g/g92/chiang7/software/lassen/COIN-OR/build/lib/pkgconfig pkg-config --libs ipopt` -llapack -lblas  -ldl -lm /g/g92/chiang7/software/hiop_lassen/lib/libhiop.a
# ny mac
LIBS = `PKG_CONFIG_PATH=/Users/chiang7/software/coin-or/lib/pkgconfig pkg-config --libs ipopt` -llapack -lblas  -ldl -lm /Users/chiang7/project/hiop/build_develop/install_db/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) '$<'`
