1 # Created by: Marc G. Fournier <scrappy@FreeBSD.org>
6 # PORTREVISION must be ?= otherwise, all slave ports get this PORTREVISION and
7 # not their own. Probably best to keep it at ?=0 when reset here too.
10 MASTER_SITES= PGSQL/source/v${DISTVERSION}
11 PKGNAMESUFFIX?= ${PORTVERSION:R}${COMPONENT}
13 MAINTAINER?= pgsql@FreeBSD.org
14 COMMENT?= PostgreSQL is the most advanced open-source database available anywhere
18 .if ${DISTVERSION:C/([0-9]*).*/\1/} >= 10
19 CONFLICTS+= ${PORTNAME}9* ${PORTNAME}1[^${PORTVERSION:R:C/.*([0-9]$)/\\1/}]*
21 CONFLICTS+= ${PORTNAME}9[^${PORTVERSION:R:E}]* ${PORTNAME}1[0-9]*
24 WRKSRC= ${WRKDIR}/postgresql-${DISTVERSION}
25 DIST_SUBDIR= postgresql
29 PKGINSTALL?= ${PKGDIR}/pkg-install${COMPONENT}
31 .if !defined(NO_BUILD)
40 LDFLAGS+= -L${LOCALBASE}/lib
41 INCLUDES+= -I${LOCALBASE}/include
42 CONFIGURE_ARGS+=--with-libraries=${PREFIX}/lib \
43 --with-includes=${PREFIX}/include \
44 --enable-thread-safety
45 CONFIGURE_ENV+= INCLUDES="${INCLUDES}" \
46 PTHREAD_LIBS="-lpthread" \
47 LDFLAGS_SL="${LDFLAGS_SL}"
51 PLIST= ${PKGDIR}/pkg-plist${COMPONENT}
53 INSTALL_DIRS?= src/common src/timezone src/backend \
54 src/backend/utils/mb/conversion_procs \
55 src/backend/snowball src/backend/replication/libpqwalreceiver \
56 src/backend/replication/pgoutput \
57 src/bin/initdb src/bin/pg_ctl \
58 src/bin/pg_archivecleanup src/bin/pg_basebackup \
59 src/bin/pg_checksums \
60 src/bin/pg_controldata src/bin/pg_resetwal src/pl \
62 src/bin/pg_test_fsync src/bin/pg_test_timing \
63 src/bin/pg_waldump src/bin/pg_upgrade
65 BUILD_DIRS?= src/port ${INSTALL_DIRS}
66 INSTALL_TARGET?=install-strip
68 .if !defined(CLIENT_ONLY) && !defined(SLAVE_ONLY)
71 USE_RC_SUBR= postgresql
72 USES+= pgsql:${DISTVERSION:C/([0-9]\.?[0-9]).*/\1/g}
78 .if defined(CLIENT_ONLY)
79 OPTIONS_DEFINE+=LIBEDIT DOCS
80 LIBEDIT_DESC= Use non-GPL libedit instead of readline
83 MAKE_ENV+= PATH=${PREFIX}/bin:${PATH}
84 CONFIGURE_ENV+= PATH=${PREFIX}/bin:${PATH}
87 .if defined(SERVER_ONLY)
88 OPTIONS_DEFINE= DTRACE LDAP INTDATE TZDATA XML DOCS
89 LDAP_DESC= Build with LDAP authentication support
90 DTRACE_DESC= Build with DTrace probes
91 TZDATA_DESC= Use internal timezone database
92 XML_DESC= Build with XML data type
94 .if ${DISTVERSION:C/([0-9]*).*/\1/} >= 11
96 LLVM_DESC= Build with support for JIT-compiling expressions
97 OPTIONS_DEFAULT+= ${OPTIONS_DEFAULT_${CHOSEN_COMPILER_TYPE}}
98 OPTIONS_DEFAULT_clang= LLVM
101 .if ${DISTVERSION:C/([0-9]*).*/\1/} < 10
102 # See http://people.freebsd.org/~girgen/postgresql-icu/README.html for more info
104 ICU_DESC= Use ICU for unicode collation
106 CONFIGURE_ARGS+=--with-icu
107 LIB_DEPENDS+= libicudata.so:devel/icu
111 # See http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/76999 for more info
112 # (requires dump/restore if modified.)
113 OPTIONS_DEFINE+= INTDATE
114 INTDATE_DESC= Builds with 64-bit date/time type
115 OPTIONS_DEFAULT+= INTDATE
118 .if !defined(SLAVE_ONLY)
119 OPTIONS_DEFINE+= NLS PAM GSSAPI OPTIMIZED_CFLAGS DEBUG DOCS
120 . if ${DISTVERSION:R} == 9.2 || ${DISTVERSION:R} == 9.3
122 OPTIONS_RADIO_KRB5= MIT_KRB5 HEIMDAL_KRB5
125 KRB5_DESC= Build with kerberos provider support
126 NLS_DESC= Use internationalized messages
127 PAM_DESC= Build with PAM Support
128 MIT_KRB5_DESC= Build with MIT kerberos support
129 HEIMDAL_KRB5_DESC= Builds with Heimdal kerberos
130 GSSAPI_DESC= Build with GSSAPI support
131 OPTIMIZED_CFLAGS_DESC= Builds with compiler optimizations (-O3)
134 SSL_DESC= Build with OpenSSL support
136 OPTIONS_DEFAULT+= SSL
139 .if defined(CLIENT_ONLY)
140 LIBEDIT_CONFIGURE_ON+=--with-libedit-preferred
141 LIBEDIT_USES= libedit
142 LIBEDIT_USES_OFF= readline
146 SSL_CONFIGURE_WITH= openssl
148 PAM_CONFIGURE_WITH= pam
150 XML_CONFIGURE_WITH= libxml
151 XML_LIB_DEPENDS= libxml2.so:textproc/libxml2
153 TZDATA_CONFIGURE_OFF= --with-system-tzdata=/usr/share/zoneinfo
155 INTDATE_CONFIGURE_OFF= --disable-integer-datetimes
157 NLS_CONFIGURE_ENABLE= nls
160 LDAP_CONFIGURE_WITH= ldap
161 LDAP_USE= OPENLDAP=yes
163 OPTIMIZED_CFLAGS_CFLAGS=-O3 -funroll-loops
165 DEBUG_CONFIGURE_ENABLE= debug
167 PLIST_SUB+= PG_USER=${PG_USER} \
169 SUB_LIST+= PG_GROUP=${PG_GROUP} \
173 .include <bsd.port.options.mk>
175 .if ${ARCH} == "i386"
176 USES+= compiler:gcc-c++11-lib
181 .if ${DISTVERSION:C/([0-9]*).*/\1/} >= 11
182 . if defined(SERVER_ONLY) && ${PORT_OPTIONS:MLLVM}
183 BUILD_DEPENDS+= llvm${LLVM_DEFAULT}>0:devel/llvm${LLVM_DEFAULT}
184 BUILD_DEPENDS+= llvm-config${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT}
185 RUN_DEPENDS+= llvm-config${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT}
186 CONFIGURE_ENV+= LLVM_CONFIG=${LOCALBASE}/bin/llvm-config${LLVM_DEFAULT}
187 CONFIGURE_ARGS+= --with-llvm
189 INSTALL_DIRS+= src/backend/jit/llvm
191 PLIST_SUB+= LLVM="@comment "
192 CONFIGURE_ARGS+= --without-llvm
196 .if ${DISTVERSION:C/([0-9]*).*/\1/} < 10
197 . if ( defined(SERVER_ONLY) && ${PORT_OPTIONS:MICU} ) || make(makesum)
199 CONFIGURE_ARGS+=--with-icu
200 PATCH_SITES+= http://people.freebsd.org/~girgen/postgresql-icu/:icu
201 PATCHFILES+= ${ICU_PATCHFILE}:icu
202 LIB_DEPENDS+= libicudata.so:devel/icu
204 .endif # server && version < 10
206 .if !defined(SLAVE_ONLY)
210 . if ${PORT_OPTIONS:MDTRACE}
211 CONFIGURE_ARGS+=--enable-dtrace
213 INSTALL_TARGET= install
216 .if ${PORT_OPTIONS:MGSSAPI}
217 CONFIGURE_ARGS+=--with-gssapi
218 .if empty(PORT_OPTIONS:MMIT_KRB5) && empty(PORT_OPTIONS:MHEIMDAL_KRB5)
219 # Kerberos libraries will pull the proper GSSAPI library
220 # via linker dependencies, but otherwise we must specify
221 # it explicitely: ld --as-needed is used for compilation,
222 # so configure's -lgssapi_krb5 won't go.
224 LDFLAGS_SL+= -lgssapi
225 PLIST_SUB+= GSSAPI=""
228 CONFIGURE_ARGS+=--without-gssapi
229 PLIST_SUB+= GSSAPI="@comment "
232 . if ${PORT_OPTIONS:MMIT_KRB5}
233 . if defined(IGNORE_WITH_SRC_KRB5) && (exists(/usr/lib/libkrb5.so) || exists(/usr/bin/krb5-config))
234 IGNORE= requires that you remove heimdal\'s /usr/bin/krb5-config and /usr/lib/libkrb5.so*, and set NO_KERBEROS=true in /etc/src.conf to build successfully with MIT-KRB
236 CONFIGURE_ARGS+=--with-krb5
237 # Allow defining a home built MIT Kerberos by setting KRB5_HOME
238 . if defined(KRB5_HOME) && exists(${KRB5_HOME}/lib/libgssapi_krb5.a) && exists(${KRB5_HOME}/bin/krb5-config)
239 LIB_DEPENDS+= libkrb5.so.3:security/krb5
244 . if ${PORT_OPTIONS:MHEIMDAL_KRB5}
245 CONFIGURE_ARGS+=--with-krb5
248 . if ${PORT_OPTIONS:MSSL}
251 PLIST_SUB+= SSL="@comment "
256 # For testing files in FILESDIR
257 .include <bsd.port.pre.mk>
259 .if defined(SERVER_ONLY)
261 @${SH} ${PKGINSTALL} ${PORTNAME} PRE-INSTALL
264 .if !defined(NO_BUILD) && !target(do-build)
267 @ cd ${WRKSRC}/src/backend && ${SETENV} ${MAKE_ENV} ${MAKE_CMD} symlinks
268 @ for dir in ${BUILD_DIRS}; do \
269 cd ${WRKSRC}/$${dir} && ${SETENV} ${MAKE_ENV} ${MAKE_CMD}; \
272 . if exists(${FILESDIR}/pkg-message${COMPONENT}.in)
273 SUB_FILES+= pkg-message${COMPONENT}
274 PKGMESSAGE= ${WRKSRC}/pkg-message${COMPONENT}
276 . if exists(${FILESDIR}/pkg-install${COMPONENT}.in)
277 SUB_FILES+= pkg-install${COMPONENT}
278 PLIST_SUB+= PG_USER=${PG_USER}
282 . if defined(SERVER_ONLY) && ${PORT_OPTIONS:MICU}
284 -e '/m4_PACKAGE_VERSION/s/\[2\.6[0-9]\]/m4_defn([m4_PACKAGE_VERSION])/' \
286 ${WRKSRC}/configure.in
290 @for dir in ${INSTALL_DIRS}; do \
291 cd ${WRKSRC}/$${dir} && \
292 ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} ${INSTALL_TARGET}; \
294 . if defined(SERVER_ONLY)
295 @ ${MKDIR} ${STAGEDIR}${PREFIX}/share/postgresql ;\
296 ${MKDIR} ${STAGEDIR}${PREFIX}/etc/periodic/daily ;\
297 ${INSTALL_SCRIPT} ${WRKDIR}/502.pgsql \
298 ${STAGEDIR}${PREFIX}/etc/periodic/daily
299 . endif # SERVER_ONLY
300 . if defined(CLIENT_ONLY)
301 @ cd ${WRKSRC}/src && ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-local
303 @ if [ -r ${PKGMESSAGE} ]; then \
304 ${MKDIR} ${STAGEDIR}${DOCSDIR} ;\
305 ${INSTALL_DATA} ${PKGMESSAGE} ${STAGEDIR}${DOCSDIR}/README${COMPONENT} ;\
309 .if defined(SERVER_ONLY)
311 @if [ `id -u` != 0 ] ; then \
312 ${ECHO} "Running postgresql regressions tests" ;\
313 cd ${WRKSRC}; ${MAKE_CMD} check ;\
315 ${ECHO} "You cannot run regression tests when postgresql is built as user root." ; \
316 ${ECHO} "Clean and rebuild the port as a regular user to run the tests." ;\
320 .include <bsd.port.post.mk>