Magellan Linux

Annotation of /branches/magellan-next/include/multilib.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5371 - (hide annotations) (download)
Wed May 19 16:20:33 2010 UTC (14 years, 5 months ago) by niro
Original Path: trunk/core/include/multilib.sminc
File size: 9779 byte(s)
-do not simply overwrite a systemwide declared PKG_CONFIG_PATH variable - save it and restore it instead
1 niro 2 # $Header: /magellan-cvs/smage/include/multilib.sminc,v 1.33 2007-11-13 15:49:09 niro Exp $
2     # multilib abis
3    
4     # do not define EMUL_LINUX_32 after inherit of multlib !!
5     # it may break i*86 builds
6    
7     # default ABIs to be build
8     case ${ARCH} in
9     x86_64)
10     : ${MULTILIB_ABIS="m32 m64"}
11     # default false
12     : ${EMUL_LINUX_32="false"}
13    
14     # add linux32 to the dependencies
15     if [[ ${EMUL_LINUX_32} = true ]]
16     then
17     EMUL_LINUX_32_SDEPENDS_x86_64=">= dev-util/linux32-1"
18     SPECIAL_VARS="${SPECIAL_VARS} EMUL_LINUX_32_SDEPENDS_x86_64"
19     fi
20     ;;
21     i*86)
22     : ${MULTILIB_ABIS="m32"}
23     # always false
24     EMUL_LINUX_32="false"
25     ;;
26     esac
27    
28     # add linux32 to the dependencies
29     if [[ ${EMUL_LINUX_32} = true ]]
30     then
31     # very dirty trick to get the dependencies right
32     # ; is the IFS, tr replaces ; with an crlfs
33     # the var ist decided with our common eval+echo magic
34     if [[ -z ${SDEPEND} ]]
35     then
36     SDEPEND="\$(eval echo \\\$EMUL_LINUX_32_SDEPENDS_\${ARCH/i*86/x86} | tr ';' '\n')"
37     else
38     SDEPEND="${SDEPEND}
39     \$(eval echo \\\$EMUL_LINUX_32_SDEPENDS_\${ARCH/i*86/x86} | tr ';' '\n')"
40     fi
41     fi
42    
43     ##
44     # overide some defaults to respect ABI_LIBDIR
45     ##
46     mlibdir()
47     {
48     local libdir=lib
49     [[ ${ARCH} = x86_64 ]] && libdir=lib64
50     [[ -n ${ABI_LIBDIR} ]] && libdir="${ABI_LIBDIR}"
51    
52     echo "${libdir}"
53     }
54    
55     ##
56     # multilib abi changers
57     ##
58     abi-m32()
59     {
60     export ABI="m32"
61     export CC="gcc -${ABI}"
62     export CXX="g++ -${ABI}"
63     export ABI_LIBDIR="lib"
64 niro 307 if [[ ${EXPORT_ABI_LDFLAGS} != false ]]
65     then
66     export LDFLAGS="-L/${ABI_LIBDIR} -L/usr/${ABI_LIBDIR}"
67     fi
68 niro 5371 # keep pkgconfig clean
69     local orig_pkg_config_path="${PKG_CONFIG_PATH}"
70     export PKG_CONFIG_PATH="/usr/${ABI_LIBDIR}/pkgconfig:${PKG_CONFIG_PATH}"
71 niro 2
72     echo -e "${COLBLUE}*** ${COLGREEN}running with -${ABI} ABI${COLDEFAULT}"
73     echo -e "${COLBLUE}*** ${COLGREEN} ABI${COLDEFAULT}='${ABI}'"
74     echo -e "${COLBLUE}*** ${COLGREEN} CC${COLDEFAULT}='${CC}'"
75     echo -e "${COLBLUE}*** ${COLGREEN} CXX${COLDEFAULT}='${CXX}'"
76     echo -e "${COLBLUE}*** ${COLGREEN} ABI_LIBDIR${COLDEFAULT}='${ABI_LIBDIR}'"
77 niro 307 if [[ ${EXPORT_ABI_LDFLAGS} != false ]]
78     then
79     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${LDFLAGS}'"
80     else
81     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${COLYELLOW}not exported${COLDEFAULT}'"
82     fi
83 niro 2 echo -e "${COLBLUE}*** ${COLGREEN} PKG_CONFIG_PATH${COLDEFAULT}='${PKG_CONFIG_PATH}'"
84    
85     # configure a linux32 emulated build
86     if [[ ${EMUL_LINUX_32} = true ]]
87     then
88     echo -e "${COLBLUE}*** ${COLGREEN} EMUL_LINUX_32${COLDEFAULT}='${EMUL_LINUX_32}'"
89     uname(){ linux32 uname $@; } && export -f uname
90     ORIG_CHOST="${CHOST}" && export CHOST="i686-pc-linux-gnu"
91     fi
92     echo -e "${COLBLUE}*** ${COLGREEN} CHOST${COLDEFAULT}='${CHOST}'"
93    
94     # run any given command
95     eval $@ || die
96    
97 niro 5371 unset ABI CC CXX ABI_LIBDIR LDFLAGS
98     # keep pkgconfig clean
99     export PKG_CONFIG_PATH="${orig_pkg_config_path}"
100 niro 2
101     # restore original settings
102     if [[ ${EMUL_LINUX_32} = true ]]
103     then
104     unset uname
105     export CHOST="${ORIG_CHOST}" && unset ORIG_CHOST
106     fi
107     }
108    
109     abi-m64()
110     {
111     export ABI="m64"
112     export CC="gcc -${ABI}"
113     export CXX="g++ -${ABI}"
114     export ABI_LIBDIR="lib64"
115 niro 307 if [[ ${EXPORT_ABI_LDFLAGS} != false ]]
116     then
117     export LDFLAGS="-L/${ABI_LIBDIR} -L/usr/${ABI_LIBDIR}"
118     fi
119 niro 5371 # keep pkgconfig clean
120     local orig_pkg_config_path="${PKG_CONFIG_PATH}"
121     export PKG_CONFIG_PATH="/usr/${ABI_LIBDIR}/pkgconfig:${PKG_CONFIG_PATH}"
122 niro 2
123     echo -e "${COLBLUE}*** ${COLGREEN}running with -${ABI} ABI${COLDEFAULT}"
124     echo -e "${COLBLUE}*** ${COLGREEN} ABI${COLDEFAULT}='${ABI}'"
125     echo -e "${COLBLUE}*** ${COLGREEN} CC${COLDEFAULT}='${CC}'"
126     echo -e "${COLBLUE}*** ${COLGREEN} CXX${COLDEFAULT}='${CXX}'"
127     echo -e "${COLBLUE}*** ${COLGREEN} ABI_LIBDIR${COLDEFAULT}='${ABI_LIBDIR}'"
128 niro 307 if [[ ${EXPORT_ABI_LDFLAGS} != false ]]
129     then
130     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${LDFLAGS}'"
131     else
132     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${COLYELLOW}not exported${COLDEFAULT}'"
133     fi
134 niro 2 echo -e "${COLBLUE}*** ${COLGREEN} CHOST${COLDEFAULT}='${CHOST}'"
135     echo -e "${COLBLUE}*** ${COLGREEN} PKG_CONFIG_PATH${COLDEFAULT}='${PKG_CONFIG_PATH}'"
136    
137     # run any given command
138     eval $@ || die
139    
140 niro 5371 unset ABI CC CXX ABI_LIBDIR LDFLAGS
141     # keep pkgconfig clean
142     export PKG_CONFIG_PATH="${orig_pkg_config_path}"
143 niro 2 }
144    
145     only-m32()
146     {
147     local abi=m32
148     local i
149    
150     for i in ${MULTILIB_ABIS}
151     do
152     if [[ ${i} = ${abi} ]]
153     then
154     # export this for mpatch etc (to repect only-${abi})
155     export MULTILIB_ONLY_ABI=${abi}
156    
157     cd ${SRCDIR}-${abi}
158     abi-${abi} $@ || die
159    
160     # unset this is very important
161     unset MULTILIB_ONLY_ABI
162     fi
163     done
164     }
165    
166     only-m64()
167     {
168     local abi=m64
169     local i
170    
171     for i in ${MULTILIB_ABIS}
172     do
173     if [[ ${i} = ${abi} ]]
174     then
175     # export this for mpatch etc (to repect only-${abi})
176     export MULTILIB_ONLY_ABI=${abi}
177    
178     cd ${SRCDIR}-${abi}
179     abi-${abi} $@ || die
180    
181     # unset this is very important
182     unset MULTILIB_ONLY_ABI
183     fi
184     done
185     }
186    
187     all-abis()
188     {
189     local abi
190     for abi in ${MULTILIB_ABIS}
191     do
192     cd ${SRCDIR}-${abi}
193     abi-${abi} $@ || die
194     done
195     }
196    
197     ##
198     # multilib compile functions
199     ##
200    
201 niro 3671 if [[ ! -z $(typeset -f mconfigure) ]]
202     then
203     # rename the old one
204     old_mconfigure=old$(typeset -f mconfigure)
205 niro 4783 eval "${old_mconfigure}"
206 niro 3671 fi
207 niro 2 mconfigure()
208     {
209     local abi
210     local abis_to_run="${MULTILIB_ABIS}"
211    
212     # respect MULTILIB_ONLY_ABI variable
213     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
214    
215     for abi in ${abis_to_run}
216     do
217     cd ${SRCDIR}-${abi}
218     abi-${abi} oldmconfigure $@ || die
219     done
220     }
221    
222 niro 4780 if [[ ! -z $(typeset -f cmake_configure) ]]
223     then
224     # rename the old one
225     old_cmake_configure=old$(typeset -f cmake_configure)
226 niro 4783 eval "${old_cmake_configure}"
227 niro 4780 fi
228     cmake_configure()
229     {
230     local abi
231     local abis_to_run="${MULTILIB_ABIS}"
232    
233     # respect MULTILIB_ONLY_ABI variable
234     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
235    
236     local saved_SRCDIR="${SRCDIR}"
237     for abi in ${abis_to_run}
238     do
239     SRCDIR="${saved_SRCDIR}-${abi}"
240     cd ${SRCDIR}
241     abi-${abi} oldcmake_configure $@ || die
242     done
243     }
244    
245 niro 3671 if [[ ! -z $(typeset -f munpack) ]]
246     then
247     # rename the old one
248     old_munpack=old$(typeset -f munpack)
249     eval "${old_munpack}"
250     fi
251 niro 2 munpack()
252     {
253     local abi
254     local abis_to_run="${MULTILIB_ABIS}"
255    
256     # respect MULTILIB_ONLY_ABI variable
257     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
258    
259     for abi in ${abis_to_run}
260     do
261     echo -e "${COLBLUE}*** ${COLGREEN}unpacking for ABI -${abi}${COLDEFAULT}"
262     oldmunpack ${SRCFILE} || die
263     mv ${SRCDIR} ${SRCDIR}-${abi} || die
264     done
265     }
266    
267 niro 3671 if [[ ! -z $(typeset -f mmake) ]]
268     then
269     # rename the old one
270     old_mmake=old$(typeset -f mmake)
271     eval "${old_mmake}"
272     fi
273 niro 2 mmake()
274     {
275     local abi
276     local abis_to_run="${MULTILIB_ABIS}"
277    
278     # respect MULTILIB_ONLY_ABI variable
279     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
280    
281     for abi in ${abis_to_run}
282     do
283     echo -e "${COLBLUE}*** ${COLGREEN}compiling for ABI -${abi}${COLDEFAULT}"
284     cd ${SRCDIR}-${abi}
285     abi-${abi} oldmmake $@ || die
286     done
287     }
288    
289 niro 3671 if [[ ! -z $(typeset -f minstall) ]]
290     then
291     # rename the old one
292     old_minstall=old$(typeset -f minstall)
293     eval "${old_minstall}"
294     fi
295 niro 2 minstall()
296     {
297     local abi
298     local abis_to_run="${MULTILIB_ABIS}"
299    
300     # respect MULTILIB_ONLY_ABI variable
301     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
302    
303     for abi in ${abis_to_run}
304     do
305     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
306     cd ${SRCDIR}-${abi}
307     abi-${abi} oldminstall $@ || die
308     done
309     }
310    
311     minstall_destdir()
312     {
313     local abi
314     local abis_to_run="${MULTILIB_ABIS}"
315    
316     # respect MULTILIB_ONLY_ABI variable
317     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
318    
319     for abi in ${abis_to_run}
320     do
321     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
322     cd ${SRCDIR}-${abi}
323     make DESTDIR=${BINDIR} $@ install || die
324     done
325     }
326    
327 niro 3671 if [[ ! -z $(typeset -f mpatch) ]]
328     then
329     # rename the old one
330     old_mpatch=old$(typeset -f mpatch)
331     eval "${old_mpatch}"
332     fi
333 niro 2 mpatch()
334     {
335     local abi
336     local abis_to_run="${MULTILIB_ABIS}"
337    
338     # respect MULTILIB_ONLY_ABI variable
339     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
340    
341     for abi in ${abis_to_run}
342     do
343     echo -e "${COLBLUE}*** ${COLGREEN}appling patch for ABI -${abi}${COLDEFAULT}"
344     cd ${SRCDIR}-${abi}
345     oldmpatch $@ || die
346     done
347     }
348    
349 niro 3671 if [[ ! -z $(typeset -f mlibtoolize) ]]
350     then
351     # rename the old one
352     old_mlibtoolize=old$(typeset -f mlibtoolize)
353     eval "${old_mlibtoolize}"
354     fi
355 niro 2 mlibtoolize()
356     {
357     local abi
358     local abis_to_run="${MULTILIB_ABIS}"
359    
360     # respect MULTILIB_ONLY_ABI variable
361     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
362    
363     for abi in ${abis_to_run}
364     do
365     echo -e "${COLBLUE}*** ${COLGREEN}running mlibtoolize for ABI -${abi}${COLDEFAULT}"
366     cd ${SRCDIR}-${abi}
367     oldmlibtoolize $@ || die
368     done
369     }
370    
371     minstalldocs()
372     {
373     local abi
374     local docfiles
375     docfiles="$@"
376    
377     local abis_to_run="${MULTILIB_ABIS}"
378    
379     # respect MULTILIB_ONLY_ABI variable
380     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
381    
382     for abi in ${abis_to_run}
383     do
384     cd ${SRCDIR}-${abi}
385     if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
386     then
387     install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
388     fi
389    
390     for i in ${docfiles}
391     do
392     cat ${SRCDIR}-${abi}/${i} | gzip -9c > ${SRCDIR}-${abi}/${i}.gz || die "gzipping docs."
393     install -m 0644 ${SRCDIR}-${abi}/${i}.gz \
394     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
395     done
396     done
397     }
398    
399     ##
400     # multilib mbuild wrappers
401     ##
402     multilib_src_prepare()
403     {
404     munpack
405     }
406    
407     multilib_src_compile()
408     {
409     mconfigure
410     mmake
411     }
412    
413     multilib_src_install()
414     {
415     minstall_destdir
416    
417     local i
418     for abi in ${MULTILIB_ABIS}
419     do
420     cd ${SRCDIR}-${abi}
421     for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
422     FAQ LICENSE NEWS README TODO
423     do
424     if [ -f ${SRCDIR}-${abi}/${i} ]
425     then
426     minstalldocs ${i} || die
427     fi
428     done
429     done
430     }
431    
432     export_inherits multilib src_prepare src_compile src_install