1# Created by: torstenb
2
3PORTNAME=	zsh
4DISTVERSION=	5.9
5CATEGORIES=	shells
6MASTER_SITES=	https://www.zsh.org/pub/ \
7		SF \
8		https://www.zsh.org/pub/:doc \
9		SF/${PORTNAME}/${PORTNAME}-doc/${PORTVERSION}:doc
10DISTFILES=	${DISTNAME}${EXTRACT_SUFX}
11
12MAINTAINER=	ports@MidnightBSD.org
13COMMENT=	Z shell
14WWW=		https://www.zsh.org/
15
16LICENSE=	ZSH
17LICENSE_NAME=	ZSH license
18LICENSE_FILE=	${WRKSRC}/LICENCE
19LICENSE_PERMS=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
20
21MAKE_JOBS_UNSAFE=	yes
22
23USES=		autoreconf cpe iconv localbase:ldflags ncurses shebangfix tar:xz
24
25SHEBANG_LANG=	zsh
26zsh_OLD_CMD=	zsh	# shebang appears as /bin/zsh and just zsh
27SHEBANG_FILES=	Functions/Calendar/* \
28		Functions/Misc/*
29
30CONFIGURE_ARGS=	--with-tcsetpgrp \
31		--enable-function-subdirs \
32		--enable-maildir-support \
33		--enable-multibyte \
34		--enable-zsh-secure-free \
35		--sysconfdir=${PREFIX}/etc
36
37# fix PREFIX != LOCALBASE
38CONFIGURE_ARGS+=--disable-site-fndir \
39		--enable-additional-fpath=${DATADIR}/site-functions
40
41CONFIGURE_ENV+=	zsh_cv_sys_path_dev_fd=no \
42		ac_cv_header_sys_capability_h=no
43CONFIGURE_TARGET=	${ARCH}-portbld-freebsd11.4
44
45GNU_CONFIGURE=	yes
46CPPFLAGS+=	-DBOOL_DEFINED
47LDFLAGS+=	-Wl,--as-needed
48#TEST_TARGET=	test
49NO_TEST=	yes
50
51OPTIONS_DEFINE=	DEBUG ETCDIR GDBM MEM PCRE STATIC \
52		DOCS EXAMPLES
53OPTIONS_SUB=	yes
54
55ETCDIR_DESC=	System-wide defaults in /etc (instead of $${PREFIX}/etc)
56GDBM_DESC=	Enable GDBM support (GPL)
57MEM_DESC=	Enable zsh-mem options
58
59GDBM_LIB_DEPENDS=	libgdbm.so:databases/gdbm
60PCRE_LIB_DEPENDS=	libpcre.so:devel/pcre
61
62DEBUG_CONFIGURE_ENABLE=	zsh-debug
63ETCDIR_CONFIGURE_OFF=	--enable-etcdir=${PREFIX}/etc
64GDBM_CONFIGURE_ENABLE=	gdbm
65MEM_CONFIGURE_ENABLE=	zsh-mem
66PCRE_CONFIGURE_ENABLE=	pcre
67
68## Some modules can only be built as a shared library.
69## If you enable STATIC, you may get strange errors if you, a script,
70## or a plugin tries to use the regex module.
71STATIC_LDFLAGS=		-static
72STATIC_CONFIGURE_ON=	--disable-dynamic --with-term-lib="tinfow tinfo"
73STATIC_CONFIGURE_OFF=	--enable-dynamic  --with-term-lib="ncursesw ncurses"
74
75DOCS=		LICENCE META-FAQ README \
76		Etc/BUGS Etc/CONTRIBUTORS Etc/FAQ Etc/completion-style-guide \
77		Doc/zsh*.html Doc/zsh.dvi
78DOCS_DISTFILES=	${DISTNAME}-doc${EXTRACT_SUFX}:doc
79
80PORTDOCS=	*
81PORTEXAMPLES=	zlogin zshenv zshrc
82
83ZSH_VER=	${PORTVERSION}
84PLIST_SUB+=	ZSH_VER="${ZSH_VER}"
85SUB_FILES=	pkg-message
86
87.include <bsd.port.pre.mk>
88
89.if empty(ICONV_LIB)
90CONFIGURE_ENV+=	ac_cv_lib_iconv_libiconv=no
91.endif
92
93post-patch:
94	@${REINPLACE_CMD} -e '/LIBS/s|-lrt||' ${WRKSRC}/configure
95	@${REINPLACE_CMD} -e "s|/etc/|${LOCALBASE}/etc/|" \
96		${WRKSRC}/Functions/MIME/zsh-mime-setup
97	${RM} ${WRKSRC}/Doc/help.txt
98
99post-patch-STATIC-on:
100	@${REINPLACE_CMD} -e "s|link=dynamic|link=either|" \
101		${WRKSRC}/Src/Modules/*.mdd
102
103post-build:
104# Fix ".so" macro problem by using "soelim" command.
105# soelim needs the manpages in man1/
106	${LN} -sf ${WRKSRC}/Doc ${WRKSRC}/man1
107	${MV} ${WRKSRC}/Doc/zshall.1 ${WRKSRC}/Doc/zshall.1.source
108	(cd ${WRKSRC} && ${SOELIM} -r ${WRKSRC}/Doc/zshall.1.source > \
109		${WRKSRC}/Doc/zshall.1)
110
111post-install:
112	${MKDIR} ${DATADIR}/site-functions
113	${LN} -f ${PREFIX}/bin/zsh ${PREFIX}/bin/rzsh
114# Precompile completions and functions
115	(${PREFIX}/bin/zsh -fc ' \
116		setopt extendedglob nomark_dirs; \
117		cd /${DATADIR}/${ZSH_VER} ; \
118		${RM} -f functions/**/*.orig ; \
119		for i in functions/**/*(/) ; do \
120			zcompile -U -M $$i.zwc $$i/*~*.zwc(^/) ; \
121			${CHMOD} 644 $$i.zwc ; \
122		done')
123
124post-install-EXAMPLES-on:
125	@${MKDIR} ${FAKE_DESTDIR}${EXAMPLESDIR}
126	(cd ${WRKSRC}/StartupFiles && ${INSTALL_DATA} ${PORTEXAMPLES} ${FAKE_DESTDIR}${EXAMPLESDIR})
127
128post-install-DOCS-on:
129	@${MKDIR} ${FAKE_DESTDIR}${DOCSDIR}
130	(cd ${WRKSRC} && ${INSTALL_DATA} ${DOCS} ${FAKE_DESTDIR}${DOCSDIR})
131
132.include <bsd.port.post.mk>
133