Skip to content

Commit

Permalink
Fix compilation using different build directory
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed May 5, 2015
1 parent 521fee1 commit c422bf0
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 49 deletions.
15 changes: 8 additions & 7 deletions Compiler/Makefile.in
Expand Up @@ -7,10 +7,11 @@
#

srcdir= .
top_builddir= ..
builddir_bin=$(top_builddir)/build/bin
builddir_lib=$(top_builddir)/build/lib/omc/
builddir_scripts=$(top_builddir)/build/share/omc/scripts
top_srcdir= @top_srcdir@
OMBUILDDIR= @OMBUILDDIR@
builddir_bin=$(OMBUILDDIR)/bin
builddir_lib=$(OMBUILDDIR)/lib/omc/
builddir_scripts=$(OMBUILDDIR)/share/omc/scripts

ANTLR_HOME = @antlrhome@
EXEEXT = @EXEEXT@
Expand Down Expand Up @@ -45,8 +46,8 @@ debug: dinstall
release: install

install_scripts:
cd scripts; cp $(SCRIPT_FILES) ../$(builddir_scripts)
cp OpenModelicaBootstrappingHeader.h $(top_builddir)/build/include/omc/c/
cd scripts; cp $(SCRIPT_FILES) $(builddir_scripts)
cp OpenModelicaBootstrappingHeader.h $(OMBUILDDIR)/include/omc/c/

install: install_scripts

Expand Down Expand Up @@ -85,4 +86,4 @@ builtin:
.PRECIOUS: Makefile

Makefile: Makefile.in
cd $(top_builddir); ./config.status
cd $(top_srcdir) && ./config.status
13 changes: 6 additions & 7 deletions Compiler/runtime/Makefile.common
Expand Up @@ -4,13 +4,12 @@
# $Id$
#

srcdir=../
top_builddir= ../..
builddir_bin=$(top_builddir)/build/bin
builddir_lib=$(top_builddir)/build/lib
builddir_inc=$(top_builddir)/build/include
builddir_doc=$(top_builddir)/build/doc
builddir_share=$(top_builddir)/build/share
top_builddir=../..
builddir_bin=$(OMBUILDDIR)/bin
builddir_lib=$(OMBUILDDIR)/lib
builddir_inc=$(OMBUILDDIR)/include
builddir_doc=$(OMBUILDDIR)/doc
builddir_share=$(OMBUILDDIR)/share

SimRuntimeCDir = $(top_builddir)/SimulationRuntime/c/util/

Expand Down
5 changes: 3 additions & 2 deletions Compiler/runtime/Makefile.in
Expand Up @@ -12,6 +12,7 @@ GRAPHSTREAMINCLUDE = ../../3rdParty/graphstream/gs-netstream/c++/src/
CJSONINCLUDE = ../../3rdParty/cJSON
CFLAGS = @CFLAGS@ $(USE_CORBA)
OMPCC = @OMPCC@
OMBUILDDIR = @OMBUILDDIR@

ifdef USE_CORBA
CORBAINCL = @CORBACFLAGS@
Expand All @@ -29,7 +30,7 @@ CXX = @CXX@
IDL = @IDLCMD@
IDLPYTHON = @IDLPYTHONCMD@
CXXFLAGS = $(CFLAGS)
CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/SimulationRuntime/c -I$(top_builddir)/SimulationRuntime/c/simulation/results -I$(top_builddir)/SimulationRuntime/c/util -I$(top_builddir)/SimulationRuntime/c/meta -I$(top_builddir)/SimulationRuntime/c/meta/gc -I$(srcdir) -I. $(CORBAINCL) -I$(FMIINCLUDE) -I$(top_builddir)/3rdParty/gc/include -I$(GRAPHSTREAMINCLUDE) -I$(GRAPHINCLUDE) -I$(CJSONINCLUDE)
CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/SimulationRuntime/c -I$(top_builddir)/SimulationRuntime/c/simulation/results -I$(top_builddir)/SimulationRuntime/c/util -I$(top_builddir)/SimulationRuntime/c/meta -I$(top_builddir)/SimulationRuntime/c/meta/gc -I.. -I. $(CORBAINCL) -I$(FMIINCLUDE) -I$(top_builddir)/3rdParty/gc/include -I$(GRAPHSTREAMINCLUDE) -I$(GRAPHINCLUDE) -I$(CJSONINCLUDE)
TRIPLE=@host_short@

