From 579677bef1678bde8f5ccbf40148adae0a9e6bc1 Mon Sep 17 00:00:00 2001 From: Adeel Asghar Date: Tue, 13 Jun 2017 14:22:46 +0200 Subject: [PATCH] Added ZeroMQ communication interface --- Compiler/CMakeLists.txt | 2 +- Compiler/Main/Main.mo | 45 +++++++++++++++ Compiler/Util/Flags.mo | 5 +- Compiler/Util/ZeroMQ.mo | 70 +++++++++++++++++++++++ Compiler/boot/LoadCompilerSources.mos | 3 +- Compiler/boot/Makefile.in | 2 +- Compiler/boot/Makefile.omdev.mingw | 1 + Compiler/runtime/Makefile.common | 3 +- Compiler/runtime/Makefile.omdev.mingw | 3 +- Compiler/runtime/ZeroMQ_omc.c | 49 ++++++++++++++++ Compiler/runtime/zeromqimpl.c | 82 +++++++++++++++++++++++++++ Makefile.common | 21 ++++++- Makefile.in | 1 + Makefile.omdev.mingw | 1 + configure.ac | 4 ++ 15 files changed, 284 insertions(+), 8 deletions(-) create mode 100644 Compiler/Util/ZeroMQ.mo create mode 100644 Compiler/runtime/ZeroMQ_omc.c create mode 100644 Compiler/runtime/zeromqimpl.c diff --git a/Compiler/CMakeLists.txt b/Compiler/CMakeLists.txt index e108beb79b8..779ae843c28 100644 --- a/Compiler/CMakeLists.txt +++ b/Compiler/CMakeLists.txt @@ -21,7 +21,7 @@ SET(SRCMO Absyn.mo AbsynDep.mo Algorithm.mo Builtin.mo ConnectUtil.mo Dependency.mo) SET(ALLMO ${SRCMO} DAEEXT.mo DynLoad.mo Print.mo System.mo Parser.mo - TaskGraphExt.mo Corba.mo Socket.mo ErrorExt.mo Settings.mo + TaskGraphExt.mo Corba.mo Socket.mo ZeroMQ.mo ErrorExt.mo Settings.mo UnitParserExt.mo SimulationResults.mo Serializer.mo) # RML diff --git a/Compiler/Main/Main.mo b/Compiler/Main/Main.mo index 1bb1f40bb1c..22079f62c6a 100644 --- a/Compiler/Main/Main.mo +++ b/Compiler/Main/Main.mo @@ -79,6 +79,7 @@ import StackOverflow; import System; import TplMain; import Util; +import ZeroMQ; protected function serverLoop "This function is the main loop of the server listening @@ -115,6 +116,40 @@ algorithm end match; end serverLoop; +protected function serverLoopZMQ +"This function is the main loop of the ZeroMQ server listening + to a port which recieves modelica expressions." + input Boolean cont; + input Option inZMQSocket; + input GlobalScript.SymbolTable inInteractiveSymbolTable; + output GlobalScript.SymbolTable outInteractiveSymbolTable; +algorithm + outInteractiveSymbolTable := match (cont,inZMQSocket,inInteractiveSymbolTable) + local + Boolean b; + String str,replystr; + GlobalScript.SymbolTable newsymb,ressymb,isymb; + Option zmqSocket; + case (false,_,isymb) then isymb; + case (_,SOME(0),_) then fail(); + case (_,zmqSocket,isymb) + equation + str = ZeroMQ.handleRequest(zmqSocket); + if Flags.isSet(Flags.INTERACTIVE_DUMP) then + Debug.trace("------- Recieved Data from client -----\n"); + Debug.trace(str); + Debug.trace("------- End recieved Data-----\n"); + end if; + (b,replystr,newsymb) = handleCommand(str, isymb) "Print.clearErrorBuf &" ; + replystr = if b then replystr else "quit requested, shutting server down\n"; + ZeroMQ.sendReply(zmqSocket, replystr); + if not b then + ZeroMQ.close(zmqSocket); + end if; + then serverLoopZMQ(b, zmqSocket, newsymb); + end match; +end serverLoopZMQ; + protected function makeDebugResult input Flags.DebugFlag inFlag; input String res; @@ -655,6 +690,14 @@ algorithm end try; end interactivemodeCorba; +protected function interactivemodeZMQ +"Initiate the interactive mode using ZMQ communication." + input GlobalScript.SymbolTable symbolTable; +algorithm + print("Starting a ZeroMQ server on port " + intString(29500) + "\n"); + serverLoopZMQ(true, ZeroMQ.initialize(29500), symbolTable); +end interactivemodeZMQ; + protected function serverLoopCorba "This function is the main loop of the server for a CORBA impl." input GlobalScript.SymbolTable inSettings; @@ -866,6 +909,8 @@ algorithm interactivemode(readSettings(args)); elseif Flags.isSet(Flags.INTERACTIVE_CORBA) then interactivemodeCorba(readSettings(args)); + elseif Flags.isSet(Flags.INTERACTIVE_ZMQ) then + interactivemodeZMQ(readSettings(args)); else // No interactive flag given, try to flatten the file. readSettings(args); FGraphStream.start(); diff --git a/Compiler/Util/Flags.mo b/Compiler/Util/Flags.mo index 89ad43d6d9f..6e1f77c525b 100644 --- a/Compiler/Util/Flags.mo +++ b/Compiler/Util/Flags.mo @@ -513,6 +513,8 @@ constant DebugFlag DISABLE_COLORING = DEBUG_FLAG(169, "disableColoring", false, Util.gettext("Disables coloring algorithm while spasity detection.")); constant DebugFlag MERGE_ALGORITHM_SECTIONS = DEBUG_FLAG(170, "mergeAlgSections", false, Util.gettext("Disables coloring algorithm while spasity detection.")); +constant DebugFlag INTERACTIVE_ZMQ = DEBUG_FLAG(171, "interactiveZMQ", false, + Util.gettext("Starts omc as a ZeroMQ server listening on the socket interface.")); // This is a list of all debug flags, to keep track of which flags are used. A @@ -690,7 +692,8 @@ constant list allDebugFlags = { EVAL_PARAM_DUMP, NF_UNITCHECK, DISABLE_COLORING, - MERGE_ALGORITHM_SECTIONS + MERGE_ALGORITHM_SECTIONS, + INTERACTIVE_ZMQ }; public diff --git a/Compiler/Util/ZeroMQ.mo b/Compiler/Util/ZeroMQ.mo new file mode 100644 index 00000000000..ab989df5e2d --- /dev/null +++ b/Compiler/Util/ZeroMQ.mo @@ -0,0 +1,70 @@ +/* + * This file is part of OpenModelica. + * + * Copyright (c) 1998-2014, Open Source Modelica Consortium (OSMC), + * c/o Linköpings universitet, Department of Computer and Information Science, + * SE-58183 Linköping, Sweden. + * + * All rights reserved. + * + * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR + * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2. + * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES + * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, + * ACCORDING TO RECIPIENTS CHOICE. + * + * The OpenModelica software and the Open Source Modelica + * Consortium (OSMC) Public License (OSMC-PL) are obtained + * from OSMC, either from the above address, + * from the URLs: http://www.ida.liu.se/projects/OpenModelica or + * http://www.openmodelica.org, and in the OpenModelica distribution. + * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. + * + * This program is distributed WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH + * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL. + * + * See the full OSMC Public License conditions for more details. + * + */ + +encapsulated package ZeroMQ +" file: ZeroMQ.mo + package: ZeroMQ + description: ZeroMQ communication module + + + This is the ZeroMQ connection module of the compiler + Used in interactive mode if omc is started with +d=interactiveZMQ + Implemented in ./runtime/zeromqimpl.c" + +public function initialize + input Integer port; + output Option zmqSocket; + + external "C" zmqSocket = ZeroMQ_initialize(port) annotation(Library = "omcruntime"); +end initialize; + +public function handleRequest + input Option zmqSocket; + output String request; + + external "C" request = ZeroMQ_handleRequest(zmqSocket) annotation(Library = "omcruntime"); +end handleRequest; + +public function sendReply + input Option zmqSocket; + input String reply; + + external "C" ZeroMQ_sendReply(zmqSocket, reply) annotation(Library = "omcruntime"); +end sendReply; + +public function close + input Option zmqSocket; + + external "C" ZeroMQ_close(zmqSocket) annotation(Library = "omcruntime"); +end close; + +annotation(__OpenModelica_Interface="util"); +end ZeroMQ; diff --git a/Compiler/boot/LoadCompilerSources.mos b/Compiler/boot/LoadCompilerSources.mos index 406ab167c5e..cc588217f22 100644 --- a/Compiler/boot/LoadCompilerSources.mos +++ b/Compiler/boot/LoadCompilerSources.mos @@ -226,7 +226,8 @@ if true then /* Suppress output */ "../Util/Socket.mo", "../Util/System.mo", "../Util/Util.mo", - "../Util/VarTransform.mo" + "../Util/VarTransform.mo", + "../Util/ZeroMQ.mo" }; backendfiles := if OpenModelica.Scripting.getEnvironmentVar("OPENMODELICA_BACKEND_STUBS")<>"" then { diff --git a/Compiler/boot/Makefile.in b/Compiler/boot/Makefile.in index 4be1330346d..b1d027dd2ef 100644 --- a/Compiler/boot/Makefile.in +++ b/Compiler/boot/Makefile.in @@ -12,7 +12,7 @@ EXE_EXT=@EXE@ EXE_SUFFIX= LIB_OMC=lib/@host_short@/omc -LDFLAGS=-L. -L$(GEN_DIR) -L"$(OMHOME)/$(LIB_OMC)" $(LOMPARSE) $(LCOMPILERRUNTIME) -lOpenModelicaRuntimeC -lModelicaExternalC -lomantlr3 $(CORBALIBS) $(FMILIB_OR_BOOT) $(GSLIB) @RT_LDFLAGS@ @LIBSOCKET@ @LIBLPSOLVE55@ @OMC_LIBS@ @GRAPHLIB@ @LD_LAPACK@ +LDFLAGS=-L. -L$(GEN_DIR) -L"$(OMHOME)/$(LIB_OMC)" $(LOMPARSE) $(LCOMPILERRUNTIME) -lOpenModelicaRuntimeC -lModelicaExternalC -lomantlr3 $(CORBALIBS) $(FMILIB_OR_BOOT) $(GSLIB) @RT_LDFLAGS@ @LIBSOCKET@ @LIBLPSOLVE55@ @OMC_LIBS@ @GRAPHLIB@ @LD_LAPACK@ -lzmq LDFLAGS_SHARED_MAIN=-L"$(OMHOME)/$(LIB_OMC)" @RT_LDFLAGS_SHARED@ ifeq (@WITH_FMIL@,yes) FMILIB = -L$(TOP_DIR)/3rdParty/FMIL/install/lib -lfmilib diff --git a/Compiler/boot/Makefile.omdev.mingw b/Compiler/boot/Makefile.omdev.mingw index a794fc206a5..1c3d11bd653 100644 --- a/Compiler/boot/Makefile.omdev.mingw +++ b/Compiler/boot/Makefile.omdev.mingw @@ -19,6 +19,7 @@ LDFLAGS=-L./ $(LOMPARSE) $(LCOMPILERRUNTIME) -L"$(OMHOME)/lib/omc" \ -Wl,--enable-stdcall-fixup -lstdc++ -static-libgcc \ -L../../3rdParty/lpsolve/build/lib \ -lgfortran -ltre -lomniORB420_rt -lomnithread40_rt \ +-lzmq \ $(EXTRA_LD_FLAGS) FMILIB = -L$(TOP_DIR)/3rdParty/FMIL/install/lib -lfmilib diff --git a/Compiler/runtime/Makefile.common b/Compiler/runtime/Makefile.common index 104fb9815e9..e54ee546f8f 100644 --- a/Compiler/runtime/Makefile.common +++ b/Compiler/runtime/Makefile.common @@ -24,7 +24,7 @@ OMC_OBJ_SHARED = Dynload_omc$(OBJEXT) Error_omc$(OBJEXT) \ ErrorMessage$(OBJEXT) systemimplmisc.o System_omc$(OBJEXT) \ Lapack_omc.o Settings_omc$(OBJEXT) \ UnitParserExt_omc.o unitparser.o \ - IOStreamExt_omc.o Socket_omc.o getMemorySize.o \ + IOStreamExt_omc.o Socket_omc.o ZeroMQ_omc.o getMemorySize.o \ is_utf8.o OMC_OBJ_STUBS = corbaimpl_stub_omc.o @@ -98,6 +98,7 @@ IOStreamExt_omc.o : IOStreamExt.c ErrorMessage.o : ErrorMessage.cpp ErrorMessage.hpp errorext.h serializer.o: serializer.cpp Socket_omc.o : socketimpl.c +ZeroMQ_omc.o : zeromqimpl.c UnitParserExt_omc.o : unitparserext.cpp unitparser.h BackendDAEEXT_omc.o : BackendDAEEXT.cpp $(RML_COMPAT) matching.c matchmaker.h matching_cheap.c diff --git a/Compiler/runtime/Makefile.omdev.mingw b/Compiler/runtime/Makefile.omdev.mingw index 0d42b58ed2f..7191ae5e3fc 100644 --- a/Compiler/runtime/Makefile.omdev.mingw +++ b/Compiler/runtime/Makefile.omdev.mingw @@ -27,6 +27,7 @@ CJSONINCLUDE = ../../3rdParty/cJSON/ OMBUILDDIR = ../../../build LPSOLVEINCLUDE = ../../3rdParty/lpsolve/build/include/ SQLITE3INCLUDE = ../../3rdParty/sqlite3/build/include/ +ZMQINCLUDE = ../../3rdParty/libzmq/include OMC=$(OMBUILDDIR)/bin/omc SHREXT=.a OMPCC = gcc -fopenmp @@ -46,7 +47,7 @@ OMCCORBASRC = omc_communication.o omc_communication_impl.o Corba_omc.o SHELL = /bin/sh CC = gcc CXX = g++ -override CFLAGS += -I. $(USE_CORBA) $(USE_METIS) -Wall -Wno-unused-variable -I../../ -I$(top_builddir) -I$(top_builddir)/SimulationRuntime/c -I$(top_builddir)/SimulationRuntime/c/simulation/results -I$(top_builddir)/SimulationRuntime/c/util -I$(top_builddir)/SimulationRuntime/c/meta -I$(top_builddir)/SimulationRuntime/c/meta/gc $(CORBAINCL) -I$(FMIINCLUDE) -I../../3rdParty/gc/include -I$(GRAPHSTREAMINCLUDE) -I$(CJSONINCLUDE) -I$(GRAPHINCLUDE) -I$(LPSOLVEINCLUDE) -I$(SQLITE3INCLUDE) +override CFLAGS += -I. $(USE_CORBA) $(USE_METIS) -Wall -Wno-unused-variable -I../../ -I$(top_builddir) -I$(top_builddir)/SimulationRuntime/c -I$(top_builddir)/SimulationRuntime/c/simulation/results -I$(top_builddir)/SimulationRuntime/c/util -I$(top_builddir)/SimulationRuntime/c/meta -I$(top_builddir)/SimulationRuntime/c/meta/gc $(CORBAINCL) -I$(FMIINCLUDE) -I../../3rdParty/gc/include -I$(GRAPHSTREAMINCLUDE) -I$(CJSONINCLUDE) -I$(GRAPHINCLUDE) -I$(LPSOLVEINCLUDE) -I$(SQLITE3INCLUDE) -I$(ZMQINCLUDE) CXXFLAGS = $(CFLAGS) include Makefile.common diff --git a/Compiler/runtime/ZeroMQ_omc.c b/Compiler/runtime/ZeroMQ_omc.c new file mode 100644 index 00000000000..c10632c583c --- /dev/null +++ b/Compiler/runtime/ZeroMQ_omc.c @@ -0,0 +1,49 @@ +/* + * This file is part of OpenModelica. + * + * Copyright (c) 1998-2010, Linköpings University, + * Department of Computer and Information Science, + * SE-58183 Linköping, Sweden. + * + * All rights reserved. + * + * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THIS OSMC PUBLIC + * LICENSE (OSMC-PL). ANY USE, REPRODUCTION OR DISTRIBUTION OF + * THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THE OSMC + * PUBLIC LICENSE. + * + * The OpenModelica software and the Open Source Modelica + * Consortium (OSMC) Public License (OSMC-PL) are obtained + * from Linköpings University, either from the above address, + * from the URL: http://www.ida.liu.se/projects/OpenModelica + * and in the OpenModelica distribution. + * + * This program is distributed WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH + * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS + * OF OSMC-PL. + * + * See the full OSMC Public License conditions for more details. + * + */ + + #if defined(_MSC_VER) || defined(__MINGW32__) + #define WIN32_LEAN_AND_MEAN + #include +#endif + +#include +#include + +#include "zeromqimpl.c" +#include "meta_modelica.h" +#include "ModelicaUtilities.h" + +extern const char* ZeroMQ_handleRequest(void* mmcZmqSocket) +{ + char *str = ZeroMQImpl_handleRequest(mmcZmqSocket); + char *res = strcpy(ModelicaAllocateString(strlen(str)),str); + free(str); + return res; +} diff --git a/Compiler/runtime/zeromqimpl.c b/Compiler/runtime/zeromqimpl.c new file mode 100644 index 00000000000..d456b89089f --- /dev/null +++ b/Compiler/runtime/zeromqimpl.c @@ -0,0 +1,82 @@ +/* + * This file is part of OpenModelica. + * + * Copyright (c) 1998-2010, Linköpings University, + * Department of Computer and Information Science, + * SE-58183 Linköping, Sweden. + * + * All rights reserved. + * + * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THIS OSMC PUBLIC + * LICENSE (OSMC-PL). ANY USE, REPRODUCTION OR DISTRIBUTION OF + * THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THE OSMC + * PUBLIC LICENSE. + * + * The OpenModelica software and the Open Source Modelica + * Consortium (OSMC) Public License (OSMC-PL) are obtained + * from Linköpings University, either from the above address, + * from the URL: http://www.ida.liu.se/projects/OpenModelica + * and in the OpenModelica distribution. + * + * This program is distributed WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH + * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS + * OF OSMC-PL. + * + * See the full OSMC Public License conditions for more details. + * + */ + +#include +#include +#include +#include + +#include "modelica_string.h" + +void* ZeroMQ_initialize(int port) +{ + // Create a pointer for storing the ZeroMQ socket + void *mmcZmqSocket = mmc_mk_some(0); + // Create the ZeroMQ context + void *context = zmq_ctx_new(); + void *zmqSocket = zmq_socket(context, ZMQ_REP); + char hostname[20]; + sprintf(hostname, "tcp://*:%d", port); + int rc = zmq_bind(zmqSocket, hostname); + if (rc != 0) { + printf("Error creating ZeroMQ Server\n"); + return mmcZmqSocket; + } + mmcZmqSocket = mmc_mk_some(zmqSocket); + return mmcZmqSocket; +} + +extern char* ZeroMQImpl_handleRequest(void *mmcZmqSocket) +{ + int bufferSize = 4000; + char *buffer = (char*)malloc(bufferSize + 1); + // Convert the void* to ZeroMQ Socket + intptr_t zmqSocket = (intptr_t)MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(mmcZmqSocket),1)); + zmq_recv((void*)zmqSocket, buffer, bufferSize, 0); + fprintf(stdout, "Recieved message %s\n", buffer);fflush(NULL); + return buffer; +} + +void ZeroMQ_sendReply(void *mmcZmqSocket, const char* reply) +{ + // Convert the void* to ZeroMQ Socket + intptr_t zmqSocket = (intptr_t)MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(mmcZmqSocket),1)); + // send the reply + fprintf(stdout, "Sending message %s\n", reply);fflush(NULL); + zmq_send((void*)zmqSocket, reply, strlen(reply) + 1, 0); +} + +void ZeroMQ_close(void *mmcZmqSocket) +{ + // Convert the void* to ZeroMQ Socket + intptr_t zmqSocket = (intptr_t)MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(mmcZmqSocket),1)); + // close the ZeroMQ socket + zmq_close((void*)zmqSocket); +} diff --git a/Makefile.common b/Makefile.common index 0b5d6e45b02..e5054a4a6da 100644 --- a/Makefile.common +++ b/Makefile.common @@ -25,7 +25,7 @@ INSTALL_MANDIR = ${DESTDIR}${datadir}/man/ INSTALL_JAVADIR = ${DESTDIR}${datadir}/omc/java INSTALL_LOCALEDIR = ${DESTDIR}${datadir}/locale -.PHONY : interactive omc release all mkbuilddirs fmi test install-dirs susan susan_all susgen sustst install-openturns runtimeCPPinstall CMinpack metis Cdaskr boehm-gc $(MINGW_EXTRA_LIBS) +.PHONY : interactive omc release all mkbuilddirs fmi test install-dirs susan susan_all susgen sustst install-openturns runtimeCPPinstall CMinpack metis Cdaskr boehm-gc libzmq $(MINGW_EXTRA_LIBS) mkbuilddirs: echo Making build directories under $(OMBUILDDIR) @@ -74,7 +74,7 @@ interactive-common: .testvariables mkbuilddirs boehm-gc idl ModelicaExternalC $( interactive-short: .testvariables interactive-common $(MAKE) -C SimulationRuntime/c -f $(defaultMakefileTarget) bootstrap-dependencies OMBUILDDIR=$(OMBUILDDIR) -interactive: .testvariables interactive-common fmil lis Cdaskr CMinpack docs $(SUNDIALS_TARGET) $(IPOPT_TARGET) $(UMFPACK_TARGET) $(MINGW_EXTRA_LIBS) +interactive: .testvariables interactive-common fmil lis Cdaskr CMinpack docs libzmq $(SUNDIALS_TARGET) $(IPOPT_TARGET) $(UMFPACK_TARGET) $(MINGW_EXTRA_LIBS) $(MAKE) -C SimulationRuntime/c -f $(defaultMakefileTarget) OMBUILDDIR=$(OMBUILDDIR) opc: .testvariables mkbuilddirs boehm-gc @@ -253,6 +253,23 @@ CMinpack-clean: #rm -f 3rdParty/CMinpack/build/Makefile rm -rf 3rdParty/CMinpack/build +libzmq: + test -d 3rdParty/libzmq + mkdir -p 3rdParty/libzmq/build + (cd 3rdParty/libzmq/build && test -f Makefile || CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" $(CMAKE) -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DCMAKE_AR:String="$(AR)" -DCMAKE_COLOR_MAKEFILE:Bool=OFF -DWITH_PERF_TOOL:Bool=OFF -DZMQ_BUILD_TESTS:Bool=OFF -DENABLE_CPACK:Bool=OFF -DCMAKE_BUILD_TYPE=Release .. -G $(CMAKE_TARGET)) + test -f 3rdParty/libzmq/build/lib/$(LIBZMQLIB) || $(MAKE) -C 3rdParty/libzmq/build + test ! `uname` = Darwin || install_name_tool -id @rpath/$(LIBZMQLIB) 3rdParty/libzmq/build/lib/$(LIBZMQLIB) + # copy dll/so to $(LIB_OMC) and $(builddir_bin) folders + (rm -f $(builddir_lib_omc)/$(LIBZMQLIB)*) + (rm -f $(builddir_bin)/$(LIBZMQLIB)*) + (cp -af 3rdParty/libzmq/build/lib/$(LIBZMQLIB)* $(builddir_lib_omc)) + (cp -af 3rdParty/libzmq/build/lib/$(LIBZMQLIB)* $(builddir_bin)) + # Darwin has to be special always + (test ! `uname` = Darwin || cp -af 3rdParty/libzmq/build/lib/lib*.dylib $(builddir_lib_omc)) + +libzmq-clean: + rm -rf 3rdParty/libzmq/build + metis: (cd 3rdParty/metis-5.1.0 && $(CMAKE) -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -G $(CMAKE_TARGET) && CC="$(CC)" CFLAGS="$(CFLAGS)" make) cp 3rdParty/metis-5.1.0/libmetis/libmetis.a $(builddir_lib_omc) diff --git a/Makefile.in b/Makefile.in index be6719a23b6..792897e704e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -40,6 +40,7 @@ MSL_EXTRA_ARGS=@MSL_EXTRA_ARGS@ LIBGC_EXTRA_CONFIGURATION=--enable-threads=posix --enable-parallel-mark LIBFMILIB=@LIBFMILIB@ LIBCMINPACKLIB=@LIBCMINPACKLIB@ +LIBZMQLIB=@LIBZMQLIB@ LD_LAPACK=@LD_LAPACK@ LAPACK_TARGET=@LAPACK_TARGET@ OPENBLAS_EXTRA_ARGS=@OPENBLAS_EXTRA_ARGS@ diff --git a/Makefile.omdev.mingw b/Makefile.omdev.mingw index 6f7cb2a0992..ff0ff8c094c 100644 --- a/Makefile.omdev.mingw +++ b/Makefile.omdev.mingw @@ -52,6 +52,7 @@ LIBGC_EXTRA_CONFIGURATION=--enable-threads=posix --enable-munmap=1 #--disable-pa MSL321_CONFIG_EXTRA_FLAGS=--enable-static --disable-shared LIBFMILIB=libfmilib.a LIBCMINPACKLIB=libcminpack.a +LIBZMQLIB=libzmq.dll MODELICA_SPEC_PLATFORM=win32 SHREXT=.dll IPOPT_TARGET=ipopt diff --git a/configure.ac b/configure.ac index 1808849d173..e8b303061a0 100644 --- a/configure.ac +++ b/configure.ac @@ -68,6 +68,7 @@ AC_SUBST(WITH_FMIL) AC_SUBST(NO_FMIL) AC_SUBST(FMILIB_SHARED) AC_SUBST(LIBCMINPACKLIB) +AC_SUBST(LIBZMQLIB) AC_SUBST(CMINPACKLIB_SHARED) AC_SUBST(SHREXT) AC_SUBST(LINK) @@ -620,6 +621,7 @@ if test "$DARWIN" = "1"; then LIBFMILIB=libfmilib_shared.dylib FMILIB_SHARED=ON LIBCMINPACKLIB=libcminpack.dylib + LIBZMQLIB=libzmq.dylib CMINPACKLIB_SHARED=ON RT_LDFLAGS_SIM="$LDFLAGS $RT_LDFLAGS -lexpat -lomcgc -lpthread -lm $LIBDL -lstdc++" RT_LDFLAGS_SIM_OPTIONAL="$SUNDIALS_LDFLAGS $IPOPT_LDFLAGS $UMFPACK_LDFLAGS -llis -lcdaskr -lcminpack -liconv" @@ -655,6 +657,7 @@ elif echo "$host" | grep -iq "mingw"; then LIBFMILIB=libfmilib.a FMILIB_SHARED=OFF LIBCMINPACKLIB=libcminpack.a + LIBZMQLIB=libzmq.a CMINPACKLIB_SHARED=OFF RT_LDFLAGS_SIM="$LDFLAGS $RT_LDFLAGS -lstdc++ -lomcgc -lexpat -lm" RT_LDFLAGS_SIM_OPTIONAL="$SUNDIALS_LDFLAGS $IPOPT_LDFLAGS $UMFPACK_LDFLAGS -llis -lcminpack" @@ -688,6 +691,7 @@ else LIBFMILIB=libfmilib_shared.so FMILIB_SHARED=ON LIBCMINPACKLIB=libcminpack.so + LIBZMQLIB=libzmq.so CMINPACKLIB_SHARED=ON # For static runtime on Linux: # -Wl,-whole-archive -lSimulationRuntimeC -Wl,-no-whole-archive