From ae091164bc64ebe2a6bc1c51c772948288138193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sj=C3=B6lund?= Date: Sun, 20 Sep 2026 15:35:34 +0200 Subject: [PATCH] Build the deb and rpm packages with CMake The Autoconf build is on its way out, so `debian/rules` and the RPM spec now configure, build and install with CMake. The binary packages and their names are unchanged; what moved between them is forced by the CMake install layout. `debian/rules` also loses the cross-compile bootstrap -- Jenkins builds armhf and arm64 natively on arm docker nodes, and CMake has no equivalent of `--with-omc` -- and passes `DEB_HOST_MULTIARCH` to `dh_shlibdeps`, which is what CMake names the libdir after. Two things the packaging has to do for CMake. It writes `OMVERSION.txt` from `REVISION`, because the source tarball carries no git and the packages would otherwise be built as version 0.1.1 and never upgrade. And it runs `libraries/install-index.mos` itself, because the `omlibrary` target downloads with `/bin/omc`, which during a `DESTDIR` build is not the `omc` just staged. `OM_RUST_RESULT_READERS`, `OM_RUST_RESULT_WRITERS` and `OM_ENABLE_RUST_SIM_RUNTIME` are on. The build-deps images install a stable Rust toolchain with rustup, so there is nothing to add to `Build-Depends` or `BuildRequires`. Contents that moved: | Package | Change | | ------------------ | ----------------------------------- | | `omc-common` | + gc headers, + `share/omc/sources` | | `libomcsimulation` | + `libomc_result`, - opcua, - ryu | | `omedit` | + the bundled language server | | `libomplot` | + `Depends: libomcsimulation` | | `libomc-dev` | dropped, no files left to ship | | `libomplot-dev` | dropped, no files left to ship | The gc headers are the one that would have broken every model build: generated code includes ``, and CMake installs it in `include/omc` rather than `include/omc/c`. `libomc_result` and `libSimulationRuntimeRust` are new, and OMPlotLib links the former, hence the `libomplot` dependency. OPC-UA and ryu are not installed by the CMake build at all; `opc/` is commented out of SimulationRuntime. Dead targets removed while here: i386, of which `libomccpp` held the last reference, and the EL6/EL7 blocks in the spec, including cmake3 and devtoolset-11. The RPM targets are el8, el9, el10, fc43 and fc44. Assisted-by: Claude Opus 5 (1M context) --- .github/workflows/build-deb.yml | 6 +- README.md | 21 ++--- debian/control | 40 ++------ debian/libomc-dev.install | 4 - debian/libomc.install | 4 - debian/libomcsimulation.install | 5 +- debian/libomplot-dev.install | 1 - debian/omc-common.install | 4 + debian/omedit.install | 1 + debian/omnotebook.install | 1 - debian/omshell.install | 2 - debian/rules | 160 ++++++++++---------------------- rpm/SPECS/openmodelica.spec.tpl | 102 ++++++++------------ 13 files changed, 113 insertions(+), 238 deletions(-) delete mode 100644 debian/libomc-dev.install delete mode 100644 debian/libomplot-dev.install diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index a82756c..80cab9d 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -1,13 +1,11 @@ # Full build of OpenModelica plus the Debian packages, the way the nightly -# Jenkins job does it: configure/make (autoconf) from a git checkout, then -# dpkg-buildpackage using the debian/ directory of this repository. +# Jenkins job does it: a CMake build from a git checkout, then dpkg-buildpackage +# using the debian/ directory of this repository. # # This is the only job that can catch a .install glob that stopped matching # because upstream moved or dropped a file -- the failure that breaks the # nightly build. It compiles all of OpenModelica, so it takes hours. The fast # metadata-only checks live in packaging.yml. -# -# Uses the Autoconf + Makefile build; to be switched to the CMake build later. name: full deb build on: diff --git a/README.md b/README.md index 7ca5ec6..da60b07 100644 --- a/README.md +++ b/README.md @@ -51,18 +51,18 @@ jammy, noble, resolute and trixie on amd64, armhf and arm64. ### What is in `debian/` -* [`control`](./debian/control) — one source stanza and 20 binary packages (`omc`, +* [`control`](./debian/control) — one source stanza and 18 binary packages (`omc`, `libomc`, `omedit`, `omshell`, `omnotebook`, `omsimulator`, `omlibrary`, …). Some build dependencies carry alternatives (`libhdf5-serial-dev | libhdf5-dev`) because a single control file has to satisfy every distribution in the matrix. Note that `apt` installs the *first* alternative it can, so an alternative is not a way to say "either of these will do" — it only helps where the first one is unavailable. * [`rules`](./debian/rules) — a hand-written rules file, *not* the `dh` sequencer. It - configures and builds the tree itself and then calls each `dh_*` helper explicitly - from the `install` and `binary-arch` targets. There are no override targets; edit the - recipes directly. + configures and builds the tree itself — with CMake, into `obj-/` — and then + calls each `dh_*` helper explicitly from the `install` and `binary-arch` targets. + There are no override targets; edit the recipes directly. * `.install` — the file lists. Everything is installed into `debian/tmp` by - `make install DESTDIR=…` first, and these files distribute it into the binary + `cmake --install` with `DESTDIR` first, and these files distribute it into the binary packages. Paths are globs, e.g. `debian/tmp/usr/lib/*/omc/libOMSimulator.so`. * Desktop integration: [`desktops/`](./debian/desktops), [`icons/`](./debian/icons), @@ -161,11 +161,10 @@ the compat level in the control files changes. ### Full build — [`build-deb.yml`](./.github/workflows/build-deb.yml) -Builds OpenModelica from a git checkout with the Autoconf + Makefile build and then runs -`dpkg-buildpackage` against this repository's `debian/`, the same sequence Jenkins uses, -and uploads the resulting `.deb` files as an artifact. It is the only job that catches a -`.install` glob that stopped matching, and the only one that proves the `Build-Depends` -are still installable. +Builds OpenModelica from a git checkout and then runs `dpkg-buildpackage` against this +repository's `debian/`, the same sequence Jenkins uses, and uploads the resulting `.deb` +files as an artifact. It is the only job that catches a `.install` glob that stopped +matching, and the only one that proves the `Build-Depends` are still installable. It compiles everything, so it takes hours, and it never starts on its own. Run it on demand via `workflow_dispatch` (with an input to pick the OpenModelica ref), or put the @@ -174,8 +173,6 @@ request, and again on every push to it, until the label comes off. There is no s the nightly Jenkins build already catches an upstream move that broke an `.install` glob. Only on `ubuntu-latest` — Jenkins covers the rest of the matrix. -It uses the Autoconf + Makefile build; switching it to the CMake build is a later change. - > [!IMPORTANT] > What no CI here tells you: whether the packages build on the other distributions > in the matrix, or on armhf and arm64. That is still Jenkins' job. diff --git a/debian/control b/debian/control index 59c430d..13bb575 100644 --- a/debian/control +++ b/debian/control @@ -3,17 +3,14 @@ Section: math Priority: optional Maintainer: OpenModelica Build System Build-Depends: debhelper-compat (= 13), -# sbuild i386 does not handle native, cross-compile armhf requires it... - clang:native | clang, - gfortran:native | gfortran, - default-jdk:native | default-jdk, - libhwloc-dev:native | libhwloc-dev, - automake, - libtool, + clang, + gfortran, + default-jdk, + libhwloc-dev, uuid-dev, libncurses5-dev, libsqlite3-dev, - cmake (>= 2.8.6), + cmake (>= 3.14), # libssl-dev (>= 0.9.8g), # Do we really depend on libssl directly? Debian stretch conflicts with it... libreadline-dev, qt6-base-dev, @@ -42,7 +39,6 @@ Build-Depends: debhelper-compat (= 13), libhdf5-serial-dev | libhdf5-dev, liblapack-dev, libcurl4-gnutls-dev | libcurl-dev, - autoconf (>=2.71), libexpat1-dev, libomp-dev, # Should be needed but seems to mess up sbuild @@ -133,17 +129,6 @@ Depends: omc-common (<< 20000), Description: The OpenModelica Compiler lib dependencies This is the core libraries of the OpenModelica project. -Package: libomc-dev -Section: math -Multi-Arch: same -Architecture: any -Depends: libomc (<< 20000), - ${shlibs:Depends}, - ${misc:Depends} -Description: The OpenModelica Compiler lib dependencies - This is the core libraries of the OpenModelica project. - Currently contains antlr3 include-files. - Package: libomcsimulation Section: math Multi-Arch: same @@ -176,19 +161,10 @@ Package: libomplot Section: math Multi-Arch: same Architecture: any -Depends: ${shlibs:Depends}, - ${misc:Depends} -Description: Plot tool for OpenModelica, lib dependencies - This tool is essential for using the plot() command in omc. - -Package: libomplot-dev -Section: math -Multi-Arch: same -Architecture: any -Depends: libomplot (<< 20000), +Depends: libomcsimulation (<< 20000), ${shlibs:Depends}, ${misc:Depends} -Description: Plot tool for OpenModelica, development package +Description: Plot tool for OpenModelica, lib dependencies This tool is essential for using the plot() command in omc. Package: omedit @@ -262,7 +238,7 @@ Description: A text-based interface to OpenModelica (based on Qt) Package: libomccpp Section: math -Architecture: i386 amd64 +Architecture: amd64 Multi-Arch: same Depends: libboost-dev, libboost-filesystem-dev, diff --git a/debian/libomc-dev.install b/debian/libomc-dev.install deleted file mode 100644 index 15e6e2e..0000000 --- a/debian/libomc-dev.install +++ /dev/null @@ -1,4 +0,0 @@ -debian/tmp/usr/include/*/omc/antlr3 -# These are not really needed, but it is a dev-package, so let's add them anyway -# debian/tmp/usr/lib/*/omc/libomcruntime.a -debian/tmp/usr/lib/*/omc/libomparse.a diff --git a/debian/libomc.install b/debian/libomc.install index fd5cb21..5438c3f 100644 --- a/debian/libomc.install +++ b/debian/libomc.install @@ -1,11 +1,7 @@ debian/tmp/usr/lib/*/omc/libOpenModelicaCompiler.so debian/tmp/usr/lib/*/omc/libOpenModelicaRuntimeC* -debian/tmp/usr/lib/*/omc/lib*antlr3.so debian/tmp/usr/lib/*/omc/libomcruntime* debian/tmp/usr/lib/*/omc/libzmq* # The Modelica External shared libs. They are in omc/ffi/ folder debian/tmp/usr/lib/*/omc/ffi/* - -# These are not really needed -#debian/tmp/usr/lib/*/omc/libomparse.a diff --git a/debian/libomcsimulation.install b/debian/libomcsimulation.install index 25ad655..28e2bb5 100644 --- a/debian/libomcsimulation.install +++ b/debian/libomcsimulation.install @@ -15,6 +15,9 @@ debian/tmp/usr/include/omc/ModelicaExternalC/* debian/tmp/usr/lib/*/omc/libOpenModelicaFMIRuntimeC* debian/tmp/usr/lib/*/omc/libSimulationRuntime* +# Result files +debian/tmp/usr/lib/*/omc/libomc_result* + ## SuiteSparse debian/tmp/usr/lib/*/omc/lib*amd* debian/tmp/usr/lib/*/omc/libbtf* @@ -24,9 +27,7 @@ debian/tmp/usr/lib/*/omc/libumfpack* debian/tmp/usr/lib/*/omc/liblis* debian/tmp/usr/lib/*/omc/libcminpack* -debian/tmp/usr/lib/*/omc/libomopc* debian/tmp/usr/lib/*/omc/libsundials_* -debian/tmp/usr/lib/*/omc/libryu* ## MOO debian/tmp/usr/lib/*/omc/libseq* diff --git a/debian/libomplot-dev.install b/debian/libomplot-dev.install deleted file mode 100644 index 3fecbc0..0000000 --- a/debian/libomplot-dev.install +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/include/omplot/qwt diff --git a/debian/omc-common.install b/debian/omc-common.install index ada4b17..4e64154 100644 --- a/debian/omc-common.install +++ b/debian/omc-common.install @@ -1,5 +1,9 @@ debian/tmp/usr/share/omc/runtime +debian/tmp/usr/share/omc/sources debian/tmp/usr/lib/omc/*.mo debian/tmp/usr/include/omc/c +# openmodelica.h includes , which is not under include/omc/c +debian/tmp/usr/include/omc/gc.h +debian/tmp/usr/include/omc/gc debian/tmp/usr/include/omc/scripting-API debian/tmp/usr/include/omc/sundials diff --git a/debian/omedit.install b/debian/omedit.install index dd2b358..b629bac 100644 --- a/debian/omedit.install +++ b/debian/omedit.install @@ -2,3 +2,4 @@ debian/desktops/omedit.desktop usr/share/applications OMEdit/OMEditLIB/Resources/icons/omedit.png usr/share/pixmaps debian/tmp/usr/bin/OMEdit debian/tmp/usr/share/omedit/nls/* +debian/tmp/usr/share/omedit/ls diff --git a/debian/omnotebook.install b/debian/omnotebook.install index 93fa8c3..a15aa1a 100644 --- a/debian/omnotebook.install +++ b/debian/omnotebook.install @@ -1,5 +1,4 @@ debian/desktops/omnotebook.desktop usr/share/applications OMNotebook/OMNotebook/OMNotebookGUI/Resources/OMNotebook_icon.svg usr/share/pixmaps debian/tmp/usr/bin/OMNotebook -debian/tmp/usr/share/omnotebook/*.xml debian/tmp/usr/share/omnotebook/*.onb diff --git a/debian/omshell.install b/debian/omshell.install index d4829c6..ae49cae 100644 --- a/debian/omshell.install +++ b/debian/omshell.install @@ -1,5 +1,3 @@ debian/desktops/omshell.desktop usr/share/applications debian/tmp/usr/bin/OMShell -debian/tmp/usr/share/omshell/*.xml -debian/tmp/usr/share/omshell/nls/*.qm OMShell/OMShell/OMShellGUI/Resources/omshell-large.svg usr/share/pixmaps diff --git a/debian/rules b/debian/rules index a3e2254..144abba 100755 --- a/debian/rules +++ b/debian/rules @@ -6,140 +6,69 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -# These are used for cross-compiling and for saving the configure script -# from having to guess our platform (since we know it already) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) - -ARCH ?= $(shell uname -m | sed s/i[0-9]86/x86/) +DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) # since we updated the copyright in .g files we need to set UTF8 as otherwise ANTLR parser barks on {\"o} export LC_ALL = C.UTF-8 -# Some variables to install binaries under debian/tmp -DEST = $(CURDIR)/debian/tmp -SRCD = $(CURDIR) - -CLANGVER ?= $(shell clang --version | grep -o "clang version [0-9.]*" | cut "-d " -f3) - -# Try to compile with gcc rather than old gcc versions -ifeq (3.0,$(CLANGVER)) - -ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) - CC = gcc - CXX = g++ -else - CC = $(DEB_HOST_GNU_TYPE)-gcc - CXX = $(DEB_HOST_GNU_TYPE)-g++ -endif - -else - -ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) - CC = clang - CXX = clang++ - CONF_OPTS_CROSS = --without-omc - SANITY_CHECK = -C OMCompiler sanity-check -else - CC = clang -target $(DEB_HOST_GNU_TYPE) -# clang++ seems unable to find some bits stuff in C++ includes - CXX = $(DEB_HOST_GNU_TYPE)-g++ -# Even GCC needs special flags because libreadline seems messed up -# Readline needed this, but messes up other libraries: -Wl,--unresolved-symbols=ignore-all - LDFLAGS = -Wl,-rpath-link -Wl,/lib/$(DEB_HOST_GNU_TYPE) -Wl,-rpath-link -Wl,/usr/lib/$(DEB_HOST_GNU_TYPE) - NATIVE_CC = clang - NATIVE_CXX = clang++ - CONF_OPTS_CROSS = --with-omc="`pwd`/cross-build/bin/omc" - SANITY_CHECK = -endif +DEST = $(CURDIR)/debian/tmp +BUILD = $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE) -endif +CC = clang +CXX = clang++ ifeq (arm-linux-gnueabihf,$(DEB_HOST_GNU_TYPE)) - CONF_OPTS=--without-cppruntime - EXTRA_INSTALL= + CPP_RUNTIME = OFF else - CONF_OPTS=--with-cppruntime - EXTRA_INSTALL= + CPP_RUNTIME = ON endif +OPTFLAG = -Os ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -Os + OPTFLAG = -O0 endif -#ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) -# NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) -EXTRA_MAKEFLAGS = $(MAKEFLAGS) -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) $(shell make --version --output-sync=recurse > /dev/null 2>&1 && echo --output-sync=recurse) -#endif - -# march=pentium4 used to be enabled because omc required sse2 regardless -# ifeq (x86,$(ARCH)) -# CFLAGS += -march=pentium4 -# endif -ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) - INSTALL_PROGRAM += -s +PARALLEL = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) +ifneq (,$(PARALLEL)) + BUILDFLAGS = --parallel $(PARALLEL) endif -configure: configure.ac - autoreconf --install - build: build-stamp build-arch: build build-indep: build -build-stamp: configure +build-stamp: dh_testdir - # We might be cross-compiling. If so, we need a working omc. Easiest way? Build it ourselves. -ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) - ./configure CFLAGS="$(CFLAGS)" CC=$(NATIVE_CC) CXX=$(NATIVE_CXX) OMPCC="gcc -fopenmp" \ - --host=$(DEB_BUILD_GNU_TYPE) \ - --build=$(DEB_BUILD_GNU_TYPE) \ - --prefix=/usr \ - --without-METIS \ - --without-FMIL \ - --without-lapack \ - --without-paradiseo \ - --disable-omshell-terminal \ - --without-lpsolve \ - --without-ipopt \ - --with-cppruntime \ - --without-omlibrary \ - --disable-modelica3d \ - $(CONF_OPTS) - $(MAKE) $(EXTRA_MAKEFLAGS) -C OMCompiler omc-no-sim - mv build cross-build - $(MAKE) clean -endif - # Cross-compile done, now configure for real - # wily armhf requires -lm for blas... - ./configure CFLAGS="$(CFLAGS)" CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS)" OMPCC="gcc -fopenmp" \ - --host=$(DEB_HOST_GNU_TYPE) \ - --build=$(DEB_BUILD_GNU_TYPE) \ - --prefix=/usr \ - --with-qt6 \ - --with-lapack="-llapack -lblas -lm" \ - --without-paradiseo \ - --without-omlibrary \ - --disable-modelica3d \ - $(CONF_OPTS) $(CONF_OPTS_CROSS) - # Add here commands to configure the package. -# --with-static-sqlite=`test -f /usr/lib/*/libsqlite3.a && echo /usr/lib/*/libsqlite3.a || echo /usr/lib/libsqlite3.a` \ -# --with-static-lpsolve=/usr -# --with-static-readline=/usr - # Add here commands to compile the package. - $(MAKE) $(EXTRA_MAKEFLAGS) all - $(MAKE) omlibrary - test -z "$(SANITY_CHECK)" || $(MAKE) $(SANITY_CHECK) - # Skip the testsuite log. People can look it up on hudson + # No git in the tarball; REVISION is the same version in dpkg's spelling. + test -e OMVERSION.txt || test ! -e REVISION || sed -e 's,^,v,' -e 'y,~,-,' REVISION > OMVERSION.txt + cmake -S . -B $(BUILD) -Wno-dev \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER="$(CC)" \ + -DCMAKE_CXX_COMPILER="$(CXX)" \ + -DCMAKE_C_FLAGS_RELEASE="$(OPTFLAG) -DNDEBUG" \ + -DCMAKE_CXX_FLAGS_RELEASE="$(OPTFLAG) -DNDEBUG" \ + -DOM_USE_CCACHE=OFF \ + -DOM_ENABLE_TESTSUITE=OFF \ + -DOM_ENABLE_DOCS=OFF \ + -DOM_ENABLE_GUI_CLIENTS=ON \ + -DOM_QT_MAJOR_VERSION=6 \ + -DOM_ENABLE_OMSIMULATOR=ON \ + -DOM_OMC_ENABLE_CPP_RUNTIME=$(CPP_RUNTIME) \ + -DOM_OMOPTIM_ENABLE=OFF \ + -DOM_RUST_RESULT_READERS=ON \ + -DOM_RUST_RESULT_WRITERS=ON \ + -DOM_ENABLE_RUST_SIM_RUNTIME=ON + cmake --build $(BUILD) $(BUILDFLAGS) touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp - # Add here commands to clean up after the build process. + rm -rf $(BUILD) + test ! -e REVISION || rm -f OMVERSION.txt dh_clean install: build @@ -147,13 +76,21 @@ install: build dh_testroot dh_prep dh_installdirs -popenmodelica -Pdebian/tmp - # Add here commands to install the package into debian/tmp. - $(MAKE) $(EXTRA_MAKEFLAGS) install $(EXTRA_INSTALL) DESTDIR=$(DEST) + DESTDIR=$(DEST) cmake --install $(BUILD) + # The cmake omlibrary target would download with /usr/bin/omc, not this omc. + rm -rf $(BUILD)/omlibrary + mkdir -p $(BUILD)/omlibrary/.openmodelica/libraries + cp libraries/install-index.json $(BUILD)/omlibrary/.openmodelica/libraries/index.json + cd $(BUILD)/omlibrary && $(DEST)/usr/bin/omc $(CURDIR)/libraries/install-index.mos + mkdir -p $(DEST)/usr/share/omlibrary/cache + cp libraries/install-index.json $(DEST)/usr/share/omlibrary/cache/index.json + cp $(BUILD)/omlibrary/.openmodelica/cache/* $(DEST)/usr/share/omlibrary/cache/ + # No language server is published for armhf, so the directory may be absent. + mkdir -p $(DEST)/usr/share/omedit/ls # We add our own Debian-specific copyright file rm -f $(DEST)/usr/share/doc/omc/COPYING dh_install -# Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot @@ -165,11 +102,10 @@ binary-arch: build install dh_installmime dh_link dh_strip - # dh_compress -X.pdf -X.onb -X.c -X.h -X.mo -X.mos -Xomc_helptext.txt -X.py dh_fixperms dh_installdeb dh_makeshlibs -V - dh_shlibdeps -l/usr/lib/$(DEB_HOST_GNU_TYPE)/omc -Lomc -- --ignore-missing-info + dh_shlibdeps -l/usr/lib/$(DEB_HOST_MULTIARCH)/omc -Lomc -- --ignore-missing-info dh_gencontrol dh_md5sums dh_builddeb diff --git a/rpm/SPECS/openmodelica.spec.tpl b/rpm/SPECS/openmodelica.spec.tpl index 039a0d4..1b21ea6 100644 --- a/rpm/SPECS/openmodelica.spec.tpl +++ b/rpm/SPECS/openmodelica.spec.tpl @@ -19,15 +19,6 @@ SOURCE1 : https://openmodelica.org/doc/openmodelica-doc-DOCUMENTATIONVERSION.tar PATCHES URL: https://openmodelica.org/ -%if 0%{?rhel} == 6 -Autoreq: 0 -Requires: readline -Requires: qt5-qtbase -Requires: qt5-qtsvg -Requires: qt5-qtwebengine -Requires: qt5-qtxmlpatterns -Requires: libffi -%endif Autoprov: 0 Prefix: /opt/%{name} Prefix: %{_bindir} @@ -36,7 +27,7 @@ Prefix: %{_bindir} # Recommended (for the repo): git rpm-build rpmdevtools epel-release %if 0%{?rhel} > 0 -# CentOS / RHEL requires the EPEL repository (for omniORB, etc) +# CentOS / RHEL requires the EPEL repository BuildRequires: epel-release Requires: epel-release %endif @@ -47,12 +38,10 @@ Requires: gcc Requires: gcc-gfortran Requires: gcc-c++ -BuildRequires: automake BuildRequires: expat-devel BuildRequires: bison BuildRequires: flex BuildRequires: lapack-devel -BuildRequires: libtool BuildRequires: uuid BuildRequires: uuid-devel BuildRequires: hdf5-devel @@ -71,7 +60,7 @@ BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: gcc-gfortran # EL8 is the only target left without qt6, in EPEL or anywhere else -%if 0%{?rhel} > 0 && 0%{?rhel} <= 8 +%if 0%{?rhel} == 8 %define omqt5 1 %endif @@ -96,16 +85,7 @@ BuildRequires: qt6-qtwebsockets-devel BuildRequires: qt6-qtquick3d-devel %endif - -# Use cmake versions > 3. On EL7 this is provided by cmake3 package. -# On EL > 7 it is just cmake. -%if 0%{?rhel} == 7 -BuildRequires: cmake3 -%define cmakecommand CMAKE=cmake3 -%else BuildRequires: cmake -%define cmakecommand CMAKE=cmake -%endif # The base centos:8 image (we use for our build-deps:el8 image) comes with # broken cmake package due to old libarchive (v3.3.2). v3.3.3 Seems to work. @@ -114,34 +94,22 @@ BuildRequires: cmake BuildRequires: libarchive >= 3.3.3 %endif -# Use gcc-11 on EL8 as well. devtoolset does not seem to be available on -# EL8. One is supposed to use gcc-toolset instead. +# EL8's system gcc is 8.5, too old to build with. %{?el8:Requires: gcc-toolset-11-gcc gcc-toolset-11-gcc-c++ gcc-toolset-11-gcc-gfortran} %if 0%{?rhel} == 8 BuildRequires: gcc-toolset-11-gcc gcc-toolset-11-gcc-c++ gcc-toolset-11-gcc-gfortran -%define devtoolsconfigureflags CC=/opt/rh/gcc-toolset-11/root/usr/bin/gcc CXX=/opt/rh/gcc-toolset-11/root/usr/bin/g++ FC=/opt/rh/gcc-toolset-11/root/usr/bin/gfortran AS=/opt/rh/gcc-toolset-11/root/usr/bin/as -%endif - -# EL7 has -static-libstdc++ inside devtools (but the system g++ does not know the flag) -- adrpo: check this, also for el6 -%{?el7:Requires: devtoolset-11-gcc} -%{?el7:Requires: devtoolset-11-gcc-c++} -%{?el7:Requires: devtoolset-11-gcc-gfortran} - -%if 0%{?rhel} <= 7 && 0%{?rhel} >= 1 -BuildRequires: devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-gcc-gfortran -%define devtoolsconfigureflags CC=/opt/rh/devtoolset-11/root/usr/bin/gcc CXX=/opt/rh/devtoolset-11/root/usr/bin/g++ FC=/opt/rh/devtoolset-11/root/usr/bin/gfortran +%define devtoolscmakeflags -DCMAKE_C_COMPILER=/opt/rh/gcc-toolset-11/root/usr/bin/gcc -DCMAKE_CXX_COMPILER=/opt/rh/gcc-toolset-11/root/usr/bin/g++ -DCMAKE_Fortran_COMPILER=/opt/rh/gcc-toolset-11/root/usr/bin/gfortran -DCMAKE_ASM_COMPILER=/opt/rh/gcc-toolset-11/root/usr/bin/as %endif %if 0%{?omqt5} -%define withqt6 '' +%define omqtmajor 5 %define omqtversion qt5 %else -%define withqt6 --with-qt6 +%define omqtmajor 6 %define omqtversion qt6 %endif -# We should use clang, but OMEdit does not compile with it due to odd default qmake flags Requires: gcc Requires: gcc-c++ Requires: lapack-devel @@ -149,16 +117,10 @@ Requires: lapack-devel Requires(post): %{_sbindir}/update-alternatives Requires(postun): %{_sbindir}/update-alternatives -# CentOS does not have suggests -%if 0%{?fedora} >= 24 || 0%{?rhel} >= 8 Suggests: boost-devel Suggests: boost-static Suggests: lapack-static Suggests: openblas-static -%else -Requires: boost-devel -Requires: boost-static -%endif BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root @@ -172,37 +134,49 @@ tar xJf %{_sourcedir}/openmodelica-doc-DOCUMENTATIONVERSION.tar.xz PATCHCMDS -%if 0%{?rhel} <= 7 && 0%{?rhel} >= 1 -source /opt/rh/devtoolset-11/enable -%endif - -%if 0%{?rhel} == 8 -source /opt/rh/gcc-toolset-11/enable -%endif - -export LANG=C.UTF-8 -autoreconf --install -./configure CFLAGS="-Os" CXXFLAGS="-Os" QTDIR=/usr/%{_lib}/%{omqtversion} --without-omniORB %{withqt6} CONFIGUREFLAGS %{?devtoolsconfigureflags} --without-omc --prefix=/opt/%{name} --without-omlibrary %{cmakecommand} +# The tarball has no git; CMake reads OMVERSION.txt. +echo 'vDEBVERSION' | tr '~' '-' > OMVERSION.txt %build -%if 0%{?rhel} <= 7 && 0%{?rhel} >= 1 -export LANG=C.UTF-8 -source /opt/rh/devtoolset-11/enable -%endif - %if 0%{?rhel} == 8 -export LANG=C.UTF-8 source /opt/rh/gcc-toolset-11/enable %endif export LANG=C.UTF-8 -make -j8 -test ! -f libraries/install-index.json || make -j8 omlibrary +# CONFIGUREFLAGS: extra cmake -D arguments, from projects.json in apt-build. +cmake -S . -B build_rpm -Wno-dev \ + -DCMAKE_INSTALL_PREFIX=/opt/%{name} \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_FLAGS_RELEASE="-Os -DNDEBUG" \ + -DCMAKE_CXX_FLAGS_RELEASE="-Os -DNDEBUG" \ + -DCMAKE_PREFIX_PATH=/usr/%{_lib}/%{omqtversion} \ + -DOM_USE_CCACHE=OFF \ + -DOM_ENABLE_TESTSUITE=OFF \ + -DOM_ENABLE_DOCS=OFF \ + -DOM_ENABLE_GUI_CLIENTS=ON \ + -DOM_QT_MAJOR_VERSION=%{omqtmajor} \ + -DOM_ENABLE_OMSIMULATOR=ON \ + -DOM_OMOPTIM_ENABLE=OFF \ + -DOM_RUST_RESULT_READERS=ON \ + -DOM_RUST_RESULT_WRITERS=ON \ + -DOM_ENABLE_RUST_SIM_RUNTIME=ON \ + %{?devtoolscmakeflags} CONFIGUREFLAGS +cmake --build build_rpm --parallel 8 %install rm -rf %{buildroot} -make install DESTDIR="%{buildroot}" +DESTDIR="%{buildroot}" cmake --install build_rpm +# The cmake omlibrary target would download with an omc that is not installed yet. +if test -f libraries/install-index.json; then + rm -rf omlibrary-download + mkdir -p omlibrary-download/.openmodelica/libraries + cp libraries/install-index.json omlibrary-download/.openmodelica/libraries/index.json + (cd omlibrary-download && %{buildroot}/opt/%{name}/bin/omc ../libraries/install-index.mos) + mkdir -p %{buildroot}/opt/%{name}/share/omlibrary/cache + cp libraries/install-index.json %{buildroot}/opt/%{name}/share/omlibrary/cache/index.json + cp omlibrary-download/.openmodelica/cache/* %{buildroot}/opt/%{name}/share/omlibrary/cache/ +fi mkdir -p %{buildroot}/opt/%{name}/lib/ %{buildroot}/opt/%{name}/share/doc/omc/ %{buildroot}%{_bindir} ln -s /usr/lib/omlibrary %{buildroot}/opt/%{name}/lib/ ln -s /opt/%{name}/bin/omc %{buildroot}%{_bindir}/omc-BRANCH