Bump databases/postgis25 to version 2.5.4_1
[dports.git] / databases / postgresql12-server / Makefile
1 # Created by: Marc G. Fournier <scrappy@FreeBSD.org>
2 # $FreeBSD$
3
4 PORTNAME?=      postgresql
5 DISTVERSION?=   12.2
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.
8 PORTREVISION?=  2
9 CATEGORIES?=    databases
10 MASTER_SITES=   PGSQL/source/v${DISTVERSION}
11 PKGNAMESUFFIX?= ${PORTVERSION:R}${COMPONENT}
12
13 MAINTAINER?=    pgsql@FreeBSD.org
14 COMMENT?=       PostgreSQL is the most advanced open-source database available anywhere
15
16 LICENSE=        PostgreSQL
17
18 .if ${DISTVERSION:C/([0-9]*).*/\1/} >= 10
19 CONFLICTS+=     ${PORTNAME}9* ${PORTNAME}1[^${PORTVERSION:R:C/.*([0-9]$)/\\1/}]*
20 .else
21 CONFLICTS+=     ${PORTNAME}9[^${PORTVERSION:R:E}]* ${PORTNAME}1[0-9]*
22 .endif
23
24 WRKSRC=         ${WRKDIR}/postgresql-${DISTVERSION}
25 DIST_SUBDIR=    postgresql
26
27 OPTIONS_SUB=    yes
28
29 PKGINSTALL?=    ${PKGDIR}/pkg-install${COMPONENT}
30 USES+=          tar:bzip2 cpe
31 .if !defined(NO_BUILD)
32 USES+=          gmake
33 GNU_CONFIGURE=  yes
34 .endif
35
36 PG_USER?=       postgres
37 PG_GROUP?=      postgres
38 PG_UID?=        770
39
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}"
48 LDFLAGS+=       -lpthread
49 MAKE_ENV=       MAKELEVEL=0
50
51 PLIST=          ${PKGDIR}/pkg-plist${COMPONENT}
52
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 \
61                 src/bin/pg_rewind \
62                 src/bin/pg_test_fsync src/bin/pg_test_timing \
63                 src/bin/pg_waldump src/bin/pg_upgrade
64
65 BUILD_DIRS?=    src/port ${INSTALL_DIRS}
66 INSTALL_TARGET?=install-strip
67
68 .if !defined(CLIENT_ONLY) && !defined(SLAVE_ONLY)
69 SERVER_ONLY=    yes
70 COMPONENT=      -server
71 USE_RC_SUBR=    postgresql
72 USES+=          pgsql:${DISTVERSION:C/([0-9]\.?[0-9]).*/\1/g}
73 USERS=          ${PG_USER}
74 GROUPS= ${PG_GROUP}
75 SUB_FILES+=     502.pgsql
76 .endif
77
78 .if defined(CLIENT_ONLY)
79 OPTIONS_DEFINE+=LIBEDIT DOCS
80 LIBEDIT_DESC=   Use non-GPL libedit instead of readline
81 USES+=          perl5
82 .else
83 MAKE_ENV+=      PATH=${PREFIX}/bin:${PATH}
84 CONFIGURE_ENV+= PATH=${PREFIX}/bin:${PATH}
85 .endif
86
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
93
94 .if ${DISTVERSION:C/([0-9]*).*/\1/} >= 11
95 OPTIONS_DEFINE+=        LLVM
96 LLVM_DESC=              Build with support for JIT-compiling expressions
97 OPTIONS_DEFAULT+=       ${OPTIONS_DEFAULT_${CHOSEN_COMPILER_TYPE}}
98 OPTIONS_DEFAULT_clang=  LLVM
99 .endif
100
101 .if ${DISTVERSION:C/([0-9]*).*/\1/} < 10
102 # See http://people.freebsd.org/~girgen/postgresql-icu/README.html for more info
103 OPTIONS_DEFINE+=        ICU
104 ICU_DESC=       Use ICU for unicode collation
105 .else
106 CONFIGURE_ARGS+=--with-icu
107 LIB_DEPENDS+=   libicudata.so:devel/icu
108 USES+=          pkgconfig
109 .endif
110
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
116 .endif
117
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
121   OPTIONS_RADIO=        KRB5
122   OPTIONS_RADIO_KRB5=   MIT_KRB5 HEIMDAL_KRB5
123 . endif
124
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)
132
133 OPTIONS_DEFINE+=        SSL
134 SSL_DESC=               Build with OpenSSL support
135
136 OPTIONS_DEFAULT+=       SSL
137 .endif # !SLAVE_ONLY
138
139 .if defined(CLIENT_ONLY)
140 LIBEDIT_CONFIGURE_ON+=--with-libedit-preferred
141 LIBEDIT_USES=           libedit
142 LIBEDIT_USES_OFF=       readline
143 .endif # CLIENT_ONLY
144
145 SSL_USES=               ssl
146 SSL_CONFIGURE_WITH=     openssl
147
148 PAM_CONFIGURE_WITH=     pam
149
150 XML_CONFIGURE_WITH=     libxml
151 XML_LIB_DEPENDS=        libxml2.so:textproc/libxml2
152
153 TZDATA_CONFIGURE_OFF=   --with-system-tzdata=/usr/share/zoneinfo
154
155 INTDATE_CONFIGURE_OFF=  --disable-integer-datetimes
156
157 NLS_CONFIGURE_ENABLE=   nls
158 NLS_USES=               gettext
159
160 LDAP_CONFIGURE_WITH=    ldap
161 LDAP_USE=               OPENLDAP=yes
162
163 OPTIMIZED_CFLAGS_CFLAGS=-O3 -funroll-loops
164
165 DEBUG_CONFIGURE_ENABLE= debug
166
167 PLIST_SUB+=             PG_USER=${PG_USER} \
168                         PG_GROUP=${PG_GROUP}
169 SUB_LIST+=              PG_GROUP=${PG_GROUP} \
170                         PG_USER=${PG_USER} \
171                         PG_UID=${PG_UID}
172
173 .include <bsd.port.options.mk>
174
175 .if ${ARCH} == "i386"
176 USES+=          compiler:gcc-c++11-lib
177 .else
178 USES+=          compiler
179 .endif
180
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
188 PLIST_SUB+=             LLVM=""
189 INSTALL_DIRS+=          src/backend/jit/llvm
190 .  else
191 PLIST_SUB+=             LLVM="@comment "
192 CONFIGURE_ARGS+=        --without-llvm
193 .  endif
194 .endif
195
196 .if ${DISTVERSION:C/([0-9]*).*/\1/} < 10
197 .  if ( defined(SERVER_ONLY) && ${PORT_OPTIONS:MICU} ) || make(makesum)
198 USES+=          autoreconf
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
203 .  endif
204 .endif # server && version < 10
205
206 .if !defined(SLAVE_ONLY)
207
208 PATCH_DIST_STRIP=-p1
209
210 .  if ${PORT_OPTIONS:MDTRACE}
211 CONFIGURE_ARGS+=--enable-dtrace
212 LDFLAGS+=-lelf
213 INSTALL_TARGET= install
214 .  endif
215
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.
223 LDFLAGS+=       -lgssapi
224 LDFLAGS_SL+=    -lgssapi
225 PLIST_SUB+=     GSSAPI=""
226 .endif
227 .else
228 CONFIGURE_ARGS+=--without-gssapi
229 PLIST_SUB+=     GSSAPI="@comment "
230 .endif
231
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
235 .   else
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
240 .    endif
241 .   endif
242 .  endif
243
244 .  if ${PORT_OPTIONS:MHEIMDAL_KRB5}
245 CONFIGURE_ARGS+=--with-krb5
246 .  endif
247
248 .  if ${PORT_OPTIONS:MSSL}
249 PLIST_SUB+=     SSL=""
250 .  else
251 PLIST_SUB+=     SSL="@comment "
252 .  endif
253
254 .endif # !SLAVE_ONLY
255
256 # For testing files in FILESDIR
257 .include <bsd.port.pre.mk>
258
259 .if defined(SERVER_ONLY)
260 pre-build:
261         @${SH} ${PKGINSTALL} ${PORTNAME} PRE-INSTALL
262 .endif
263
264 .if !defined(NO_BUILD) && !target(do-build)
265
266 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}; \
270         done
271
272 .  if exists(${FILESDIR}/pkg-message${COMPONENT}.in)
273 SUB_FILES+=     pkg-message${COMPONENT}
274 PKGMESSAGE=     ${WRKSRC}/pkg-message${COMPONENT}
275 .  endif
276 .  if exists(${FILESDIR}/pkg-install${COMPONENT}.in)
277 SUB_FILES+=     pkg-install${COMPONENT}
278 PLIST_SUB+=     PG_USER=${PG_USER}
279 .  endif
280
281 post-patch:
282 .  if defined(SERVER_ONLY) && ${PORT_OPTIONS:MICU}
283         @${REINPLACE_CMD} \
284                 -e '/m4_PACKAGE_VERSION/s/\[2\.6[0-9]\]/m4_defn([m4_PACKAGE_VERSION])/' \
285                 -e '/icu/s/_57//' \
286                 ${WRKSRC}/configure.in
287 .  endif
288
289 do-install:
290         @for dir in ${INSTALL_DIRS}; do \
291             cd ${WRKSRC}/$${dir} && \
292                 ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} ${INSTALL_TARGET}; \
293         done
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
302 .  endif
303         @ if [ -r ${PKGMESSAGE} ]; then \
304                 ${MKDIR} ${STAGEDIR}${DOCSDIR} ;\
305                 ${INSTALL_DATA} ${PKGMESSAGE} ${STAGEDIR}${DOCSDIR}/README${COMPONENT} ;\
306         fi
307 .endif # !NO_BUILD
308
309 .if defined(SERVER_ONLY)
310 check:
311         @if [ `id -u` != 0 ] ; then \
312           ${ECHO} "Running postgresql regressions tests" ;\
313           cd ${WRKSRC}; ${MAKE_CMD} check ;\
314          else \
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." ;\
317          fi
318 .endif
319
320 .include <bsd.port.post.mk>