Annotation of /trunk/include/cmake.sminc
Parent Directory | Revision Log
Revision 33242 -
(hide annotations)
(download)
Mon Oct 21 10:08:11 2019 UTC (4 years, 6 months ago) by niro
File size: 5741 byte(s)
Mon Oct 21 10:08:11 2019 UTC (4 years, 6 months ago) by niro
File size: 5741 byte(s)
-make cmakes srcdir and builddir configurable
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 | 2 | |
135 | # disable colors if requested | ||
136 | if [[ ${NOCOLORS} = true ]] | ||
137 | then | ||
138 | niro | 29802 | default_opts+=" -DCMAKE_COLOR_MAKEFILE=OFF" |
139 | niro | 2 | fi |
140 | |||
141 | niro | 29802 | default_opts+=" -DCMAKE_VERBOSE_MAKEFILE=ON" |
142 | default_opts+=" -DCMAKE_BUILD_TYPE=Release" | ||
143 | default_opts+=" -DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr}" | ||
144 | niro | 30125 | if [[ ${MULTILIB_BUILD} = true ]] |
145 | then | ||
146 | # eval these variables later with the abi-${ABI} caller | ||
147 | default_opts+=' -DLIB_SUFFIX=$(cmake_libsuffix)' | ||
148 | default_opts+=' -DLIB_INSTALL_DIR=${PREFIX:-/usr}/$(mlibdir)' | ||
149 | default_opts+=' -DLIB_SUFFIX=$(cmake_libsuffix)' | ||
150 | else | ||
151 | # eval these variables now | ||
152 | default_opts+=" -DLIB_SUFFIX=$(cmake_libsuffix)" | ||
153 | default_opts+=" -DLIB_INSTALL_DIR=${PREFIX:-/usr}/$(mlibdir)" | ||
154 | default_opts+=" -DLIB_SUFFIX=$(cmake_libsuffix)" | ||
155 | fi | ||
156 | niro | 29802 | |
157 | if [[ ${MULTILIB_BUILD} = true ]] | ||
158 | then | ||
159 | local abi | ||
160 | local abis_to_run="${MULTILIB_ABIS}" | ||
161 | |||
162 | # respect MULTILIB_ONLY_ABI variable | ||
163 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
164 | for abi in ${abis_to_run} | ||
165 | do | ||
166 | niro | 33242 | : ${CMAKE_SRCDIR="${SRCDIR}-${abi}/${SRCSUBDIR}"} |
167 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build-${abi}"} | ||
168 | cd ${CMAKE_BUILDDIR} | ||
169 | abi-${abi} cmake ${default_opts} ${configure_opts} ${CMAKE_SRCDIR} || die | ||
170 | niro | 29802 | done |
171 | else | ||
172 | niro | 33242 | : ${CMAKE_SRCDIR="${SRCDIR}/${SRCSUBDIR}"} |
173 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build"} | ||
174 | niro | 29802 | cd ${BUILDDIR}/build |
175 | cmake ${default_opts} ${configure_opts} ${SRCDIR}/${SRCSUBDIR} || die | ||
176 | fi | ||
177 | niro | 2 | } |
178 | |||
179 | niro | 29802 | cmake_setup_builddir() |
180 | { | ||
181 | if [[ ${MULTILIB_BUILD} = true ]] | ||
182 | then | ||
183 | niro | 33242 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build-$(mabi)"} |
184 | all-abis install -d ${CMAKE_BUILDDIR} || die | ||
185 | niro | 29802 | else |
186 | niro | 33242 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
187 | install -d ${CMAKE_BUILDDIR} || die | ||
188 | niro | 29802 | fi |
189 | } | ||
190 | |||
191 | niro | 30000 | cmake_mmake() |
192 | { | ||
193 | if [[ ${MULTILIB_BUILD} = true ]] | ||
194 | then | ||
195 | niro | 33242 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build-$(mabi)"} |
196 | mmake -C ${CMAKE_BUILDDIR} "$@" || die | ||
197 | niro | 30000 | else |
198 | niro | 33242 | : ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
199 | mmake -C ${CMAKE_BUILDDIR} "$@" || die | ||
200 | niro | 30000 | fi |
201 | } | ||
202 | |||
203 | niro | 2 | cmake_src_compile() |
204 | { | ||
205 | niro | 33242 | : ${CMAKE_SRCDIR="${SRCDIR}"} |
206 | cd ${CMAKE_SRCDIR} | ||
207 | niro | 2 | |
208 | niro | 29802 | cmake_setup_builddir || die |
209 | niro | 29992 | cmake_configure "$@" || die |
210 | niro | 30000 | cmake_mmake || die |
211 | niro | 2 | } |
212 | |||
213 | niro | 20976 | cmake_src_check() |
214 | { | ||
215 | niro | 33242 | #: ${CMAKE_BUILDDIR="${BUILDDIR}/build"} |
216 | #cd ${CMAKE_BUILDDIR} | ||
217 | niro | 21166 | #mmake -j1 -k check || die |
218 | return 0 | ||
219 | niro | 20976 | } |
220 | |||
221 | niro | 29802 | cmake_multilib_src_check() |
222 | { | ||
223 | #local abi | ||
224 | #local abis_to_run="${MULTILIB_ABIS}" | ||
225 | # | ||
226 | ## respect MULTILIB_ONLY_ABI variable | ||
227 | #[[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
228 | #for abi in ${abis_to_run} | ||
229 | #do | ||
230 | niro | 33242 | # : ${CMAKE_BUILDDIR="${BUILDDIR}/build-${abi}"} |
231 | # cd ${CMAKE_BUILDDIR} | ||
232 | niro | 29802 | # mmake -j1 -k check || die |
233 | #done | ||
234 | return 0 | ||
235 | } | ||
236 | |||
237 | niro | 2 | cmake_src_install() |
238 | { | ||
239 | niro | 33242 | : ${CMAKE_SRCDIR="${SRCDIR}"} |
240 | |||
241 | niro | 30002 | cmake_mmake DESTDIR=${BINDIR} install || die |
242 | niro | 2 | |
243 | niro | 33242 | cd ${CMAKE_SRCDIR} |
244 | niro | 2 | local i |
245 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ | ||
246 | FAQ LICENSE NEWS README TODO | ||
247 | do | ||
248 | niro | 33242 | if [ -f ${CMAKE_SRCDIR}/${i} ] |
249 | niro | 2 | then |
250 | minstalldocs ${i} || die | ||
251 | fi | ||
252 | done | ||
253 | } | ||
254 | |||
255 | niro | 29802 | cmake_multilib_src_install() |
256 | { | ||
257 | local abi | ||
258 | local abis_to_run="${MULTILIB_ABIS}" | ||
259 | niro | 30002 | |
260 | cmake_mmake DESTDIR=${BINDIR} install || die | ||
261 | |||
262 | niro | 29802 | # respect MULTILIB_ONLY_ABI variable |
263 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
264 | for abi in ${abis_to_run} | ||
265 | do | ||
266 | niro | 33242 | : ${CMAKE_SRCDIR="${SRCDIR}-${abi}"} |
267 | |||
268 | cd ${CMAKE_SRCDIR} | ||
269 | niro | 29802 | local i |
270 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ | ||
271 | FAQ LICENSE NEWS README TODO | ||
272 | do | ||
273 | niro | 33242 | if [ -f ${CMAKE_SRCDIR}/${i} ] |
274 | niro | 29802 | then |
275 | minstalldocs ${i} || die | ||
276 | fi | ||
277 | done | ||
278 | done | ||
279 | } | ||
280 | |||
281 | export_inherits cmake src_prepare src_compile | ||
282 | if [[ ${MULTILIB_BUILD} = true ]] | ||
283 | then | ||
284 | export_inherits cmake_multilib src_check src_install | ||
285 | else | ||
286 | export_inherits cmake src_check src_install | ||
287 | fi |