Skip to content

Commit

Permalink
Fix compilation on OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Apr 15, 2016
1 parent 9b56b3c commit 7265334
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
20 changes: 10 additions & 10 deletions Compiler/boot/Makefile.common
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions Compiler/runtime/Makefile.common
Expand Up @@ -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)
Expand Down Expand Up @@ -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 $@
Expand All @@ -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
Expand All @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion Compiler/runtime/Makefile.in
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions Compiler/runtime/settingsimpl.c
Expand Up @@ -34,6 +34,7 @@
#include <string.h>
#include <assert.h>
#include "omc_config.h"
#include "OpenModelicaBootstrappingHeader.h"

#if defined(_MSC_VER) || defined(__MINGW32__)
#else
Expand All @@ -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)
{
Expand All @@ -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 <sys/stat.h>
#include <linux/limits.h>
#include <unistd.h>
Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Expand Up @@ -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)
Expand Down Expand Up @@ -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/'"
Expand Down

0 comments on commit 7265334

Please sign in to comment.