Magellan Linux

Annotation of /branches/R11-stable/include/multilib.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 307 - (hide annotations) (download)
Mon Dec 22 11:33:39 2008 UTC (15 years, 10 months ago) by niro
Original Path: trunk/core/include/multilib.sminc
File size: 8688 byte(s)
-added option to supress export of ABI_LDFLAGS
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     # rename the old one
194     old_mconfigure=old$(typeset -f mconfigure)
195     eval ${old_mconfigure}
196     mconfigure()
197     {
198     local abi
199     local abis_to_run="${MULTILIB_ABIS}"
200    
201     # respect MULTILIB_ONLY_ABI variable
202     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
203    
204     for abi in ${abis_to_run}
205     do
206     cd ${SRCDIR}-${abi}
207     abi-${abi} oldmconfigure $@ || die
208     done
209     }
210    
211     # rename the old one
212     old_munpack=old$(typeset -f munpack)
213     eval "${old_munpack}"
214     munpack()
215     {
216     local abi
217     local abis_to_run="${MULTILIB_ABIS}"
218    
219     # respect MULTILIB_ONLY_ABI variable
220     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
221    
222     for abi in ${abis_to_run}
223     do
224     echo -e "${COLBLUE}*** ${COLGREEN}unpacking for ABI -${abi}${COLDEFAULT}"
225     oldmunpack ${SRCFILE} || die
226     mv ${SRCDIR} ${SRCDIR}-${abi} || die
227     done
228     }
229    
230     # rename the old one
231     old_mmake=old$(typeset -f mmake)
232     eval "${old_mmake}"
233     mmake()
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     for abi in ${abis_to_run}
242     do
243     echo -e "${COLBLUE}*** ${COLGREEN}compiling for ABI -${abi}${COLDEFAULT}"
244     cd ${SRCDIR}-${abi}
245     abi-${abi} oldmmake $@ || die
246     done
247     }
248    
249     # rename the old one
250     old_minstall=old$(typeset -f minstall)
251     eval "${old_minstall}"
252     minstall()
253     {
254     local abi
255     local abis_to_run="${MULTILIB_ABIS}"
256    
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}installing for ABI -${abi}${COLDEFAULT}"
263     cd ${SRCDIR}-${abi}
264     abi-${abi} oldminstall $@ || die
265     done
266     }
267    
268     minstall_destdir()
269     {
270     local abi
271     local abis_to_run="${MULTILIB_ABIS}"
272    
273     # respect MULTILIB_ONLY_ABI variable
274     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
275    
276     for abi in ${abis_to_run}
277     do
278     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
279     cd ${SRCDIR}-${abi}
280     make DESTDIR=${BINDIR} $@ install || die
281     done
282     }
283    
284     # rename the old one
285     old_mpatch=old$(typeset -f mpatch)
286     eval "${old_mpatch}"
287     mpatch()
288     {
289     local abi
290     local abis_to_run="${MULTILIB_ABIS}"
291    
292     # respect MULTILIB_ONLY_ABI variable
293     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
294    
295     for abi in ${abis_to_run}
296     do
297     echo -e "${COLBLUE}*** ${COLGREEN}appling patch for ABI -${abi}${COLDEFAULT}"
298     cd ${SRCDIR}-${abi}
299     oldmpatch $@ || die
300     done
301     }
302    
303     # rename the old one
304     old_mlibtoolize=old$(typeset -f mlibtoolize)
305     eval "${old_mlibtoolize}"
306     mlibtoolize()
307     {
308     local abi
309     local abis_to_run="${MULTILIB_ABIS}"
310    
311     # respect MULTILIB_ONLY_ABI variable
312     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
313    
314     for abi in ${abis_to_run}
315     do
316     echo -e "${COLBLUE}*** ${COLGREEN}running mlibtoolize for ABI -${abi}${COLDEFAULT}"
317     cd ${SRCDIR}-${abi}
318     oldmlibtoolize $@ || die
319     done
320     }
321    
322     minstalldocs()
323     {
324     local abi
325     local docfiles
326     docfiles="$@"
327    
328     local abis_to_run="${MULTILIB_ABIS}"
329    
330     # respect MULTILIB_ONLY_ABI variable
331     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
332    
333     for abi in ${abis_to_run}
334     do
335     cd ${SRCDIR}-${abi}
336     if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
337     then
338     install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
339     fi
340    
341     for i in ${docfiles}
342     do
343     cat ${SRCDIR}-${abi}/${i} | gzip -9c > ${SRCDIR}-${abi}/${i}.gz || die "gzipping docs."
344     install -m 0644 ${SRCDIR}-${abi}/${i}.gz \
345     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
346     done
347     done
348     }
349    
350     ##
351     # multilib mbuild wrappers
352     ##
353     multilib_src_prepare()
354     {
355     munpack
356     }
357    
358     multilib_src_compile()
359     {
360     mconfigure
361     mmake
362     }
363    
364     multilib_src_install()
365     {
366     minstall_destdir
367    
368     local i
369     for abi in ${MULTILIB_ABIS}
370     do
371     cd ${SRCDIR}-${abi}
372     for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
373     FAQ LICENSE NEWS README TODO
374     do
375     if [ -f ${SRCDIR}-${abi}/${i} ]
376     then
377     minstalldocs ${i} || die
378     fi
379     done
380     done
381     }
382    
383     export_inherits multilib src_prepare src_compile src_install