Contents of /trunk/include/cmake.sminc
Parent Directory | Revision Log
Revision 33628 -
(show annotations)
(download)
Thu Aug 10 15:10:19 2023 UTC (8 months, 3 weeks ago) by niro
File size: 6549 byte(s)
Thu Aug 10 15:10:19 2023 UTC (8 months, 3 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 | # $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 | >= dev-util/cmake-2.4.7 |
6 | >= virtual/sed" |
7 | |
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 | # install cmake opts |
101 | cmake_install() |
102 | { |
103 | local feature="$1" |
104 | local option="$2" |
105 | echo "-DINSTALL_${feature}=${option}" |
106 | } |
107 | |
108 | # generic cmake opts |
109 | cmake_opt() |
110 | { |
111 | local feature="$1" |
112 | local option="$2" |
113 | echo "-D${feature}=${option}" |
114 | } |
115 | |
116 | cmake_libsuffix() |
117 | { |
118 | local libsuffix |
119 | |
120 | libsuffix="$(mlibdir)" |
121 | libsuffix="${libsuffix/lib}" |
122 | echo "${libsuffix}" |
123 | } |
124 | |
125 | cmake_src_prepare() |
126 | { |
127 | munpack ${SRCFILE} || die |
128 | } |
129 | |
130 | cmake_configure() |
131 | { |
132 | local configure_opts="$@" |
133 | local default_opts |
134 | [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
135 | [[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
136 | |
137 | # disable colors if requested |
138 | if [[ ${NOCOLORS} = true ]] |
139 | then |
140 | default_opts+=" -DCMAKE_COLOR_MAKEFILE=OFF" |
141 | fi |
142 | |
143 | default_opts+=" -DCMAKE_VERBOSE_MAKEFILE=ON" |
144 | default_opts+=" -DCMAKE_BUILD_TYPE=Release" |
145 | default_opts+=" -DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr}" |
146 | if [[ ${MULTILIB_BUILD} = true ]] |
147 | then |
148 | # eval these variables later with the abi-${ABI} caller |
149 | # 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 | else |
154 | # eval these variables now |
155 | # 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 | fi |
160 | |
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 | #: ${CMAKE_SRCDIR="${SRCDIR}-${abi}/${SRCSUBDIR}"} |
171 | #: ${CMAKE_BUILDDIR="${BUILDDIR}/build-${abi}"} |
172 | CMAKE_SRCDIR="${SRCDIR}-${abi}/${SRCSUBDIR}" |
173 | CMAKE_BUILDDIR="${BUILDDIR}/build-${abi}" |
174 | cd ${CMAKE_BUILDDIR} |
175 | abi-${abi} cmake ${default_opts} ${configure_opts} ${CMAKE_SRCDIR} || die |
176 | done |
177 | else |
178 | : ${CMAKE_SRCDIR="${SRCDIR}/${SRCSUBDIR}"} |
179 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
180 | cd ${BUILDDIR}/build |
181 | cmake ${default_opts} ${configure_opts} ${SRCDIR}/${SRCSUBDIR} || die |
182 | fi |
183 | } |
184 | |
185 | cmake_setup_builddir() |
186 | { |
187 | [[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
188 | |
189 | if [[ ${MULTILIB_BUILD} = true ]] |
190 | then |
191 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build-$(mabi)"} |
192 | all-abis install -d ${CMAKE_BUILDDIR} || die |
193 | else |
194 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
195 | install -d ${CMAKE_BUILDDIR} || die |
196 | fi |
197 | } |
198 | |
199 | cmake_mmake() |
200 | { |
201 | [[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
202 | |
203 | if [[ ${MULTILIB_BUILD} = true ]] |
204 | then |
205 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build-$(mabi)"} |
206 | mmake -C ${CMAKE_BUILDDIR} "$@" || die |
207 | else |
208 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
209 | mmake -C ${CMAKE_BUILDDIR} "$@" || die |
210 | fi |
211 | } |
212 | |
213 | cmake_src_compile() |
214 | { |
215 | [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
216 | |
217 | if [[ ${MULTILIB_BUILD} = true ]] |
218 | then |
219 | : ${CMAKE_SRCDIR="${SRCDIR}-$(mabi)/${SRCSUBDIR}"} |
220 | else |
221 | : ${CMAKE_SRCDIR="${SRCDIR}"} |
222 | fi |
223 | cd ${CMAKE_SRCDIR} |
224 | |
225 | cmake_setup_builddir || die |
226 | cmake_configure "$@" || die |
227 | cmake_mmake || die |
228 | } |
229 | |
230 | cmake_src_check() |
231 | { |
232 | #[[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
233 | # |
234 | #: ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
235 | #cd ${CMAKE_BUILDDIR} |
236 | #mmake -j1 -k check || die |
237 | return 0 |
238 | } |
239 | |
240 | cmake_multilib_src_check() |
241 | { |
242 | #[[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
243 | # |
244 | #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 | # : ${CMAKE_BUILDDIR="${BUILDDIR}/build-${abi}"} |
252 | # cd ${CMAKE_BUILDDIR} |
253 | # mmake -j1 -k check || die |
254 | #done |
255 | return 0 |
256 | } |
257 | |
258 | cmake_src_install() |
259 | { |
260 | [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
261 | |
262 | : ${CMAKE_SRCDIR="${SRCDIR}"} |
263 | |
264 | cmake_mmake DESTDIR=${BINDIR} install || die |
265 | |
266 | cd ${CMAKE_SRCDIR} |
267 | local i |
268 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
269 | FAQ LICENSE NEWS README TODO |
270 | do |
271 | if [ -f ${CMAKE_SRCDIR}/${i} ] |
272 | then |
273 | minstalldocs ${i} || die |
274 | fi |
275 | done |
276 | } |
277 | |
278 | cmake_multilib_src_install() |
279 | { |
280 | local abi |
281 | local abis_to_run="${MULTILIB_ABIS}" |
282 | [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
283 | |
284 | cmake_mmake DESTDIR=${BINDIR} install || die |
285 | |
286 | # 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 | : ${CMAKE_SRCDIR="${SRCDIR}-${abi}"} |
291 | |
292 | cd ${CMAKE_SRCDIR} |
293 | local i |
294 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
295 | FAQ LICENSE NEWS README TODO |
296 | do |
297 | if [ -f ${CMAKE_SRCDIR}/${i} ] |
298 | 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 |