include Makefile.common
Expand All @@ -38,4 +39,4 @@ config.unix.h: config.unix.h.in
cd $(top_builddir) && ./config.status

Makefile: Makefile.in
cd $(top_builddir) && ./config.status
cd @top_builddir@ && ./config.status
1 change: 1 addition & 0 deletions Compiler/runtime/Makefile.omdev.mingw
Expand Up @@ -23,6 +23,7 @@ FMIINCLUDE = ../../3rdParty/FMIL/install/include
GRAPHINCLUDE=../../3rdParty/metis-5.1.0/include
GRAPHSTREAMINCLUDE = ../../3rdParty/graphstream/gs-netstream/c++/src/
CJSONINCLUDE = ../../3rdParty/cJSON/
OMBUILDDIR = ../../build

OMPCC = gcc -fopenmp

Expand Down
8 changes: 4 additions & 4 deletions Makefile.common
Expand Up @@ -377,17 +377,17 @@ msgpack-clean:
test ! -f 3rdParty/msgpack-0.5.8/Makefile || $(MAKE) -C 3rdParty/msgpack-0.5.8 distclean || true
rm -f 3rdParty/msgpack-0.5.8/Makefile

graphstream: mkbuilddirs build/share/omc/java/org.omc.graphstream.jar
graphstream: mkbuilddirs $(OMBUILDDIR)/share/omc/java/org.omc.graphstream.jar
if test -f 3rdParty/graphstream/Makefile; then $(MAKE) CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" -C 3rdParty/graphstream/; fi

build/share/omc/java/org.omc.graphstream.jar: mkbuilddirs
if test -f 3rdParty/graphstream/org.omc.graphstream.jar; then cp -p 3rdParty/graphstream/org.omc.graphstream.jar build/share/omc/java/.; fi
$(OMBUILDDIR)/share/omc/java/org.omc.graphstream.jar: mkbuilddirs
if test -f 3rdParty/graphstream/org.omc.graphstream.jar; then cp -p 3rdParty/graphstream/org.omc.graphstream.jar $(OMBUILDDIR)/share/omc/java/.; fi

graphstream-clean:
if test -f 3rdParty/graphstream/Makefile; then $(MAKE) -C 3rdParty/graphstream/ clean; fi

sanity-check: omc
build/bin/omc Examples/SanityCheck.mos
$(OMBUILDDIR)/bin/omc Examples/SanityCheck.mos

MODELICAEXTERNALC=3rdParty/ModelicaExternalC
ModelicaExternalC: $(LIBMODELICAEXTERNALC) $(LIBMODELICASTANDARDTABLES)
Expand Down
14 changes: 7 additions & 7 deletions Makefile.in
Expand Up @@ -69,9 +69,9 @@ settings:
omc: omc-bootstrapped

boehm-gc-lib: @LIBGC@
build/$(LIB_OMC)/libomcgc.so: 3rdParty/gc/.libs/libomcgc.so
mkdir -p build/$(LIB_OMC)
cp -pPR $< $<.* build/$(LIB_OMC)/
$(OMBUILDDIR)/$(LIB_OMC)/libomcgc.so: 3rdParty/gc/.libs/libomcgc.so
mkdir -p $(OMBUILDDIR)/$(LIB_OMC)
cp -pPR $< $<.* $(OMBUILDDIR)/$(LIB_OMC)/
3rdParty/gc/.libs/libomcgc.so: 3rdParty/gc/Makefile
$(MAKE) -C 3rdParty/gc/ libomcgc.la

