1PORTNAME=	squid
2DISTVERSION=	7.4
3CATEGORIES=	www
4MASTER_SITES=	https://github.com/${PORTNAME}-cache/${PORTNAME}/releases/download/${PORTNAME:tu}_${DISTVERSION:S|.|_|g}/
5
6MAINTAINER=	ports@MidnightBSD.org
7COMMENT=	HTTP Caching Proxy
8WWW=		https://www.squid-cache.org/ \
9		https://github.com/squid-cache/squid/
10
11LICENSE=	gpl2
12LICENSE_FILE=	${WRKSRC}/COPYING
13
14USES=		compiler:c++17-lang cpe gmake localbase:ldflags perl5 \
15		shebangfix tar:xz
16CPE_VENDOR=	squid-cache
17USE_RC_SUBR=	squid
18
19SHEBANG_FILES=	contrib/*.pl scripts/*.pl tools/*.pl
20
21GNU_CONFIGURE=	yes
22CONFIGURE_ARGS=	--bindir=${PREFIX}/sbin \
23		--datadir=${ETCDIR} \
24		--disable-arch-native \
25		--disable-epoll \
26		--disable-strict-error-checking \
27		--enable-build-info \
28		--enable-removal-policies="lru heap" \
29		--libexecdir=${PREFIX}/libexec/squid \
30		--localstatedir=/var \
31		--sbindir=${PREFIX}/sbin \
32		--sysconfdir=${ETCDIR} \
33		--with-default-user=squid \
34		--with-included-ltdl \
35		--with-logdir=/var/log/squid \
36		--with-pidfile=/var/run/squid/squid.pid \
37		--with-swapdir=/var/squid/cache \
38		--without-cap \
39		--without-gnutls \
40		--without-netfilter-conntrack \
41		--without-systemd
42
43CONFLICTS=	squid-devel
44
45SUB_FILES+=	900.squid-rotate-log pkg-install pkg-message
46
47USERS=		squid
48GROUPS=		squid
49
50.if !defined(SQUID_CONFIGURE_ARGS) || \
51	${SQUID_CONFIGURE_ARGS:M*--disable-unlinkd*} == ""
52PLIST_SUB+=	UNLINKD=""
53.else
54PLIST_SUB+=	UNLINKD="@comment "
55.endif
56PORTDOCS=	${MYDOCS:T}
57PORTEXAMPLES=	*
58
59OPTIONS_DEFINE=		ARP_ACL CACHE_DIGESTS DEBUG DELAY_POOLS DOCS ECAP \
60			EXAMPLES FOLLOW_XFF FS_AUFS FS_DISKD FS_ROCK HTCP ICAP \
61			ICMP IPV6 KQUEUE LARGEFILE LAX_HTTP NETTLE SNMP SSL \
62			SSL_CRTD STACKTRACES TDB VIA_DB WCCP WCCPV2
63OPTIONS_DEFAULT=	ARP_ACL AUTH_NIS CACHE_DIGESTS DELAY_POOLS FOLLOW_XFF \
64			FS_AUFS FS_DISKD FS_ROCK GSSAPI_NONE HTCP ICAP ICMP \
65			KQUEUE LARGEFILE LAX_HTTP SNMP SSL SSL_CRTD TP_IPFW \
66			VIA_DB WCCP WCCPV2
67OPTIONS_GROUP=		AUTH
68OPTIONS_GROUP_AUTH=	AUTH_LDAP AUTH_NIS AUTH_SASL AUTH_SMB AUTH_SQL
69OPTIONS_RADIO=		FW
70OPTIONS_RADIO_FW=	TP_IPF TP_IPFW TP_PF
71OPTIONS_SINGLE=		GSSAPI
72OPTIONS_SINGLE_GSSAPI=	GSSAPI_BASE GSSAPI_HEIMDAL GSSAPI_MIT GSSAPI_NONE
73OPTIONS_SUB=		yes
74
75ARP_ACL_DESC=		ARP/MAC/EUI based authentification
76AUTH_DESC=		Authentication helpers
77AUTH_LDAP_DESC=		Install LDAP authentication helpers
78AUTH_NIS_DESC=		Install NIS/YP authentication helpers
79AUTH_SASL_DESC=		Install SASL authentication helpers
80AUTH_SMB_DESC=		Install SMB auth. helpers (req. Samba)
81AUTH_SQL_DESC=		Install SQL based auth
82CACHE_DIGESTS_DESC=	Use cache digests
83DEBUG_DESC=		Build with extended debugging support
84DELAY_POOLS_DESC=	Delay pools (bandwidth limiting)
85ECAP_DESC=		Loadable content adaptation modules
86FOLLOW_XFF_DESC=	Support for the X-Following-For header
87FS_AUFS_DESC=		AUFS (threaded-io) support
88FS_DISKD_DESC=		DISKD storage engine controlled by separate service
89FS_ROCK_DESC=		ROCK storage engine
90HTCP_DESC=		HTCP support
91ICAP_DESC=		the ICAP client
92ICMP_DESC=		ICMP pinging and network measurement
93KQUEUE_DESC=		Kqueue(2) support
94LARGEFILE_DESC=		Support large (>2GB) cache and log files
95LAX_HTTP_DESC=		Do not enforce strict HTTP compliance
96NETTLE_DESC=		Nettle MD5 algorithm support
97SNMP_DESC=		SNMP support
98SSL_CRTD_DESC=		Use ssl_crtd to handle SSL cert requests
99SSL_DESC=		SSL gatewaying support
100STACKTRACES_DESC=	Enable automatic backtraces on fatal errors
101TDB_DESC=		TrivialDB support required for session and time quota external helpers
102TP_IPFW_DESC=		Transparent proxying with IPFW
103TP_IPF_DESC=		Transparent proxying with IPFilter
104TP_PF_DESC=		Transparent proxying with PF
105VIA_DB_DESC=		Forward/Via database
106WCCPV2_DESC=		Web Cache Coordination Protocol v2
107WCCP_DESC=		Web Cache Coordination Protocol
108
109ARP_ACL_CONFIGURE_ENABLE=	eui
110AUTH_LDAP_USES=			ldap
111AUTH_LDAP_CONFIGURE_WITH=	ldap
112AUTH_LDAP_VARS=			BASIC_AUTH+=LDAP \
113				DIGEST_AUTH+="eDirectory LDAP" \
114				EXTERNAL_ACL+="LDAP_group eDirectory_userip"
115AUTH_SASL_LIB_DEPENDS=		libsasl2.so:security/cyrus-sasl2
116AUTH_SASL_VARS=			BASIC_AUTH+=SASL
117AUTH_SMB_USES=			samba:run
118AUTH_SMB_VARS=			BASIC_AUTH+=SMB \
119				EXTERNAL_ACL+=wbinfo_group
120AUTH_SQL_RUN_DEPENDS=		p5-DBI>=1.08:databases/p5-DBI
121AUTH_SQL_VARS=			EXTERNAL_ACL+=SQL_session
122CACHE_DIGESTS_CONFIGURE_ENABLE=	cache-digests
123DELAY_POOLS_CONFIGURE_ENABLE=	delay-pools
124ECAP_LIB_DEPENDS=		libecap.so:www/libecap
125ECAP_USES=			pkgconfig:build
126ECAP_CONFIGURE_ENABLE=		ecap
127FOLLOW_XFF_CONFIGURE_ENABLE=	follow-x-forwarded-for
128FS_AUFS_CONFIGURE_WITH=		pthreads
129# Nil aufs threads is default, set any other value via SQUID_CONFIGURE_ARGS,
130# e.g. SQUID_CONFIGURE_ARGS=--with-aufs-threads=N
131FS_AUFS_LDFLAGS=		-pthread
132FS_AUFS_VARS=			DISKIO_MODULES+=DiskThreads \
133				STORAGE_SCHEMES+=aufs
134FS_DISKD_VARS=			DISKIO_MODULES+=DiskDaemon \
135				STORAGE_SCHEMES+=diskd
136FS_ROCK_VARS=			STORAGE_SCHEMES+=rock
137GSSAPI_BASE_USES=		gssapi
138GSSAPI_BASE_CONFIGURE_ON=	${GSSAPI_CONFIGURE_ARGS} \
139				krb5_config=${GSSAPIBASEDIR}/bin/krb5-config
140.if exists(/usr/libdata/pkgconfig/mit-krb5.pc)
141GSSAPI_BASE_CONFIGURE_ON+=	--with-mit-krb5=${GSSAPIBASEDIR}
142.else
143GSSAPI_BASE_CONFIGURE_ON+=	--with-heimdal-krb5=${GSSAPIBASEDIR} \
144				--without-mit-krb5
145.endif
146GSSAPI_BASE_PLIST_SUB=		AUTH_KERB=""
147GSSAPI_HEIMDAL_USES=		gssapi:heimdal
148GSSAPI_HEIMDAL_CONFIGURE_ON=	${GSSAPI_CONFIGURE_ARGS} \
149				--with-heimdal-krb5=${GSSAPIBASEDIR} \
150				--without-mit-krb5 \
151				krb5_config=${GSSAPIBASEDIR}/bin/krb5-config
152GSSAPI_HEIMDAL_PLIST_SUB=	AUTH_KERB=""
153GSSAPI_MIT_USES=		gssapi:mit
154GSSAPI_MIT_CONFIGURE_ON=	${GSSAPI_CONFIGURE_ARGS} \
155				--with-mit-krb5=${GSSAPIBASEDIR} \
156				krb5_config=${GSSAPIBASEDIR}/bin/krb5-config
157GSSAPI_MIT_PLIST_SUB=		AUTH_KERB=""
158GSSAPI_NONE_CONFIGURE_ON=	--without-gss \
159				--without-heimdal-krb5 \
160				--without-mit-krb5
161HTCP_CONFIGURE_ENABLE=		htcp
162ICAP_CONFIGURE_ENABLE=		icap-client
163ICMP_CONFIGURE_ENABLE=		icmp
164IPV6_CONFIGURE_ENABLE=		ipv6
165KQUEUE_CONFIGURE_ENABLE=	kqueue
166LARGEFILE_CONFIGURE_WITH=	large-files
167LAX_HTTP_CONFIGURE_ENABLE=	http-violations
168NETTLE_LIB_DEPENDS=		libnettle.so:security/nettle
169NETTLE_CONFIGURE_WITH=		nettle
170SNMP_CONFIGURE_ENABLE=		snmp
171SSL_USES=			ssl
172SSL_CONFIGURE_ON=		--enable-security-cert-generators="file" \
173				--with-openssl \
174				LIBOPENSSL_CFLAGS=-I${OPENSSLINC} \
175				LIBOPENSSL_LIBS="-lcrypto -lssl"
176SSL_CONFIGURE_ENABLE=		ssl
177SSL_CRTD_IMPLIES=		SSL
178SSL_CRTD_CONFIGURE_ENABLE=	ssl-crtd
179STACKTRACES_LIB_DEPENDS=	libunwind.so:devel/libunwind
180STACKTRACES_CONFIGURE_ENABLE=	stacktraces
181STACKTRACES_CFLAGS=		-g
182STACKTRACES_LDFLAGS=		-lunwind
183STACKTRACES_EXTRA_PATCHES=	${FILESDIR}/extra-patch-gen-stacktrace
184STACKTRACES_VARS=		STRIP=""
185TDB_LIB_DEPENDS=		libtdb.so:${SAMBA_TDB_PORT}
186TDB_USES=			pkgconfig:build samba:env
187TDB_CONFIGURE_WITH=		tdb
188TDB_VARS=			EXTERNAL_ACL+="time_quota session"
189TP_IPFW_CONFIGURE_ENABLE=	ipfw-transparent
190TP_IPF_CONFIGURE_ENABLE=	ipf-transparent
191TP_PF_CONFIGURE_ENABLE=		pf-transparent
192TP_PF_CONFIGURE_WITH=		nat-devpf
193VIA_DB_CONFIGURE_ENABLE=	forw-via-db
194WCCPV2_CONFIGURE_ENABLE=	wccpv2
195WCCP_CONFIGURE_ENABLE=		wccp
196
197MYDOCS=		QUICKSTART README RELEASENOTES.html doc/debug-sections.txt
198
199change_files=	ChangeLog errors/Makefile.am errors/Makefile.in src/Makefile.am \
200		src/Makefile.in src/cf_gen.cc src/squid.8.in \
201		test-suite/Makefile.in test-suite/Makefile.am
202
203.include <bsd.mport.options.mk>
204
205# Authentication methods and modules:
206BASIC_AUTH+=	DB NCSA PAM POP3 RADIUS fake getpwnam
207DIGEST_AUTH+=	file
208EXTERNAL_ACL+=	file_userip unix_group delayer
209
210# POLA: allow the old global make.conf(5) (pre src.conf(5)) defines, too:
211.if ${PORT_OPTIONS:MAUTH_NIS} && !defined(NO_NIS) && !defined(WITHOUT_NIS)
212BASIC_AUTH+=	NIS
213CPPFLAGS+=	-DBOOL_DEFINED
214.endif
215
216# POLA: allow the old global make.conf(5) (pre src.conf(5)) defines, too:
217.if ${PORT_OPTIONS:MGSSAPI_NONE} || defined(NO_KERBEROS) || \
218	defined(WITHOUT_KERBEROS)
219NEGOTIATE_AUTH=	none
220PLIST_SUB+=	AUTH_KERB="@comment "
221.else
222# The kerberos_ldap_group external helper also depends on LDAP and SASL:
223# The kerberos_sid_group external helper depends on kerberos_ldap_group meanwhile
224. if ${PORT_OPTIONS:MAUTH_LDAP} && ${PORT_OPTIONS:MAUTH_SASL}
225EXTERNAL_ACL+=	kerberos_ldap_group kerberos_sid_group
226. endif
227NEGOTIATE_AUTH=	kerberos wrapper
228.endif
229
230# Storage schemes:
231STORAGE_SCHEMES+=	ufs
232DISKIO_MODULES+=	AIO Blocking IpcIo Mmapped
233
234CONFIGURE_ARGS+=	--enable-auth-basic="${BASIC_AUTH}" \
235			--enable-auth-digest="${DIGEST_AUTH}" \
236			--enable-auth-negotiate="${NEGOTIATE_AUTH}" \
237			--enable-auth-ntlm="fake" \
238			--enable-disk-io="${DISKIO_MODULES}" \
239			--enable-external-acl-helpers="${EXTERNAL_ACL}" \
240			--enable-log-daemon-helpers="file DB" \
241			--enable-security-cert-validators="fake" \
242			--enable-storeid-rewrite-helpers="file" \
243			--enable-storeio="${STORAGE_SCHEMES}" \
244			--enable-url-rewrite-helpers="fake LFS"
245# Other options set via 'make config':
246
247.if ${PORT_OPTIONS:MDEBUG} || defined(WITH_DEBUG)
248CONFIGURE_ARGS+=	--disable-optimizations
249WITH_DEBUG?=		yes
250.endif
251
252# Finally, add additional user specified configuration options:
253CONFIGURE_ARGS+=	${SQUID_CONFIGURE_ARGS}
254
255post-patch:
256	@(cd ${WRKSRC} && ${REINPLACE_CMD} \
257		-e 's|\.conf\.default|.conf.sample|' \
258		-e 's|)\.default|).sample|' \
259		${change_files})
260	@(cd ${WRKSRC} && ${MV} src/mime.conf.default src/mime.conf.sample)
261
262post-patch-IPV6-off:
263	@${REINPLACE_CMD} -E -e's| ::1$$||' -e's| ::1?/128||g' \
264		-e'/acl localnet src f[ce][08]0::/d' \
265		-e's| 2001:DB8::[^[:space:]]+$$||' \
266		-e'/tcp_outgoing_address 2001:db8::/d' \
267		${WRKSRC}/src/cf.data.pre
268
269post-install:
270	@${MKDIR} ${PREFIX}/etc/periodic/weekly \
271		  ${EXAMPLESDIR} \
272		  ${DOCSDIR}
273	${INSTALL_SCRIPT} ${WRKDIR}/900.squid-rotate-log \
274		${PREFIX}/etc/periodic/weekly
275	${INSTALL_DATA} ${WRKSRC}/src/auth/basic/DB/passwd.sql \
276		${EXAMPLESDIR}
277	(cd ${WRKSRC} && ${INSTALL_DATA} ${MYDOCS} ${DOCSDIR})
278
279.include <bsd.port.mk>
280