From f948faf059f1049354d83d95f0d945fef1056365 Mon Sep 17 00:00:00 2001 From: Federico Beffa Date: Fri, 8 Dec 2023 15:58:58 +0100 Subject: [PATCH] fastcap: init at 2.0-18Sep92 --- ...stcap-mulglobal-drop-conflicting-lib.patch | 13 +++ ...ap-mulsetup-add-forward-declarations.patch | 19 ++++ pkgs/by-name/fa/fastcap/package.nix | 94 +++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 pkgs/by-name/fa/fastcap/fastcap-mulglobal-drop-conflicting-lib.patch create mode 100644 pkgs/by-name/fa/fastcap/fastcap-mulsetup-add-forward-declarations.patch create mode 100644 pkgs/by-name/fa/fastcap/package.nix diff --git a/pkgs/by-name/fa/fastcap/fastcap-mulglobal-drop-conflicting-lib.patch b/pkgs/by-name/fa/fastcap/fastcap-mulglobal-drop-conflicting-lib.patch new file mode 100644 index 000000000000..efb3b570db04 --- /dev/null +++ b/pkgs/by-name/fa/fastcap/fastcap-mulglobal-drop-conflicting-lib.patch @@ -0,0 +1,13 @@ +Don't use timing as there is a type conflict. + +--- nix-build-fastcap-2.0-18Sep92.drv-1/src/mulGlobal.h.orig 2015-07-21 15:58:49.199101566 +0200 ++++ nix-build-fastcap-2.0-18Sep92.drv-1/src/mulGlobal.h 2015-07-21 16:18:39.456751313 +0200 +@@ -57,7 +57,7 @@ + /* time variables/structs */ + #ifndef _TIME_ /* if not on a Sun4 */ + #ifndef NEWS /* if not on a NWS-38XX */ +-#include ++//#include + #endif + #endif + diff --git a/pkgs/by-name/fa/fastcap/fastcap-mulsetup-add-forward-declarations.patch b/pkgs/by-name/fa/fastcap/fastcap-mulsetup-add-forward-declarations.patch new file mode 100644 index 000000000000..00eb7e96b5f5 --- /dev/null +++ b/pkgs/by-name/fa/fastcap/fastcap-mulsetup-add-forward-declarations.patch @@ -0,0 +1,19 @@ +Add forward declarations. + +--- fastcap/src/mulSetup.c.orig 2015-07-22 13:55:21.592119775 +0200 ++++ fastcap/src/mulSetup.c 2015-07-22 14:08:50.157688209 +0200 +@@ -35,6 +35,14 @@ + + #include "mulGlobal.h" + ++static getnbrs(ssystem*); ++static linkcubes(ssystem*); ++static setMaxq(ssystem*); ++static getAllInter(ssystem*); ++static set_vector_masks(ssystem*); ++static indexkid(ssystem*, cube*, int*, int*); ++static int placeq(int, ssystem*, charge*); ++ + cube *cstack[1024]; /* Stack used in several routines. */ + + /* diff --git a/pkgs/by-name/fa/fastcap/package.nix b/pkgs/by-name/fa/fastcap/package.nix new file mode 100644 index 000000000000..f809b1094ff4 --- /dev/null +++ b/pkgs/by-name/fa/fastcap/package.nix @@ -0,0 +1,94 @@ +{ stdenv +, fetchzip +, ghostscript +, lib +, texliveMedium +}: + +stdenv.mkDerivation rec { + pname = "fastcap"; + version = "2.0-18Sep92"; + + src = fetchzip { + url = "https://www.rle.mit.edu/cpg/codes/fastcap-${version}.tgz"; + hash = "sha256-fnmC6WNd7xk8fphxkMZUq2+Qz+2mWIP2lvBUBAmUvHI"; + stripRoot = false; + }; + + patches = [ + ./fastcap-mulglobal-drop-conflicting-lib.patch + ./fastcap-mulsetup-add-forward-declarations.patch + ]; + + nativeBuildInputs = [ + ghostscript + texliveMedium + ]; + + postPatch = '' + substituteInPlace ./doc/Makefile \ + --replace '/bin/rm' 'rm' + + for f in "doc/*.tex" ; do + sed -i -E $f \ + -e 's/\\special\{psfile=([^,]*),.*scale=([#0-9.]*).*\}/\\includegraphics[scale=\2]{\1}/' \ + -e 's/\\psfig\{figure=([^,]*),.*width=([#0-9.]*in).*\}/\\includegraphics[width=\2]{\1}/' \ + -e 's/\\psfig\{figure=([^,]*),.*height=([#0-9.]*in).*\}/\\includegraphics[height=\2]{\1}/' \ + -e 's/\\psfig\{figure=([^,]*)\}/\\includegraphics{\1}/' + done + + for f in "doc/mtt.tex" "doc/tcad.tex" "doc/ug.tex"; do + sed -i -E $f \ + -e 's/^\\documentstyle\[(.*)\]\{(.*)\}/\\documentclass[\1]{\2}\n\\usepackage{graphicx}\n\\usepackage{robinspace}/' \ + -e 's/\\setlength\{\\footheight\}\{.*\}/%/' \ + -e 's/\\setstretch\{.*\}/%/' + done + ''; + + dontConfigure = true; + + makeFlags = [ + "RM=rm" + "SHELL=sh" + "all" + ]; + + outputs = [ "out" "doc" ]; + + postBuild = '' + make manual + pushd doc + find -name '*.dvi' -exec dvipdf {} \; + popd + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/ + mv bin $out/bin + rm $out/bin/README + + mkdir -p $doc/share/doc/fastcap-${version} + cp doc/*.pdf $doc/share/doc/fastcap-${version} + + mkdir -p $out/share/fastcap + mv examples $out/share/fastcap + + runHook postInstall + ''; + + meta = with lib; { + description = "Multipole-accelerated capacitance extraction program"; + longDescription = '' + Fastcap is a three dimensional capacitance extraction program that + compute self and mutual capacitances between conductors of arbitrary + shapes, sizes and orientations. + ''; + homepage = "https://www.rle.mit.edu/cpg/research_codes.htm"; + license = licenses.mit; + maintainers = with maintainers; [ fbeffa ]; + platforms = platforms.linux; + mainProgram = "fastcap"; + }; +}