summaryrefslogtreecommitdiff
path: root/lang/ruby/json.mk
blob: e88c492a72e0383d94ebb68fee2e44489ea87e7a (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
# $NetBSD: json.mk,v 1.8 2014/03/15 08:16:03 obache Exp $

# This file handles appropriate dependency to ruby-json pacakge.
#

# === Package-settable variables ===
#
# RUBY_JSON_REQD
#	Specify required version of ruby-json and optionally dependency
#	method after colon.  For example, RUBY_JSON_REQD=1.8.0:build 
#	request ruby-json 1.8.0 and later for BUILD_DEPENDS.
#
#	Default: (empty)
#
# RUBY_JSON_TYPE
#	Specify depending packages: ruby-json, ruby-json-pure or both.
#
#	Possible values: json, pure
#	Default: json
#

.if !defined(_RUBY_JSON_MK)
_RUBY_JSON_MK=	# defined

RUBY_JSON_TYPE?= json

.if empty(RUBY_JSON_REQD)
WARNINGS+= "[lang/ruby/json.mk] No needs to include ../../lang/ruby/json.mk"
.else # !empty(RUBY_JSON_REQD)

.if !empty(RUBY_JSON_REQD:M*\:*)
_RUBY_JSON_DEPENDS=	${RUBY_JSON_REQD:C/([0-9\.]+)\:(.*)/\2/}
_RUBY_JSON_VERS=	${RUBY_JSON_REQD:C/([0-9\.]+)\:(.*)/\1/}
.else
_RUBY_JSON_DEPENDS=	full
_RUBY_JSON_VERS=	${RUBY_JSON_REQD}
.endif

.include "../../lang/ruby/rubyversion.mk"

.  if empty(RUBY_JSON_VERSION)
_RUBY_JSON_REQD=	true
.  else

_RUBY_JSON_MAJOR=	${RUBY_JSON_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/}
_RUBY_JSON_MINOR=	${RUBY_JSON_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\2/}
_RUBY_JSON_TEENY=	${RUBY_JSON_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\3/}

_RUBY_JSON_REQD_MAJOR=	${_RUBY_JSON_VERS:C/^([0-9]+).*/\1/}
_RUBY_JSON_REQD_MINOR=	\
	${_RUBY_JSON_VERS:C/^${_RUBY_JSON_REQD_MAJOR}\.?//:C/^([0-9]+).*/\1/}
.    if empty(_RUBY_JSON_REQD_MINOR)
_RUBY_JSON_REQD_MINOR=	0
_RUBY_JSON_REQD_TEENY=	0
.    else
_RUBY_JSON_REQD_TEENY=	\
  ${_RUBY_JSON_VERS:C/^${_RUBY_JSON_REQD_MAJOR}\.${_RUBY_JSON_REQD_MINOR}\.?//}
.    endif
.    if empty(_RUBY_JSON_REQD_TEENY)
_RUBY_JSON_REQD_TEENY=	0
.    endif

.    if ${_RUBY_JSON_REQD_MAJOR} > ${_RUBY_JSON_MAJOR}
_RUBY_JSON_REQD=	true
.    elif ${_RUBY_JSON_REQD_MAJOR} == ${_RUBY_JSON_MAJOR}
.      if ${_RUBY_JSON_REQD_MINOR} > ${_RUBY_JSON_MINOR}
_RUBY_JSON_REQD=	true
.      elif ${_RUBY_JSON_REQD_MINOR} == ${_RUBY_JSON_MINOR}
.        if ${_RUBY_JSON_REQD_TEENY} > ${_RUBY_JSON_TEENY}
_RUBY_JSON_REQD=	true
.        endif
.      endif
.    endif
.  endif # empty(RUBY_JSON_VERSION)

.  if !empty(_RUBY_JSON_REQD)
.    if ${RUBY_JSON_TYPE} == "pure"
_RUBY_JSON_PKGSRCDIR=	../../textproc/ruby-json-pure
_RUBY_JSON_PKGNAME=	${RUBY_PKGPREFIX}-json-pure
.    else
_RUBY_JSON_PKGSRCDIR=	../../textproc/ruby-json
_RUBY_JSON_PKGNAME=	${RUBY_PKGPREFIX}-json
.    endif
.    if ${_RUBY_JSON_DEPENDS} == "build"
BUILD_DEPENDS+= ${_RUBY_JSON_PKGNAME}>=${_RUBY_JSON_VERS}:${_RUBY_JSON_PKGSRCDIR}
.    else
DEPENDS+= ${_RUBY_JSON_PKGNAME}>=${_RUBY_JSON_VERS}:${_RUBY_JSON_PKGSRCDIR}
.    endif
.  endif

.endif # !empty(RUBY_JSON_REQD)

.endif