Skip to content

Commit

Permalink
gmt5, gmt6: deprecate gmt5, fix sighandler and cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
remkos authored and reneeotten committed Nov 29, 2024
1 parent 03479d2 commit b901a3c
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 59 deletions.
70 changes: 22 additions & 48 deletions science/gmt5/Portfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup cmake 1.0
PortGroup cmake 1.1
PortGroup github 1.0
PortGroup deprecated 1.0

# https://trac.macports.org/ticket/71306
deprecated.upstream_support no

name gmt5
github.setup GenericMappingTools gmt 5.4.5
github.tarball_from releases
distname ${github.project}-${github.version}-src
revision 20
subport gmt6 {
github.setup GenericMappingTools gmt 6.5.0
revision 2
epoch 1
}

categories science
platforms darwin
maintainers {me.com:remko.scharroo @remkos} openmaintainer
license GPL-3

description The Generic Mapping Tools
long_description GMT is an open source collection of ~120 tools \
for manipulating geographic and Cartesian data sets and \
Expand All @@ -38,32 +38,24 @@ use_xz yes
distname gmt-${version}
distfiles ${distname}-src${extract.suffix}

if {${subport} eq "gmt5"} {
checksums rmd160 900befd66ec4a9aea75c53d99ed83f7e25163e35\
sha256 078d4997507cb15344c74a874568985e45bdbd6d3a72d330c74c47f4c0359bb1 \
size 59175704
} else {
checksums rmd160 3e47113d134bde756b98906a4704b3151902c4d1 \
sha256 4022adb44033f9c1d5a4d275b69506449e4d486efe2218313f3ff7a6c6c3141e \
size 58696516
}
checksums rmd160 900befd66ec4a9aea75c53d99ed83f7e25163e35\
sha256 078d4997507cb15344c74a874568985e45bdbd6d3a72d330c74c47f4c0359bb1 \
size 59175704

patchfiles patch-gmt5-common_sighandler.diff \
patch-gmt5-ConfigCMake.diff

depends_lib port:curl \
port:dcw-gmt \
port:ghostscript \
port:gshhg-gmt \
port:netcdf

if {${subport} eq "gmt5"} {
patchfiles patch-gmt5-arm64.diff
}

default_variants +gdal +pcre
if {![variant_isset lgpl]} {
default_variants-append +nonfree
}

cmake.out_of_source yes
cmake.install_prefix ${prefix}/lib/${subport}

# Mimic CMake's default FLAGS:
Expand All @@ -73,8 +65,7 @@ if {[variant_isset debug]} {
# optflags deliberately unset:
configure.optflags
# Set CMAKE_BUILD_TYPE=RelWithDebInfo to get reliable backtraces:
configure.args-delete -DCMAKE_BUILD_TYPE=Release
configure.args-append -DCMAKE_BUILD_TYPE=RelWithDebInfo
configure.args-replace -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=RelWithDebInfo
}

configure.cflags-append -fstrict-aliasing
Expand All @@ -92,40 +83,27 @@ configure.args-append -DDCW_ROOT=${prefix}/share/gmt/dcw \
-DGMT_INSTALL_TRADITIONAL_FOLDERNAMES=off \
-DLICENSE_RESTRICTED=GPL

if {${subport} eq "gmt6"} {
configure.args-append -DGS_ROOT=${prefix}
}

post-destroot {
if {${subport} eq "gmt6"} {
foreach l {gmt postscriptlight} {
file delete ${destroot}${prefix}/lib/${subport}/bin/lib${l}.${version}.dylib
}
}
ln -s ${prefix}/lib/${subport}/bin/gmt ${destroot}${prefix}/bin/${subport}
}

variant fftw3 description {Optional support for FFTW-3 library} {
depends_lib-append port:fftw-3-single
configure.args-delete -DFFTW3_ROOT=off
configure.args-append -DFFTW3_ROOT=${prefix}
configure.args-replace -DFFTW3_ROOT=off -DFFTW3_ROOT=${prefix}
}

variant gdal description {GDAL import support} {
depends_lib-append port:gdal
configure.args-delete -DGDAL_ROOT=off
configure.args-append -DGDAL_ROOT=${prefix}
configure.args-replace -DGDAL_ROOT=off -DGDAL_ROOT=${prefix}
}

variant pcre description {PCRE regular expression support} {
depends_lib-append port:pcre
configure.args-delete -DPCRE_ROOT=off
configure.args-append -DPCRE_ROOT=${prefix}
configure.args-replace -DPCRE_ROOT=off -DPCRE_ROOT=${prefix}
}

