pullup 3232
[pkgsrcv2.git] / mk / license.mk
1 # $NetBSD: license.mk,v 1.33 2010/04/26 11:03:10 obache Exp $
2 #
3 # This file handles everything about the LICENSE variable. It is
4 # included automatically by bsd.pkg.mk.
5 #
6 # XXX There should be one place to set the default list and for users
7 # to set the ACCEPTABLE_LICENSES list, used by both source builds and
8 # binary installs#
9 #
10 # XXX: Some of this content arguably belongs in the pkgsrc guide
11 # instead.
12 #
13 # === User-settable variables ===
14 #
15 # ACCEPTABLE_LICENSES
16 #
17 #       If a package declares a license and that license is not a
18 #       member of the list defined by this variable, pkgsrc will not
19 #       build the package and instead print an error message.
20 #       (pkg_install has code to behave the same way, but it is not
21 #       yet turned on.)
22 #
23 #       XXX: Perhaps there should be some mechanism to prevent running
24 #       programs that are part of packages that declare LICENSEs that
25 #       are not in ACCEPTABLE_LICENSES or some per-user variable.
26 #       This is surely controversial and requires discussion.
27 #
28 #       To include the default licenses, you can use the += operator
29 #       in mk.conf. To override it, use the plain = operator.
30 #
31 #       Default value: ${DEFAULT_ACCEPTABLE_LICENSES}
32 #
33 # === Package-settable variables ===
34 #
35 # LICENSE
36 #
37 #       The license of the package.
38 #
39 #       Dual licenses can be specified with OR expressions:
40 #       LICENSE=        license1 OR license2
41 #
42 #       If more than one license applies at the same time, AND expressions
43 #       can be used:
44 #       LICENSE=        license1 AND license2
45 #
46 #       Expressions can be nested if necessary:
47 #       LICENSE=        (license1 AND license2) OR license3
48 #       Parenthesis are required when mixing AND and OR.
49 #
50 #       Every package should specify its license.  (Prior to early 2009,
51 #       Open Source and Free software did not have license tags.)
52 #
53 #       Licenses are collected in the licenses/ subdirectory of
54 #       pkgsrc.  For open source license, we generally use the same
55 #       names as either the Open Source Initiative or the Free
56 #       Software Foundation, choosing a name to reduce confusion.
57 #       Open source and free licenses do not have a -license suffix,
58 #       and non-free licenses do.
59 #
60 #       http://opensource.org/licenses/category
61 #       http://www.fsf.org/licensing/licenses/index_html
62 #
63 # === Predefined variables ===
64 #
65 # DEFAULT_ACCEPTABLE_LICENSES
66 #       The list of licenses that will be the default value of
67 #       ACCEPTABLE_LICENSES.  Adapting the longstanding policy of Open
68 #       Source or Free licenses not requiring tags, it should contain
69 #       all licenses that are Open Source or Free, so as to provide
70 #       the most expansive default that almost all people find
71 #       acceptable.  (Many people will want to add more licenses to
72 #       ACCEPTABLE_LICENSES; the point is to have a default that very
73 #       few people want to shrink.)
74 #
75 #       Licenses not formally approved as Free or Open Source may be
76 #       added if they have terms that would obviously be approved if
77 #       the effort were made.  Such license names will have a comment
78 #       near them in the assignment to DEFAULT_ACCEPTABLE_LICENSES.
79 #
80 #       The pkg_install sources also have a
81 #       DEFAULT_ACCEPTABLE_LICENSES list, and that should be updated
82 #       to match the list here.  See
83 #       pkgsrc/pkgtools/pkg_install/files/lib/license.c
84 #
85 # === See also ===
86 #
87 #       ../doc/TODO, section "Licenses of packages"
88 #
89 # Keywords: licence license
90 #
91
92 # This list is not complete.  Free and Open Source licenses should be
93 # added to the list as they are added to pkgsrc.
94
95 # The convention is that Free or Open Source licenses do not have a
96 # -license suffix, and nonfree licenses end in -license.
97
98 # XXX open-font-license should perhaps be changed to open-font
99
100 DEFAULT_ACCEPTABLE_LICENSES= \
101         public-domain \
102         gnu-fdl-v1.1 gnu-fdl-v1.2 gnu-fdl-v1.3 \
103         gnu-gpl-v2 gnu-lgpl-v2 gnu-lgpl-v2.1 \
104         gnu-gpl-v3 gnu-lgpl-v3 \
105         original-bsd modified-bsd 2-clause-bsd \
106         x11 mit miros \
107         apache-1.1 apache-2.0 \
108         artistic artistic-2.0 \
109         cddl-1.0 \
110         cpl-1.0 \
111         open-font-license \
112         mpl-1.0 mpl-1.1 \
113         zpl \
114         python-software-foundation \
115         ipafont \
116         isc
117
118 # not approved by OSI, derived from BSD
119 DEFAULT_ACCEPTABLE_LICENSES+=   info-zip
120
121 ##### Variant spellings
122
123 .if defined(ACCEPTABLE_LICENCES) && !defined(ACCEPTABLE_LICENSES)
124 ACCEPTABLE_LICENSES=    ${ACCEPTABLE_LICENCES}
125 .endif
126
127 .if !defined(LICENSE)
128 .  if defined(PKG_DEVELOPER)
129 WARNINGS+=              "[license.mk] Every package should define a LICENSE."
130 .  endif
131
132 .else
133
134 .if defined(_ACCEPTABLE)
135 WARNINGS+=      "Deprecated variable _ACCEPTABLE found, use SKIP_LICENSE_CHECK=yes"
136 SKIP_LICENSE_CHECK=     yes
137 .endif
138
139 SKIP_LICENSE_CHECK?=    no
140
141 .if !empty(SKIP_LICENSE_CHECK:M[Yy][Ee][Ss])
142 _ACCEPTABLE_LICENSE=    skipped
143 .else
144 _ACCEPTABLE_LICENSE!=   \
145     if test `${PKG_ADMIN} -V` -lt 20090528; then \
146         echo outdated; \
147     else \
148         ${SETENV} PKGSRC_ACCEPTABLE_LICENSES=${ACCEPTABLE_LICENSES:Q} \
149         PKGSRC_DEFAULT_ACCEPTABLE_LICENSES=${DEFAULT_ACCEPTABLE_LICENSES:Q} \
150         ${PKG_ADMIN} check-license ${LICENSE:Q} || echo failure; \
151     fi
152 .endif
153
154 .if ${_ACCEPTABLE_LICENSE} == "no"
155 .  if defined(MAKECONF)
156 _MAKE_CONF?=    ${MAKECONF}
157 .  elif ${OPSYS} == "NetBSD" && ${MAKE} == "/usr/bin/make"
158 _MAKE_CONF?=    /etc/mk.conf
159 .  else
160 _MAKE_CONF?=    ${PREFIX}/etc/mk.conf
161 .endif
162 .  if ${OPSYS} == "NetBSD" && ${PKG_TOOLS_BIN} == "/usr/sbin"
163 _PKG_INSTALL_CONF?=     /etc/pkg_install.conf
164 .  else
165 _PKG_INSTALL_CONF?=     ${PREFIX}/etc/pkg_install.conf
166 .endif
167
168 .  if empty(LICENSE:MAND) && empty(LICENSE:MOR) && empty(LICENSE:M*[()]*)
169 PKG_FAIL_REASON+= "${PKGNAME} has an unacceptable license condition: " \
170     "    "${LICENSE:Q} \
171     "You can mark the license \`\`license'' as acceptable by adding" \
172     "    ACCEPTABLE_LICENSES+= ${LICENSE}" \
173     "to ${_MAKE_CONF} or by adding" \
174     "    ACCEPTABLE_LICENSES= ${LICENSE}" \
175     "to ${_PKG_INSTALL_CONF}."
176 PKG_FAIL_REASON+= "The following command will show you the license text:" \
177     "    ${MAKE} show-license"
178 .  else
179 PKG_FAIL_REASON+= "${PKGNAME} has an unacceptable license condition: " \
180     "    "${LICENSE:Q} \
181     "You can mark the license \`\`license'' as acceptable by adding" \
182     "    ACCEPTABLE_LICENSES+= license" \
183     "to ${_MAKE_CONF} or by adding" \
184     "    ACCEPTABLE_LICENSES= license" \
185     "to ${_PKG_INSTALL_CONF}."
186 .  endif
187
188 .elif ${_ACCEPTABLE_LICENSE} == "failure"
189 PKG_FAIL_REASON+= "License conditions for ${PKGNAME} could not be evaluated"
190 .elif ${_ACCEPTABLE_LICENSE} == "outdated"
191 PKG_FAIL_REASON+= \
192     "Your pkg_install is too old to evaluate license conditions" \
193     "You can bypass this check by setting SKIP_LICENSE_CHECK=yes"
194 .endif
195
196 .endif