1PORTNAME=	grass
2DISTVERSION=	8.4.2
3PORTREVISION=	4
4CATEGORIES=	databases geography
5MASTER_SITES=	https://grass.osgeo.org/%SUBDIR%/ \
6		http://grass.cict.fr/%SUBDIR%/ \
7		http://grass.fbk.eu/%SUBDIR%/ \
8		http://grass.gis-lab.info/%SUBDIR%/ \
9		http://grass.meteo.uni.wroc.pl/%SUBDIR%/ \
10		http://grass.polytechnic.edu.na/%SUBDIR%/ \
11		http://grass.unibuc.ro/%SUBDIR%/ \
12		http://mirrors.ibiblio.org/grass/%SUBDIR%/ \
13		http://pinus.gntech.ac.kr/grass/%SUBDIR%/ \
14		http://wgbis.ces.iisc.ernet.in/grass/%SUBDIR%/ \
15		http://wgrass.media.osaka-cu.ac.jp/grassh/%SUBDIR%/
16MASTER_SITE_SUBDIR=	grass${VER}/source
17PKGNAMESUFFIX=	8
18
19MAINTAINER=	ports@MidnightBSD.org
20COMMENT=	Open source Geographical Information System (GIS)
21WWW=		https://grass.osgeo.org/
22
23LICENSE=	gpl2+
24LICENSE_FILE=	${WRKSRC}/GPL.TXT
25
26BUILD_DEPENDS=	${PY_NUMPY} \
27		${PYTHON_PKGNAMEPREFIX}six>0:devel/py-six@${PY_FLAVOR}
28LIB_DEPENDS=	libfftw3.so:math/fftw3 \
29		libfontconfig.so:x11-fonts/fontconfig \
30		libfreetype.so:print/freetype2 \
31		libgdal.so:graphics/gdal \
32		libgeos.so:graphics/geos \
33		libgeotiff.so:graphics/libgeotiff \
34		libpng.so:graphics/png \
35		libproj.so:graphics/proj \
36		libtiff.so:graphics/tiff \
37		libzstd.so:archivers/zstd
38RUN_DEPENDS=	${PY_NUMPY} \
39		${PYTHON_PKGNAMEPREFIX}six>0:devel/py-six@${PY_FLAVOR} \
40		${PYTHON_PKGNAMEPREFIX}sqlite3>0:databases/py-sqlite3@${PY_FLAVOR}
41
42USES=		blaslapack compiler:c11 gl gmake gnome iconv jpeg perl5 \
43		pkgconfig python readline shebangfix sqlite xorg
44SHEBANG_GLOB=	*.py
45SHEBANG_LANG=	nviz
46nviz_OLD_CMD=	nviz
47nviz_CMD=	${PREFIX}/${GRASS_INST_DIR}/bin/nviz
48USE_XORG=	ice sm x11 xext xi xmu xrender xt
49USE_GL=		gl glu
50USE_GNOME=	cairo
51USE_WX=		3.2
52WX_COMPS=	python:run wx
53GNU_CONFIGURE=	yes
54
55CONFIGURE_ARGS=	--enable-largefile \
56		--exec-prefix=${LOCALBASE} \
57		--prefix=${LOCALBASE} \
58		--with-blas \
59		--with-cairo \
60		--with-freetype \
61		--with-freetype-includes=${LOCALBASE}/include/freetype2 \
62		--with-gdal=${LOCALBASE}/bin/gdal-config \
63		--with-geos=${LOCALBASE}/bin/geos-config \
64		--with-includes=${LOCALBASE}/include \
65		--with-lapack \
66		--with-libs=${LOCALBASE}/lib \
67		--with-opengl-includes=${LOCALBASE}/include/ \
68		--with-opengl-libs=${LOCALBASE}/lib/ \
69		--with-proj-includes=${LOCALBASE}/include \
70		--with-proj-libs=${LOCALBASE}/lib \
71		--with-proj-share=${LOCALBASE}/share/proj \
72		--with-proj=${LOCALBASE}/bin/proj \
73		--with-pthread=yes \
74		--with-readline \
75		--with-wxwidgets=${WX_CONFIG}
76
77CFLAGS+=	-std=c11
78
79SUB_LIST=	PYTHON_CMD=${PYTHON_CMD}
80BINARY_ALIAS=	python3=${PYTHON_CMD}
81ALL_TARGET=	default
82USE_LDCONFIG=	${PREFIX}/${GRASS_INST_DIR}/lib
83MAKE_ENV+=	TARGET="${CONFIGURE_TARGET}"
84VER=		${PORTVERSION:R:C/\.//}
85
86PLIST_SUB=	GRASS_INST_DIR="${GRASS_INST_DIR}" \
87		MAJVER="${PKGNAMESUFFIX}" \
88		VER="${VER}" \
89		VERS="${PORTVERSION:C/([0-9]+).([0-9]+)(.*)/\1.\2/}" \
90		VERSION="${PORTVERSION}"
91
92OPTIONS_DEFINE=		NETCDF NLS PDAL
93OPTIONS_MULTI=		DB
94OPTIONS_MULTI_DB=	MYSQL ODBC PGSQL
95OPTIONS_DEFAULT=	NETCDF NLS PDAL PGSQL
96OPTIONS_SUB=		yes
97
98PDAL_DESC=		Enable points cloud data modules
99DB_DESC=		Database support
100MYSQL_USES=		mysql
101MYSQL_CONFIGURE_ON=	--with-mysql \
102			--with-mysql-includes=${LOCALBASE}/include/mysql \
103			--with-mysql-libs=${LOCALBASE}/lib/mysql
104NETCDF_CONFIGURE_ON=	--with-netcdf=${LOCALBASE}/bin/nc-config
105NETCDF_LIB_DEPENDS=	libnetcdf.so:science/netcdf
106NLS_CONFIGURE_WITH=	nls
107NLS_USES=		gettext
108ODBC_LIB_DEPENDS=	libodbc.so:databases/unixODBC
109ODBC_CONFIGURE_WITH=	odbc
110PDAL_CONFIGURE_ON=	--with-pdal=${LOCALBASE}/bin/pdal-config
111PDAL_LIB_DEPENDS=	libpdalcpp.so:math/pdal
112PGSQL_USES=		pgsql
113PGSQL_CONFIGURE_WITH=	postgres
114
115.if exists(/usr/include/omp.h)
116CONFIGURE_ARGS+=	--with-openmp
117.endif
118
119.include <bsd.port.pre.mk>
120
121.if !defined (GRASS_INST_DIR)
122GRASS_INST_DIR=	${PORTNAME}${VER}
123.endif
124
125MANDIRS=	${PREFIX}/grass${VER}/docs/man/man1
126
127post-patch:
128	${REINPLACE_CMD} \
129		's|= python3|= ${PYTHON_CMD:T}|' ${WRKSRC}/include/Make/Platform.make.in
130	${REINPLACE_CMD} \
131		's|$$(ARCH)|$$(TARGET)|g' ${WRKSRC}/include/Make/Grass.make
132# Replace hardcoded python interpreter to PYTHON_CMD
133	${REINPLACE_CMD} 's|"GRASS_PYTHON", "python"|"GRASS_PYTHON", "${PYTHON_CMD}"|g' \
134		${WRKSRC}/scripts/wxpyimgview/wxpyimgview.py
135	${REINPLACE_CMD} \
136		's|environ\["GRASS_PYTHON"\] = "python3"|environ["GRASS_PYTHON"] = "${PYTHON_CMD}"|g' \
137		${WRKSRC}/python/grass/script/setup.py
138
139post-install:
140	${RM} -rf ${FAKE_DESTDIR}${PREFIX}/${GRASS_INST_DIR}/demolocation/PERMANENT/.tmp/
141
142# STRIP PART
143	${STRIP_CMD} ${FAKE_DESTDIR}${PREFIX}/${GRASS_INST_DIR}/bin/*
144	${STRIP_CMD} ${FAKE_DESTDIR}${PREFIX}/${GRASS_INST_DIR}/driver/db/*
145.for i in clean_temp current_time_s_ms echo i.find lock run r.watershed/seg \
146	r.watershed/ram lister/vector lister/cell
147	${STRIP_CMD} ${FAKE_DESTDIR}${PREFIX}/${GRASS_INST_DIR}/etc/${i}
148.endfor
149	${STRIP_CMD} ${FAKE_DESTDIR}${PREFIX}/${GRASS_INST_DIR}/lib/*
150	${STRIP_CMD} ${FAKE_DESTDIR}${PREFIX}/${GRASS_INST_DIR}/utils/g.echo
151
152# symlink grass8
153	${LN} -sf ${PORTNAME} \
154		${PREFIX}/bin/${PORTNAME}${PKGNAMESUFFIX}
155.include <bsd.port.post.mk>
156