variant openmp description {Enable experimental OpenMP parallel acceleration} {
configure.args-delete -DGMT_OPENMP=off
configure.args-append -DGMT_OPENMP=on
configure.args-replace -DGMT_OPENMP=off -DGMT_OPENMP=on

# FIXME: llvm-gcc42 is broken, https://trac.macports.org/ticket/40713
# Only clang really needs to be blacklisted
Expand All @@ -137,18 +115,14 @@ variant openmp description {Enable experimental OpenMP parallel acceleration} {
}

variant lgpl conflicts nonfree description {disallow use of GPL code, license will be LGPL} {
license-delete GPL-3
license-append LGPL-3
configure.args-delete -DLICENSE_RESTRICTED=GPL
configure.args-append -DLICENSE_RESTRICTED=LGPL
license-replace GPL-3 LGPL-3
configure.args-replace -DLICENSE_RESTRICTED=GPL -DLICENSE_RESTRICTED=LGPL
}

variant nonfree conflicts lgpl description {enable nonfree code, libraries and binaries \
will not be redistributable} {
license-delete GPL-3
license-append Restrictive
configure.args-delete -DLICENSE_RESTRICTED=GPL
configure.args-append -DLICENSE_RESTRICTED=no
license-replace GPL-3 Restrictive
configure.args-replace -DLICENSE_RESTRICTED=GPL -DLICENSE_RESTRICTED=no
}

notes "
Expand Down
43 changes: 43 additions & 0 deletions science/gmt5/files/patch-gmt5-ConfigCMake.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Removing unnecessary date functions with outdated syntax
Resolves: https://trac.macports.org/ticket/71306
--- cmake/modules/ConfigCMake.cmake.orig 2019-01-03 21:39:17
+++ cmake/modules/ConfigCMake.cmake 2024-11-28 14:34:33
@@ -76,38 +76,6 @@

set (GMT_LONG_VERSION_STRING "${GMT_PACKAGE_NAME} - ${GMT_PACKAGE_DESCRIPTION_SUMMARY}, Version ${GMT_PACKAGE_VERSION_WITH_SVN_REVISION}")

-# Get date
-if(DEFINED ENV{SOURCE_DATE_EPOCH})
- EXECUTE_PROCESS(
- COMMAND "date" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" "+%Y;%m;%d;%B"
- OUTPUT_VARIABLE _today
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-else(DEFINED ENV{SOURCE_DATE_EPOCH})
- try_run (_exit_today _compiled_today
- ${CMAKE_BINARY_DIR}/CMakeTmp
- ${CMAKE_MODULE_PATH}/today.c
- CMAKE_FLAGS
- RUN_OUTPUT_VARIABLE _today)
-
- if (NOT _compiled_today OR _exit_today EQUAL -1)
- message (WARNING "Date not implemented, please file a bug report.")
- set(_today "1313;13;13;Undecember")
- endif (NOT _compiled_today OR _exit_today EQUAL -1)
-endif(DEFINED ENV{SOURCE_DATE_EPOCH})
-
-list(GET _today 0 YEAR)
-list(GET _today 1 MONTH)
-list(GET _today 2 DAY)
-list(GET _today 3 MONTHNAME)
-list(GET _today 0 1 2 DATE)
-string (REPLACE ";" "-" DATE "${DATE}")
-set (_today)
-
-# set package date
-if (NOT GMT_VERSION_YEAR)
- set (GMT_VERSION_YEAR ${YEAR})
-endif (NOT GMT_VERSION_YEAR)
-
# apply license restrictions
if (LICENSE_RESTRICTED) # on
if (LICENSE_RESTRICTED STREQUAL GPL)
11 changes: 0 additions & 11 deletions science/gmt5/files/patch-gmt5-arm64.diff

This file was deleted.

23 changes: 23 additions & 0 deletions science/gmt5/files/patch-gmt5-common_sighandler.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- src/common_sighandler.c.orig 2019-01-03 15:39:17
+++ src/common_sighandler.c 2024-07-15 17:48:27
@@ -58,11 +58,19 @@
# if __DARWIN_UNIX03
# ifdef __x86_64__
# define UC_IP(uc) ((void *) (uc)->uc_mcontext->__ss.__rip)
+# elif defined(__arm64__) /* Apple Silicon, e.g. M1 */
+# define UC_IP(uc) ((void *) (uc)->uc_mcontext->__ss.__pc)
+# elif defined(__POWERPC__) /* Both ppc and ppc64 */
+# define UC_IP(uc) ((void *) (uc)->uc_mcontext->__ss.__srr0)
# else
# define UC_IP(uc) ((void *) (uc)->uc_mcontext->__ss.__eip)
# endif
# else
-# define UC_IP(uc) ((void *) (uc)->uc_mcontext->ss.eip)
+# ifdef __ppc__
+# define UC_IP(uc) ((void *) (uc)->uc_mcontext->ss.srr0)
+# else
+# define UC_IP(uc) ((void *) (uc)->uc_mcontext->ss.eip)
+# endif
# endif
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# ifdef __x86_64__
137 changes: 137 additions & 0 deletions science/gmt6/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup cmake 1.1
PortGroup github 1.0

name gmt6
github.setup GenericMappingTools gmt 6.5.0
github.tarball_from releases
distname ${github.project}-${github.version}-src
revision 2
epoch 1

categories science
maintainers {me.com:remko.scharroo @remkos} openmaintainer
license GPL-3

description The Generic Mapping Tools
long_description GMT is an open source collection of ~120 tools \
for manipulating geographic and Cartesian data sets and \
producing PostScript illustrations ranging from simple x-y \
plots via contour maps to artificially illuminated surfaces \
and 3D perspective views.

homepage https://www.generic-mapping-tools.org/
master_sites https://github.com/GenericMappingTools/gmt/releases/download/${version} \
ftp://ftp.soest.hawaii.edu/gmt \
ftp://ftp.star.nesdis.noaa.gov/pub/sod/lsa/gmt \
ftp://ftp.iris.washington.edu/pub/gmt \
ftp://ftp.iag.usp.br/pub/gmt \
ftp://gmt.mirror.ac.za/gmt \
http://mirrors.ustc.edu.cn/gmt \
http://www.scc.u-tokai.ac.jp/gmt
use_xz yes
distname gmt-${version}
distfiles ${distname}-src${extract.suffix}

checksums rmd160 3e47113d134bde756b98906a4704b3151902c4d1 \
sha256 4022adb44033f9c1d5a4d275b69506449e4d486efe2218313f3ff7a6c6c3141e \
size 58696516

patchfiles patch-gmt6-common_sighandler.diff

depends_lib port:curl \
port:dcw-gmt \
port:ghostscript \
port:gshhg-gmt \
port:netcdf

default_variants +gdal +pcre
if {![variant_isset lgpl]} {
default_variants-append +nonfree
}

cmake.install_prefix ${prefix}/lib/${subport}

# Mimic CMake's default FLAGS:
if {[variant_isset debug]} {
configure.optflags -O0
} else {
# optflags deliberately unset:
configure.optflags
# Set CMAKE_BUILD_TYPE=RelWithDebInfo to get reliable backtraces:
configure.args-replace -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=RelWithDebInfo
}

configure.cflags-append -fstrict-aliasing
configure.args-append -DDCW_ROOT=${prefix}/share/gmt/dcw \
-DCOPY_DCW=off \
-DGSHHG_ROOT=${prefix}/share/gmt/gshhg \
-DCOPY_GSHHG=off \
-DGS_ROOT=${prefix} \
-DNETCDF_ROOT=${prefix} \
-DCURL_ROOT=${prefix} \
-DFFTW3_ROOT=off \
-DGDAL_ROOT=off \
-DPCRE_ROOT=off \
-DGMT_OPENMP=off \
-DGMT_INSTALL_MODULE_LINKS=off \
-DGMT_INSTALL_TRADITIONAL_FOLDERNAMES=off \
-DLICENSE_RESTRICTED=GPL

post-destroot {
foreach l {gmt postscriptlight} {
file delete ${destroot}${prefix}/lib/${subport}/bin/lib${l}.${version}.dylib
}
ln -s ${prefix}/lib/${subport}/bin/gmt ${destroot}${prefix}/bin/${subport}
}

variant fftw3 description {Optional support for FFTW-3 library} {
depends_lib-append port:fftw-3-single
configure.args-replace -DFFTW3_ROOT=off -DFFTW3_ROOT=${prefix}
}

variant gdal description {GDAL import support} {
depends_lib-append port:gdal
configure.args-replace -DGDAL_ROOT=off -DGDAL_ROOT=${prefix}
}

variant pcre description {PCRE regular expression support} {
depends_lib-append port:pcre
configure.args-replace -DPCRE_ROOT=off -DPCRE_ROOT=${prefix}
}

variant openmp description {Enable experimental OpenMP parallel acceleration} {
configure.args-replace -DGMT_OPENMP=off -DGMT_OPENMP=on

# FIXME: llvm-gcc42 is broken, https://trac.macports.org/ticket/40713
# Only clang really needs to be blacklisted
compiler.blacklist *gcc-4.2 *clang*
compiler.fallback macports-gcc-5 macports-gcc-4.9 macports-gcc-4.8 macports-gcc-4.7 macports-gcc-4.6 macports-gcc-4.5 macports-gcc-4.4 macports-gcc-4.3

# Needed for compiling with GCC and Accelerate Framework on OSX:
configure.cflags-append -flax-vector-conversions
}

variant lgpl conflicts nonfree description {disallow use of GPL code, license will be LGPL} {
license-replace GPL-3 LGPL-3
configure.args-replace -DLICENSE_RESTRICTED=GPL -DLICENSE_RESTRICTED=LGPL
}

variant nonfree conflicts lgpl description {enable nonfree code, libraries and binaries \
will not be redistributable} {
license-replace GPL-3 Restrictive
configure.args-replace -DLICENSE_RESTRICTED=GPL -DLICENSE_RESTRICTED=no
}

notes "
${subport} is installed in ${prefix}/lib/${subport}.
${prefix}/bin/${subport} is a symblic link to ${prefix}/lib/${subport}/bin/gmt.
"

# livecheck for the proper branch (5 or 6) and skipping any release candidates
set firstchar [string range ${version} 0 0]
livecheck.type regex
livecheck.url ${github.homepage}/releases/
livecheck.regex gmt-(${firstchar}\\.\[0-9]+\\.\[0-9]+)-src${extract.suffix}
Loading

0 comments on commit b901a3c

Please sign in to comment.