Contents of /smage/trunk/include/cmake.sminc
Parent Directory | Revision Log
Revision 13780 -
(show annotations)
(download)
Wed Oct 30 12:52:26 2019 UTC (4 years, 10 months ago) by niro
File size: 6205 byte(s)
Wed Oct 30 12:52:26 2019 UTC (4 years, 10 months ago) by niro
File size: 6205 byte(s)
-sync with upstream
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 | else |
153 | # eval these variables now |
154 | default_opts+=" -DLIB_SUFFIX=$(cmake_libsuffix)" |
155 | default_opts+=" -DLIB_INSTALL_DIR=${PREFIX:-/usr}/$(mlibdir)" |
156 | default_opts+=" -DLIB_SUFFIX=$(cmake_libsuffix)" |
157 | fi |
158 | |
159 | if [[ ${MULTILIB_BUILD} = true ]] |
160 | then |
161 | local abi |
162 | local abis_to_run="${MULTILIB_ABIS}" |
163 | |
164 | # respect MULTILIB_ONLY_ABI variable |
165 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" |
166 | for abi in ${abis_to_run} |
167 | do |
168 | : ${CMAKE_SRCDIR="${SRCDIR}-${abi}/${SRCSUBDIR}"} |
169 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build-${abi}"} |
170 | cd ${CMAKE_BUILDDIR} |
171 | abi-${abi} cmake ${default_opts} ${configure_opts} ${CMAKE_SRCDIR} || die |
172 | done |
173 | else |
174 | : ${CMAKE_SRCDIR="${SRCDIR}/${SRCSUBDIR}"} |
175 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
176 | cd ${BUILDDIR}/build |
177 | cmake ${default_opts} ${configure_opts} ${SRCDIR}/${SRCSUBDIR} || die |
178 | fi |
179 | } |
180 | |
181 | cmake_setup_builddir() |
182 | { |
183 | [[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
184 | |
185 | if [[ ${MULTILIB_BUILD} = true ]] |
186 | then |
187 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build-$(mabi)"} |
188 | all-abis install -d ${CMAKE_BUILDDIR} || die |
189 | else |
190 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
191 | install -d ${CMAKE_BUILDDIR} || die |
192 | fi |
193 | } |
194 | |
195 | cmake_mmake() |
196 | { |
197 | [[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
198 | |
199 | if [[ ${MULTILIB_BUILD} = true ]] |
200 | then |
201 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build-$(mabi)"} |
202 | mmake -C ${CMAKE_BUILDDIR} "$@" || die |
203 | else |
204 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
205 | mmake -C ${CMAKE_BUILDDIR} "$@" || die |
206 | fi |
207 | } |
208 | |
209 | cmake_src_compile() |
210 | { |
211 | [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
212 | |
213 | : ${CMAKE_SRCDIR="${SRCDIR}"} |
214 | cd ${CMAKE_SRCDIR} |
215 | |
216 | cmake_setup_builddir || die |
217 | cmake_configure "$@" || die |
218 | cmake_mmake || die |
219 | } |
220 | |
221 | cmake_src_check() |
222 | { |
223 | #[[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
224 | # |
225 | #: ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
226 | #cd ${CMAKE_BUILDDIR} |
227 | #mmake -j1 -k check || die |
228 | return 0 |
229 | } |
230 | |
231 | cmake_multilib_src_check() |
232 | { |
233 | #[[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
234 | # |
235 | #local abi |
236 | #local abis_to_run="${MULTILIB_ABIS}" |
237 | # |
238 | ## respect MULTILIB_ONLY_ABI variable |
239 | #[[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" |
240 | #for abi in ${abis_to_run} |
241 | #do |
242 | # : ${CMAKE_BUILDDIR="${BUILDDIR}/build-${abi}"} |
243 | # cd ${CMAKE_BUILDDIR} |
244 | # mmake -j1 -k check || die |
245 | #done |
246 | return 0 |
247 | } |
248 | |
249 | cmake_src_install() |
250 | { |
251 | [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
252 | |
253 | : ${CMAKE_SRCDIR="${SRCDIR}"} |
254 | |
255 | cmake_mmake DESTDIR=${BINDIR} install || die |
256 | |
257 | cd ${CMAKE_SRCDIR} |
258 | local i |
259 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
260 | FAQ LICENSE NEWS README TODO |
261 | do |
262 | if [ -f ${CMAKE_SRCDIR}/${i} ] |
263 | then |
264 | minstalldocs ${i} || die |
265 | fi |
266 | done |
267 | } |
268 | |
269 | cmake_multilib_src_install() |
270 | { |
271 | local abi |
272 | local abis_to_run="${MULTILIB_ABIS}" |
273 | [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
274 | |
275 | cmake_mmake DESTDIR=${BINDIR} install || die |
276 | |
277 | # respect MULTILIB_ONLY_ABI variable |
278 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" |
279 | for abi in ${abis_to_run} |
280 | do |
281 | : ${CMAKE_SRCDIR="${SRCDIR}-${abi}"} |
282 | |
283 | cd ${CMAKE_SRCDIR} |
284 | local i |
285 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
286 | FAQ LICENSE NEWS README TODO |
287 | do |
288 | if [ -f ${CMAKE_SRCDIR}/${i} ] |
289 | then |
290 | minstalldocs ${i} || die |
291 | fi |
292 | done |
293 | done |
294 | } |
295 | |
296 | export_inherits cmake src_prepare src_compile |
297 | if [[ ${MULTILIB_BUILD} = true ]] |
298 | then |
299 | export_inherits cmake_multilib src_check src_install |
300 | else |
301 | export_inherits cmake src_check src_install |
302 | fi |