Annotation of /trunk/include/cmake.sminc
Parent Directory | Revision Log
Revision 33628 -
(hide annotations)
(download)
Thu Aug 10 15:10:19 2023 UTC (13 months, 2 weeks ago) by niro
File size: 6549 byte(s)
Thu Aug 10 15:10:19 2023 UTC (13 months, 2 weeks ago) by niro
File size: 6549 byte(s)
-use newer CMAKE_INSTALL_LIBDIR macro for variable LIBDIR via mlibdir() and evaluate CMAKE_SRCDIR/CMAKE_BUILDDIR correctly on multilib builds
1 | niro | 2 | # $Header: /magellan-cvs/smage/include/cmake.sminc,v 1.9 2008/04/20 17:40:19 niro Exp $ |
2 | # cmake config tools | ||
3 | |||
4 | SDEPEND="${SDEPEND} | ||
5 | niro | 29889 | >= dev-util/cmake-2.4.7 |
6 | >= virtual/sed" | ||
7 | niro | 2 | |
8 | # enables features like --enable-blah with make | ||
9 | cmake_enable() | ||
10 | { | ||
11 | local feature="$1" | ||
12 | local option="$2" | ||
13 | [[ -z ${option} ]] && option=ON | ||
14 | |||
15 | echo "-DENABLE_${feature}=${option}" | ||
16 | } | ||
17 | |||
18 | # disables features like --disable-blah with make | ||
19 | cmake_disable() | ||
20 | { | ||
21 | local feature="$1" | ||
22 | echo "-DENABLE_${feature}=OFF" | ||
23 | } | ||
24 | |||
25 | # enables features like --with-blah with make | ||
26 | cmake_with() | ||
27 | { | ||
28 | local feature="$1" | ||
29 | local option="$2" | ||
30 | [[ -z ${option} ]] && option=ON | ||
31 | |||
32 | echo "-DWITH_${feature}=${option}" | ||
33 | } | ||
34 | |||
35 | # enables features like --with-blah with make | ||
36 | cmake_without() | ||
37 | { | ||
38 | local feature="$1" | ||
39 | echo "-DWITH_${feature}=OFF" | ||
40 | } | ||
41 | |||
42 | # tell cmake that we support a feature | ||
43 | cmake_have() | ||
44 | { | ||
45 | local feature="$1" | ||
46 | local option="$2" | ||
47 | [[ -z ${option} ]] && option=ON | ||
48 | |||
49 | echo "-DHAVE_${feature}=${option}" | ||
50 | } | ||
51 | |||
52 | # tell cmake that we don't support a feature | ||
53 | cmake_have_not() | ||
54 | { | ||
55 | local feature="$1" | ||
56 | echo "-DHAVE_${feature}=OFF" | ||
57 | } | ||
58 | |||
59 | # tell cmake that we want a feature | ||
60 | cmake_want() | ||
61 | { | ||
62 | local feature="$1" | ||
63 | local option="$2" | ||
64 | [[ -z ${option} ]] && option=ON | ||
65 | |||
66 | echo "-DWANT_${feature}=${option}" | ||
67 | } | ||
68 | |||
69 | # tell cmake that we don't want a feature | ||
70 | cmake_want_not() | ||
71 | { | ||
72 | local feature="$1" | ||
73 | echo "-DWANT_${feature}=OFF" | ||
74 | } | ||
75 | |||
76 | # tell cmake that we don't want a feature using -DNO | ||
77 | cmake_no() | ||
78 | { | ||
79 | local feature="$1" | ||
80 | echo "-DNO_${feature}=1" | ||
81 | } | ||
82 | |||
83 | # tell cmake that we forcefully build a feature | ||
84 | cmake_build() | ||
85 | { | ||
86 | local feature="$1" | ||
87 | local option="$2" | ||
88 | [[ -z ${option} ]] && option=ON | ||
89 | |||
90 | echo "-DBUILD_${feature}=${option}" | ||
91 | } | ||
92 | |||
93 | # tell cmake that we don't build a feature | ||
94 | cmake_build_not() | ||
95 | { | ||
96 | local feature="$1" | ||
97 | echo "-DBUILD_${feature}=OFF" | ||
98 | } | ||
99 | |||
100 | niro | 8012 | # install cmake opts |
101 | cmake_install() | ||
102 | { | ||
103 | local feature="$1" | ||
104 | local option="$2" | ||
105 | niro | 8018 | echo "-DINSTALL_${feature}=${option}" |
106 | niro | 8012 | } |
107 | |||
108 | # generic cmake opts | ||
109 | cmake_opt() | ||
110 | { | ||
111 | local feature="$1" | ||
112 | local option="$2" | ||
113 | niro | 8018 | echo "-D${feature}=${option}" |
114 | niro | 8012 | } |
115 | |||
116 | niro | 29889 | cmake_libsuffix() |
117 | { | ||
118 | local libsuffix | ||
119 | |||
120 | libsuffix="$(mlibdir)" | ||
121 | libsuffix="${libsuffix/lib}" | ||
122 | echo "${libsuffix}" | ||
123 | } | ||
124 | |||
125 | niro | 2 | cmake_src_prepare() |
126 | { | ||
127 | munpack ${SRCFILE} || die | ||
128 | } | ||
129 | |||
130 | cmake_configure() | ||
131 | { | ||
132 | local configure_opts="$@" | ||
133 | niro | 29802 | local default_opts |
134 | niro | 33261 | [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
135 | [[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR | ||
136 | niro | 2 | |
137 | # disable colors if requested | ||
138 | if [[ ${NOCOLORS} = true ]] | ||
139 | then | ||
140 | niro | 29802 | default_opts+=" -DCMAKE_COLOR_MAKEFILE=OFF" |
141 | niro | 2 | fi |
142 | |||
143 | niro | 29802 | default_opts+=" -DCMAKE_VERBOSE_MAKEFILE=ON" |
144 | default_opts+=" -DCMAKE_BUILD_TYPE=Release" | ||
145 | default_opts+=" -DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr}" | ||
146 | niro | 30125 | if [[ ${MULTILIB_BUILD} = true ]] |
147 | then | ||
148 | # eval these variables later with the abi-${ABI} caller | ||
149 | niro | 33628 | # default_opts+=' -DLIB_SUFFIX=$(cmake_libsuffix)' |
150 | # default_opts+=' -DLIB_INSTALL_DIR=${PREFIX:-/usr}/$(mlibdir)' | ||
151 | # default_opts+=' -DLIB_SUFFIX=$(cmake_libsuffix)' | ||
152 | default_opts+=' -DCMAKE_INSTALL_LIBDIR=${PREFIX:-/usr}/$(mlibdir)' | ||
153 | niro | 30125 | else |
154 | # eval these variables now | ||
155 | niro | 33628 | # default_opts+=" -DLIB_SUFFIX=$(cmake_libsuffix)" |
156 | # default_opts+=" -DLIB_INSTALL_DIR=${PREFIX:-/usr}/$(mlibdir)" | ||
157 | # default_opts+=" -DLIB_SUFFIX=$(cmake_libsuffix)" | ||
158 | default_opts+=" -DCMAKE_INSTALL_LIBDIR=${PREFIX:-/usr}/$(mlibdir)" | ||
159 | niro | 30125 | fi |
160 | niro | 29802 | |
161 | if [[ ${MULTILIB_BUILD} = true ]] | ||
162 | then | ||
163 | local abi | ||
164 | local abis_to_run="${MULTILIB_ABIS}" | ||
165 | |||
166 | # respect MULTILIB_ONLY_ABI variable | ||
167 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
168 | for abi in ${abis_to_run} | ||
169 | do | ||
170 | niro | 33628 | #: ${CMAKE_SRCDIR="${SRCDIR}-${abi}/${SRCSUBDIR}"} |
171 | #: ${CMAKE_BUILDDIR="${BUILDDIR}/build-${abi}"} | ||
172 | CMAKE_SRCDIR="${SRCDIR}-${abi}/${SRCSUBDIR}" | ||
173 | CMAKE_BUILDDIR="${BUILDDIR}/build-${abi}" | ||
174 | niro | 33242 | cd ${CMAKE_BUILDDIR} |
175 | abi-${abi} cmake ${default_opts} ${configure_opts} ${CMAKE_SRCDIR} || die | ||
176 | niro | 29802 | done |
177 | else | ||
178 | niro | 33242 | : ${CMAKE_SRCDIR="${SRCDIR}/${SRCSUBDIR}"} |
179 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build"} | ||
180 | niro | 29802 | cd ${BUILDDIR}/build |
181 | cmake ${default_opts} ${configure_opts} ${SRCDIR}/${SRCSUBDIR} || die | ||
182 | fi | ||
183 | niro | 2 | } |
184 | |||
185 | niro | 29802 | cmake_setup_builddir() |
186 | { | ||
187 | niro | 33261 | [[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
188 | |||
189 | niro | 29802 | if [[ ${MULTILIB_BUILD} = true ]] |
190 | then | ||
191 | niro | 33242 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build-$(mabi)"} |
192 | all-abis install -d ${CMAKE_BUILDDIR} || die | ||
193 | niro | 29802 | else |
194 | niro | 33242 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
195 | install -d ${CMAKE_BUILDDIR} || die | ||
196 | niro | 29802 | fi |
197 | } | ||
198 | |||
199 | niro | 30000 | cmake_mmake() |
200 | { | ||
201 | niro | 33261 | [[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
202 | |||
203 | niro | 30000 | if [[ ${MULTILIB_BUILD} = true ]] |
204 | then | ||
205 | niro | 33242 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build-$(mabi)"} |
206 | mmake -C ${CMAKE_BUILDDIR} "$@" || die | ||
207 | niro | 30000 | else |
208 | niro | 33242 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
209 | mmake -C ${CMAKE_BUILDDIR} "$@" || die | ||
210 | niro | 30000 | fi |
211 | } | ||
212 | |||
213 | niro | 2 | cmake_src_compile() |
214 | { | ||
215 | niro | 33261 | [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
216 | |||
217 | niro | 33314 | if [[ ${MULTILIB_BUILD} = true ]] |
218 | then | ||
219 | : ${CMAKE_SRCDIR="${SRCDIR}-$(mabi)/${SRCSUBDIR}"} | ||
220 | else | ||
221 | : ${CMAKE_SRCDIR="${SRCDIR}"} | ||
222 | fi | ||
223 | niro | 33242 | cd ${CMAKE_SRCDIR} |
224 | niro | 2 | |
225 | niro | 29802 | cmake_setup_builddir || die |
226 | niro | 29992 | cmake_configure "$@" || die |
227 | niro | 30000 | cmake_mmake || die |
228 | niro | 2 | } |
229 | |||
230 | niro | 20976 | cmake_src_check() |
231 | { | ||
232 | niro | 33261 | #[[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
233 | # | ||
234 | niro | 33242 | #: ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
235 | #cd ${CMAKE_BUILDDIR} | ||
236 | niro | 21166 | #mmake -j1 -k check || die |
237 | return 0 | ||
238 | niro | 20976 | } |
239 | |||
240 | niro | 29802 | cmake_multilib_src_check() |
241 | { | ||
242 | niro | 33261 | #[[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
243 | # | ||
244 | niro | 29802 | #local abi |
245 | #local abis_to_run="${MULTILIB_ABIS}" | ||
246 | # | ||
247 | ## respect MULTILIB_ONLY_ABI variable | ||
248 | #[[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
249 | #for abi in ${abis_to_run} | ||
250 | #do | ||
251 | niro | 33242 | # : ${CMAKE_BUILDDIR="${BUILDDIR}/build-${abi}"} |
252 | # cd ${CMAKE_BUILDDIR} | ||
253 | niro | 29802 | # mmake -j1 -k check || die |
254 | #done | ||
255 | return 0 | ||
256 | } | ||
257 | |||
258 | niro | 2 | cmake_src_install() |
259 | { | ||
260 | niro | 33261 | [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
261 | |||
262 | niro | 33242 | : ${CMAKE_SRCDIR="${SRCDIR}"} |
263 | |||
264 | niro | 30002 | cmake_mmake DESTDIR=${BINDIR} install || die |
265 | niro | 2 | |
266 | niro | 33242 | cd ${CMAKE_SRCDIR} |
267 | niro | 2 | local i |
268 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ | ||
269 | FAQ LICENSE NEWS README TODO | ||
270 | do | ||
271 | niro | 33242 | if [ -f ${CMAKE_SRCDIR}/${i} ] |
272 | niro | 2 | then |
273 | minstalldocs ${i} || die | ||
274 | fi | ||
275 | done | ||
276 | } | ||
277 | |||
278 | niro | 29802 | cmake_multilib_src_install() |
279 | { | ||
280 | local abi | ||
281 | local abis_to_run="${MULTILIB_ABIS}" | ||
282 | niro | 33261 | [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
283 | niro | 30002 | |
284 | cmake_mmake DESTDIR=${BINDIR} install || die | ||
285 | |||
286 | niro | 29802 | # respect MULTILIB_ONLY_ABI variable |
287 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
288 | for abi in ${abis_to_run} | ||
289 | do | ||
290 | niro | 33242 | : ${CMAKE_SRCDIR="${SRCDIR}-${abi}"} |
291 | |||
292 | cd ${CMAKE_SRCDIR} | ||
293 | niro | 29802 | local i |
294 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ | ||
295 | FAQ LICENSE NEWS README TODO | ||
296 | do | ||
297 | niro | 33242 | if [ -f ${CMAKE_SRCDIR}/${i} ] |
298 | niro | 29802 | then |
299 | minstalldocs ${i} || die | ||
300 | fi | ||
301 | done | ||
302 | done | ||
303 | } | ||
304 | |||
305 | export_inherits cmake src_prepare src_compile | ||
306 | if [[ ${MULTILIB_BUILD} = true ]] | ||
307 | then | ||
308 | export_inherits cmake_multilib src_check src_install | ||
309 | else | ||
310 | export_inherits cmake src_check src_install | ||
311 | fi |