1PORTNAME?= postgresql 2DISTVERSION?= 14.20 3# PORTREVISION must be ?= otherwise, all slave ports get this PORTREVISION and 4# not their own. Probably best to keep it at ?=0 when reset here too. 5PORTREVISION?= 1 6CATEGORIES?= databases 7MASTER_SITES= PGSQL/source/v${DISTVERSION} 8PKGNAMESUFFIX?= ${PORTVERSION:R}${COMPONENT} 9 10MAINTAINER?= ports@MidnightBSD.org 11COMMENT?= PostgreSQL is the most advanced open-source database available anywhere 12WWW= https://www.postgresql.org/ 13 14LICENSE= pgsql 15 16.if ${DISTVERSION:C/([0-9]*).*/\1/} >= 10 17CONFLICTS+= ${PORTNAME}9* ${PORTNAME}1[^${PORTVERSION:R:C/.*([0-9]$)/\\1/}]* 18.else 19CONFLICTS+= ${PORTNAME}9[^${PORTVERSION:R:E}]* ${PORTNAME}1[0-9]* 20.endif 21 22WRKSRC= ${WRKDIR}/postgresql-${DISTVERSION} 23DIST_SUBDIR= postgresql 24 25OPTIONS_SUB= yes 26 27PKGINSTALL?= ${PKGDIR}/pkg-install${COMPONENT} 28USES+= tar:bzip2 cpe 29.if !defined(NO_BUILD) 30USES+= gmake 31GNU_CONFIGURE= yes 32.endif 33 34PG_USER?= postgres 35PG_GROUP?= postgres 36PG_UID?= 770 37 38LDFLAGS+= -L${LOCALBASE}/lib 39INCLUDES+= -I${LOCALBASE}/include 40CONFIGURE_ARGS+=--with-libraries=${PREFIX}/lib \ 41 --with-includes=${PREFIX}/include \ 42 --enable-thread-safety \ 43 --with-template=freebsd 44CONFIGURE_ENV+= INCLUDES="${INCLUDES}" \ 45 PTHREAD_LIBS="-lpthread" \ 46 LDFLAGS_SL="${LDFLAGS_SL}" 47LDFLAGS+= -lpthread 48MAKE_ENV= MAKELEVEL=0 49 50PLIST= ${PKGDIR}/pkg-plist${COMPONENT} 51 52INSTALL_DIRS?= src/common src/timezone src/backend \ 53 src/backend/utils/mb/conversion_procs \ 54 src/backend/snowball src/backend/replication/libpqwalreceiver \ 55 src/backend/replication/pgoutput \ 56 src/bin/initdb src/bin/pg_ctl \ 57 src/bin/pg_archivecleanup src/bin/pg_basebackup \ 58 src/bin/pg_checksums \ 59 src/bin/pg_controldata src/bin/pg_resetwal src/pl \ 60 src/bin/pg_rewind \ 61 src/bin/pg_test_fsync src/bin/pg_test_timing \ 62 src/bin/pg_waldump src/bin/pg_upgrade 63 64BUILD_DIRS?= src/port ${INSTALL_DIRS} 65INSTALL_TARGET?=install-strip 66 67.if !defined(CLIENT_ONLY) && !defined(SLAVE_ONLY) 68SERVER_ONLY= yes 69COMPONENT= -server 70USE_RC_SUBR= postgresql 71USES+= pgsql:${DISTVERSION:C/([0-9]\.?[0-9]).*/\1/g} 72USERS= ${PG_USER} 73GROUPS= ${PG_GROUP} 74SUB_FILES+= 502.pgsql 75.endif 76 77OPTIONS_SUB= yes 78 79.if defined(CLIENT_ONLY) 80OPTIONS_DEFINE+=LIBEDIT DOCS 81LIBEDIT_DESC= Use non-GPL libedit instead of readline 82.else 83MAKE_ENV+= PATH=${PREFIX}/bin:${PATH} 84CONFIGURE_ENV+= PATH=${PREFIX}/bin:${PATH} 85.endif 86 87.if defined(SERVER_ONLY) 88OPTIONS_DEFINE= DTRACE LDAP INTDATE TZDATA XML DOCS 89LDAP_DESC= Build with LDAP authentication support 90TZDATA_DESC= Use internal timezone database 91XML_DESC= Build with XML data type 92 93DTRACE_CONFIGURE_ENABLE=dtrace 94DTRACE_LDFLAGS= -lelf 95DTRACE_INSTALL_TARGET= install 96 97.if ${DISTVERSION:C/([0-9]*).*/\1/} >= 14 98OPTIONS_DEFINE+= LZ4 99OPTIONS_DEFAULT+= LZ4 100LZ4_DESC= Build with LZ4 compression support 101LZ4_CONFIGURE_WITH= lz4 102LZ4_LIB_DEPENDS+= liblz4.so:archivers/liblz4 103.endif 104 105.if ${DISTVERSION:C/([0-9]*).*/\1/} >= 11 106OPTIONS_DEFINE+= LLVM 107#OPTIONS_DEFAULT+= LLVM 108LLVM_DESC= Build with support for JIT-compiling expressions 109.endif 110 111.if ${DISTVERSION:C/([0-9]*).*/\1/} < 10 112# See http://people.freebsd.org/~girgen/postgresql-icu/README.html for more info 113OPTIONS_DEFINE+= ICU 114ICU_DESC= Use ICU for unicode collation 115.else 116CONFIGURE_ARGS+=--with-icu 117LIB_DEPENDS+= libicudata.so:devel/icu 118USES+= pkgconfig 119.endif 120 121# See http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/76999 for more info 122# (requires dump/restore if modified.) 123OPTIONS_DEFINE+= INTDATE 124INTDATE_DESC= Builds with 64-bit date/time type 125OPTIONS_DEFAULT+= INTDATE 126.endif 127 128.if !defined(SLAVE_ONLY) 129OPTIONS_DEFINE+= NLS PAM GSSAPI OPTIMIZED_CFLAGS DEBUG DOCS 130. if ${DISTVERSION:R} == 9.2 || ${DISTVERSION:R} == 9.3 131 OPTIONS_RADIO= KRB5 132 OPTIONS_RADIO_KRB5= MIT_KRB5 HEIMDAL_KRB5 133. endif 134 135KRB5_DESC= Build with kerberos provider support 136NLS_DESC= Use internationalized messages 137PAM_DESC= Build with PAM Support 138MIT_KRB5_DESC= Build with MIT kerberos support 139HEIMDAL_KRB5_DESC= Builds with Heimdal kerberos 140GSSAPI_DESC= Build with GSSAPI support 141OPTIMIZED_CFLAGS_DESC= Builds with compiler optimizations (-O3) 142 143OPTIONS_DEFINE+= SSL 144SSL_DESC= Build with OpenSSL support 145 146OPTIONS_DEFAULT+= SSL 147 148GSSAPI_CONFIGURE_WITH= gssapi 149.endif # !SLAVE_ONLY 150 151.if defined(CLIENT_ONLY) 152LIBEDIT_CONFIGURE_ON+=--with-libedit-preferred 153LIBEDIT_USES= libedit 154LIBEDIT_USES_OFF= readline 155.endif # CLIENT_ONLY 156 157SSL_USES= ssl 158SSL_CONFIGURE_WITH= openssl 159 160PAM_CONFIGURE_WITH= pam 161 162XML_CONFIGURE_WITH= libxml 163XML_LIB_DEPENDS= libxml2.so:textproc/libxml2 164 165TZDATA_CONFIGURE_OFF= --with-system-tzdata=/usr/share/zoneinfo 166 167INTDATE_CONFIGURE_OFF= --disable-integer-datetimes 168 169NLS_CONFIGURE_ENABLE= nls 170NLS_USES= gettext 171 172LDAP_CONFIGURE_WITH= ldap 173LDAP_USE= OPENLDAP=yes 174 175OPTIMIZED_CFLAGS_CFLAGS=-O3 -funroll-loops 176 177DEBUG_CONFIGURE_ENABLE= debug 178 179PLIST_SUB+= PG_VERSION=${PORTVERSION:R} \ 180 PG_USER=${PG_USER} \ 181 PG_USER_regex=[[:<:]]${PG_USER}[[:>:]] \ 182 PG_GROUP=${PG_GROUP} \ 183 PG_GROUP_regex=[[:<:]]${PG_GROUP}[[:>:]] 184SUB_LIST+= PG_GROUP=${PG_GROUP} \ 185 PG_VERSION=${PORTVERSION:R} \ 186 PG_USER=${PG_USER} \ 187 PG_UID=${PG_UID} 188 189.include <bsd.mport.options.mk> 190 191.if ${ARCH} == "i386" 192USES+= compiler:gcc-c++11-lib 193.else 194USES+= compiler 195.endif 196 197.if ${DISTVERSION:C/([0-9]*).*/\1/} < 10 198. if ( defined(SERVER_ONLY) && ${PORT_OPTIONS:MICU} ) || make(makesum) 199USES+= autoreconf 200CONFIGURE_ARGS+=--with-icu 201PATCH_SITES+= http://people.freebsd.org/~girgen/postgresql-icu/:icu 202PATCHFILES+= ${ICU_PATCHFILE}:icu 203LIB_DEPENDS+= libicudata.so:devel/icu 204. endif 205.endif # server && version < 10 206 207.if !defined(SLAVE_ONLY) 208 209PATCH_DIST_STRIP=-p1 210 211.if ${PORT_OPTIONS:MGSSAPI} 212.if empty(PORT_OPTIONS:MMIT_KRB5) && empty(PORT_OPTIONS:MHEIMDAL_KRB5) 213# Kerberos libraries will pull the proper GSSAPI library 214# via linker dependencies, but otherwise we must specify 215# it explicitely: ld --as-needed is used for compilation, 216# so configure's -lgssapi_krb5 won't go. 217LDFLAGS+= -lgssapi 218LDFLAGS_SL+= -lgssapi 219.endif 220.endif 221 222. if ${PORT_OPTIONS:MMIT_KRB5} 223. if defined(IGNORE_WITH_SRC_KRB5) && (exists(/usr/lib/libkrb5.so) || exists(/usr/bin/krb5-config)) 224IGNORE= 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 225. else 226CONFIGURE_ARGS+=--with-krb5 227# Allow defining a home built MIT Kerberos by setting KRB5_HOME 228. if defined(KRB5_HOME) && exists(${KRB5_HOME}/lib/libgssapi_krb5.a) && exists(${KRB5_HOME}/bin/krb5-config) 229LIB_DEPENDS+= libkrb5.so.3:security/krb5 230. endif 231. endif 232. endif 233 234. if ${PORT_OPTIONS:MHEIMDAL_KRB5} 235CONFIGURE_ARGS+=--with-krb5 236. endif 237 238.endif # !SLAVE_ONLY 239 240# For testing files in FILESDIR 241.include <bsd.port.pre.mk> 242 243.if ${PORT_OPTIONS:MLLVM} 244CONFIGURE_ARGS+= --with-llvm 245BUILD_DEPENDS+= llvm${PG_LLVM_VERSION}>0:devel/llvm${PG_LLVM_VERSION} 246BUILD_DEPENDS+= llvm-config${PG_LLVM_VERSION}:devel/llvm${PG_LLVM_VERSION} 247RUN_DEPENDS+= llvm-config${PG_LLVM_VERSION}:devel/llvm${PG_LLVM_VERSION} 248CONFIGURE_ENV+= LLVM_CONFIG=${LOCALBASE}/bin/llvm-config${PG_LLVM_VERSION} 249.endif 250 251# Convert LLVM_DEFAULT to COMPILER_VERSION format to make it 252# suitable for version comparison. 253.if ${LLVM_DEFAULT} >= 70 && ${LLVM_DEFAULT} <= 90 254LLVM_DEFAULT_VERSION= ${LLVM_DEFAULT} 255.else 256LLVM_DEFAULT_VERSION= ${LLVM_DEFAULT}0 257.endif 258 259# Convert COMPILER_VERSION to LLVM_DEFAULT format to make it 260# suitable for LLVM port name. 261# All supported BSD versions have Clang 10.0.1 or later. 262LLVM_PORT_SUFFIX= ${COMPILER_VERSION:C/.$//} 263 264# sync LLVM to the preferred compiler if possible 265# or else use a lower version compiler that is compatible 266.if ${COMPILER_VERSION} > ${LLVM_DEFAULT_VERSION} 267# LLVM versions in ports are, in order, 70, 80 90, 10, 11, 12... where 10 > 90. [sic] 268. if ${LLVM_PORT_SUFFIX} < 70 269PG_LLVM_VERSION=${LLVM_PORT_SUFFIX} 270PG_COMPILER_VERSION=${LLVM_PORT_SUFFIX} 271. else 272PG_LLVM_VERSION=11 273PG_COMPILER_VERSION=11 274. endif 275.else 276PG_LLVM_VERSION=${LLVM_DEFAULT} 277PG_COMPILER_VERSION=${LLVM_PORT_SUFFIX} 278.endif 279 280.if ${DISTVERSION:C/([0-9]*).*/\1/} >= 11 281. if defined(SERVER_ONLY) && ${PORT_OPTIONS:MLLVM} 282INSTALL_DIRS+= src/backend/jit/llvm 283. if ${LLVM_PORT_SUFFIX} != ${PG_COMPILER_VERSION} 284LLVM_CONFIGURE_ARGS?= CC=${LOCALBASE}/bin/clang${PG_COMPILER_VERSION} 285. endif 286. endif 287.endif 288 289.if defined(SERVER_ONLY) 290pre-build: 291 @${SH} ${PKGINSTALL} ${PORTNAME} PRE-INSTALL 292.endif 293 294.if !defined(NO_BUILD) && !target(do-build) 295 296do-build: 297 @ cd ${WRKSRC}/src/backend && ${SETENV} ${MAKE_ENV} ${FAKE_MAKEENV} ${MAKE_CMD} ${FAKE_MAKEARGS} symlinks 298 @ for dir in ${BUILD_DIRS}; do \ 299 cd ${WRKSRC}/$${dir} && ${SETENV} ${MAKE_ENV} ${FAKE_MAKEENV} ${MAKE_CMD} ${FAKE_MAKEARGS}; \ 300 done 301 302. if exists(${FILESDIR}/pkg-message${COMPONENT}.in) 303SUB_FILES+= pkg-message${COMPONENT} 304PKGMESSAGE= ${WRKSRC}/pkg-message${COMPONENT} 305. endif 306. if exists(${FILESDIR}/pkg-install${COMPONENT}.in) 307SUB_FILES+= pkg-install${COMPONENT} 308. endif 309 310post-patch: 311. if defined(SERVER_ONLY) && ${PORT_OPTIONS:MICU} 312 @${REINPLACE_CMD} \ 313 -e '/m4_PACKAGE_VERSION/s/\[2\.6[0-9]\]/m4_defn([m4_PACKAGE_VERSION])/' \ 314 -e '/icu/s/_57//' \ 315 ${WRKSRC}/configure.in 316. elif defined(CLIENT_ONLY) && !defined(OPENSSL_PORT) 317 @${REINPLACE_CMD} \ 318 -e '/^PKG_CONFIG_REQUIRES_PRIVATE = libssl libcrypto/d' \ 319 ${WRKSRC}/src/interfaces/libpq/Makefile 320. endif 321 322do-install: 323 @for dir in ${INSTALL_DIRS}; do \ 324 cd ${WRKSRC}/$${dir} && \ 325 ${SETENV} ${MAKE_ENV} ${FAKE_MAKEENV} ${MAKE_CMD} ${MAKE_ARGS} ${FAKE_MAKEARGS} ${INSTALL_TARGET}; \ 326 done 327. if defined(SERVER_ONLY) 328 @ ${MKDIR} ${PREFIX}/share/postgresql ;\ 329 ${MKDIR} ${PREFIX}/etc/periodic/daily ;\ 330 ${INSTALL_SCRIPT} ${WRKDIR}/502.pgsql \ 331 ${PREFIX}/etc/periodic/daily 332. endif # SERVER_ONLY 333. if defined(CLIENT_ONLY) 334 @ cd ${WRKSRC}/src && ${SETENV} ${MAKE_ENV} ${FAKE_MAKEENV} ${MAKE_CMD} ${MAKE_ARGS} ${FAKE_MAKEARGS} install-local 335. endif 336 @ if [ -r ${PKGMESSAGE} ]; then \ 337 ${MKDIR} ${DOCSDIR} ;\ 338 ${INSTALL_DATA} ${PKGMESSAGE} ${DOCSDIR}/README${COMPONENT} ;\ 339 fi 340.endif # !NO_BUILD 341 342.if defined(SERVER_ONLY) 343check: 344 @if [ `id -u` != 0 ] ; then \ 345 ${ECHO} "Running postgresql regressions tests" ;\ 346 cd ${WRKSRC}; ${MAKE_CMD} check ;\ 347 else \ 348 ${ECHO} "You cannot run regression tests when postgresql is built as user root." ; \ 349 ${ECHO} "Clean and rebuild the port as a regular user to run the tests." ;\ 350 fi 351.endif 352 353.include <bsd.port.post.mk> 354