update Wed Feb 10 14:33:06 PST 2010
[pkgsrc.git] / mk / pgsql.buildlink3.mk
1 # $NetBSD: pgsql.buildlink3.mk,v 1.28 2010/02/10 19:33:54 joerg 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?=         84
29 PGSQL_VERSIONS_ACCEPTED?=       84 83 82
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.1.dylib)
45 _PGSQL_VERSION_84_INSTALLED=    yes
46 .endif
47 .if exists(${LOCALBASE}/lib/libecpg.6.0.0.dylib)
48 _PGSQL_VERSION_83_INSTALLED=    yes
49 .endif
50 .if exists(${LOCALBASE}/lib/libecpg.5.0.2.dylib)
51 _PGSQL_VERSION_82_INSTALLED=    yes
52 .endif
53 .else
54 .if exists(${LOCALBASE}/lib/libecpg.so.6.0.1)
55 _PGSQL_VERSION_84_INSTALLED=    yes
56 .endif
57 .if exists(${LOCALBASE}/lib/libecpg.so.6.0.0)
58 _PGSQL_VERSION_83_INSTALLED=    yes
59 .endif
60 .if exists(${LOCALBASE}/lib/libecpg.so.5.0.2)
61 _PGSQL_VERSION_82_INSTALLED=    yes
62 .endif
63 .endif
64
65 # if a version is explicitely required, take it
66 .if defined(PGSQL_VERSION_REQD)
67 _PGSQL_VERSION= ${PGSQL_VERSION_REQD}
68 .endif
69 # if the default is already installed, it is first choice
70 .if !defined(_PGSQL_VERSION)
71 .if defined(_PGSQL_VERSION_${PGSQL_VERSION_DEFAULT}_OK)
72 .if defined(_PGSQL_VERSION_${PGSQL_VERSION_DEFAULT}_INSTALLED)
73 _PGSQL_VERSION= ${PGSQL_VERSION_DEFAULT}
74 .endif
75 .endif
76 .endif
77 # prefer an already installed version, in order of "accepted"
78 .if !defined(_PGSQL_VERSION)
79 .for pv in ${PGSQL_VERSIONS_ACCEPTED}
80 .if defined(_PGSQL_VERSION_${pv}_INSTALLED)
81 _PGSQL_VERSION?=        ${pv}
82 .else
83 # keep information as last resort - see below
84 _PGSQL_VERSION_FIRSTACCEPTED?=  ${pv}
85 .endif
86 .endfor
87 .endif
88 # if the default is OK for the addon pkg, take this
89 .if !defined(_PGSQL_VERSION)
90 .if defined(_PGSQL_VERSION_${PGSQL_VERSION_DEFAULT}_OK)
91 _PGSQL_VERSION= ${PGSQL_VERSION_DEFAULT}
92 .endif
93 .endif
94 # take the first one accepted by the package
95 .if !defined(_PGSQL_VERSION)
96 _PGSQL_VERSION= ${_PGSQL_VERSION_FIRSTACCEPTED}
97 .endif
98
99 #
100 # set variables for the version we decided to use:
101 #
102 .if ${_PGSQL_VERSION} == "84"
103 PGSQL_TYPE=     postgresql84-client
104 PGPKGSRCDIR=    ../../databases/postgresql84-client
105 .elif ${_PGSQL_VERSION} == "83"
106 PGSQL_TYPE=     postgresql83-client
107 PGPKGSRCDIR=    ../../databases/postgresql83-client
108 .elif ${_PGSQL_VERSION} == "82"
109 PGSQL_TYPE=     postgresql82-client
110 PGPKGSRCDIR=    ../../databases/postgresql82-client
111 .else
112 # force an error
113 PGSQL_TYPE=             none
114 PKG_FAIL_REASON+=       "${_PGSQL_VERSION} is not a valid package"
115 .endif
116
117 .include "${PGPKGSRCDIR}/buildlink3.mk"
118 PGSQL_PREFIX=   ${BUILDLINK_PREFIX.${PGSQL_TYPE}}
119
120 PGSQL_VERSION=  ${_PGSQL_VERSION}
121
122 .endif  # PGVERSION_MK