From 0023baede0c85fd618eac307002723655c770d98 Mon Sep 17 00:00:00 2001 From: salman Date: Sat, 13 Jun 2026 13:47:15 +0200 Subject: [PATCH] Make static linking the default packaging path --- Readme.md | 41 +++++++++++++++++++++++++++++++++++------ fortran/Makefile | 3 +-- package.json | 7 ++++++- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/Readme.md b/Readme.md index 4b03624..2e9a5b3 100644 --- a/Readme.md +++ b/Readme.md @@ -52,7 +52,14 @@ make ``` This creates the `trimspNL` binary in the repository root. For packaged -Electron builds, copy or rebuild it into: +Electron builds, the default is now to use the static binary: + +```bash +cd trimsp/fortran +make trimspNL-static +``` + +and copy or rebuild it into: ```text resources/bin/trimspNL @@ -71,6 +78,13 @@ example: This reads `myrun.inp` and writes `myrun.out`, `myrun.rge`, and `myrun.err`. +If you need the dynamic binary explicitly, build: + +```bash +cd trimsp/fortran +make trimspNL +``` + ###### Running the GUI ###### Install [Node.js] (`nodejs`, `nodejs-libs` and `npm`), @@ -87,18 +101,33 @@ Next time you can simply run `npm start` only. ###### Building RPM and DEB packages ###### -Install [Node.js] (`nodejs`, `nodejs-libs` and `npm`), then run: +Install [Node.js] (`nodejs`, `nodejs-libs` and `npm`), plus the Fortran toolchain +(`make` and `gfortran`), then run: ```bash cd trimsp -cp trimspNL resources/bin/trimspNL npm install npm run make ``` -This uses Electron Forge to build Linux packages from the current checkout. -The packaged application bundles `resources/bin/trimspNL` inside the app -resources, so make sure that file exists and is up to date before packaging. +This automatically compiles `fortran/trimspNL-static` and copies it to +`resources/bin/trimspNL` before Electron Forge builds the packages. + +If static linking fails on a given machine, you can stage the dynamic binary +manually instead: + +```bash +npm run build:fortran:dynamic +``` + +For Flatpak, build with the same default static Fortran binary: + +```bash +npm run make:flatpak +``` + +This compiles `fortran/trimspNL-static` and stages it as +`resources/bin/trimspNL` before the Flatpak packaging step. The generated files are written under: diff --git a/fortran/Makefile b/fortran/Makefile index 5667dee..353d663 100644 --- a/fortran/Makefile +++ b/fortran/Makefile @@ -23,11 +23,10 @@ trimspNL : trimspNL.F $(FC) $(FCFLAGS) -o $@ $< clean: - rm -f *.o *~ \#* .#* trimspNL + rm -f *.o *~ \#* .#* trimspNL trimspNL-static install: mv trimspNL $(prefix)/bin/. trimspNL-static : trimspNL.F $(FC) $(FCFLAGS) -static -o $@ $< - diff --git a/package.json b/package.json index 23d1ea2..649182b 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,15 @@ "description": "Trim.SP simulation to calculate stopping profile of implanted probes.", "main": "main.js", "scripts": { + "build:fortran": "make -C fortran trimspNL-static && cp fortran/trimspNL-static resources/bin/trimspNL", + "build:fortran:dynamic": "make -C fortran trimspNL && cp fortran/trimspNL resources/bin/trimspNL", + "build:fortran:static": "npm run build:fortran", "start": "electron-forge start", + "prepackage": "npm run build:fortran", "package": "electron-forge package", + "premake": "npm run build:fortran", "make": "electron-forge make", - "make:flatpak": "FORGE_FLATPAK=1 electron-forge make --targets=@electron-forge/maker-flatpak", + "make:flatpak": "npm run build:fortran && FORGE_FLATPAK=1 electron-forge make --targets=@electron-forge/maker-flatpak", "checksums:md5": "sh -c 'for d in out/make/deb/x64 out/make/rpm/x64 out/make/flatpak/x86_64; do [ -d \"$d\" ] || continue; for f in \"$d\"/*; do [ -f \"$f\" ] || continue; case \"$f\" in *.deb|*.rpm|*.flatpak) base=$(basename \"$f\"); (cd \"$d\" && md5sum \"$base\" > \"$base.md5\");; esac; done; done'", "checksums:sha256": "sh -c 'for d in out/make/deb/x64 out/make/rpm/x64 out/make/flatpak/x86_64; do [ -d \"$d\" ] || continue; for f in \"$d\"/*; do [ -f \"$f\" ] || continue; case \"$f\" in *.deb|*.rpm|*.flatpak) base=$(basename \"$f\"); (cd \"$d\" && sha256sum \"$base\" > \"$base.sha256\");; esac; done; done'", "checksums": "npm run checksums:md5 && npm run checksums:sha256"