Expand Down Expand Up @@ -117,10 +117,10 @@ lis: lis-configure mkbuilddirs
@echo Building Lis from sources
$(MAKE) -C 3rdParty/lis-1.4.12/src
# Copy the library; not headers (as they are not used by the runtime system)
cp -Pp 3rdParty/lis-1.4.12/src/.libs/liblis@SHREXT@* build/$(LIB_OMC)/
cp -Pp 3rdParty/lis-1.4.12/src/.libs/liblis@SHREXT@* $(OMBUILDDIR)/$(LIB_OMC)/
@# FreeBSD lis does not create the symlinks...
! test -f build/lib/omc/liblis.so.0.0 -a ! -f build/lib/omc/liblis.so.0 || ln -s liblis.so.0.0 build/lib/omc/liblis.so.0
! test -f build/lib/omc/liblis.so.0.0 -a ! -f build/lib/omc/liblis.so || ln -s liblis.so.0.0 build/lib/omc/liblis.so
! test -f build/lib/omc/liblis.so.0.0 -a ! -f $(OMBUILDDIR)/lib/omc/liblis.so.0 || ln -s liblis.so.0.0 $(OMBUILDDIR)/lib/omc/liblis.so.0
! test -f build/lib/omc/liblis.so.0.0 -a ! -f $(OMBUILDDIR)/lib/omc/liblis.so || ln -s liblis.so.0.0 $(OMBUILDDIR)/lib/omc/liblis.so
lis-configure:
# Configure and build lis
if ! test -f 3rdParty/lis-1.4.12/Makefile; then cd 3rdParty/lis-1.4.12 && autoconf && ./configure "--host=$(host)" --enable-shared --disable-static MPICC="false" CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS) @LIS_LDFLAGS@" && $(MAKE) clean; fi
Expand Down Expand Up @@ -174,7 +174,7 @@ utf8-iconv:
.PRECIOUS: Makefile

Makefile: Makefile.in config.status
$(top_builddir)/config.status
./config.status

config.status: configure
./config.status -recheck
Expand Down
6 changes: 3 additions & 3 deletions Parser/Makefile.common
Expand Up @@ -12,9 +12,9 @@ BUILDINC = -I../Compiler/runtime -I../SimulationRuntime/c/meta -I../SimulationRu
all: install

