3 # Provide support for PostgreSQL (pgsql)
6 # Usage: USES= pgsql[:version]
8 # Maintainer can set version required. Minimum and maximum
9 # versions can be specified; e.g. 9.0-, 9.2+
11 # WANT_PGSQL= server[:fetch] pltcl plperl
13 # Add PostgreSQL component dependency, using
14 # WANT_PGSQL= component[:target].
15 # For the full list use make -V _USE_PGSQL_DEP
16 # If no version is given (by the maintainer via the port or
17 # by the user via defined variable), try to find the
18 # currently installed version. Fall back to default if
21 # MAINTAINER: pgsql@FreeBSD.org
23 .if !defined(_INCLUDE_USES_PGSQL_MK)
25 _INCLUDE_USES_PGSQL_MK= yes
27 # Variables set by pgsql.mk:
30 # Detected PostgreSQL version. Do *not* use this
31 # to add dependencies; use WANT_PGSQL as explained above
34 # When adding a version, please keep the comment in
35 # Mk/bsd.default-versions.mk in sync.
36 VALID_PGSQL_VER= 9.1 9.2 9.3 9.4 9.5
38 # Override non-default LIBVERS like this:
42 .for v in ${VALID_PGSQL_VER:S,.,,}
43 PGSQL$v_LIBVER?= ${PGSQL_LIBVER}
46 .for v in ${PGSQL_DEFAULT}
47 . if ! ${VALID_PGSQL_VER:M$v}
48 IGNORE= Invalid PGSQL default version ${PGSQL_DEFAULT}; valid versions are ${VALID_PGSQL_VER}
52 . for w in WITH DEFAULT
54 WARNING+= "$w_PGSQL_VER is defined, consider using DEFAULT_VERSIONS=pgsql=${$w_PGSQL_VER:C,^.,&.,} instead"
55 PGSQL_DEFAULT?= ${$w_PGSQL_VER:C,^.,&.,}
59 . ifdef DEFAULT_PGSQL_VER && WITH_PGSQL_VER
60 IGNORE= will not allow setting both DEFAULT_PGSQL_VER and WITH_PGSQL_VER. Use DEFAULT_VERSIONS=pgsql=9.0 instead
63 # Setting/finding PostgreSQL version we want.
64 PG_CONFIG?= ${LOCALBASE}/bin/pg_config
65 . if exists(${PG_CONFIG})
66 _PGSQL_VER!= ${PG_CONFIG} --version | ${SED} -n 's/PostgreSQL[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\)[^0-9].*/\1/p'
69 # Handle the + and - version stuff
70 . if !empty(pgsql_ARGS)
71 . if ${pgsql_ARGS:M*+}
72 . for version in ${VALID_PGSQL_VER}
73 . if ${pgsql_ARGS:S/+//} <= ${version}
74 _WANT_PGSQL_VER+=${version}
77 . elif ${pgsql_ARGS:M*-}
78 . for version in ${VALID_PGSQL_VER}
79 . if ${pgsql_ARGS:S/-//} >= ${version}
80 _WANT_PGSQL_VER+=${version}
84 _WANT_PGSQL_VER?= ${pgsql_ARGS}
87 # Try to match default version, otherwise just take the first version
88 # that matches. Prefer the installed version if it matches
89 . if !empty(_WANT_PGSQL_VER)
90 . for version in ${_WANT_PGSQL_VER}
91 . if ${PGSQL_DEFAULT} == ${version}
94 PGSQL_VER?= ${version}
96 . if defined(_PGSQL_VER)
97 . for v in ${_PGSQL_VER}
98 . if ${_WANT_PGSQL_VER:M$v} == ${_PGSQL_VER}
99 PGSQL_VER= ${_PGSQL_VER}
103 . if defined(_PGSQL_VER) && ${_PGSQL_VER} != ${PGSQL_VER}
104 IGNORE?= cannot install: the port wants postgresql-client version ${_WANT_PGSQL_VER} and you have version ${_PGSQL_VER} installed
108 # OK, so the port is ambivalent, we'll just take what's on the system.
109 PGSQL_VER?= ${_PGSQL_VER}
111 # After all that, we still have found nothing!
112 . if empty(PGSQL_VER)
113 PGSQL_VER= ${PGSQL_DEFAULT}
116 # We don't want to be :S,.,, the whole time when doing port version checks
117 PGSQL_VER_NODOT= ${PGSQL_VER:S,.,,}
119 # And now we are checking if we can use it
120 . if defined(PGSQL${PGSQL_VER_NODOT}_LIBVER)
121 # Compat. Please DO NOT use IGNORE_WITH_PGSQL!
122 . if defined(IGNORE_WITH_PGSQL)
123 DEV_WARNING+= "Do not set IGNORE_WITH_PGSQL, use the version argument to USES=pgsql"
124 . for ver in ${IGNORE_WITH_PGSQL}
125 . if (${PGSQL_VER} == ${ver})
126 IGNORE?= cannot install: does not work with postgresql${PGSQL_VER_NODOT}-client (PostgreSQL ${IGNORE_WITH_PGSQL} not supported)
129 . endif # IGNORE_WITH_PGSQL
131 .if !defined(WANT_PGSQL) || ${WANT_PGSQL:Mlib}
132 LIB_DEPENDS+= libpq.so.${PGSQL${PGSQL_VER_NODOT}_LIBVER}:databases/postgresql${PGSQL_VER_NODOT}-client
135 _USE_PGSQL_DEP= client contrib docs pgtcl pltcl plperl server
136 _USE_PGSQL_DEP_client= psql
137 _USE_PGSQL_DEP_contrib= vacuumlo
138 _USE_PGSQL_DEP_docs= postgresql${PGSQL_VER_NODOT}-docs>0
139 _USE_PGSQL_DEP_pgtcl= ${LOCALBASE}/lib/pgtcl/pkgIndex.tcl
140 _USE_PGSQL_DEP_plperl= postgresql${PGSQL_VER_NODOT}-plperl>0
141 _USE_PGSQL_DEP_pltcl= postgresql${PGSQL_VER_NODOT}-pltcl>0
142 _USE_PGSQL_DEP_server= postgres
143 . if defined(WANT_PGSQL)
144 . for depend in ${_USE_PGSQL_DEP}
145 . if ${WANT_PGSQL:M${depend}}
146 BUILD_DEPENDS+= ${_USE_PGSQL_DEP_${depend}}:databases/postgresql${PGSQL_VER_NODOT}-${depend}
147 RUN_DEPENDS+= ${_USE_PGSQL_DEP_${depend}}:databases/postgresql${PGSQL_VER_NODOT}-${depend}
148 . elif ${WANT_PGSQL:M${depend}\:*}
149 BUILD_DEPENDS+= ${NONEXISTENT}:databases/postgresql${PGSQL_VER_NODOT}-${depend}:${WANT_PGSQL:M${depend}\:*:C,^[^:]*\:,,}
155 IGNORE?= cannot install: unknown PostgreSQL version: ${PGSQL_VER}
156 . endif # Check for correct version
157 CPPFLAGS+= -I${LOCALBASE}/include
158 LDFLAGS+= -L${LOCALBASE}/lib
160 .endif # !defined(_INCLUDE_USES_PGSQL_MK)