2 |
# cmake config tools |
# cmake config tools |
3 |
|
|
4 |
SDEPEND="${SDEPEND} |
SDEPEND="${SDEPEND} |
5 |
>= dev-util/cmake-2.4.7" |
>= dev-util/cmake-2.4.7 |
6 |
|
>= virtual/sed" |
7 |
|
|
8 |
# enables features like --enable-blah with make |
# enables features like --enable-blah with make |
9 |
cmake_enable() |
cmake_enable() |
97 |
echo "-DBUILD_${feature}=OFF" |
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() |
cmake_src_prepare() |
126 |
{ |
{ |
127 |
munpack ${SRCFILE} || die |
munpack ${SRCFILE} || die |
130 |
cmake_configure() |
cmake_configure() |
131 |
{ |
{ |
132 |
local configure_opts="$@" |
local configure_opts="$@" |
133 |
local libsuffix="$(mlibdir)" |
local default_opts |
134 |
local libsuffix="${libsuffix/lib}" |
[[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
135 |
|
[[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
136 |
|
|
137 |
# disable colors if requested |
# disable colors if requested |
138 |
if [[ ${NOCOLORS} = true ]] |
if [[ ${NOCOLORS} = true ]] |
139 |
then |
then |
140 |
configure_opts="${configure_opts} -DCMAKE_COLOR_MAKEFILE=OFF" |
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 |
fi |
158 |
|
|
159 |
cmake \ |
if [[ ${MULTILIB_BUILD} = true ]] |
160 |
-DCMAKE_BUILD_TYPE=Release \ |
then |
161 |
-DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr} \ |
local abi |
162 |
-DLIB_SUFFIX=${libsuffix} \ |
local abis_to_run="${MULTILIB_ABIS}" |
163 |
-DLIB_INSTALL_DIR=${PREFIX:-/usr}/$(mlibdir) \ |
|
164 |
${configure_opts} \ |
# respect MULTILIB_ONLY_ABI variable |
165 |
${SRCDIR} \ |
[[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" |
166 |
|| die |
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_src_compile() |
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 |
cd ${SRCDIR} |
[[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR |
198 |
|
|
199 |
# remove build dir if exist |
if [[ ${MULTILIB_BUILD} = true ]] |
200 |
[[ -d ${BUILDDIR}/build ]] && rm -rf ${BUILDDIR}/build |
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 |
# build outside of the source dir |
: ${CMAKE_SRCDIR="${SRCDIR}"} |
214 |
install -d ${BUILDDIR}/build || die |
cd ${CMAKE_SRCDIR} |
|
cd ${BUILDDIR}/build |
|
215 |
|
|
216 |
cmake_configure || die |
cmake_setup_builddir || die |
217 |
mmake || die |
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() |
cmake_src_install() |
250 |
{ |
{ |
251 |
cd ${BUILDDIR}/build |
[[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR |
|
make DESTDIR=${BINDIR} install || die |
|
252 |
|
|
253 |
cd ${SRCDIR} |
: ${CMAKE_SRCDIR="${SRCDIR}"} |
254 |
|
|
255 |
|
cmake_mmake DESTDIR=${BINDIR} install || die |
256 |
|
|
257 |
|
cd ${CMAKE_SRCDIR} |
258 |
local i |
local i |
259 |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
260 |
FAQ LICENSE NEWS README TODO |
FAQ LICENSE NEWS README TODO |
261 |
do |
do |
262 |
if [ -f ${SRCDIR}/${i} ] |
if [ -f ${CMAKE_SRCDIR}/${i} ] |
263 |
then |
then |
264 |
minstalldocs ${i} || die |
minstalldocs ${i} || die |
265 |
fi |
fi |
266 |
done |
done |
267 |
} |
} |
268 |
|
|
269 |
export_inherits cmake src_prepare src_compile src_install |
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 |