install: $(ANTLR_LIB) libomparse.a
mkdir -p ../build/include/$(host_short)/omc/antlr3
cp $(ANTLR)/antlr3config.h $(ANTLR)/include/*.h ../build/include/$(host_short)/omc/antlr3
cp $(ANTLR_LIB) libomparse.a ../build/$(LIB_OMC)/
mkdir -p $(OMBUILDDIR)/include/$(host_short)/omc/antlr3
cp $(ANTLR)/antlr3config.h $(ANTLR)/include/*.h $(OMBUILDDIR)/include/$(host_short)/omc/antlr3
cp $(ANTLR_LIB) libomparse.a $(OMBUILDDIR)/$(LIB_OMC)/

$(ANTLR)/antlr3config.h: $(ANTLR)/antlr3config.h.in $(ANTLR)/configure
(cd $(ANTLR) && ./configure $(ANTLR64) $(ANTLRDEBUG) $(host) CC="$(CC)" LDFLAGS="" CFLAGS="" CPPFLAGS="")
Expand Down
3 changes: 2 additions & 1 deletion Parser/Makefile.in
Expand Up @@ -16,6 +16,7 @@ LIB_OMC=lib/@host_short@/omc
ANTLR_LIB=libomantlr3@SHREXT@
include Makefile.common
LDFLAGS=@RPATH@
OMBUILDDIR=@OMBUILDDIR@

Makefile: Makefile.in
(cd ..; ./config.status)
(cd @top_srcdir@; ./config.status)
2 changes: 1 addition & 1 deletion SimulationRuntime/c/Makefile.common
Expand Up @@ -8,7 +8,7 @@ include Makefile.objs

OMC_MINIMAL_RUNTIME=

CPPFLAGS = -I. -I$(top_builddir)/Compiler/runtime -I$(top_builddir)/3rdParty/gc/include -I$(top_builddir)/3rdParty/FMIL/install/include/ -I$(top_builddir)/3rdParty/lis-1.4.12/include/ -I$(top_builddir)/3rdParty/Ipopt/include/ $(CONFIG_CPPFLAGS) -DGC_REDIRECT_TO_LOCAL
CPPFLAGS = -I. -I$(top_builddir)/Compiler/runtime -I$(top_builddir)/3rdParty/gc/include -I$(top_builddir)/3rdParty/FMIL/install/include/ -I$(top_builddir)/3rdParty/lis-1.4.12/include/ -I$(top_builddir)/3rdParty/Ipopt/include/ $(CONFIG_CPPFLAGS) -DGC_REDIRECT_TO_LOCAL -I$(builddir_inc)/c
override CFLAGS += $(CPPFLAGS) $(CONFIG_CFLAGS) $(EXTRA_CFLAGS)

ifeq ($(OMC_MINIMAL_RUNTIME),)
Expand Down
4 changes: 2 additions & 2 deletions SimulationRuntime/c/simulation/solver/linearSolverUmfpack.h
Expand Up @@ -39,8 +39,8 @@

#include "simulation_data.h"

#include "../../../../build/include/omc/c/suitesparse/Include/umfpack.h"
#include "../../../../build/include/omc/c/suitesparse/Include/umfpack_get_numeric.h"
#include "suitesparse/Include/umfpack.h"
#include "suitesparse/Include/umfpack_get_numeric.h"

typedef struct DATA_UMFPACK
{
Expand Down
6 changes: 6 additions & 0 deletions SimulationRuntime/c/util/java_interface/Makefile
@@ -1,3 +1,6 @@
OMBUILDDIR = /home/marsj/OpenModelica/build
top_builddir = ../../../..

include Makefile.common

modelica_java.jar: $(java_sources)
Expand All @@ -9,3 +12,6 @@ test: $(java_sources)
rm -rf bin-test; mkdir bin-test
@"$(JAVAC)" -source 5 -cp "$(antlr):$(junit)" -d bin-test $(java_sources) $(java_tests)
OPENMODELICAHOME=$(OPENMODELICAHOME) $(JAVA) -cp "bin-test:src:$(antlr):$(junit)" org.junit.runner.JUnitCore $(junit_tests)

Makefile: Makefile.in
(cd ../../../..; ./config.status)
9 changes: 4 additions & 5 deletions SimulationRuntime/c/util/java_interface/Makefile.common
Expand Up @@ -8,9 +8,8 @@ JAVA=java
JAR=jar
endif

OPENMODELICAHOME=$(shell pwd)/../../../../build
antlr = $(OPENMODELICAHOME)/../3rdParty/antlr/3.2/tool/antlr-3.2.jar
antlr_depends = $(OPENMODELICAHOME)/../3rdParty/antlr/3.2/tool/antlr-2.7.7.jar
antlr = $(top_builddir)/3rdParty/antlr/3.2/tool/antlr-3.2.jar
antlr_depends = $(top_builddir)/3rdParty/antlr/3.2/tool/antlr-2.7.7.jar
licenses = antlr_license.txt
junit = junit-4.6.jar

Expand Down Expand Up @@ -117,9 +116,9 @@ clean:
$(antlr_compile) $<

install-nomodelica:
cp $(antlr) $(antlr_depends) ../../../../build/share/omc/java
cp $(antlr) $(antlr_depends) $(OMBUILDDIR)/share/omc/java
# Don't need these; we put them in the COPYING file instead
# cp $(licenses) ../../../../build/share/doc/omc
install: install-nomodelica
cp modelica_java.jar ../../../../build/share/omc/java
cp modelica_java.jar $(OMBUILDDIR)/share/omc/java

17 changes: 17 additions & 0 deletions SimulationRuntime/c/util/java_interface/Makefile.in
@@ -0,0 +1,17 @@
OMBUILDDIR = @OMBUILDDIR@
top_builddir = @top_builddir@

include Makefile.common

modelica_java.jar: $(java_sources)
@echo "* Compiling modelica_java.jar"
@rm -rf bin-jar; mkdir bin-jar
@"$(JAVAC)" -source 5 -cp "$(antlr)" -d bin-jar $(java_sources)
@$(JAR) cf modelica_java.jar $(java_sources:src/%=-C src %) $(resources:src/%=-C src %) -C bin-jar . || (rm $@ && false)
test: $(java_sources)
rm -rf bin-test; mkdir bin-test
@"$(JAVAC)" -source 5 -cp "$(antlr):$(junit)" -d bin-test $(java_sources) $(java_tests)
OPENMODELICAHOME=$(OPENMODELICAHOME) $(JAVA) -cp "bin-test:src:$(antlr):$(junit)" org.junit.runner.JUnitCore $(junit_tests)

Makefile: Makefile.in
(cd @top_builddir@; ./config.status)
3 changes: 3 additions & 0 deletions SimulationRuntime/c/util/java_interface/Makefile.omdev.mingw
@@ -1,3 +1,6 @@
OMBUILDDIR = ../../../../build
top_builddir = ../../../../

include Makefile.common

modelica_java.jar: $(java_sources)
Expand Down
20 changes: 10 additions & 10 deletions configure.ac
Expand Up @@ -228,12 +228,12 @@ if test "$OMC" = "no" ; then
AC_MSG_ERROR([cross-compilation attempt detected, but no omc executable was given])
fi
AC_MSG_RESULT([building it through bootstrapping (you might end up unable to recompile omc if you modify source code)])
OMC="$ac_pwd$ac_dir_suffix/build/bin/omc"
OMC="$ac_pwd$ac_dir_suffix/$OMBUILDDIR/bin/omc"
elif "$OMC" +version > /dev/null 2>&1; then
AC_MSG_RESULT([$OMC])
else
AC_MSG_RESULT([failed (tried $OMC). Building it through bootstrapping (you might end up unable to recompile omc if you modify source code).])
OMC="$ac_pwd$ac_dir_suffix/build/bin/omc"
OMC="$ac_pwd$ac_dir_suffix/$OMBUILDDIR/bin/omc"
fi

dnl Checks for libraries.
Expand Down Expand Up @@ -269,16 +269,15 @@ AC_CHECK_HEADERS(sys/time.h, [], [AC_MSG_ERROR(Missing header files)])
# AC_CHECK_HEADERS(sqlite3.h, [], [AC_MSG_ERROR(Missing header files)])

AC_MSG_CHECKING([for antlr.Tool support])
omc_antlr_jar=build/share/omc/java/antlr-3.1.3.jar
mkdir -p build/share/omc/java
cp "3rdParty/antlr/3.2/tool/antlr-3.2.jar" "3rdParty/antlr/3.2/tool/antlr-2.7.7.jar" build/share/omc/java/
mkdir -p $OMBUILDDIR/share/omc/java
cp "3rdParty/antlr/3.2/tool/antlr-3.2.jar" "3rdParty/antlr/3.2/tool/antlr-2.7.7.jar" $OMBUILDDIR/share/omc/java/
echo "" > $$grammar.g
if java -cp build/share/omc/java/antlr-3.2.jar antlr.Tool $$grammar.g ; then
if java -cp $OMBUILDDIR/share/omc/java/antlr-3.2.jar antlr.Tool $$grammar.g ; then
rm -f $$grammar.g
AC_MSG_RESULT([yes])
else
rm -f $$grammar.g
AC_MSG_ERROR([no antlr.Tool support])
AC_MSG_ERROR([no antlr.Tool support (JRE not working)])
fi

AC_MSG_CHECKING([if the user wants to compile OMShell-terminal])
Expand Down Expand Up @@ -624,7 +623,7 @@ if test "$DARWIN" = "1"; then
APP=".app"
EXE=".app"
SHREXT=".dylib"
LIBGC="build/lib/$host_short/omc/libomcgc.a"
LIBGC="$OMBUILDDIR/lib/$host_short/omc/libomcgc.a"
LIBSIMULATION=libSimulationRuntimeC.dylib
LIBRUNTIME=libOpenModelicaRuntimeC.dylib
LIBFMIRUNTIME=libOpenModelicaFMIRuntimeC.dylib
Expand Down Expand Up @@ -653,7 +652,7 @@ elif test "$host" = "i586-pc-mingw32msvc"; then
EXE=".exe"
# Yes, we build static libs on Windows, so the "shared" extension is .a
SHREXT=".a"
LIBGC="build/lib/$host_short/omc/libomcgc.a"
LIBGC="$OMBUILDDIR/lib/$host_short/omc/libomcgc.a"
LIBSIMULATION=libSimulationRuntimeC.a
LIBRUNTIME=libOpenModelicaRuntimeC.a
LIBFMIRUNTIME=libOpenModelicaFMIRuntimeC.a
Expand All @@ -678,7 +677,7 @@ else
APP=""
EXE=""
SHREXT=".so"
LIBGC="build/lib/$host_short/omc/libomcgc.so"
LIBGC="$OMBUILDDIR/lib/$host_short/omc/libomcgc.so"
LIBSIMULATION=libSimulationRuntimeC.so
LIBRUNTIME=libOpenModelicaRuntimeC.so
LIBFMIRUNTIME=libOpenModelicaFMIRuntimeC.so
Expand Down Expand Up @@ -800,6 +799,7 @@ Compiler/runtime/Makefile \
Compiler/runtime/config.unix.h \
Parser/Makefile \
SimulationRuntime/c/Makefile \
SimulationRuntime/c/util/java_interface/Makefile \
SimulationRuntime/cpp/Makefile \
SimulationRuntime/ParModelica/Makefile \
SimulationRuntime/ParModelica/auto/Makefile \
Expand Down

0 comments on commit c422bf0

Please sign in to comment.