Magellan Linux

Annotation of /trunk/include/multilib.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6406 - (hide annotations) (download)
Mon Aug 23 11:25:26 2010 UTC (14 years, 2 months ago) by niro
Original Path: trunk/core/include/multilib.sminc
File size: 9716 byte(s)
-renamed EMUL_LINUX_32_SDEPENDS_x86_64 to EMUL_LINUX_32_SDEPEND_x86_64
1 niro 6346 # $Id$
2 niro 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 niro 6406 EMUL_LINUX_32_SDEPEND_x86_64=">= dev-util/linux32-1"
18     SPECIAL_VARS="${SPECIAL_VARS} EMUL_LINUX_32_SDEPEND_x86_64"
19 niro 2 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 niro 6406 SDEPEND="\$(eval echo \\\$EMUL_LINUX_32_SDEPEND_\${ARCH/i*86/x86} | tr ';' '\n')"
37 niro 2 else
38     SDEPEND="${SDEPEND}
39 niro 6406 \$(eval echo \\\$EMUL_LINUX_32_SDEPEND_\${ARCH/i*86/x86} | tr ';' '\n')"
40 niro 2 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 niro 6346 mabi()
198     {
199     echo \${ABI}
200     }
201    
202 niro 2 ##
203     # multilib compile functions
204     ##
205    
206 niro 3671 if [[ ! -z $(typeset -f mconfigure) ]]
207     then
208     # rename the old one
209     old_mconfigure=old$(typeset -f mconfigure)
210 niro 4783 eval "${old_mconfigure}"
211 niro 3671 fi
212 niro 2 mconfigure()
213     {
214     local abi
215     local abis_to_run="${MULTILIB_ABIS}"
216    
217     # respect MULTILIB_ONLY_ABI variable
218     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
219    
220     for abi in ${abis_to_run}
221     do
222     cd ${SRCDIR}-${abi}
223     abi-${abi} oldmconfigure $@ || die
224     done
225     }
226    
227 niro 4780 if [[ ! -z $(typeset -f cmake_configure) ]]
228     then
229     # rename the old one
230     old_cmake_configure=old$(typeset -f cmake_configure)
231 niro 4783 eval "${old_cmake_configure}"
232 niro 4780 fi
233     cmake_configure()
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    
241     local saved_SRCDIR="${SRCDIR}"
242     for abi in ${abis_to_run}
243     do
244     SRCDIR="${saved_SRCDIR}-${abi}"
245     cd ${SRCDIR}
246     abi-${abi} oldcmake_configure $@ || die
247     done
248     }
249    
250 niro 3671 if [[ ! -z $(typeset -f munpack) ]]
251     then
252     # rename the old one
253     old_munpack=old$(typeset -f munpack)
254     eval "${old_munpack}"
255     fi
256 niro 2 munpack()
257     {
258     local abi
259     local abis_to_run="${MULTILIB_ABIS}"
260    
261     # respect MULTILIB_ONLY_ABI variable
262     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
263    
264     for abi in ${abis_to_run}
265     do
266     echo -e "${COLBLUE}*** ${COLGREEN}unpacking for ABI -${abi}${COLDEFAULT}"
267 niro 5486 oldmunpack ${SRCFILE} || die
268 niro 2 mv ${SRCDIR} ${SRCDIR}-${abi} || die
269     done
270     }
271    
272 niro 3671 if [[ ! -z $(typeset -f mmake) ]]
273     then
274     # rename the old one
275     old_mmake=old$(typeset -f mmake)
276     eval "${old_mmake}"
277     fi
278 niro 2 mmake()
279     {
280     local abi
281     local abis_to_run="${MULTILIB_ABIS}"
282    
283     # respect MULTILIB_ONLY_ABI variable
284     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
285    
286     for abi in ${abis_to_run}
287     do
288     echo -e "${COLBLUE}*** ${COLGREEN}compiling for ABI -${abi}${COLDEFAULT}"
289     cd ${SRCDIR}-${abi}
290     abi-${abi} oldmmake $@ || die
291     done
292     }
293    
294 niro 3671 if [[ ! -z $(typeset -f minstall) ]]
295     then
296     # rename the old one
297     old_minstall=old$(typeset -f minstall)
298     eval "${old_minstall}"
299     fi
300 niro 2 minstall()
301     {
302     local abi
303     local abis_to_run="${MULTILIB_ABIS}"
304    
305     # respect MULTILIB_ONLY_ABI variable
306     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
307    
308     for abi in ${abis_to_run}
309     do
310     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
311     cd ${SRCDIR}-${abi}
312     abi-${abi} oldminstall $@ || die
313     done
314     }
315    
316     minstall_destdir()
317     {
318     local abi
319     local abis_to_run="${MULTILIB_ABIS}"
320    
321     # respect MULTILIB_ONLY_ABI variable
322     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
323    
324     for abi in ${abis_to_run}
325     do
326     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
327     cd ${SRCDIR}-${abi}
328     make DESTDIR=${BINDIR} $@ install || die
329     done
330     }
331    
332 niro 3671 if [[ ! -z $(typeset -f mpatch) ]]
333     then
334     # rename the old one
335     old_mpatch=old$(typeset -f mpatch)
336     eval "${old_mpatch}"
337     fi
338 niro 2 mpatch()
339     {
340     local abi
341     local abis_to_run="${MULTILIB_ABIS}"
342    
343     # respect MULTILIB_ONLY_ABI variable
344     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
345    
346     for abi in ${abis_to_run}
347     do
348     echo -e "${COLBLUE}*** ${COLGREEN}appling patch for ABI -${abi}${COLDEFAULT}"
349     cd ${SRCDIR}-${abi}
350     oldmpatch $@ || die
351     done
352     }
353    
354 niro 3671 if [[ ! -z $(typeset -f mlibtoolize) ]]
355     then
356     # rename the old one
357     old_mlibtoolize=old$(typeset -f mlibtoolize)
358     eval "${old_mlibtoolize}"
359     fi
360 niro 2 mlibtoolize()
361     {
362     local abi
363     local abis_to_run="${MULTILIB_ABIS}"
364    
365     # respect MULTILIB_ONLY_ABI variable
366     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
367    
368     for abi in ${abis_to_run}
369     do
370     echo -e "${COLBLUE}*** ${COLGREEN}running mlibtoolize for ABI -${abi}${COLDEFAULT}"
371     cd ${SRCDIR}-${abi}
372     oldmlibtoolize $@ || die
373     done
374     }
375    
376     minstalldocs()
377     {
378     local abi
379     local docfiles
380     docfiles="$@"
381    
382     local abis_to_run="${MULTILIB_ABIS}"
383    
384     # respect MULTILIB_ONLY_ABI variable
385     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
386    
387     for abi in ${abis_to_run}
388     do
389     cd ${SRCDIR}-${abi}
390     if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
391     then
392     install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
393     fi
394    
395     for i in ${docfiles}
396     do
397     cat ${SRCDIR}-${abi}/${i} | gzip -9c > ${SRCDIR}-${abi}/${i}.gz || die "gzipping docs."
398     install -m 0644 ${SRCDIR}-${abi}/${i}.gz \
399     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
400     done
401     done
402     }
403    
404     ##
405     # multilib mbuild wrappers
406     ##
407     multilib_src_prepare()
408     {
409     munpack
410     }
411    
412     multilib_src_compile()
413     {
414     mconfigure
415     mmake
416     }
417    
418     multilib_src_install()
419     {
420     minstall_destdir
421    
422     local i
423     for abi in ${MULTILIB_ABIS}
424     do
425     cd ${SRCDIR}-${abi}
426     for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
427     FAQ LICENSE NEWS README TODO
428     do
429     if [ -f ${SRCDIR}-${abi}/${i} ]
430     then
431     minstalldocs ${i} || die
432     fi
433     done
434     done
435     }
436    
437     export_inherits multilib src_prepare src_compile src_install