https://wiki.archlinux.org/api.php?action=feedcontributions&user=Hotspur&feedformat=atomArchWiki - User contributions [en]2024-03-29T10:30:07ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Talk:Cross-compiling_tools_package_guidelines&diff=78014Talk:Cross-compiling tools package guidelines2009-10-16T10:31:25Z<p>Hotspur: /* Out of path executables */</p>
<hr />
<div>==Package Naming==<br />
Should the packages contain the entire target in their name? The current naming suggest is not used in the example PKGBUILD. [[User:Allan|Allan]] 22:57, 15 October 2009 (EDT)<br />
<br />
==Out of path executables==<br />
Where would these go? binutils buts its biniaries (without the target in their name) in /usr/lib/cross-i686-pc-mingw32/i686-pc-mingw32/bin. It is a bit unwieldy but seems OK... Maybe just use /usr/lib/cross-i686-pc-mingw32/bin (i.e. ${_target}/bin)? [[User:Allan|Allan]] 22:59, 15 October 2009 (EDT)<br />
<br />
The default location seems to unrememberable. The ''/usr/lib/cross-${_target}/bin/'' is definetely better, but still... What about ''/usr/bin/cross/${_target}'' (I know it is a minor difference to ''/usr/lib'' but somehow I would expect user executables inside ''/usr/bin'')?<br />
<br />
I was not able to reproduce it now, but I think that with some <code>./configure</code> settings, not all executables have their not-prefixed-counterparts in ''/usr/lib/cross-i686-pc-mingw32/i686-pc-mingw32/bin'' so we would need to do some symlinks anyway.<br />
--[[User:Hotspur|Hotspur]] 06:31, 16 October 2009 (EDT)</div>Hotspurhttps://wiki.archlinux.org/index.php?title=User:Hotspur&diff=78013User:Hotspur2009-10-16T10:22:04Z<p>Hotspur: Initial commit</p>
<hr />
<div>Oops, nothing here so far.<br />
<br />
My e-mail address is accessible via my [http://aur.archlinux.org/account.php?Action=AccountInfo&ID=13890 AUR account].<br />
<br />
-- Vojtech Horky</div>Hotspurhttps://wiki.archlinux.org/index.php?title=Cross-compiling_tools_package_guidelines&diff=77875Cross-compiling tools package guidelines2009-10-15T18:55:32Z<p>Hotspur: Example now uses MinGW</p>
<hr />
<div>== Important ==<br />
This page describes a proposal, not an accepted approach!<br />
<br />
== Package Naming ==<br />
The package name shall be prefixed with the word '''cross-''', followed by architecture name and the package name itself shall come at the end.<br />
<br />
Thus, cross GCC for MIPS shall be '''cross-mips-gcc'''.<br />
<br />
<br />
== File Placement ==<br />
To prevent file conflicts, place everything into '''/usr/lib/cross-<arch>'''. The only exception to this rule are executables, that shall be placed directly into ''/usr/bin/'' (however, to prevent conflicts here, prefix all of them with architecture name).<br />
<br />
Typically, <code>./configure</code> would have at least following parameters:<br />
<pre>_target=<your-target> # e.g. i686-pc-mingw32<br />
_sysroot=/usr/lib/${_target}<br />
...<br />
./configure \<br />
--prefix=${_sysroot} --sysroot=${_sysroot} \<br />
--bindir=/usr/bin</pre><br />
<br />
== Example ==<br />
This is PKGBUILD for binutils for MinGW.<br />
Things worth noticing are:<br />
*specifying root directory of the cross-environment<br />
*usage of <code>${_pkgname}</code>, <code>${_target}</code> and <code>${_sysroot}</code> variables to make the code more readable<br />
*removal of the duplicated/conflicting files<br />
<pre># Maintainer: Allan McRae <allan@archlinux.org><br />
<br />
# cross toolchain build order: binutils, headers, gcc (pass 1), w32api, mingwrt, gcc (pass 2)<br />
<br />
_target=i686-pc-mingw32<br />
_sysroot=/usr/lib/cross-${_target}<br />
<br />
pkgname=cross-${_target}-binutils<br />
_pkgname=binutils<br />
pkgver=2.19.1<br />
pkgrel=1<br />
pkgdesc="MinGW Windows binutils"<br />
arch=('i686' 'x86_64')<br />
url="http://www.gnu.org/software/binutils/"<br />
license=('GPL')<br />
depends=('glibc>=2.10.1' 'zlib')<br />
options=('!libtool' '!distcc' '!ccache')<br />
source=(http://ftp.gnu.org/gnu/${_pkgname}/${_pkgname}-${pkgver}.tar.bz2)<br />
md5sums=('09a8c5821a2dfdbb20665bc0bd680791')<br />
<br />
build() {<br />
cd ${srcdir}/${_pkgname}-${pkgver}<br />
mkdir build && cd build<br />
<br />
../configure --prefix=${_sysroot} --bindir=/usr/bin \<br />
--with-sysroot=${_sysroot} \<br />
--build=$CHOST --host=$CHOST --target=${_target} \<br />
--with-gcc --with-gnu-as --with-gnu-ld \<br />
--enable-shared --without-included-gettext \<br />
--disable-nls --disable-debug --disable-win32-registry<br />
make || return 1<br />
make DESTDIR=${pkgdir}/ install || return 1<br />
<br />
# clean-up cross compiler root<br />
rm -r ${pkgdir}/${_sysroot}/{info,man}<br />
}</pre><br />
<br />
== Hows and whys ==<br />
Why not installing into ''/opt''? There would be no need for fooling around with non-standard executable namings etc.?<br />
: Two reasons:<br />
:: First, according to File Hierarchy Standard, these files just belong somwhere to ''/usr''. Period.<br />
:: Second, installing into ''/opt'' is a last meassure when there is no other option.<br />
<br />
What is that ''out-of-path executables'' thing?<br />
: This weird thing allows easier cross-compiling. Sometimes, project Makefiles do not use '''CC''' & co. variables and instead use '''gcc''' directly. If you just want to try to cross-compile such project, editing the Makefile could be a very lengthy operation. However, changing the <code>$PATH</code> to use "our" executables first is a very quick solution.<br />
: You would then run <code>PATH=/usr/bin/cross/<i>arch</i>/:$PATH make</code> instead of <code>make</code>.</div>Hotspurhttps://wiki.archlinux.org/index.php?title=Cross-compiling_tools_package_guidelines&diff=77873Cross-compiling tools package guidelines2009-10-15T18:51:34Z<p>Hotspur: /* Hows and whys */</p>
<hr />
<div>== Important ==<br />
This page describes a proposal, not an accepted approach!<br />
<br />
== Package Naming ==<br />
The package name shall be prefixed with the word '''cross-''', followed by architecture name and the package name itself shall come at the end.<br />
<br />
Thus, cross GCC for MIPS shall be '''cross-mips-gcc'''.<br />
<br />
<br />
== File Placement ==<br />
To prevent file conflicts, place everything into '''/usr/lib/cross-<arch>'''. The only exception to this rule are executables, that shall be placed directly into ''/usr/bin/'' (however, to prevent conflicts here, prefix all of them with architecture name).<br />
<br />
Typically, <code>./configure</code> would have at least following parameters:<br />
<pre>_target=<your-target> # e.g. i686-pc-mingw32<br />
_sysroot=/usr/lib/${_target}<br />
...<br />
./configure \<br />
--prefix=${_sysroot} --sysroot=${_sysroot} \<br />
--bindir=/usr/bin</pre><br />
<br />
== Example ==<br />
This is PKGBUILD for GCC for MIPS.<br />
Things worth noticing are:<br />
*manually specifying where to find the '''as''' and '''ld''' binaries<br />
*usage of <code>${_pkgname}</code> and <code>${_target}</code> variables to make the code more readable<br />
*removal of the duplicated/conflicting files<br />
<pre># Contributor: Your name <your@email.somewhere.net><br />
pkgname=cross-mips-gcc<br />
_pkgname=gcc<br />
pkgver=4.3.2<br />
pkgrel=2<br />
pkgdesc="The GNU Compiler Collection for the MIPS architecture"<br />
url="http://www.gnu.org/software/binutils/"<br />
arch=('i686' 'x86_64')<br />
license=('GPL')<br />
depends=('mpfr' 'sh' 'cross-mips-binutils')<br />
options=('!ccache' '!distcc' '!emptydirs' '!libtool' '!strip')<br />
source=("ftp://ftp.gnu.org/gnu/gcc/gcc-${pkgver}/${_pkgname}-core-${pkgver}.tar.bz2")<br />
md5sums=('dd8048b43d3d4e5595bcade47b9144c6')<br />
_target="mipsel-linux-gnu"<br />
<br />
build() {<br />
cd ${srcdir}/${_pkgname}-${pkgver}<br />
<br />
./configure \<br />
"--prefix=/usr" \<br />
"--libexecdir=/usr/lib" \<br />
"--program-prefix=${_target}-" \<br />
"--target=${_target}" \<br />
"--mandir=/usr/share/man" \<br />
--without-headers \<br />
--with-gnu-as --with-gnu-ld \<br />
--with-as=/usr/bin/${_target}-as \<br />
--with-ld=/usr/bin/${_target}-ld \<br />
--disable-nls --disable-multilib --disable-shared \<br />
--disable-libgcj --disable-threads --disable-tls \<br />
--enable-languages=c || return 1<br />
<br />
make all-gcc || return 1<br />
<br />
make DESTDIR=${pkgdir} install-gcc || return 1<br />
<br />
msg "Removing duplicit files..."<br />
# remove these files as they are already in the system<br />
# (with native gcc)<br />
rm -Rf ${pkgdir}/usr/info<br />
rm -f ${pkgdir}/usr/lib/libiberty.a<br />
rm -Rf ${pkgdir}/usr/share/man<br />
rm -Rf ${pkgdir}/usr/share/info<br />
<br />
msg "Creating out-of-path executables..."<br />
# symlink executables to single directory with no-arch-prefix name<br />
mkdir -p ${pkgdir}/usr/bin/cross/${_target}/;<br />
cd ${pkgdir}/usr/bin/cross/${_target}/;<br />
for bin in ${pkgdir}/usr/bin/${_target}-*; do<br />
bbin=`basename "$bin"`;<br />
ln -s "/usr/bin/${bbin}" `echo "$bbin" | sed "s#^${_target}-##"`;<br />
done<br />
}</pre><br />
<br />
<br />
== Hows and whys ==<br />
Why not installing into ''/opt''? There would be no need for fooling around with non-standard executable namings etc.?<br />
: Two reasons:<br />
:: First, according to File Hierarchy Standard, these files just belong somwhere to ''/usr''. Period.<br />
:: Second, installing into ''/opt'' is a last meassure when there is no other option.<br />
<br />
What is that ''out-of-path executables'' thing?<br />
: This weird thing allows easier cross-compiling. Sometimes, project Makefiles do not use '''CC''' & co. variables and instead use '''gcc''' directly. If you just want to try to cross-compile such project, editing the Makefile could be a very lengthy operation. However, changing the <code>$PATH</code> to use "our" executables first is a very quick solution.<br />
: You would then run <code>PATH=/usr/bin/cross/<i>arch</i>/:$PATH make</code> instead of <code>make</code>.</div>Hotspurhttps://wiki.archlinux.org/index.php?title=Cross-compiling_tools_package_guidelines&diff=77872Cross-compiling tools package guidelines2009-10-15T18:50:46Z<p>Hotspur: Recommended file placement is now /usr/lib/cross-*</p>
<hr />
<div>== Important ==<br />
This page describes a proposal, not an accepted approach!<br />
<br />
== Package Naming ==<br />
The package name shall be prefixed with the word '''cross-''', followed by architecture name and the package name itself shall come at the end.<br />
<br />
Thus, cross GCC for MIPS shall be '''cross-mips-gcc'''.<br />
<br />
<br />
== File Placement ==<br />
To prevent file conflicts, place everything into '''/usr/lib/cross-<arch>'''. The only exception to this rule are executables, that shall be placed directly into ''/usr/bin/'' (however, to prevent conflicts here, prefix all of them with architecture name).<br />
<br />
Typically, <code>./configure</code> would have at least following parameters:<br />
<pre>_target=<your-target> # e.g. i686-pc-mingw32<br />
_sysroot=/usr/lib/${_target}<br />
...<br />
./configure \<br />
--prefix=${_sysroot} --sysroot=${_sysroot} \<br />
--bindir=/usr/bin</pre><br />
<br />
== Example ==<br />
This is PKGBUILD for GCC for MIPS.<br />
Things worth noticing are:<br />
*manually specifying where to find the '''as''' and '''ld''' binaries<br />
*usage of <code>${_pkgname}</code> and <code>${_target}</code> variables to make the code more readable<br />
*removal of the duplicated/conflicting files<br />
<pre># Contributor: Your name <your@email.somewhere.net><br />
pkgname=cross-mips-gcc<br />
_pkgname=gcc<br />
pkgver=4.3.2<br />
pkgrel=2<br />
pkgdesc="The GNU Compiler Collection for the MIPS architecture"<br />
url="http://www.gnu.org/software/binutils/"<br />
arch=('i686' 'x86_64')<br />
license=('GPL')<br />
depends=('mpfr' 'sh' 'cross-mips-binutils')<br />
options=('!ccache' '!distcc' '!emptydirs' '!libtool' '!strip')<br />
source=("ftp://ftp.gnu.org/gnu/gcc/gcc-${pkgver}/${_pkgname}-core-${pkgver}.tar.bz2")<br />
md5sums=('dd8048b43d3d4e5595bcade47b9144c6')<br />
_target="mipsel-linux-gnu"<br />
<br />
build() {<br />
cd ${srcdir}/${_pkgname}-${pkgver}<br />
<br />
./configure \<br />
"--prefix=/usr" \<br />
"--libexecdir=/usr/lib" \<br />
"--program-prefix=${_target}-" \<br />
"--target=${_target}" \<br />
"--mandir=/usr/share/man" \<br />
--without-headers \<br />
--with-gnu-as --with-gnu-ld \<br />
--with-as=/usr/bin/${_target}-as \<br />
--with-ld=/usr/bin/${_target}-ld \<br />
--disable-nls --disable-multilib --disable-shared \<br />
--disable-libgcj --disable-threads --disable-tls \<br />
--enable-languages=c || return 1<br />
<br />
make all-gcc || return 1<br />
<br />
make DESTDIR=${pkgdir} install-gcc || return 1<br />
<br />
msg "Removing duplicit files..."<br />
# remove these files as they are already in the system<br />
# (with native gcc)<br />
rm -Rf ${pkgdir}/usr/info<br />
rm -f ${pkgdir}/usr/lib/libiberty.a<br />
rm -Rf ${pkgdir}/usr/share/man<br />
rm -Rf ${pkgdir}/usr/share/info<br />
<br />
msg "Creating out-of-path executables..."<br />
# symlink executables to single directory with no-arch-prefix name<br />
mkdir -p ${pkgdir}/usr/bin/cross/${_target}/;<br />
cd ${pkgdir}/usr/bin/cross/${_target}/;<br />
for bin in ${pkgdir}/usr/bin/${_target}-*; do<br />
bbin=`basename "$bin"`;<br />
ln -s "/usr/bin/${bbin}" `echo "$bbin" | sed "s#^${_target}-##"`;<br />
done<br />
}</pre><br />
<br />
<br />
== Hows and whys ==<br />
Why not installing into ''/opt''? There would be no need for fooling around with non-standard executable namings etc.?<br />
: Two reasons:<br />
:: First, according to File Hierarchy Standard, these files just belong to ''/usr''. Period.<br />
:: Second, installing into ''/opt'' is a last meassure when there is no other option.<br />
<br />
Binutils creates some ugly looking directories (architecture named) directly under ''/usr''!<br />
: You need to manually specify '''tooldir''' during make (both with <code>make all</code> and <code>make install</code>).<br />
<pre>make tooldir=/usr all || return 1<br />
make tooldir=/usr DESTDIR=${pkgdir} install || return 1</pre><br />
<br />
What is that ''out-of-path executables'' thing?<br />
: This weird thing allows easier cross-compiling. Sometimes, project Makefiles do not use '''CC''' & co. variables and instead use '''gcc''' directly. If you just want to try to cross-compile such project, editing the Makefile could be a very lengthy operation. However, changing the <code>$PATH</code> to use "our" executables first is a very quick solution.<br />
: You would then run <code>PATH=/usr/bin/cross/<i>arch</i>/:$PATH make</code> instead of <code>make</code>.</div>Hotspurhttps://wiki.archlinux.org/index.php?title=Cross-compiling_tools_package_guidelines&diff=77720Cross-compiling tools package guidelines2009-10-13T09:44:03Z<p>Hotspur: /* Hows and whys */</p>
<hr />
<div>== Important ==<br />
This page describes a proposal, not an accepted approach!<br />
<br />
== Package Naming ==<br />
The package name shall be prefixed with the word '''cross-''', followed by architecture name and the package name itself shall come at the end.<br />
<br />
Thus, cross GCC for MIPS shall be '''cross-mips-gcc'''.<br />
<br />
<br />
== File Placement ==<br />
Place all the files in the ''/usr/'', to avoid conflicts with existing binaries, prefix them with architecture name (typically, the best way is to use the target name specified during the build).<br />
<br />
<br />
== Example ==<br />
This is PKGBUILD for GCC for MIPS.<br />
Things worth noticing are:<br />
*manually specifying where to find the '''as''' and '''ld''' binaries<br />
*usage of <code>${_pkgname}</code> and <code>${_target}</code> variables to make the code more readable<br />
*removal of the duplicated/conflicting files<br />
<pre># Contributor: Your name <your@email.somewhere.net><br />
pkgname=cross-mips-gcc<br />
_pkgname=gcc<br />
pkgver=4.3.2<br />
pkgrel=2<br />
pkgdesc="The GNU Compiler Collection for the MIPS architecture"<br />
url="http://www.gnu.org/software/binutils/"<br />
arch=('i686' 'x86_64')<br />
license=('GPL')<br />
depends=('mpfr' 'sh' 'cross-mips-binutils')<br />
options=('!ccache' '!distcc' '!emptydirs' '!libtool' '!strip')<br />
source=("ftp://ftp.gnu.org/gnu/gcc/gcc-${pkgver}/${_pkgname}-core-${pkgver}.tar.bz2")<br />
md5sums=('dd8048b43d3d4e5595bcade47b9144c6')<br />
_target="mipsel-linux-gnu"<br />
<br />
build() {<br />
cd ${srcdir}/${_pkgname}-${pkgver}<br />
<br />
./configure \<br />
"--prefix=/usr" \<br />
"--libexecdir=/usr/lib" \<br />
"--program-prefix=${_target}-" \<br />
"--target=${_target}" \<br />
"--mandir=/usr/share/man" \<br />
--without-headers \<br />
--with-gnu-as --with-gnu-ld \<br />
--with-as=/usr/bin/${_target}-as \<br />
--with-ld=/usr/bin/${_target}-ld \<br />
--disable-nls --disable-multilib --disable-shared \<br />
--disable-libgcj --disable-threads --disable-tls \<br />
--enable-languages=c || return 1<br />
<br />
make all-gcc || return 1<br />
<br />
make DESTDIR=${pkgdir} install-gcc || return 1<br />
<br />
msg "Removing duplicit files..."<br />
# remove these files as they are already in the system<br />
# (with native gcc)<br />
rm -Rf ${pkgdir}/usr/info<br />
rm -f ${pkgdir}/usr/lib/libiberty.a<br />
rm -Rf ${pkgdir}/usr/share/man<br />
rm -Rf ${pkgdir}/usr/share/info<br />
<br />
msg "Creating out-of-path executables..."<br />
# symlink executables to single directory with no-arch-prefix name<br />
mkdir -p ${pkgdir}/usr/bin/cross/${_target}/;<br />
cd ${pkgdir}/usr/bin/cross/${_target}/;<br />
for bin in ${pkgdir}/usr/bin/${_target}-*; do<br />
bbin=`basename "$bin"`;<br />
ln -s "/usr/bin/${bbin}" `echo "$bbin" | sed "s#^${_target}-##"`;<br />
done<br />
}</pre><br />
<br />
<br />
== Hows and whys ==<br />
Why not installing into ''/opt''? There would be no need for fooling around with non-standard executable namings etc.?<br />
: Two reasons:<br />
:: First, according to File Hierarchy Standard, these files just belong to ''/usr''. Period.<br />
:: Second, installing into ''/opt'' is a last meassure when there is no other option.<br />
<br />
Binutils creates some ugly looking directories (architecture named) directly under ''/usr''!<br />
: You need to manually specify '''tooldir''' during make (both with <code>make all</code> and <code>make install</code>).<br />
<pre>make tooldir=/usr all || return 1<br />
make tooldir=/usr DESTDIR=${pkgdir} install || return 1</pre><br />
<br />
What is that ''out-of-path executables'' thing?<br />
: This weird thing allows easier cross-compiling. Sometimes, project Makefiles do not use '''CC''' & co. variables and instead use '''gcc''' directly. If you just want to try to cross-compile such project, editing the Makefile could be a very lengthy operation. However, changing the <code>$PATH</code> to use "our" executables first is a very quick solution.<br />
: You would then run <code>PATH=/usr/bin/cross/<i>arch</i>/:$PATH make</code> instead of <code>make</code>.</div>Hotspurhttps://wiki.archlinux.org/index.php?title=Cross-compiling_tools_package_guidelines&diff=77719Cross-compiling tools package guidelines2009-10-13T09:41:04Z<p>Hotspur: Added out-of-path symlinking</p>
<hr />
<div>== Important ==<br />
This page describes a proposal, not an accepted approach!<br />
<br />
== Package Naming ==<br />
The package name shall be prefixed with the word '''cross-''', followed by architecture name and the package name itself shall come at the end.<br />
<br />
Thus, cross GCC for MIPS shall be '''cross-mips-gcc'''.<br />
<br />
<br />
== File Placement ==<br />
Place all the files in the ''/usr/'', to avoid conflicts with existing binaries, prefix them with architecture name (typically, the best way is to use the target name specified during the build).<br />
<br />
<br />
== Example ==<br />
This is PKGBUILD for GCC for MIPS.<br />
Things worth noticing are:<br />
*manually specifying where to find the '''as''' and '''ld''' binaries<br />
*usage of <code>${_pkgname}</code> and <code>${_target}</code> variables to make the code more readable<br />
*removal of the duplicated/conflicting files<br />
<pre># Contributor: Your name <your@email.somewhere.net><br />
pkgname=cross-mips-gcc<br />
_pkgname=gcc<br />
pkgver=4.3.2<br />
pkgrel=2<br />
pkgdesc="The GNU Compiler Collection for the MIPS architecture"<br />
url="http://www.gnu.org/software/binutils/"<br />
arch=('i686' 'x86_64')<br />
license=('GPL')<br />
depends=('mpfr' 'sh' 'cross-mips-binutils')<br />
options=('!ccache' '!distcc' '!emptydirs' '!libtool' '!strip')<br />
source=("ftp://ftp.gnu.org/gnu/gcc/gcc-${pkgver}/${_pkgname}-core-${pkgver}.tar.bz2")<br />
md5sums=('dd8048b43d3d4e5595bcade47b9144c6')<br />
_target="mipsel-linux-gnu"<br />
<br />
build() {<br />
cd ${srcdir}/${_pkgname}-${pkgver}<br />
<br />
./configure \<br />
"--prefix=/usr" \<br />
"--libexecdir=/usr/lib" \<br />
"--program-prefix=${_target}-" \<br />
"--target=${_target}" \<br />
"--mandir=/usr/share/man" \<br />
--without-headers \<br />
--with-gnu-as --with-gnu-ld \<br />
--with-as=/usr/bin/${_target}-as \<br />
--with-ld=/usr/bin/${_target}-ld \<br />
--disable-nls --disable-multilib --disable-shared \<br />
--disable-libgcj --disable-threads --disable-tls \<br />
--enable-languages=c || return 1<br />
<br />
make all-gcc || return 1<br />
<br />
make DESTDIR=${pkgdir} install-gcc || return 1<br />
<br />
msg "Removing duplicit files..."<br />
# remove these files as they are already in the system<br />
# (with native gcc)<br />
rm -Rf ${pkgdir}/usr/info<br />
rm -f ${pkgdir}/usr/lib/libiberty.a<br />
rm -Rf ${pkgdir}/usr/share/man<br />
rm -Rf ${pkgdir}/usr/share/info<br />
<br />
msg "Creating out-of-path executables..."<br />
# symlink executables to single directory with no-arch-prefix name<br />
mkdir -p ${pkgdir}/usr/bin/cross/${_target}/;<br />
cd ${pkgdir}/usr/bin/cross/${_target}/;<br />
for bin in ${pkgdir}/usr/bin/${_target}-*; do<br />
bbin=`basename "$bin"`;<br />
ln -s "/usr/bin/${bbin}" `echo "$bbin" | sed "s#^${_target}-##"`;<br />
done<br />
}</pre><br />
<br />
<br />
== Hows and whys ==<br />
Why not installing into ''/opt''? There would be no need for fooling around with non-standard executable namings etc.?<br />
: Two reasons:<br />
:: First, according to File Hierarchy Standard, these files just belongs to ''/usr''. Period.<br />
:: Second, installing into ''/opt'' is a last meassure when there is no other option.<br />
<br />
Binutils creates some ugly looking directories (architecture named) directly under ''/usr''!<br />
: You need to manually specify '''tooldir''' during make (both with <code>make all</code> and <code>make install</code>).<br />
<br />
What is that ''out-of-path executables'' thing?<br />
: This weird thing allows easier cross-compiling. Sometimes, project Makefiles do not use '''CC''' & co. variables and instead use '''gcc''' directly. If you just want to try to cross-compile such project, editing the Makefile could be a very lengthy operation. However, changing the <code>$PATH</code> to use "our" executables first is a very quick solution.<br />
: You would then run <code>PATH=/usr/bin/cross/<i>arch</i>/:$PATH make</code> instead of <code>make</code>.</div>Hotspurhttps://wiki.archlinux.org/index.php?title=Cross-compiling_tools_package_guidelines&diff=77717Cross-compiling tools package guidelines2009-10-13T09:11:33Z<p>Hotspur: Initial commit</p>
<hr />
<div>== Important ==<br />
This page describes a proposal, not an accepted approach!<br />
<br />
== Package Naming ==<br />
The package name shall be prefixed with the word '''cross-''', followed by architecture name and the package name itself shall come at the end.<br />
<br />
Thus, cross GCC for MIPS shall be '''cross-mips-gcc'''.<br />
<br />
<br />
== File Placement ==<br />
Place all the files in the ''/usr/'', to avoid conflicts with existing binaries, prefix them with architecture name (typically, the best way is to use the target name specified during the build).<br />
<br />
<br />
== Example ==<br />
This is PKGBUILD for GCC for MIPS.<br />
Things worth noticing are:<br />
*manually specifying where to find the '''as''' and '''ld''' binaries<br />
*usage of <code>${_pkgname}</code> and <code>${_target}</code> variables to make the code more readable<br />
*removal of the duplicated/conflicting files<br />
<pre># Contributor: Your name <your@email.somewhere.net><br />
pkgname=cross-mips-gcc<br />
_pkgname=gcc<br />
pkgver=4.3.2<br />
pkgrel=2<br />
pkgdesc="The GNU Compiler Collection for the MIPS architecture"<br />
url="http://www.gnu.org/software/binutils/"<br />
arch=('i686' 'x86_64')<br />
license=('GPL')<br />
depends=('mpfr' 'sh' 'cross-mips-binutils')<br />
options=('!ccache' '!distcc' '!emptydirs' '!libtool' '!strip')<br />
source=("ftp://ftp.gnu.org/gnu/gcc/gcc-${pkgver}/${_pkgname}-core-${pkgver}.tar.bz2")<br />
md5sums=('dd8048b43d3d4e5595bcade47b9144c6')<br />
_target="mipsel-linux-gnu"<br />
<br />
build() {<br />
cd ${srcdir}/${_pkgname}-${pkgver}<br />
<br />
./configure \<br />
"--prefix=/usr" \<br />
"--libexecdir=/usr/lib" \<br />
"--program-prefix=${_target}-" \<br />
"--target=${_target}" \<br />
"--mandir=/usr/share/man" \<br />
--without-headers \<br />
--with-gnu-as --with-gnu-ld \<br />
--with-as=/usr/bin/${_target}-as \<br />
--with-ld=/usr/bin/${_target}-ld \<br />
--disable-nls --disable-multilib --disable-shared \<br />
--disable-libgcj --disable-threads --disable-tls \<br />
--enable-languages=c || return 1<br />
<br />
make all-gcc || return 1<br />
<br />
make DESTDIR=${pkgdir} install-gcc || return 1<br />
<br />
msg "Removing duplicit files..."<br />
# remove these files as they are already in the system<br />
# (with native gcc)<br />
rm -Rf ${pkgdir}/usr/info<br />
rm -f ${pkgdir}/usr/lib/libiberty.a<br />
rm -Rf ${pkgdir}/usr/share/man<br />
rm -Rf ${pkgdir}/usr/share/info<br />
}</pre><br />
<br />
<br />
== Hows and whys ==<br />
Why not installing into ''/opt''? There would be no need for fooling around with non-standard executable namings etc.?<br />
: Two reasons:<br />
:: First, according to File Hierarchy Standard, these files just belongs to ''/usr''. Period.<br />
:: Second, installing into ''/opt'' is a last meassure when there is no other option.<br />
<br />
Binutils creates some ugly looking directories (architecture named) directly under ''/usr''!<br />
: You need to manually specify '''tooldir''' during make (both with <code>make all</code> and <code>make install</code>).</div>Hotspurhttps://wiki.archlinux.org/index.php?title=Clean_Cache&diff=72008Clean Cache2009-07-14T14:37:34Z<p>Hotspur: Corrected invalid link.</p>
<hr />
<div>[[Category:Package management (English)]]<br />
[[Category:Scripts (English)]]<br />
[[Category:General (English)]]<br />
''Contributor: alterkacker''<br />
<br />
http://bbs.archlinux.org/viewtopic.php?id=9104<br />
Here is a python script to clean the <code>/var/cache/pacman/pkg</code> directory while allowing you to specify how many package versions should be retained.<br />
<br />
<pre><br />
#!/usr/bin/env python<br />
"""cache_clean - a simple python script to clean up the /var/cache/pacman/pkg directory.<br />
More versatile than 'pacman -Sc' in that you can select how many old versions<br />
to keep.<br />
Usage: cache_clean {-p} {-v} <# of copies to keep><br />
# of copies to keep - (required) how many generations of each package to keep<br />
-p - (optional) preview what would be deleted; forces verbose (-v) mode.<br />
-v - (optional) show deleted packages."""<br />
# Note that the determination of package age is done by simply looking at the date-time<br />
# modified stamp on the file. There is just enough variation in the way package version<br />
# is done that I thought this would be simpler & just as good.<br />
# Also note that you must be root to run this script.<br />
<br />
import getopt<br />
import os<br />
import re<br />
import sys<br />
<br />
# helper function to get tuple of (file dtm, file name, file sz) <br />
def fn_stats(fn):<br />
s = os.stat(fn)<br />
return (s[8], fn, s[6])<br />
<br />
# cleanup does the actual pkg file deletion<br />
def cleanup(run_list):<br />
# strictly speaking only the first two of these globals need to be listed.<br />
global n_deleted, bytes_deleted, opt_verbose, opt_preview, n_to_keep<br />
# return if the run_list is too short<br />
#print run_list<br />
#return<br />
if len(run_list) <= n_to_keep: return<br />
# Build list of tuples (date-time file modified, file name, file size)<br />
dtm_list = [fn_stats(tfn) for tfn in run_list]<br />
# Sort the list by date-time<br />
dtm_list.sort()<br />
# Build list of the filenames to delete (all but last n_to_keep).<br />
# <showing_off><br />
#kill_list = [tfn[1] for tfn in dtm_list[:-n_to_keep]]<br />
#bytes_deleted = reduce(lambda x, y: x+y, [x[2] for x in dtm_list[:-n_to_keep]])<br />
# </showing_off><br />
kill_list = []<br />
for x in dtm_list[:-n_to_keep]:<br />
kill_list.append(x[1])<br />
bytes_deleted += x[2]<br />
if opt_verbose: print kill_list<br />
n_deleted += len(kill_list)<br />
# and finally delete (if not in preview mode)<br />
if not opt_preview:<br />
for dfn in kill_list:<br />
os.unlink(dfn)<br />
<br />
######################################################################<br />
# mainline processing<br />
<br />
# process command line options<br />
try:<br />
opts, pargs = getopt.getopt(sys.argv[1:], 'vp')<br />
opt_dict = dict(opts)<br />
opt_preview = opt_dict.has_key('-p')<br />
opt_verbose = opt_dict.has_key('-v')<br />
if opt_preview: opt_verbose = True<br />
if len(pargs) == 1:<br />
n_to_keep = pargs[0]<br />
else:<br />
raise getopt.GetoptError("missing required argument.")<br />
try:<br />
n_to_keep = int(n_to_keep)<br />
if n_to_keep <= 0: raise ValueError<br />
except ValueError, e:<br />
raise getopt.GetoptError("# of copies to keep must be numeric > 0!")<br />
except getopt.GetoptError, msg:<br />
print "Error:",msg,"\n",__doc__<br />
sys.exit(1)<br />
<br />
# change to the pkg directory & get a sorted list of its contents<br />
os.chdir('/var/cache/pacman/pkg')<br />
pkg_fns = os.listdir('.')<br />
pkg_fns.sort()<br />
<br />
# Pattern to use to extract the package name from the tar file name:<br />
# for pkg e.g. 'gnome-common-2.8.0-1-i686.pkg.tar.gz' group(1) is 'gnome-common'.<br />
bpat = re.compile(r'^(.+)-\d[^-]+-.+?(-i686|-x86_64)?\.pkg\.tar\.gz$')<br />
<br />
n_deleted = 0<br />
bytes_deleted = 0<br />
pkg_base_nm = ''<br />
# now look for "runs" of the same package name differing only in version info.<br />
for run_end in range(len(pkg_fns)):<br />
fn = pkg_fns[run_end]<br />
mo = bpat.match(fn) # test for a match of the package name pattern<br />
if mo:<br />
tbase = mo.group(1) # gets the 'base' package name<br />
# include the architecture in the name if it's present<br />
if mo.lastindex > 1:<br />
tbase += mo.group(2)<br />
#print 'tbase: ',tbase,' ',mo.lastindex<br />
# is it a new base name, i.e. the start of a new run?<br />
if tbase != pkg_base_nm: # if so then process the prior run<br />
if pkg_base_nm != '':<br />
cleanup(pkg_fns[run_start:run_end])<br />
pkg_base_nm = tbase # & setup for the new run<br />
run_start = run_end<br />
else:<br />
print >>sys.stderr, "File '"+fn+"' doesn't match package pattern!"<br />
<br />
# catch the final run of the list<br />
run_end += 1<br />
cleanup(pkg_fns[run_start:run_end])<br />
<br />
if opt_verbose:<br />
if opt_preview:<br />
print "Preview mode (no files deleted):",<br />
print n_deleted,"files deleted,",bytes_deleted/1000,"kbytes."</pre></div>Hotspur