Browse Source

makefiles

Claudio Gomes 7 years ago
parent
commit
fb8966e016

+ 11 - 0
examples/mass_spring_damper/fmusdk/fmu10/Makefile

@@ -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 {} \;

+ 76 - 0
examples/mass_spring_damper/fmusdk/fmu10/src/Makefile

@@ -0,0 +1,76 @@
+# 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/*.o
+	rm -f model_exchange/*.o
+	(cd models; $(MAKE) clean)
+
+# Sources shared between co-simulation and model exchange
+SHARED_SRCS = \
+	shared/sim_support.c \
+	shared/xmlVersionParser.c \
+	shared/parser/stack.c \
+	shared/parser/xml_parser.c
+
+# Dependencies for only fmusim_cs
+CO_SIMULATION_DEPS = \
+	co_simulation/main.c \
+	co_simulation/fmi_cs.h \
+	shared/include/fmiFunctions.h \
+	shared/include/fmiPlatformTypes.h
+
+# Dependencies for only fmusim_me
+MODEL_EXCHANGE_DEPS = \
+	model_exchange/main.c \
+	model_exchange/fmi_me.h \
+	shared/include/fmiModelFunctions.h \
+	shared/include/fmiModelTypes.h
+
+# Dependencies shared between both fmusim_cs and fmusim_me
+SHARED_DEPS = \
+	shared/sim_support.c \
+	shared/sim_support.h \
+	shared/xmlVersionParser.c \
+	shared/xmlVersionParser.h \
+	shared/parser/expat.h \
+	shared/parser/expat_external.h \
+	shared/parser/stack.c \
+	shared/parser/stack.h \
+	shared/parser/xml_parser.c \
+	shared/parser/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) ../bin/
+	$(CC) $(CFLAGS) -g -Wall -DFMI_COSIMULATION -DSTANDALONE_XML_PARSER \
+		-Ico_simulation -Ishared/include -Ishared/parser -Ishared \
+		co_simulation/main.c $(SHARED_SRCS) \
+		-o $@ -lexpat -lxml2 -ldl
+	cp fmusim_cs ../bin/
+
+fmusim_me: $(MODEL_EXCHANGE_DEPS) $(SHARED_DEPS) ../bin/
+	$(CC) $(CFLAGS) -g -Wall -DSTANDALONE_XML_PARSER \
+		-Imodel_exchange -Ishared/include -Ishared/parser -Ishared \
+		model_exchange/main.c $(SHARED_SRCS) \
+		-o $@ -lexpat -lxml2 -ldl
+	cp fmusim_me ../bin/
+
+../bin/:
+	if [ ! -d ../bin ]; then \
+		echo "Creating ../bin/"; \
+		mkdir ../bin/; \
+	fi

+ 72 - 0
examples/mass_spring_damper/fmusdk/fmu10/src/models/Makefile

@@ -0,0 +1,72 @@
+# 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:
+	chmod 777 build_fmu
+	./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 fmu/sources
+	rsync -av --ignore-missing-args ./*.h ./fmu/sources
+	-cp *.html *.png fmu/documentation
+	cp modelDescription_$(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

+ 3 - 0
examples/mass_spring_damper/fmusdk/fmu10/src/models/bouncingBall/Makefile

@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile

+ 59 - 0
examples/mass_spring_damper/fmusdk/fmu10/src/models/build_fmu

@@ -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)

+ 3 - 0
examples/mass_spring_damper/fmusdk/fmu10/src/models/dq/Makefile

@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile

+ 3 - 0
examples/mass_spring_damper/fmusdk/fmu10/src/models/inc/Makefile

@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile

+ 3 - 0
examples/mass_spring_damper/fmusdk/fmu10/src/models/values/Makefile

@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile

+ 3 - 0
examples/mass_spring_damper/fmusdk/fmu10/src/models/vanDerPol/Makefile

@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile

+ 11 - 0
examples/mass_spring_damper/fmusdk/fmu20/Makefile

@@ -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 {} \;

+ 88 - 0
examples/mass_spring_damper/fmusdk/fmu20/src/Makefile

@@ -0,0 +1,88 @@
+# 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/*.o
+	rm -f model_exchange/*.o
+	(cd models; $(MAKE) clean)
+
+# Sources shared between co-simulation and model exchange
+SHARED_SRCS = \
+	shared/sim_support.c \
+	shared/xmlVersionParser.c
+
+CPP_SRCS = \
+	shared/parser/XmlElement.cpp \
+	shared/parser/XmlParser.cpp \
+	shared/parser/XmlParserCApi.cpp
+
+# Dependencies for only fmusim_cs
+CO_SIMULATION_DEPS = \
+	co_simulation/main.c
+
+# Dependencies for only fmusim_me
+MODEL_EXCHANGE_DEPS = \
+	model_exchange/main.c
+
+# Dependencies shared between both fmusim_cs and fmusim_me
+SHARED_DEPS = \
+	shared/sim_support.c \
+	shared/sim_support.h \
+	shared/xmlVersionParser.c \
+	shared/xmlVersionParser.h \
+	shared/fmi2.h \
+	shared/include/fmi2Functions.h \
+	shared/include/fmi2FunctionTypes.h \
+	shared/include/fmi2TypesPlatform.h \
+	shared/parser/fmu20/XmlElement.h \
+	shared/parser/fmu20/XmlParser.h \
+	shared/parser/fmu20/XmlParserException.h \
+	shared/parser/XmlParserCApi.h
+
+# Set CFLAGS to -m32 to build for linux32
+#CFLAGS=-m32
+# See also models/build_fmu
+
+CXX=c++
+# Create the binaries in the current directory because co_simulation already has
+# a directory named "fmusim_cs"
+fmusim_cs: $(CO_SIMULATION_DEPS) $(SHARED_DEPS) ../bin/
+	$(CC) $(CFLAGS) -g -Wall -DFMI_COSIMULATION \
+		-DSTANDALONE_XML_PARSER -DLIBXML_STATIC \
+		-Ishared/include -Ishared/parser -Ishared \
+		co_simulation/main.c $(SHARED_SRCS) \
+		-c
+	$(CXX) $(CFLAGS) -g -Wall -DFMI_COSIMULATION \
+		-DSTANDALONE_XML_PARSER -DLIBXML_STATIC \
+		-Ishared/include -Ishared/parser -Ishared \
+		main.o sim_support.o xmlVersionParser.o $(CPP_SRCS) \
+		-o $@ -ldl -lxml2
+	cp fmusim_cs ../bin/
+
+fmusim_me: $(MODEL_EXCHANGE_DEPS) $(SHARED_DEPS) ../bin/
+	$(CC) $(CFLAGS) -g -Wall \
+		-DSTANDALONE_XML_PARSER -DLIBXML_STATIC \
+		-Ishared/include -Ishared/parser -Ishared \
+		model_exchange/main.c $(SHARED_SRCS) \
+		-c
+	$(CXX) $(CFLAGS) -g -Wall \
+		-DSTANDALONE_XML_PARSER -DLIBXML_STATIC \
+		-Ishared/include -Ishared/parser -Ishared \
+		main.o sim_support.o xmlVersionParser.o $(CPP_SRCS) \
+		-o $@ -ldl -lxml2
+	cp fmusim_me ../bin/
+
+../bin/:
+	if [ ! -d ../bin ]; then \
+		echo "Creating ../bin/"; \
+		mkdir ../bin/; \
+	fi

+ 72 - 0
examples/mass_spring_damper/fmusdk/fmu20/src/models/Makefile

@@ -0,0 +1,72 @@
+# 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
+INCLUDE = -I../../co_simulation/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:
+	chmod 777 build_fmu
+	./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 $(INCLUDE) $(CFLAGS) $< -o $@
+
+# Under Linux, compile with -fvisibility=hidden, see
+# https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html
+%.so: %.o
+	$(CC) $(CBITSFLAGS) -fvisibility=hidden -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 fmu/sources
+	rsync -av --ignore-missing-args ./*.h ./fmu/sources
+	-cp *.html *.png fmu/documentation
+	cp modelDescription_$(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

+ 3 - 0
examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/Makefile

@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile

+ 55 - 0
examples/mass_spring_damper/fmusdk/fmu20/src/models/build_fmu

@@ -0,0 +1,55 @@
+#!/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
+
+include="-DDISABLE_PREFIX -I../../shared/include"
+
+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} INCLUDE="${include}" PIC=${pic} SHARED_LIBRARY_SUFFIX=${sharedLibrarySuffix} $directory.fmu)

+ 3 - 0
examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/Makefile

@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile

+ 3 - 0
examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/Makefile

@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile

+ 3 - 0
examples/mass_spring_damper/fmusdk/fmu20/src/models/values/Makefile

@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile

+ 3 - 0
examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/Makefile

@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile