summaryrefslogtreecommitdiff
path: root/mk/pgsql.buildlink3.mk
blob: 20af99f70d8eecac8f8c3ad01110e4557a02c13c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# $NetBSD: pgsql.buildlink3.mk,v 1.52 2020/07/27 00:17:12 gdt Exp $
#
# User-settable variables:
#
# PGSQL_VERSION_DEFAULT
#
# Package-settable variables:
#
# PGSQL_VERSIONS_ACCEPTED
#
# Variables set by this file:
#
# PG_LIB_EXT
# PGSQL_TYPE
# PGPKGSRCDIR

.if !defined(PGVERSION_MK)
PGVERSION_MK=	defined

_VARGROUPS+=		pgsql
_USER_VARS.pgsql=	PGSQL_VERSION_DEFAULT
_PKG_VARS.pgsql=	PGSQL_VERSIONS_ACCEPTED
_SYS_VARS.pgsql=	PG_LIB_EXT PGSQL_TYPE PGPKGSRCDIR

.include "../../mk/bsd.prefs.mk"

PGSQL_VERSION_DEFAULT?=		12
PGSQL_VERSIONS_ACCEPTED?=	12 11 10 96 95

# transform the list into individual variables
.for pv in ${PGSQL_VERSIONS_ACCEPTED}
_PGSQL_VERSION_${pv}_OK=	yes
.endfor

.if ${SHLIB_TYPE} == "dylib"
PG_LIB_EXT=dylib
.else
PG_LIB_EXT=so
.endif

# check what is installed
.if ${OPSYS} == "Darwin"
.  if exists(${LOCALBASE}/lib/libecpg.6.12.dylib)
_PGSQL_VERSION_12_INSTALLED=	yes
.  endif
.  if exists(${LOCALBASE}/lib/libecpg.6.11.dylib)
_PGSQL_VERSION_11_INSTALLED=	yes
.  endif
.  if exists(${LOCALBASE}/lib/libecpg.6.10.dylib)
_PGSQL_VERSION_10_INSTALLED=	yes
.  endif
.  if exists(${LOCALBASE}/lib/libecpg.6.8.dylib)
_PGSQL_VERSION_96_INSTALLED=	yes
.  endif
.  if exists(${LOCALBASE}/lib/libecpg.6.7.dylib)
_PGSQL_VERSION_95_INSTALLED=	yes
.  endif
.else
.  if exists(${LOCALBASE}/lib/libecpg.so.6.12)
_PGSQL_VERSION_12_INSTALLED=	yes
.  endif
.  if exists(${LOCALBASE}/lib/libecpg.so.6.11)
_PGSQL_VERSION_11_INSTALLED=	yes
.  endif
.  if exists(${LOCALBASE}/lib/libecpg.so.6.10)
_PGSQL_VERSION_10_INSTALLED=	yes
.  endif
.  if exists(${LOCALBASE}/lib/libecpg.so.6.8)
_PGSQL_VERSION_96_INSTALLED=	yes
.  endif
.  if exists(${LOCALBASE}/lib/libecpg.so.6.7)
_PGSQL_VERSION_95_INSTALLED=	yes
.  endif
.endif

# if a version is explicitely required, take it
.if defined(PGSQL_VERSION_REQD)
_PGSQL_VERSION=	${PGSQL_VERSION_REQD}
.endif
# if the default is already installed, it is first choice
.if !defined(_PGSQL_VERSION)
.if defined(_PGSQL_VERSION_${PGSQL_VERSION_DEFAULT}_OK)
.if defined(_PGSQL_VERSION_${PGSQL_VERSION_DEFAULT}_INSTALLED)
_PGSQL_VERSION=	${PGSQL_VERSION_DEFAULT}
.endif
.endif
.endif
# prefer an already installed version, in order of "accepted"
.if !defined(_PGSQL_VERSION)
.for pv in ${PGSQL_VERSIONS_ACCEPTED}
.if defined(_PGSQL_VERSION_${pv}_INSTALLED)
_PGSQL_VERSION?=	${pv}
.else
# keep information as last resort - see below
_PGSQL_VERSION_FIRSTACCEPTED?=	${pv}
.endif
.endfor
.endif
# if the default is OK for the addon pkg, take this
.if !defined(_PGSQL_VERSION)
.if defined(_PGSQL_VERSION_${PGSQL_VERSION_DEFAULT}_OK)
_PGSQL_VERSION=	${PGSQL_VERSION_DEFAULT}
.endif
.endif
# take the first one accepted by the package
.if !defined(_PGSQL_VERSION)
_PGSQL_VERSION=	${_PGSQL_VERSION_FIRSTACCEPTED}
.endif

# set variables for the version we decided to use:
.if ${_PGSQL_VERSION} == "12"
PGSQL_TYPE=	postgresql12-client
PGPKGSRCDIR=	../../databases/postgresql12-client
.elif ${_PGSQL_VERSION} == "11"
PGSQL_TYPE=	postgresql11-client
PGPKGSRCDIR=	../../databases/postgresql11-client
.elif ${_PGSQL_VERSION} == "10"
PGSQL_TYPE=	postgresql10-client
PGPKGSRCDIR=	../../databases/postgresql10-client
.elif ${_PGSQL_VERSION} == "96"
PGSQL_TYPE=	postgresql96-client
PGPKGSRCDIR=	../../databases/postgresql96-client
.elif ${_PGSQL_VERSION} == "95"
PGSQL_TYPE=	postgresql95-client
PGPKGSRCDIR=	../../databases/postgresql95-client
.else
# force an error
PGSQL_TYPE=		none
PKG_FAIL_REASON+=	"${_PGSQL_VERSION} is not a valid package"
.endif

.include "${PGPKGSRCDIR}/buildlink3.mk"
PGSQL_PREFIX=	${BUILDLINK_PREFIX.${PGSQL_TYPE}}

PGSQL_VERSION=	${_PGSQL_VERSION}

.endif	# PGVERSION_MK