Magellan Linux

Annotation of /trunk/include/multilib.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4780 - (hide annotations) (download)
Sun Dec 27 23:16:16 2009 UTC (14 years, 10 months ago) by niro
Original Path: trunk/core/include/multilib.sminc
File size: 9476 byte(s)
-added cmake_configure wrapper
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 2 export PKG_CONFIG_PATH="/usr/${ABI_LIBDIR}/pkgconfig"
69    
70     echo -e "${COLBLUE}*** ${COLGREEN}running with -${ABI} ABI${COLDEFAULT}"
71     echo -e "${COLBLUE}*** ${COLGREEN} ABI${COLDEFAULT}='${ABI}'"
72     echo -e "${COLBLUE}*** ${COLGREEN} CC${COLDEFAULT}='${CC}'"
73     echo -e "${COLBLUE}*** ${COLGREEN} CXX${COLDEFAULT}='${CXX}'"
74     echo -e "${COLBLUE}*** ${COLGREEN} ABI_LIBDIR${COLDEFAULT}='${ABI_LIBDIR}'"
75 niro 307 if [[ ${EXPORT_ABI_LDFLAGS} != false ]]
76     then
77     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${LDFLAGS}'"
78     else
79     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${COLYELLOW}not exported${COLDEFAULT}'"
80     fi
81 niro 2 echo -e "${COLBLUE}*** ${COLGREEN} PKG_CONFIG_PATH${COLDEFAULT}='${PKG_CONFIG_PATH}'"
82    
83     # configure a linux32 emulated build
84     if [[ ${EMUL_LINUX_32} = true ]]
85     then
86     echo -e "${COLBLUE}*** ${COLGREEN} EMUL_LINUX_32${COLDEFAULT}='${EMUL_LINUX_32}'"
87     uname(){ linux32 uname $@; } && export -f uname
88     ORIG_CHOST="${CHOST}" && export CHOST="i686-pc-linux-gnu"
89     fi
90     echo -e "${COLBLUE}*** ${COLGREEN} CHOST${COLDEFAULT}='${CHOST}'"
91    
92     # run any given command
93     eval $@ || die
94    
95     unset ABI CC CXX ABI_LIBDIR LDFLAGS PKG_CONFIG_PATH
96    
97     # restore original settings
98     if [[ ${EMUL_LINUX_32} = true ]]
99     then
100     unset uname
101     export CHOST="${ORIG_CHOST}" && unset ORIG_CHOST
102     fi
103     }
104    
105     abi-m64()
106     {
107     export ABI="m64"
108     export CC="gcc -${ABI}"
109     export CXX="g++ -${ABI}"
110     export ABI_LIBDIR="lib64"
111 niro 307 if [[ ${EXPORT_ABI_LDFLAGS} != false ]]
112     then
113     export LDFLAGS="-L/${ABI_LIBDIR} -L/usr/${ABI_LIBDIR}"
114     fi
115 niro 2 export PKG_CONFIG_PATH="/usr/${ABI_LIBDIR}/pkgconfig"
116    
117     echo -e "${COLBLUE}*** ${COLGREEN}running with -${ABI} ABI${COLDEFAULT}"
118     echo -e "${COLBLUE}*** ${COLGREEN} ABI${COLDEFAULT}='${ABI}'"
119     echo -e "${COLBLUE}*** ${COLGREEN} CC${COLDEFAULT}='${CC}'"
120     echo -e "${COLBLUE}*** ${COLGREEN} CXX${COLDEFAULT}='${CXX}'"
121     echo -e "${COLBLUE}*** ${COLGREEN} ABI_LIBDIR${COLDEFAULT}='${ABI_LIBDIR}'"
122 niro 307 if [[ ${EXPORT_ABI_LDFLAGS} != false ]]
123     then
124     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${LDFLAGS}'"
125     else
126     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${COLYELLOW}not exported${COLDEFAULT}'"
127     fi
128 niro 2 echo -e "${COLBLUE}*** ${COLGREEN} CHOST${COLDEFAULT}='${CHOST}'"
129     echo -e "${COLBLUE}*** ${COLGREEN} PKG_CONFIG_PATH${COLDEFAULT}='${PKG_CONFIG_PATH}'"
130    
131     # run any given command
132     eval $@ || die
133    
134     unset ABI CC CXX ABI_LIBDIR LDFLAGS PKG_CONFIG_PATH
135     }
136    
137     only-m32()
138     {
139     local abi=m32
140     local i
141    
142     for i in ${MULTILIB_ABIS}
143     do
144     if [[ ${i} = ${abi} ]]
145     then
146     # export this for mpatch etc (to repect only-${abi})
147     export MULTILIB_ONLY_ABI=${abi}
148    
149     cd ${SRCDIR}-${abi}
150     abi-${abi} $@ || die
151    
152     # unset this is very important
153     unset MULTILIB_ONLY_ABI
154     fi
155     done
156     }
157    
158     only-m64()
159     {
160     local abi=m64
161     local i
162    
163     for i in ${MULTILIB_ABIS}
164     do
165     if [[ ${i} = ${abi} ]]
166     then
167     # export this for mpatch etc (to repect only-${abi})
168     export MULTILIB_ONLY_ABI=${abi}
169    
170     cd ${SRCDIR}-${abi}
171     abi-${abi} $@ || die
172    
173     # unset this is very important
174     unset MULTILIB_ONLY_ABI
175     fi
176     done
177     }
178    
179     all-abis()
180     {
181     local abi
182     for abi in ${MULTILIB_ABIS}
183     do
184     cd ${SRCDIR}-${abi}
185     abi-${abi} $@ || die
186     done
187     }
188    
189     ##
190     # multilib compile functions
191     ##
192    
193 niro 3671 if [[ ! -z $(typeset -f mconfigure) ]]
194     then
195     # rename the old one
196     old_mconfigure=old$(typeset -f mconfigure)
197     eval ${old_mconfigure}
198     fi
199 niro 2 mconfigure()
200     {
201     local abi
202     local abis_to_run="${MULTILIB_ABIS}"
203    
204     # respect MULTILIB_ONLY_ABI variable
205     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
206    
207     for abi in ${abis_to_run}
208     do
209     cd ${SRCDIR}-${abi}
210     abi-${abi} oldmconfigure $@ || die
211     done
212     }
213    
214 niro 4780
215     if [[ ! -z $(typeset -f cmake_configure) ]]
216     then
217     # rename the old one
218     old_cmake_configure=old$(typeset -f cmake_configure)
219     eval ${old_cmake_configure}
220     fi
221     cmake_configure()
222     {
223     local abi
224     local abis_to_run="${MULTILIB_ABIS}"
225    
226     # respect MULTILIB_ONLY_ABI variable
227     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
228    
229     local saved_SRCDIR="${SRCDIR}"
230     for abi in ${abis_to_run}
231     do
232     SRCDIR="${saved_SRCDIR}-${abi}"
233     cd ${SRCDIR}
234     abi-${abi} oldcmake_configure $@ || die
235     done
236     }
237    
238 niro 3671 if [[ ! -z $(typeset -f munpack) ]]
239     then
240     # rename the old one
241     old_munpack=old$(typeset -f munpack)
242     eval "${old_munpack}"
243     fi
244 niro 2 munpack()
245     {
246     local abi
247     local abis_to_run="${MULTILIB_ABIS}"
248    
249     # respect MULTILIB_ONLY_ABI variable
250     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
251    
252     for abi in ${abis_to_run}
253     do
254     echo -e "${COLBLUE}*** ${COLGREEN}unpacking for ABI -${abi}${COLDEFAULT}"
255     oldmunpack ${SRCFILE} || die
256     mv ${SRCDIR} ${SRCDIR}-${abi} || die
257     done
258     }
259    
260 niro 3671 if [[ ! -z $(typeset -f mmake) ]]
261     then
262     # rename the old one
263     old_mmake=old$(typeset -f mmake)
264     eval "${old_mmake}"
265     fi
266 niro 2 mmake()
267     {
268     local abi
269     local abis_to_run="${MULTILIB_ABIS}"
270    
271     # respect MULTILIB_ONLY_ABI variable
272     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
273    
274     for abi in ${abis_to_run}
275     do
276     echo -e "${COLBLUE}*** ${COLGREEN}compiling for ABI -${abi}${COLDEFAULT}"
277     cd ${SRCDIR}-${abi}
278     abi-${abi} oldmmake $@ || die
279     done
280     }
281    
282 niro 3671 if [[ ! -z $(typeset -f minstall) ]]
283     then
284     # rename the old one
285     old_minstall=old$(typeset -f minstall)
286     eval "${old_minstall}"
287     fi
288 niro 2 minstall()
289     {
290     local abi
291     local abis_to_run="${MULTILIB_ABIS}"
292    
293     # respect MULTILIB_ONLY_ABI variable
294     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
295    
296     for abi in ${abis_to_run}
297     do
298     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
299     cd ${SRCDIR}-${abi}
300     abi-${abi} oldminstall $@ || die
301     done
302     }
303    
304     minstall_destdir()
305     {
306     local abi
307     local abis_to_run="${MULTILIB_ABIS}"
308    
309     # respect MULTILIB_ONLY_ABI variable
310     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
311    
312     for abi in ${abis_to_run}
313     do
314     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
315     cd ${SRCDIR}-${abi}
316     make DESTDIR=${BINDIR} $@ install || die
317     done
318     }
319    
320 niro 3671 if [[ ! -z $(typeset -f mpatch) ]]
321     then
322     # rename the old one
323     old_mpatch=old$(typeset -f mpatch)
324     eval "${old_mpatch}"
325     fi
326 niro 2 mpatch()
327     {
328     local abi
329     local abis_to_run="${MULTILIB_ABIS}"
330    
331     # respect MULTILIB_ONLY_ABI variable
332     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
333    
334     for abi in ${abis_to_run}
335     do
336     echo -e "${COLBLUE}*** ${COLGREEN}appling patch for ABI -${abi}${COLDEFAULT}"
337     cd ${SRCDIR}-${abi}
338     oldmpatch $@ || die
339     done
340     }
341    
342 niro 3671 if [[ ! -z $(typeset -f mlibtoolize) ]]
343     then
344     # rename the old one
345     old_mlibtoolize=old$(typeset -f mlibtoolize)
346     eval "${old_mlibtoolize}"
347     fi
348 niro 2 mlibtoolize()
349     {
350     local abi
351     local abis_to_run="${MULTILIB_ABIS}"
352    
353     # respect MULTILIB_ONLY_ABI variable
354     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
355    
356     for abi in ${abis_to_run}
357     do
358     echo -e "${COLBLUE}*** ${COLGREEN}running mlibtoolize for ABI -${abi}${COLDEFAULT}"
359     cd ${SRCDIR}-${abi}
360     oldmlibtoolize $@ || die
361     done
362     }
363    
364     minstalldocs()
365     {
366     local abi
367     local docfiles
368     docfiles="$@"
369    
370     local abis_to_run="${MULTILIB_ABIS}"
371    
372     # respect MULTILIB_ONLY_ABI variable
373     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
374    
375     for abi in ${abis_to_run}
376     do
377     cd ${SRCDIR}-${abi}
378     if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
379     then
380     install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
381     fi
382    
383     for i in ${docfiles}
384     do
385     cat ${SRCDIR}-${abi}/${i} | gzip -9c > ${SRCDIR}-${abi}/${i}.gz || die "gzipping docs."
386     install -m 0644 ${SRCDIR}-${abi}/${i}.gz \
387     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
388     done
389     done
390     }
391    
392     ##
393     # multilib mbuild wrappers
394     ##
395     multilib_src_prepare()
396     {
397     munpack
398     }
399    
400     multilib_src_compile()
401     {
402     mconfigure
403     mmake
404     }
405    
406     multilib_src_install()
407     {
408     minstall_destdir
409    
410     local i
411     for abi in ${MULTILIB_ABIS}
412     do
413     cd ${SRCDIR}-${abi}
414     for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
415     FAQ LICENSE NEWS README TODO
416     do
417     if [ -f ${SRCDIR}-${abi}/${i} ]
418     then
419     minstalldocs ${i} || die
420     fi
421     done
422     done
423     }
424    
425     export_inherits multilib src_prepare src_compile src_install