Magellan Linux

Annotation of /smage/branches/alx07x-stable/include/cmake.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15579 - (hide annotations) (download)
Fri Sep 11 05:43:27 2020 UTC (3 years, 8 months ago) by niro
File size: 6310 byte(s)
-released stable
1 niro 3179 # $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 11527 >= dev-util/cmake-2.4.7
6     >= virtual/sed"
7 niro 3179
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 niro 11527 cmake_libsuffix()
117     {
118     local libsuffix
119    
120     libsuffix="$(mlibdir)"
121     libsuffix="${libsuffix/lib}"
122     echo "${libsuffix}"
123     }
124    
125 niro 3179 cmake_src_prepare()
126     {
127     munpack ${SRCFILE} || die
128     }
129    
130     cmake_configure()
131     {
132     local configure_opts="$@"
133 niro 11527 local default_opts
134 niro 13780 [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR
135     [[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR
136 niro 3179
137     # disable colors if requested
138     if [[ ${NOCOLORS} = true ]]
139     then
140 niro 11527 default_opts+=" -DCMAKE_COLOR_MAKEFILE=OFF"
141 niro 3179 fi
142    
143 niro 11527 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 niro 13780 : ${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 niro 11527 done
173     else
174 niro 13780 : ${CMAKE_SRCDIR="${SRCDIR}/${SRCSUBDIR}"}
175     : ${CMAKE_BUILDDIR="${BUILDDIR}/build"}
176 niro 11527 cd ${BUILDDIR}/build
177     cmake ${default_opts} ${configure_opts} ${SRCDIR}/${SRCSUBDIR} || die
178     fi
179 niro 3179 }
180    
181 niro 11527 cmake_setup_builddir()
182     {
183 niro 13780 [[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR
184    
185 niro 11527 if [[ ${MULTILIB_BUILD} = true ]]
186     then
187 niro 13780 : ${CMAKE_BUILDDIR="${BUILDDIR}/build-$(mabi)"}
188     all-abis install -d ${CMAKE_BUILDDIR} || die
189 niro 11527 else
190 niro 13780 : ${CMAKE_BUILDDIR="${BUILDDIR}/build"}
191     install -d ${CMAKE_BUILDDIR} || die
192 niro 11527 fi
193     }
194    
195     cmake_mmake()
196     {
197 niro 13780 [[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR
198    
199 niro 11527 if [[ ${MULTILIB_BUILD} = true ]]
200     then
201 niro 13780 : ${CMAKE_BUILDDIR="${BUILDDIR}/build-$(mabi)"}
202     mmake -C ${CMAKE_BUILDDIR} "$@" || die
203 niro 11527 else
204 niro 13780 : ${CMAKE_BUILDDIR="${BUILDDIR}/build"}
205     mmake -C ${CMAKE_BUILDDIR} "$@" || die
206 niro 11527 fi
207     }
208    
209 niro 3179 cmake_src_compile()
210     {
211 niro 13780 [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR
212 niro 3179
213 niro 15338 if [[ ${MULTILIB_BUILD} = true ]]
214     then
215     : ${CMAKE_SRCDIR="${SRCDIR}-$(mabi)/${SRCSUBDIR}"}
216     else
217     : ${CMAKE_SRCDIR="${SRCDIR}"}
218     fi
219 niro 13780 cd ${CMAKE_SRCDIR}
220    
221 niro 11527 cmake_setup_builddir || die
222     cmake_configure "$@" || die
223     cmake_mmake || die
224 niro 3179 }
225    
226 niro 5455 cmake_src_check()
227     {
228 niro 13780 #[[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR
229     #
230     #: ${CMAKE_BUILDDIR="${BUILDDIR}/build"}
231     #cd ${CMAKE_BUILDDIR}
232 niro 5455 #mmake -j1 -k check || die
233     return 0
234     }
235    
236 niro 11527 cmake_multilib_src_check()
237     {
238 niro 13780 #[[ -n ${CMAKE_BUILDDIR} ]] || local CMAKE_BUILDDIR
239     #
240 niro 11527 #local abi
241     #local abis_to_run="${MULTILIB_ABIS}"
242     #
243     ## respect MULTILIB_ONLY_ABI variable
244     #[[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
245     #for abi in ${abis_to_run}
246     #do
247 niro 13780 # : ${CMAKE_BUILDDIR="${BUILDDIR}/build-${abi}"}
248     # cd ${CMAKE_BUILDDIR}
249 niro 11527 # mmake -j1 -k check || die
250     #done
251     return 0
252     }
253    
254 niro 3179 cmake_src_install()
255     {
256 niro 13780 [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR
257    
258     : ${CMAKE_SRCDIR="${SRCDIR}"}
259    
260 niro 11527 cmake_mmake DESTDIR=${BINDIR} install || die
261 niro 3179
262 niro 13780 cd ${CMAKE_SRCDIR}
263 niro 3179 local i
264     for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
265     FAQ LICENSE NEWS README TODO
266     do
267 niro 13780 if [ -f ${CMAKE_SRCDIR}/${i} ]
268 niro 3179 then
269     minstalldocs ${i} || die
270     fi
271     done
272     }
273    
274 niro 11527 cmake_multilib_src_install()
275     {
276     local abi
277     local abis_to_run="${MULTILIB_ABIS}"
278 niro 13780 [[ -n ${CMAKE_SRCDIR} ]] || local CMAKE_SRCDIR
279 niro 11527
280     cmake_mmake DESTDIR=${BINDIR} install || die
281    
282     # respect MULTILIB_ONLY_ABI variable
283     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
284     for abi in ${abis_to_run}
285     do
286 niro 13780 : ${CMAKE_SRCDIR="${SRCDIR}-${abi}"}
287    
288     cd ${CMAKE_SRCDIR}
289 niro 11527 local i
290     for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
291     FAQ LICENSE NEWS README TODO
292     do
293 niro 13780 if [ -f ${CMAKE_SRCDIR}/${i} ]
294 niro 11527 then
295     minstalldocs ${i} || die
296     fi
297     done
298     done
299     }
300    
301     export_inherits cmake src_prepare src_compile
302     if [[ ${MULTILIB_BUILD} = true ]]
303     then
304     export_inherits cmake_multilib src_check src_install
305     else
306     export_inherits cmake src_check src_install
307     fi