Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngspice: fix the port for < 10.8 #25537

Merged
merged 7 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions science/ngspice/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,22 @@ checksums rmd160 577a26e18e70fdf1fceb87ae3c6a783c3cf00d8e \

set docdir ${prefix}/share/doc/${name}

# checking whether C compiler accepts -std=gnu11... no
# C compiler cannot compile C11 code, etc.
compiler.c_standard 2011
compiler.cxx_standard 2011

if {${name} eq ${subport}} {

# freetype2 headers are not found by default
configure.cppflags-prepend -I${prefix}/include/freetype2

# TASK_BASIC_INFO_COUNT and friends were renamed in 10.8
patchfiles-append patch-ngspice-older-MACH-defines.diff

# https://trac.macports.org/ticket/70175
patchfiles-append patch-fix-linking.diff

depends_lib-append port:readline \
port:libtool \
port:xorg-libX11 \
Expand All @@ -43,13 +54,26 @@ if {${name} eq ${subport}} {
--enable-pss \
--enable-relpath \
--disable-openmp \
--disable-silent-rules \
--with-readline=${prefix} \
--with-x

# https://trac.macports.org/ticket/70665
# https://github.com/macports/macports-ports/commit/e485b0a0c8125cb9d8bcc6241a9c2016514188c8
if {${os.platform} eq "darwin" && ${os.major} <= 10} {
configure.cppflags-append \
-D__NOEXTENSIONS__

# Do not let an arbitrary compiler be set as CC_FOR_BUILD,
# do not link C++ code with gcc.
patchfiles-append patch-use-cxx-to-link-cxx-code.diff
configure.env-append CC_FOR_BUILD=${configure.cc}
}

# Set CFLAGS and LDFLAGS
configure.ldflags-append -L${prefix}/lib

build.args VERBOSE=1
build.args VERBOSE=1
post-destroot {
xinstall -d ${destroot}${docdir}
xinstall -m 644 -W ${worksrcpath} \
Expand All @@ -67,11 +91,11 @@ if {${name} eq ${subport}} {
}

variant manual description {Legacy compatibility variant} {
depends_run-append port:ngspice-docs
depends_run-append port:ngspice-docs
}

variant lib description {Enable dynamic lib} {
depends_run-append port:ngspice-lib
depends_run-append port:ngspice-lib
}

default_variants +manual +lib
Expand Down Expand Up @@ -118,6 +142,9 @@ subport ngspice-lib {
# freetype2 headers are not found by default
configure.cppflags-prepend -I${prefix}/include/freetype2

# TASK_BASIC_INFO_COUNT and friends were renamed in 10.8
patchfiles-append patch-ngspice-older-MACH-defines.diff

depends_lib-append port:autoconf \
port:automake \
port:bison \
Expand All @@ -134,9 +161,16 @@ subport ngspice-lib {
--with-readline=${prefix} \
--with-ngshared

# https://trac.macports.org/ticket/70665
# https://github.com/macports/macports-ports/commit/e485b0a0c8125cb9d8bcc6241a9c2016514188c8
if {${os.platform} eq "darwin" && ${os.major} <= 10} {
configure.cppflags-append \
-D__NOEXTENSIONS__
}

# Set CFLAGS and LDFLAGS
configure.cflags-append -m64 -O2 -Wall -I${prefix}/include/freetype2 -I${prefix}/include
configure.ldflags-append -m64 -L${prefix}/lib
configure.cflags-append -O2 -Wall -I${prefix}/include/freetype2 -I${prefix}/include
configure.ldflags-append -L${prefix}/lib
markemer marked this conversation as resolved.
Show resolved Hide resolved

# Use the correct prefix
use_configure yes
Expand Down
12 changes: 12 additions & 0 deletions science/ngspice/files/patch-fix-linking.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--- src/Makefile.in 2024-07-13 01:09:10.000000000 +0800
+++ src/Makefile.in 2024-08-31 13:25:22.000000000 +0800
@@ -875,7 +875,8 @@
-e 's|@XSPICEINIT[@]|$(XSPICEINIT)|g' \
-e 's|@pkglibdir[@]|$(spinitpath)|g'

-AM_CFLAGS = -static
+# MacOS linker does not need this.
+# AM_CFLAGS = -static
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a weird old leftover, ngspice goes all the way back to SPICE3 essentially.

CLEANFILES = ngspice.idx spinit tclspinit pkgIndex.tcl
MAINTAINERCLEANFILES = Makefile.in
@SHARED_MODULE_TRUE@lib_LTLIBRARIES = libngspice.la
17 changes: 17 additions & 0 deletions science/ngspice/files/patch-ngspice-older-MACH-defines.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- src/frontend/get_resident_set_size.c.orig 2020-12-22 17:35:59.000000000 -0800
+++ src/frontend/get_resident_set_size.c 2020-12-22 17:39:53.000000000 -0800
@@ -110,6 +110,14 @@
return (unsigned long long) info.WorkingSetSize;

#elif defined(__APPLE__) && defined(__MACH__)
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080
+# define MACH_TASK_BASIC_INFO_COUNT TASK_BASIC_INFO_COUNT
+# define mach_task_basic_info_data_t task_basic_info_data_t
+# define MACH_TASK_BASIC_INFO TASK_BASIC_INFO
+# define mach_task_basic_info task_basic_info
+#endif
+
/* OSX ------------------------------------------------------ */
struct mach_task_basic_info info;
mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
11 changes: 11 additions & 0 deletions science/ngspice/files/patch-use-cxx-to-link-cxx-code.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- src/Makefile.in 2024-07-13 01:09:10.000000000 +0800
+++ src/Makefile.in 2024-08-31 14:02:16.000000000 +0800
@@ -482,7 +482,7 @@
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
-CCLD = $(CC)
+CCLD = $(CXX)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@