Skip to content

Commit

Permalink
- Link with Sundials only if requested
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11928 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed May 21, 2012
1 parent 419bf19 commit ff0642d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Compiler/BackEnd/SimCode.mo
Expand Up @@ -487,7 +487,7 @@ uniontype MakefileParams
String omhome;
String cflags;
String ldflags;
String senddatalibs;
String runtimelibs "Libraries that are required by the runtime library";
list<String> includes;
list<String> libs;
String platform;
Expand Down Expand Up @@ -2868,7 +2868,7 @@ protected function createMakefileParams
input list<String> libs;
output MakefileParams makefileParams;
protected
String omhome,ccompiler,cxxcompiler,linker,exeext,dllext,cflags,ldflags,senddatalibs,platform;
String omhome,ccompiler,cxxcompiler,linker,exeext,dllext,cflags,ldflags,rtlibs,platform;
algorithm
ccompiler := System.getCCompiler();
cxxcompiler := System.getCXXCompiler();
Expand All @@ -2880,10 +2880,10 @@ algorithm
cflags := System.getCFlags();
cflags := Debug.bcallret2(Flags.isSet(Flags.OPENMP),stringAppend,cflags," -fopenmp",cflags);
ldflags := System.getLDFlags();
senddatalibs := System.getRTLibs();
rtlibs := System.getRTLibs();
platform := System.modelicaPlatform();
makefileParams := MAKEFILE_PARAMS(ccompiler, cxxcompiler, linker, exeext, dllext,
omhome, cflags, ldflags, senddatalibs, includes, libs, platform);
omhome, cflags, ldflags, rtlibs, includes, libs, platform);
end createMakefileParams;

protected function generateHelpVarInfo
Expand Down
2 changes: 1 addition & 1 deletion Compiler/runtime/config.h
Expand Up @@ -51,7 +51,7 @@
#define CONFIGURE_COMMANDLINE "Manually created Makefiles for Visual Studio"
#endif

#define LDFLAGS_RT " -static-libgcc -luuid -lole32 -lws2_32"
#define LDFLAGS_RT " -static-libgcc -luuid -lole32 -lws2_32 -lsundials_kinsol -lsundials_nvecserial -llapack"
#define CONFIG_EXE_EXT ".exe"
#define CONFIG_DLL_EXT ".dll"
#define CONFIG_OS "Windows_NT"
Expand Down
2 changes: 1 addition & 1 deletion Compiler/runtime/config.unix.h.in
@@ -1,6 +1,6 @@
/* @configure_input@ */
#define CONFIGURE_COMMANDLINE "Configured @date@ using arguments: '@CONFIGURE_ARGS@'"
#define LDFLAGS_RT "@RT_LDFLAGS@ -lpthread"
#define LDFLAGS_RT "@RT_LDFLAGS@ @SUNDIALS_LDFLAGS@ -lpthread"
#define CONFIG_EXE_EXT ""
#define CONFIG_DLL_EXT ".so"
#define CONFIG_PLATFORM "Unix"
Expand Down
11 changes: 4 additions & 7 deletions Compiler/susan_codegen/SimCode/CodegenC.tpl
Expand Up @@ -2137,9 +2137,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
CFLAGS=$(CFLAGS_BASED_ON_INIT_FILE) <%makefileParams.cflags%> <%match sopt case SOME(s as SIMULATION_SETTINGS(__)) then s.cflags /* From the simulate() command */%>
CPPFLAGS=-I"<%makefileParams.omhome%>/include/omc" -I. <%dirExtra%> <%makefileParams.includes ; separator=" "%>
LIBSIMULATIONRUNTIMEC=<% if boolOr(acceptMetaModelicaGrammar(), Flags.isSet(Flags.GEN_DEBUG_SYMBOLS)) then "-Wl,-whole-archive "%>-lSimulationRuntimeC<% if stringEq(makefileParams.platform, "win32") then "" else " -ldl"%><% if boolOr(acceptMetaModelicaGrammar(), Flags.isSet(Flags.GEN_DEBUG_SYMBOLS)) then " -Wl,-no-whole-archive"%>
LDFLAGS=-L"<%makefileParams.omhome%>/lib/omc" $(LIBSIMULATIONRUNTIMEC) <%ParModelicaLibs%> <%makefileParams.ldflags%>
SENDDATALIBS=<%makefileParams.senddatalibs%>
SUNDIALSLIBS=-lsundials_kinsol -lsundials_nvecserial <% if stringEq(makefileParams.platform, "win32") then "-llapack-mingw" else "-llapack"%>
LDFLAGS=-L"<%makefileParams.omhome%>/lib/omc" $(LIBSIMULATIONRUNTIMEC) <%ParModelicaLibs%> <%makefileParams.ldflags%> <%makefileParams.runtimelibs%>
PERL=perl
FILEPREFIX=<%fileNamePrefix%>
MAINFILE=$(FILEPREFIX)<% if boolOr(acceptMetaModelicaGrammar(), Flags.isSet(Flags.GEN_DEBUG_SYMBOLS)) then ".conv"%>.c
Expand All @@ -2152,7 +2150,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
.PHONY: $(FILEPREFIX)_records.c

