Magellan Linux

Annotation of /trunk/include/multilib.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5485 - (hide annotations) (download)
Tue Jun 29 23:01:28 2010 UTC (14 years, 4 months ago) by niro
Original Path: trunk/core/include/multilib.sminc
File size: 9804 byte(s)
-allow dest in munpack()
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 niro 5485 local dest="$2"
256 niro 2
257     # respect MULTILIB_ONLY_ABI variable
258     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
259    
260     for abi in ${abis_to_run}
261     do
262     echo -e "${COLBLUE}*** ${COLGREEN}unpacking for ABI -${abi}${COLDEFAULT}"
263 niro 5485 oldmunpack ${SRCFILE} ${dest} || die
264 niro 2 mv ${SRCDIR} ${SRCDIR}-${abi} || die
265     done
266     }
267    
268 niro 3671 if [[ ! -z $(typeset -f mmake) ]]
269     then
270     # rename the old one
271     old_mmake=old$(typeset -f mmake)
272     eval "${old_mmake}"
273     fi
274 niro 2 mmake()
275     {
276     local abi
277     local abis_to_run="${MULTILIB_ABIS}"
278    
279     # respect MULTILIB_ONLY_ABI variable
280     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
281    
282     for abi in ${abis_to_run}
283     do
284     echo -e "${COLBLUE}*** ${COLGREEN}compiling for ABI -${abi}${COLDEFAULT}"
285     cd ${SRCDIR}-${abi}
286     abi-${abi} oldmmake $@ || die
287     done
288     }
289    
290 niro 3671 if [[ ! -z $(typeset -f minstall) ]]
291     then
292     # rename the old one
293     old_minstall=old$(typeset -f minstall)
294     eval "${old_minstall}"
295     fi
296 niro 2 minstall()
297     {
298     local abi
299     local abis_to_run="${MULTILIB_ABIS}"
300    
301     # respect MULTILIB_ONLY_ABI variable
302     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
303    
304     for abi in ${abis_to_run}
305     do
306     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
307     cd ${SRCDIR}-${abi}
308     abi-${abi} oldminstall $@ || die
309     done
310     }
311    
312     minstall_destdir()
313     {
314     local abi
315     local abis_to_run="${MULTILIB_ABIS}"
316    
317     # respect MULTILIB_ONLY_ABI variable
318     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
319    
320     for abi in ${abis_to_run}
321     do
322     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
323     cd ${SRCDIR}-${abi}
324     make DESTDIR=${BINDIR} $@ install || die
325     done
326     }
327    
328 niro 3671 if [[ ! -z $(typeset -f mpatch) ]]
329     then
330     # rename the old one
331     old_mpatch=old$(typeset -f mpatch)
332     eval "${old_mpatch}"
333     fi
334 niro 2 mpatch()
335     {
336     local abi
337     local abis_to_run="${MULTILIB_ABIS}"
338    
339     # respect MULTILIB_ONLY_ABI variable
340     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
341    
342     for abi in ${abis_to_run}
343     do
344     echo -e "${COLBLUE}*** ${COLGREEN}appling patch for ABI -${abi}${COLDEFAULT}"
345     cd ${SRCDIR}-${abi}
346     oldmpatch $@ || die
347     done
348     }
349    
350 niro 3671 if [[ ! -z $(typeset -f mlibtoolize) ]]
351     then
352     # rename the old one
353     old_mlibtoolize=old$(typeset -f mlibtoolize)
354     eval "${old_mlibtoolize}"
355     fi
356 niro 2 mlibtoolize()
357     {
358     local abi
359     local abis_to_run="${MULTILIB_ABIS}"
360    
361     # respect MULTILIB_ONLY_ABI variable
362     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
363    
364     for abi in ${abis_to_run}
365     do
366     echo -e "${COLBLUE}*** ${COLGREEN}running mlibtoolize for ABI -${abi}${COLDEFAULT}"
367     cd ${SRCDIR}-${abi}
368     oldmlibtoolize $@ || die
369     done
370     }
371    
372     minstalldocs()
373     {
374     local abi
375     local docfiles
376     docfiles="$@"
377    
378     local abis_to_run="${MULTILIB_ABIS}"
379    
380     # respect MULTILIB_ONLY_ABI variable
381     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
382    
383     for abi in ${abis_to_run}
384     do
385     cd ${SRCDIR}-${abi}
386     if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
387     then
388     install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
389     fi
390    
391     for i in ${docfiles}
392     do
393     cat ${SRCDIR}-${abi}/${i} | gzip -9c > ${SRCDIR}-${abi}/${i}.gz || die "gzipping docs."
394     install -m 0644 ${SRCDIR}-${abi}/${i}.gz \
395     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
396     done
397     done
398     }
399    
400     ##
401     # multilib mbuild wrappers
402     ##
403     multilib_src_prepare()
404     {
405     munpack
406     }
407    
408     multilib_src_compile()
409     {
410     mconfigure
411     mmake
412     }
413    
414     multilib_src_install()
415     {
416     minstall_destdir
417    
418     local i
419     for abi in ${MULTILIB_ABIS}
420     do
421     cd ${SRCDIR}-${abi}
422     for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
423     FAQ LICENSE NEWS README TODO
424     do
425     if [ -f ${SRCDIR}-${abi}/${i} ]
426     then
427     minstalldocs ${i} || die
428     fi
429     done
430     done
431     }
432    
433     export_inherits multilib src_prepare src_compile src_install