ngspice: add recipe

This commit is contained in:
Gerasim Troeglazov
2024-12-26 18:48:46 +10:00
parent d42378ddff
commit dbc553064c
2 changed files with 270 additions and 0 deletions

View File

@@ -0,0 +1,145 @@
SUMMARY="The Next Generation Spice (Electronic Circuit Simulator)"
DESCRIPTION="Ngspice is a mixed-level/mixed-signal circuit simulator based on three open source software packages: \
Spice3f5, Cider1b1 and Xspice:
* Spice3 is the most famous and used circuit simulator. It was developed University of California at Berkeley (UCB), \
by \"a cast of thousand\" (as they say).
* Cider is a mixed-level simulator that already includes Spice3f5 and adds a device simulator to it: DSIM. Cider \
couples the circuit level simulator to the device simulator to provide greater simulation accuracy (at the expense \
of greater simulation time). Critical devices can be described with technology parameters (numerical models) and \
non critical ones with the original spice's compact models.
* Xspice is an extension to Spice3 that provides code modeling support and simulation of digital components through \
an embedded event driven algorithm."
HOMEPAGE="https://ngspice.sourceforge.io/"
COPYRIGHT="Ngspice developers"
LICENSE="GNU GPL v2
MPL v2.0"
REVISION="1"
SOURCE_URI="https://sourceforge.net/projects/ngspice/files/ng-spice-rework/$portVersion/ngspice-$portVersion.tar.gz"
CHECKSUM_SHA256="14dd6a6f08531f2051c13ae63790a45708bd43f3e77886a6a84898c297b13699"
SOURCE_DIR="ngspice-$portVersion"
PATCHES="ngspice-$portVersion.patchset"
ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"
commandBinDir=$binDir
commandSuffix=$secondaryArchSuffix
if [ "$targetArchitecture" = x86_gcc2 ]; then
commandSuffix=
commandBinDir=$prefix/bin
fi
libVersion="0.0.10"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
PROVIDES="
ngspice$secondaryArchSuffix = $portVersion
cmd:ngspice$commandSuffix = $portVersion
lib:libngspice$secondaryArchSuffix = $libVersionCompat
"
REQUIRES="
haiku$secondaryArchSuffix
lib:libfftw3$secondaryArchSuffix
lib:libgomp$secondaryArchSuffix
lib:libreadline$secondaryArchSuffix
lib:libncurses$secondaryArchSuffix
"
PROVIDES_devel="
ngspice${secondaryArchSuffix}_devel = $portVersion
devel:libngspice$secondaryArchSuffix = $libVersionCompat
"
REQUIRES_devel="
ngspice$secondaryArchSuffix == $portVersion base
devel:libgomp$secondaryArchSuffix
devel:libfftw3$secondaryArchSuffix
devel:libreadline$secondaryArchSuffix
devel:libncurses$secondaryArchSuffix
"
BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel
devel:libgomp$secondaryArchSuffix
devel:libfftw3$secondaryArchSuffix
devel:libreadline$secondaryArchSuffix
devel:libncurses$secondaryArchSuffix
"
BUILD_PREREQUIRES="
cmd:aclocal
cmd:autoreconf
cmd:gcc$secondaryArchSuffix
cmd:ld$secondaryArchSuffix
cmd:libtoolize
cmd:grep
cmd:make
cmd:pkg_config$secondaryArchSuffix
cmd:sed
"
BUILD()
{
./autogen.sh
export CFLAGS="-O2"
export LDFLAGS="-s -lnetwork"
mkdir $sourceDir/releasesh
cd $sourceDir/releasesh
runConfigure ../configure \
--without-x \
--with-ngshared \
--with-readline=yes \
--enable-xspice \
--enable-cider \
--enable-predictor \
--enable-osdi \
--enable-klu \
--enable-openmp \
--disable-debug
make clean
make $jobArgs
mkdir $sourceDir/release
cd $sourceDir/release
runConfigure --omit-dirs binDir ../configure \
--bindir=$commandBinDir \
--without-x \
--with-readline=yes \
--enable-xspice \
--enable-cider \
--enable-predictor \
--enable-osdi \
--enable-klu \
--enable-openmp \
--disable-debug
make clean
make $jobArgs
}
INSTALL()
{
cd $sourceDir/releasesh
make install
cd $sourceDir/release
make install
rm $libDir/*.la
prepareInstalledDevelLib libngspice
fixPkgconfig
packageEntries devel \
$developDir
}
TEST()
{
make test
}

View File

@@ -0,0 +1,125 @@
From ebf3944dcaab384a642ee78eee578a8650fc1514 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 26 Dec 2024 18:01:05 +1000
Subject: fix build
diff --git a/src/frontend/get_avail_mem_size.c b/src/frontend/get_avail_mem_size.c
index ebec4fd..9b4ec7e 100644
--- a/src/frontend/get_avail_mem_size.c
+++ b/src/frontend/get_avail_mem_size.c
@@ -11,6 +11,9 @@
#undef BOOLEAN
#include <windows.h>
+#elif defined(__HAIKU__)
+#include <kernel/OS.h>
+
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
#include <unistd.h>
#include <sys/types.h>
@@ -64,6 +67,15 @@ unsigned long long getAvailableMemorySize(void)
GlobalMemoryStatusEx( &status );
return status.ullAvailPhys;
+#elif defined (__HAIKU__)
+ system_info info;
+ get_system_info(&info);
+ uint32 ignored = (info.ignored_pages*B_PAGE_SIZE)/(1024*1024);
+ uint32 max = (info.max_pages*B_PAGE_SIZE)/(1024*1024);
+ uint32 used = (info.used_pages*B_PAGE_SIZE)/(1024*1024);
+
+return ((max+ignored)-used);
+
#elif defined(__APPLE__) && defined(__MACH__)
mach_port_t host_port;
diff --git a/src/frontend/get_phys_mem_size.c b/src/frontend/get_phys_mem_size.c
index c40e5a3..a23547d 100644
--- a/src/frontend/get_phys_mem_size.c
+++ b/src/frontend/get_phys_mem_size.c
@@ -13,6 +13,9 @@
#undef BOOLEAN
#include <windows.h>
+#elif defined(__HAIKU__)
+#include <kernel/OS.h>
+
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
#include <unistd.h>
#include <sys/types.h>
@@ -114,6 +117,14 @@ unsigned long long getMemorySize(void)
return 0L; /* Failed? */
#endif /* sysctl and sysconf variants */
+#elif defined (__HAIKU__)
+ system_info info;
+ get_system_info(&info);
+ uint32 ignored = (info.ignored_pages*B_PAGE_SIZE)/(1024*1024);
+ uint32 max = (info.max_pages*B_PAGE_SIZE)/(1024*1024);
+
+return ((max+ignored));
+
#else
return 0L; /* Unknown OS. */
#endif
diff --git a/src/frontend/get_resident_set_size.c b/src/frontend/get_resident_set_size.c
index aeff605..3c5dd72 100644
--- a/src/frontend/get_resident_set_size.c
+++ b/src/frontend/get_resident_set_size.c
@@ -14,7 +14,7 @@
#include <windows.h>
#include <psapi.h>
-#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
+#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__)) || defined(__HAIKU__)
#include <unistd.h>
#include <sys/resource.h>
@@ -133,6 +133,9 @@ unsigned long long getCurrentRSS(void)
fclose( fp );
return rss * (unsigned long long) sysconf(_SC_PAGESIZE);
+#elif defined (__HAIKU__)
+ return 0L;
+
#else
/* AIX, BSD, Solaris, and Unknown OS ------------------------ */
return (unsigned long long) 0L; /* Unsupported. */
--
2.45.2
From 58db81008e0e956c273364ea1e41c863aee7e455 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 26 Dec 2024 18:01:20 +1000
Subject: Remove libdl for Haiku
diff --git a/configure.ac b/configure.ac
index 7488033..c44e9ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1108,7 +1108,7 @@ if test "x$enable_xspice" = xno; then
XSPICEINIT="*"
if test "x$enable_osdi" = xyes || test "x$enable_osdi" = x ; then\
case $host_os in
- *mingw* | *msys* | *cygwin* | *solaris* )
+ *mingw* | *msys* | *cygwin* | *solaris* | *haiku* )
XSPICEDLLIBS=""
;;
* )
@@ -1137,6 +1137,10 @@ else
AC_DEFINE([IPC_UNIX_SOCKETS], [1], [Client-Server via socket.])
XSPICEDLLIBS="-ldl"
;;
+ *haiku* )
+ AC_DEFINE([IPC_UNIX_SOCKETS], [1], [Client-Server via socket.])
+ XSPICEDLLIBS=""
+ ;;
*solaris* )
AC_DEFINE([IPC_UNIX_SOCKETS], [1], [Client-Server via socket.])
XSPICEDLLIBS=""
--
2.45.2