omc_main_target: $(MAINOBJ) $(FILEPREFIX)_records.o $(FILEPREFIX)_functions.c $(FILEPREFIX)_functions.h
<%\t%> $(CXX) -I. -o $(FILEPREFIX)$(EXEEXT) $(MAINOBJ) $(FILEPREFIX)_records.o $(CPPFLAGS) <%dirExtra%> <%libsPos1%> <%libsPos2%> $(CFLAGS) $(LDFLAGS) -linteractive $(SENDDATALIBS) $(SUNDIALSLIBS) <%match System.os() case "OSX" then "-lf2c" else "-Wl,-Bstatic -lf2c -Wl,-Bdynamic"%>
<%\t%> $(CXX) -I. -o $(FILEPREFIX)$(EXEEXT) $(MAINOBJ) $(FILEPREFIX)_records.o $(CPPFLAGS) <%dirExtra%> <%libsPos1%> <%libsPos2%> $(CFLAGS) $(LDFLAGS) -linteractive $(LDFLAGS) <%match System.os() case "OSX" then "-lf2c" else "-Wl,-Bstatic -lf2c -Wl,-Bdynamic"%>
<%fileNamePrefix%>.conv.c: $(FILEPREFIX).c
<%\t%>$(PERL) <%makefileParams.omhome%>/share/omc/scripts/convert_lines.pl $< $@.tmp
<%\t%>@mv $@.tmp $@
Expand Down Expand Up @@ -2366,16 +2364,15 @@ case FUNCTIONCODE(makefileParams=MAKEFILE_PARAMS(__)) then
EXEEXT=<%makefileParams.exeext%>
DLLEXT=<%makefileParams.dllext%>
CFLAGS= -I"<%makefileParams.omhome%>/include/omc" <%makefileParams.includes ; separator=" "%> <%makefileParams.cflags%>
LDFLAGS= -L"<%makefileParams.omhome%>/lib/omc" -lSimulationRuntimeC <%makefileParams.ldflags%>
SENDDATALIBS=<%makefileParams.senddatalibs%>
LDFLAGS= -L"<%makefileParams.omhome%>/lib/omc" -lSimulationRuntimeC <%makefileParams.ldflags%> <%makefileParams.runtimelibs%>
PERL=perl
MAINFILE=<%name%><% if boolOr(acceptMetaModelicaGrammar(), Flags.isSet(Flags.GEN_DEBUG_SYMBOLS)) then ".conv"%>.c

