#!/bin/bash
-CPPFLAGS="-fPIC -ggdb -std=c++11 -Wall -pedantic -Wno-switch -Wno-unused-function -Iinclude -Iinclude/linux"
+CPPFLAGS="-fPIC -ggdb -std=c++11 -Wall -pedantic -Wno-switch -Wno-unused-function -Iinclude -Iinclude/linux -I../FMILibrary/src/Util/include -I../FMILibrary/src/ZIP/include -I../FMILibrary/src/Import/include -I../FMILibrary/ThirdParty/FMI/default"
LDFLAGS="-L/builds/fmildebug/ -lfmilib_shared"
+# Stop on first non-zero return value
+set -e
+
rm -rf obj
mkdir obj
-g++ ${CPPFLAGS} -o obj/fmu_control.o -c src/fmu_control.cpp
+g++ ${CPPFLAGS} -o obj/fmi_util.o -c src/fmi_util.c
+g++ ${CPPFLAGS} -o obj/fmu_control.o -c src/fmu_control.cpp
g++ ${CPPFLAGS} -o obj/sim_support.o -c src/sim_support.c
g++ ${CPPFLAGS} -o obj/stack.o -c src/stack.c
-g++ -ggdb -shared -Wl,-soname,libFMUSimulatorDebug.so -o libFMUSimulatorDebug.so obj/fmu_control.o obj/sim_support.o obj/stack.o ${LDFLAGS}
+g++ -ggdb -shared -Wl,-soname,libFMUSimulatorDebug.so -o libFMUSimulatorDebug.so obj/fmi_util.o obj/fmu_control.o obj/sim_support.o obj/stack.o ${LDFLAGS}
-patchelf --add-needed libfmilib_shared.so libFMUSimulator.so
-patchelf --set-rpath \$ORIGIN libFMUSimulator.so
\ No newline at end of file
+patchelf --add-needed libfmilib_shared.so libFMUSimulatorDebug.so
+patchelf --set-rpath \$ORIGIN libFMUSimulatorDebug.so