forked from cxbrooks/fmusdk2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for MacOS and Linux for FMI-1.0 only, ported from the fmusdk …
…git repo, based on mtiller's Linux port.
- Loading branch information
Showing
12 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
all: | ||
(cd src; $(MAKE)) | ||
|
||
clean: | ||
(cd src; $(MAKE) clean) | ||
|
||
distclean: clean | ||
rm -f bin/fmusim_cs* bin/fmusim_me* | ||
rm -rf fmu | ||
find . -name "*~" -exec rm {} \; | ||
find . -name "#*~" -exec rm {} \; |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
all: | ||
(cd src; $(MAKE)) | ||
|
||
clean: | ||
(cd src; $(MAKE) clean) | ||
|
||
distclean: clean | ||
rm -f bin/fmusim_cs* bin/fmusim_me* | ||
rm -rf fmu | ||
find . -name "*~" -exec rm {} \; | ||
find . -name "#*~" -exec rm {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# fmusim makefile for Mac OS X | ||
|
||
EXECS = \ | ||
fmusim_cs \ | ||
fmusim_me | ||
|
||
# Build simulators for co_simulation and model_exchange and then build the .fmu files. | ||
all: $(EXECS) | ||
(cd models; $(MAKE)) | ||
|
||
clean: | ||
rm -f $(EXECS) | ||
rm -rf *.dSYM | ||
rm -f cosimulation/fmusim_cs/*.o | ||
rm -f model_exchange/fmusim_me/*.o | ||
(cd models; $(MAKE) clean) | ||
|
||
# Sources shared between co-simulation and model exchange | ||
SHARED_SRCS = \ | ||
shared/sim_support.c \ | ||
shared/stack.c \ | ||
shared/xml_parser.c | ||
|
||
# Dependencies for only fmusim_cs | ||
CO_SIMULATION_DEPS = \ | ||
co_simulation/fmusim_cs/main.c \ | ||
co_simulation/fmusim_cs/fmi_cs.h \ | ||
co_simulation/include/fmiFunctions.h \ | ||
co_simulation/include/fmiPlatformTypes.h | ||
|
||
# Dependencies for only fmusim_me | ||
MODEL_EXCHANGE_DEPS = \ | ||
model_exchange/fmusim_me/main.c \ | ||
model_exchange/fmusim_me/fmi_me.h \ | ||
model_exchange/include/fmiModelFunctions.h \ | ||
model_exchange/include/fmiModelTypes.h | ||
|
||
# Dependencies shared between both fmusim_cs and fmusim_me | ||
SHARED_DEPS = \ | ||
shared/expat.h \ | ||
shared/expat_external.h \ | ||
shared/sim_support.c \ | ||
shared/sim_support.h \ | ||
shared/stack.c \ | ||
shared/stack.h \ | ||
shared/xml_parser.c \ | ||
shared/xml_parser.h | ||
|
||
# Set CFLAGS to -m32 to build for linux32 | ||
#CFLAGS=-m32 | ||
# See also models/build_fmu | ||
|
||
# Create the binaries in the current directory because co_simulation already has | ||
# a directory named "fmusim_cs" | ||
fmusim_cs: $(CO_SIMULATION_DEPS) $(SHARED_DEPS) | ||
$(CC) $(CFLAGS) -g -Wall -DFMI_COSIMULATION -Ico_simulation/fmusim_cs -Ico_simulation/include \ | ||
-Ishared \ | ||
co_simulation/fmusim_cs/main.c $(SHARED_SRCS) \ | ||
-o $@ -lexpat -ldl | ||
cp fmusim_cs ../bin | ||
|
||
fmusim_me: $(MODEL_EXCHANGE_DEPS) $(SHARED_DEPS) | ||
$(CC) $(CFLAGS) -g -Wall -Imodel_exchange/fmusim_me -Imodel_exchange/include -Ishared \ | ||
model_exchange/fmusim_me/main.c $(SHARED_SRCS) \ | ||
-o $@ -lexpat -ldl | ||
cp fmusim_me ../bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Build the .fmu files for both co-simulation and model-exchange. | ||
# | ||
# The build_fmu script calls make with the appropriate makefile variables set. | ||
|
||
# The architecture: linux32, linux64, darwin32, darwin64 | ||
ARCH = darwin64 | ||
|
||
# Either cs for co-simuluation or me for model exchange. | ||
CSORME = cs | ||
CSORME_INCLUDE = -DFMI_COSIMULATION -I../../co_simulation/include | ||
#CSORME = me | ||
#CSORME_INCLUDE = -I../../model_exchange/include | ||
|
||
# The suffix for shared libraries. | ||
# dylib for Mac OS X, so for Linux | ||
SHARED_LIBRARY_SUFFIX = dylib | ||
#SHARED_LIBRARY_SUFFIX = so | ||
|
||
# Empty for Mac OS X, -fPIC for Linux | ||
PIC = | ||
#PIC = -fPIC | ||
|
||
# Build the .fmu files for both co-simulation and model-exchange | ||
all: | ||
./build_fmu me bouncingBall | ||
./build_fmu me dq | ||
./build_fmu me inc | ||
./build_fmu me values | ||
./build_fmu me vanDerPol | ||
./build_fmu cs bouncingBall | ||
./build_fmu cs dq | ||
./build_fmu cs inc | ||
./build_fmu cs values | ||
./build_fmu cs vanDerPol | ||
|
||
# CBITSFLAGS is set to -m32 to build linux32 fmus | ||
|
||
%.o: %.c | ||
echo `pwd` | ||
$(CC) -g -c $(CBITSFLAGS) $(PIC) -Wall $(CSORME_INCLUDE) $(CFLAGS) $< -o $@ | ||
|
||
%.so: %.o | ||
$(CC) $(CBITSFLAGS) -shared -Wl,-soname,$@ -o $@ $< | ||
|
||
%.dylib: %.o | ||
$(CC) -dynamiclib -o $@ $< | ||
|
||
%.fmu: %.$(SHARED_LIBRARY_SUFFIX) | ||
rm -rf fmu | ||
mkdir -p fmu/binaries/$(ARCH) fmu/sources fmu/documentation | ||
cp $< fmu/binaries/$(ARCH) | ||
-cp *.c *.h fmu/sources | ||
-cp *.html *.png fmu/documentation | ||
cat modelDescription.xml ../$(CSORME).xml > fmu/modelDescription.xml | ||
cp model.png fmu | ||
@if [ ! -d ../../../fmu/$(CSORME) ]; then \ | ||
echo "mkdir -p ../../../fmu/$(CSORME)"; \ | ||
mkdir -p ../../../fmu/$(CSORME); \ | ||
fi | ||
(cd fmu; zip -q -r ../../../../fmu/$(CSORME)/$@ *) | ||
|
||
clean: | ||
(cd bouncingBall; make dirclean) | ||
(cd dq; make dirclean) | ||
(cd inc; make dirclean) | ||
(cd values; make dirclean) | ||
(cd vanDerPol; make dirclean) | ||
|
||
dirclean: | ||
rm -rf *.so *.dylib *.o *.fmu *~ fmu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CFLAGS = -I.. | ||
|
||
include ../Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/sh | ||
# Build a model exchange or co-simulation fmu | ||
# Usage: build_fmu cs|me directory | ||
|
||
if [ $# -ne 2 ]; then | ||
echo "Usage: $0 cs|me directory" | ||
exit 2 | ||
fi | ||
|
||
csOrMe=$1 | ||
directory=$2 | ||
|
||
# Error checking | ||
if [ "$csOrMe" != "me" -a "$csOrMe" != "cs" ]; then | ||
echo "$0: first argument must be either 'me' or 'cs', not $csOrMe" | ||
exit 3 | ||
fi | ||
|
||
if [ ! -d $directory ]; then | ||
echo "$0: directory $directory does not exist" | ||
exit 4 | ||
fi | ||
|
||
if [ "$csOrMe" = "cs" ]; then | ||
csOrMeInclude="-DFMI_COSIMULATION -I../../co_simulation/include" | ||
else | ||
csOrMeInclude=-I../../model_exchange/include | ||
fi | ||
|
||
case "`uname -s`" in | ||
CYGWIN*) arch=win | ||
sharedLibrarySuffix=dll;; | ||
Darwin) arch=darwin | ||
sharedLibrarySuffix=dylib;; | ||
Linux) arch=linux | ||
pic=-fPIC | ||
sharedLibrarySuffix=so;; | ||
esac | ||
|
||
# Number of bits, default to 64 | ||
bits=64 | ||
case "`uname -m`" in | ||
*64) bits=64;; | ||
*32) bits=32;; | ||
*i[3-6]86) bits=32;; | ||
esac | ||
|
||
# Uncomment the next line to force building 32-bit | ||
#bits=32 | ||
# See also ../Makefile | ||
|
||
if [ $arch = linux -a $bits = 32 ]; then | ||
CBITSFLAGS=-m32 | ||
fi | ||
|
||
set -x | ||
(cd $directory; \ | ||
make dirclean; \ | ||
make ARCH=${arch}${bits} CBITSFLAGS=${CBITSFLAGS} CSORME=${csOrMe} CSORME_INCLUDE="${csOrMeInclude}" PIC=${pic} SHARED_LIBRARY_SUFFIX=${sharedLibrarySuffix} $directory.fmu) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CFLAGS = -I.. | ||
|
||
include ../Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CFLAGS = -I.. | ||
|
||
include ../Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CFLAGS = -I.. | ||
|
||
include ../Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CFLAGS = -I.. | ||
|
||
include ../Makefile |