From 7265334849d6c5599ab89497f4060f3b93de6314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sj=C3=B6lund?= Date: Fri, 15 Apr 2016 18:50:20 +0200 Subject: [PATCH] Fix compilation on OSX --- Compiler/boot/Makefile.common | 20 ++++++++++---------- Compiler/runtime/Makefile.common | 10 +++++----- Compiler/runtime/Makefile.in | 2 +- Compiler/runtime/settingsimpl.c | 9 +++++++-- configure.ac | 2 ++ 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Compiler/boot/Makefile.common b/Compiler/boot/Makefile.common index 7982cb732e9..6bd35b6bb0d 100644 --- a/Compiler/boot/Makefile.common +++ b/Compiler/boot/Makefile.common @@ -58,26 +58,26 @@ bootstrap-from-tarball: $(PATCHES) touch build/OpenModelicaScriptingAPI.h $(MAKE) -f $(defaultMakefileTarget) install INCLUDESOURCES=1 OMC=.omc BOOTSTRAP_STAGE_1=1 CPPFLAGS="$(CPPFLAGS) -DOMC_BOOTSTRAPPING_STAGE_1" @echo "Bootstrapping phase 1/3 completed" - $(MAKE) -f $(defaultMakefileTarget) --no-print-directory clean OMC=$(BOOTSTRAP_OMC) - $(MAKE) -f $(defaultMakefileTarget) --no-print-directory runtime-depends OMBUILDDIR=$(OMBUILDDIR) - OPENMODELICA_BACKEND_STUBS=1 $(MAKE) -f $(defaultMakefileTarget) generate-files-in-steps OMC=$(BOOTSTRAP_OMC) OMC_EXTRA_FLAGS= + $(MAKE) -f $(defaultMakefileTarget) --no-print-directory clean OMC="$(BOOTSTRAP_OMC)" + $(MAKE) -f $(defaultMakefileTarget) --no-print-directory runtime-depends OMBUILDDIR=$(OMBUILDDIR) OMC="$(BOOTSTRAP_OMC)" + OPENMODELICA_BACKEND_STUBS=1 $(MAKE) -f $(defaultMakefileTarget) generate-files-in-steps OMC="$(BOOTSTRAP_OMC)" OMC_EXTRA_FLAGS= # Patch _main.c to avoid a new tarball $(PATCH_SOURCES) echo '#include "Patternm.h"' >> build/SimCodeFunctionUtil_includes.h # We have not compiled OpenModelicaScriptingAPI.mo yet touch build/OpenModelicaScriptingAPI.h - $(MAKE) -f $(defaultMakefileTarget) install INCLUDESOURCES=1 OMC=$(BOOTSTRAP_OMC) + $(MAKE) -f $(defaultMakefileTarget) install INCLUDESOURCES=1 OMC="$(BOOTSTRAP_OMC)" @echo "Bootstrapping phase 2/3 completed" - $(MAKE) -f $(defaultMakefileTarget) clean OMC=$(BOOTSTRAP_OMC) - $(MAKE) -f $(defaultMakefileTarget) --no-print-directory -C $(TOP_DIR)/Compiler/Template OMC=$(BOOTSTRAP_OMC) clean - $(MAKE) -f $(defaultMakefileTarget) --no-print-directory -C $(TOP_DIR)/Compiler/Script OMC=$(BOOTSTRAP_OMC) clean - $(MAKE) -f $(defaultMakefileTarget) generate-files-in-steps OMC=$(BOOTSTRAP_OMC) "OMC_EXTRA_FLAGS=$(OMC_EXTRA_FLAGS)" - $(MAKE) -f $(defaultMakefileTarget) install INCLUDESOURCES=1 OMC=$(BOOTSTRAP_OMC) CPPFLAGS="$(CPPFLAGS) -DOMC_BOOTSTRAPPING_STAGE_1" + $(MAKE) -f $(defaultMakefileTarget) clean OMC="$(BOOTSTRAP_OMC)" + $(MAKE) -f $(defaultMakefileTarget) --no-print-directory -C $(TOP_DIR)/Compiler/Template OMC="$(BOOTSTRAP_OMC)" clean + $(MAKE) -f $(defaultMakefileTarget) --no-print-directory -C $(TOP_DIR)/Compiler/Script OMC="$(BOOTSTRAP_OMC)" clean + $(MAKE) -f $(defaultMakefileTarget) generate-files-in-steps OMC="$(BOOTSTRAP_OMC)" "OMC_EXTRA_FLAGS=$(OMC_EXTRA_FLAGS)" + $(MAKE) -f $(defaultMakefileTarget) install INCLUDESOURCES=1 OMC="$(BOOTSTRAP_OMC)" CPPFLAGS="$(CPPFLAGS) -DOMC_BOOTSTRAPPING_STAGE_1" @echo "Bootstrapping phase 3/3 completed" runtime-depends: @# NOTE: OpenModelicaBootstrappingHeader.h has to be regenerated without any other process writing to so/etc or you get bus errors - $(MAKE) -f $(defaultMakefileTarget) -C .. OpenModelicaBootstrappingHeader.h OMBUILDDIR=$(OMBUILDDIR) + $(MAKE) -f $(defaultMakefileTarget) -C .. OpenModelicaBootstrappingHeader.h OMBUILDDIR=$(OMBUILDDIR) OMC="$(OMC)" $(MAKE) -f $(defaultMakefileTarget) parser compilerruntime parser: $(MAKE) -f $(defaultMakefileTarget) -C ../../Parser install OMBUILDDIR=$(OMBUILDDIR) diff --git a/Compiler/runtime/Makefile.common b/Compiler/runtime/Makefile.common index 83a8b39db94..7514d1a2f3e 100644 --- a/Compiler/runtime/Makefile.common +++ b/Compiler/runtime/Makefile.common @@ -22,9 +22,9 @@ endif OMC_OBJ_BOOT = Dynload_omc$(OBJEXT) Error_omc$(OBJEXT) FMI_omc$(OBJEXT) \ GraphStreamExt_omc$(OBJEXT) HpcOmSchedulerExt_omc$(OBJEXT) HpcOmBenchmarkExt_omc$(OBJEXT) \ ptolemyio_omc$(OBJEXT) SimulationResults_omc$(OBJEXT) System_omc$(OBJEXT) \ - TaskGraphResults_omc$(OBJEXT) + TaskGraphResults_omc$(OBJEXT) Settings_omc$(OBJEXT) -OMC_OBJ = $(OMC_OBJ_BOOT) Print_omc.o Settings_omc.o serializer.o \ +OMC_OBJ = $(OMC_OBJ_BOOT) Print_omc.o serializer.o \ IOStreamExt_omc.o ErrorMessage.o systemimplmisc.o \ UnitParserExt_omc.o unitparser.o BackendDAEEXT_omc.o Socket_omc.o matching.o matching_cheap.o \ Lapack_omc.o getMemorySize.o $(OMCCORBASRC) @@ -59,11 +59,11 @@ libomcruntime-boot.a : $(OMC_OBJ) libomcruntime.dylib : $(OMC_OBJ) rm -f $@ - $(CXX) -shared $(RPATH) -install_name @rpath/$@ -o $@ $(OMC_OBJ) $(LDFLAGS) + $(CXX) -shared $(RPATH) -install_name @rpath/$@ -o $@ $(OMC_OBJ) $(LDFLAGS) $(CXXFLAGS) libomcruntime-boot.dylib : $(OMC_OBJ) rm -f $@ - $(CXX) -shared $(RPATH) -install_name @rpath/$@ -o $@ $(OMC_OBJ) $(LDFLAGS) + $(CXX) -shared $(RPATH) -install_name `pwd`/$@ -o $@ $(OMC_OBJ) $(LDFLAGS) $(CXXFLAGS) libomcruntime.so : $(OMC_OBJ) rm -f $@ @@ -78,7 +78,6 @@ omc_communication.cc : omc_communication.idl omc_communication.h: omc_communication.cc Print_omc.o : printimpl.c printimpl.h -Settings_omc.o : settingsimpl.c omc_config.h $(configUnix) omc_communication_impl.o: omc_communication.h Corba_omc.o: omc_communication.h corbaimpl.cpp Database_omc.o: Database.c Database_omc.c @@ -101,6 +100,7 @@ HpcOmSchedulerExt_omc$(OBJEXT) : TaskGraphResultsCmp.h HpcOmSchedulerExt.cpp $(B ptolemyio_omc$(OBJEXT) : ptolemyio.cpp errorext.h $(RML_COMPAT) $(BOOTH) FMI_omc$(OBJEXT) : FMIImpl.c $(BOOTH) GraphStreamExt_omc$(OBJEXT) : $(BOOTH) GraphStreamExt_impl.cpp $(RML_COMPAT) +Settings_omc$(OBJEXT) : Settings_omc.cpp settingsimpl.c omc_config.h $(configUnix) $(BOOTH) %.boot.o: %.c $(CC) -c -o "$@" "$<" $(CFLAGS) $(CPPFLAGS) -I../boot/tarball-include/ diff --git a/Compiler/runtime/Makefile.in b/Compiler/runtime/Makefile.in index 318bf2b15dd..d3e0971c074 100644 --- a/Compiler/runtime/Makefile.in +++ b/Compiler/runtime/Makefile.in @@ -35,7 +35,7 @@ CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/SimulationRuntime/c -I$(top_builddir)/Si TRIPLE=@host_short@ SHREXT=@SHREXT@ RPATH=@RPATH@ -LDFLAGS = -L "$(builddir_lib)/$(TRIPLE)/omc/" -lOpenModelicaRuntimeC +LDFLAGS = -L "$(builddir_lib)/$(TRIPLE)/omc/" -lOpenModelicaRuntimeC @OMCRUNTIME_SHARED_LDFLAGS@ include Makefile.common diff --git a/Compiler/runtime/settingsimpl.c b/Compiler/runtime/settingsimpl.c index cf5e25add96..1cdc574aef3 100644 --- a/Compiler/runtime/settingsimpl.c +++ b/Compiler/runtime/settingsimpl.c @@ -34,6 +34,7 @@ #include #include #include "omc_config.h" +#include "OpenModelicaBootstrappingHeader.h" #if defined(_MSC_VER) || defined(__MINGW32__) #else @@ -59,7 +60,7 @@ extern char* _replace(char* source_str,char* search_str,char* replace_str); //De static char* winPath = NULL; -#if defined(linux) || defined(__APPLE_CC__) +#if !defined(OPENMODELICA_BOOTSTRAPPING_STAGE_1) && (defined(linux) || defined(__APPLE_CC__)) /* Helper function to strip /bin/... or /lib/... from the executable path of omc */ static void stripbinpath(char *omhome) { @@ -73,7 +74,11 @@ static void stripbinpath(char *omhome) #endif /* Do not free or modify the returned variable of getInstallationDirectoryPath. It's part of the environment! */ -#if defined(linux) +#if defined(OPENMODELICA_BOOTSTRAPPING_STAGE_1) +const char* SettingsImpl__getInstallationDirectoryPath(void) { + return CONFIG_DEFAULT_OPENMODELICAHOME; +} +#elif defined(linux) #include #include #include diff --git a/configure.ac b/configure.ac index 072de00ffcc..adb2cfb9945 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,7 @@ AC_SUBST(RT_LDFLAGS_GENERATED_CODE) AC_SUBST(RT_LDFLAGS_GENERATED_CODE_SIM) AC_SUBST(RT_LDFLAGS_GENERATED_CODE_SOURCE_FMU) AC_SUBST(RT_LDFLAGS_SHARED) +AC_SUBST(OMCRUNTIME_SHARED_LDFLAGS) AC_SUBST(SUNDIALS_LDFLAGS) AC_SUBST(IPOPT_LDFLAGS) AC_SUBST(IPOPT_CFLAGS) @@ -630,6 +631,7 @@ if test "$DARWIN" = "1"; then RT_LDFLAGS_GENERATED_CODE_SIM="$LDFLAGS -lSimulationRuntimeC $LD_LAPACK -lm -lomcgc" RT_LDFLAGS_GENERATED_CODE_SOURCE_FMU="$LDFLAGS $LD_LAPACK -lm$LD_NOUNDEFINED" RT_LDFLAGS_SHARED= + OMCRUNTIME_SHARED_LDFLAGS="$RT_LDFLAGS -Wl,-undefined -Wl,dynamic_lookup" LINK="cp -fr" RPATH="-Wl,-rpath,'@loader_path/../lib/$host_short/omc/'" RPATH_QMAKE="-Wl,-rpath,'@loader_path/../../../../lib/$host_short/omc',-rpath,'@loader_path/../../../../lib/',-rpath,'$PREFIX/lib/$host_short/omc',-rpath,'$PREFIX/lib/'"