Add files from parent branch HEAD:
[pkgsrc.git] / mk / pgsql.buildlink3.mk
1 # $NetBSD: pgsql.buildlink3.mk,v 1.24 2008/03/04 12:50:25 adam Exp $
2 #
3 # User-settable variables:
4 #
5 # PGSQL_VERSION_DEFAULT
6 #
7 # Package-settable variables:
8 #
9 # PGSQL_VERSIONS_ACCEPTED
10 #
11 # Variables set by this file:
12 #
13 # PG_LIB_EXT
14 # PGSQL_TYPE
15 # PGPKGSRCDIR
16 #
17
18 .if !defined(PGVERSION_MK)
19 PGVERSION_MK=   defined
20
21 _VARGROUPS+=            pgsql
22 _USER_VARS.pgsql=       PGSQL_VERSION_DEFAULT
23 _PKG_VARS.pgsql=        PGSQL_VERSIONS_ACCEPTED
24 _SYS_VARS.pgsql=        PG_LIB_EXT PGSQL_TYPE PGPKGSRCDIR
25
26 .include "../../mk/bsd.prefs.mk"
27
28 PGSQL_VERSION_DEFAULT?=         82
29 PGSQL_VERSIONS_ACCEPTED?=       83 82 81
30
31 # transform the list into individual variables
32 .for pv in ${PGSQL_VERSIONS_ACCEPTED}
33 _PGSQL_VERSION_${pv}_OK=        yes
34 .endfor
35
36 .if ${_OPSYS_SHLIB_TYPE} == "dylib"
37 PG_LIB_EXT=dylib
38 .else
39 PG_LIB_EXT=so
40 .endif
41
42 # check what is installed
43 .if ${OPSYS} == "Darwin"
44 .if exists(${LOCALBASE}/lib/libecpg.6.0.0.dylib)
45 _PGSQL_VERSION_83_INSTALLED=    yes
46 .endif
47 .if exists(${LOCALBASE}/lib/libecpg.5.0.2.dylib)
48 _PGSQL_VERSION_82_INSTALLED=    yes
49 .endif
50 .if exists(${LOCALBASE}/lib/libecpg.5.0.1.dylib)
51 _PGSQL_VERSION_81_INSTALLED=    yes
52 .endif
53 .if exists(${LOCALBASE}/lib/libecpg.5.0.dylib)
54 _PGSQL_VERSION_80_INSTALLED=    yes
55 .endif
56 .if exists(${LOCALBASE}/lib/libecpg.4.1.dylib)
57 _PGSQL_VERSION_74_INSTALLED=    yes
58 .endif
59 .if exists(${LOCALBASE}/lib/libecpg.3.dylib)
60 _PGSQL_VERSION_73_INSTALLED=yes
61 .endif
62 .else
63 .if exists(${LOCALBASE}/lib/libecpg.so.6.0.0)
64 _PGSQL_VERSION_83_INSTALLED=    yes
65 .endif
66 .if exists(${LOCALBASE}/lib/libecpg.so.5.0.2)
67 _PGSQL_VERSION_82_INSTALLED=    yes
68 .endif
69 .if exists(${LOCALBASE}/lib/libecpg.so.5.0.1)
70 _PGSQL_VERSION_81_INSTALLED=    yes
71 .endif
72 .if exists(${LOCALBASE}/lib/libecpg.so.5.0.0)
73 _PGSQL_VERSION_80_INSTALLED=    yes
74 .endif
75 .if exists(${LOCALBASE}/lib/libecpg.so.4.1)
76 _PGSQL_VERSION_74_INSTALLED=    yes
77 .endif
78 .if exists(${LOCALBASE}/lib/libecpg.so.3)
79 _PGSQL_VERSION_73_INSTALLED=yes
80 .endif
81 .endif
82
83 # if a version is explicitely required, take it
84 .if defined(PGSQL_VERSION_REQD)
85 _PGSQL_VERSION= ${PGSQL_VERSION_REQD}
86 .endif
87 # if the default is already installed, it is first choice
88 .if !defined(_PGSQL_VERSION)
89 .if defined(_PGSQL_VERSION_${PGSQL_VERSION_DEFAULT}_OK)
90 .if defined(_PGSQL_VERSION_${PGSQL_VERSION_DEFAULT}_INSTALLED)
91 _PGSQL_VERSION= ${PGSQL_VERSION_DEFAULT}
92 .endif
93 .endif
94 .endif
95 # prefer an already installed version, in order of "accepted"
96 .if !defined(_PGSQL_VERSION)
97 .for pv in ${PGSQL_VERSIONS_ACCEPTED}
98 .if defined(_PGSQL_VERSION_${pv}_INSTALLED)
99 _PGSQL_VERSION?=        ${pv}
100 .else
101 # keep information as last resort - see below
102 _PGSQL_VERSION_FIRSTACCEPTED?=  ${pv}
103 .endif
104 .endfor
105 .endif
106 # if the default is OK for the addon pkg, take this
107 .if !defined(_PGSQL_VERSION)
108 .if defined(_PGSQL_VERSION_${PGSQL_VERSION_DEFAULT}_OK)
109 _PGSQL_VERSION= ${PGSQL_VERSION_DEFAULT}
110 .endif
111 .endif
112 # take the first one accepted by the package
113 .if !defined(_PGSQL_VERSION)
114 _PGSQL_VERSION= ${_PGSQL_VERSION_FIRSTACCEPTED}
115 .endif
116
117 #
118 # set variables for the version we decided to use:
119 #
120 .if ${_PGSQL_VERSION} == "83"
121 PGSQL_TYPE=     postgresql83-client
122 PGPKGSRCDIR=    ../../databases/postgresql83-client
123 .elif ${_PGSQL_VERSION} == "82"
124 PGSQL_TYPE=     postgresql82-client
125 PGPKGSRCDIR=    ../../databases/postgresql82-client
126 .elif ${_PGSQL_VERSION} == "81"
127 PGSQL_TYPE=     postgresql81-client
128 PGPKGSRCDIR=    ../../databases/postgresql81-client
129 .elif ${_PGSQL_VERSION} == "80"
130 PGSQL_TYPE=     postgresql80-client
131 PGPKGSRCDIR=    ../../databases/postgresql80-client
132 .else
133 # force an error
134 PGSQL_TYPE=             none
135 PKG_FAIL_REASON+=       "${_PGSQL_VERSION} is not a valid package"
136 .endif
137
138 .include "${PGPKGSRCDIR}/buildlink3.mk"
139 PGSQL_PREFIX=   ${BUILDLINK_PREFIX.${PGSQL_TYPE}}
140
141 PGSQL_VERSION=  ${_PGSQL_VERSION}
142
143 .endif  # PGVERSION_MK