.PHONY: <%name%>
<%name%>: $(MAINFILE) <%name%>.h <%name%>_records.c
<%\t%> $(CC) $(CFLAGS) -c -o <%name%>.o $(MAINFILE)
<%\t%> $(CC) $(CFLAGS) -c -o <%name%>_records.o <%name%>_records.c
<%\t%> $(LINK) -o <%name%>$(DLLEXT) <%name%>.o <%name%>_records.o <%libsStr%> $(CFLAGS) $(LDFLAGS) $(SENDDATALIBS) -lm
<%\t%> $(LINK) -o <%name%>$(DLLEXT) <%name%>.o <%name%>_records.o <%libsStr%> $(CFLAGS) $(LDFLAGS) -lm
<%name%>.conv.c: <%name%>.c
<%\t%> $(PERL) <%makefileParams.omhome%>/share/omc/scripts/convert_lines.pl $< $@.tmp
<%\t%> @mv $@.tmp $@
Expand Down
3 changes: 1 addition & 2 deletions Compiler/susan_codegen/SimCode/CodegenFMU.tpl
Expand Up @@ -1042,8 +1042,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
PLAT34 = <%makefileParams.platform%>
CFLAGS=$(CFLAGS_BASED_ON_INIT_FILE) -I"<%makefileParams.omhome%>/include/omc" <%makefileParams.cflags%> <%match sopt case SOME(s as SIMULATION_SETTINGS(__)) then s.cflags /* From the simulate() command */%>
CPPFLAGS=-I"<%makefileParams.omhome%>/include/omc" -I. <%dirExtra%> <%makefileParams.includes ; separator=" "%>
SUNDIALSLIBS=-lsundials_kinsol -lsundials_nvecserial <% if stringEq(makefileParams.platform, "win32") then "-llapack-mingw" else "-llapack"%>
LDFLAGS=-L"<%makefileParams.omhome%>/lib/omc" -lSimulationRuntimeC -linteractive <%makefileParams.ldflags%> <%makefileParams.senddatalibs%> $(SUNDIALSLIBS)
LDFLAGS=-L"<%makefileParams.omhome%>/lib/omc" -lSimulationRuntimeC -linteractive <%makefileParams.ldflags%> <%makefileParams.runtimelibs%>
PERL=perl
MAINFILE=<%fileNamePrefix%>_FMU<% if acceptMetaModelicaGrammar() then ".conv"%>.c
MAINOBJ=<%fileNamePrefix%>_FMU<% if acceptMetaModelicaGrammar() then ".conv"%>.o
Expand Down
2 changes: 1 addition & 1 deletion Compiler/susan_codegen/SimCode/SimCodeTV.mo
Expand Up @@ -150,7 +150,7 @@ package SimCode
String omhome;
String cflags;
String ldflags;
String senddatalibs;
String runtimelibs;
list<String> includes;
list<String> libs;
String platform;
Expand Down
2 changes: 2 additions & 0 deletions configure.in
Expand Up @@ -27,6 +27,7 @@ AC_SUBST(USE_MODPAR)
AC_SUBST(BOOSTHOME)
AC_SUBST(GENERATED_AUTOCONF_FILES)
AC_SUBST(RT_LDFLAGS)
AC_SUBST(SUNDIALS_LDFLAGS)
AC_SUBST(QMAKE)
AC_SUBST(EXE)
AC_SUBST(RML_TRACE)
Expand Down Expand Up @@ -305,6 +306,7 @@ AC_CHECK_HEADERS(kinsol/kinsol.h kinsol/kinsol_dense.h nvector/nvector_serial.h
if ! test "$NO_SUNDIALS" = "yes"; then
FINAL_MESSAGES="$FINAL_MESSAGES\nSimulations may use sundials suite: Yes"
WITH_SUNDIALS="#define WITH_SUNDIALS"
SUNDIALS_LDFLAGS="-lsundials_kinsol -lsundials_nvecserial -llapack"
else
FINAL_MESSAGES="$FINAL_MESSAGES\nSimulations may use sundials suite: No"
WITH_SUNDIALS="/* Without Sundials */"
Expand Down

0 comments on commit ff0642d

Please sign in to comment.