This howto is for ppl who want to recompile ubuntu packages and keep the ubuntu settings(so that it is more stable) PLUS add some of your own compiling flags(maybe for your cpu type).
Make sure you have the *deb-src* lines uncommented in */etc/sources.list*.
Make a directory where you will do your work. This way you can easily see what has been downloaded and easy remove it later.
mkdir recompileUbuntuPackages
cd recompileUbuntuPackages
- [SIZE=3][COLOR=Indigo]Download needed header-files etc for <package-name>[/COLOR][/SIZE]
sudo apt-get build-dep <package-name>
This is the only thing that will change the build. If you do not have this step you will build an exact duplicate of the original package. You can pass flags(options) to the compiler using CXXFLAGS and CFLAGS. For which options you can add have a look at http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options
- [SIZE=3][COLOR=Indigo]Add your own compiling flags[/COLOR][/SIZE]
Add these flags to your environment file.
sudo kate /etc/environment
and add for example*(note that this is a pentium3; change for your own cpu type.) *
CFLAGS="-O2 -march=pentium3 -funroll-loops -ffast-math -fomit-frame-pointer -fno-exceptions"
CXXFLAGS="-O2 -march=pentium3 -funroll-loops -ffast-math -fomit-frame-pointer -fno-exceptions"
Restart computer to get the variables into the system or do an *export CFLAGS CXXFLAGS* after you have typed the above into konsole.
- [SIZE=3][COLOR=Indigo]Download <package-name> and compile it to a deb-package[/COLOR][/SIZE]
sudo apt-get -b source **<package-name>**
[COLOR=Purple] 3.1[/COLOR] [COLOR=Purple]Download & Compile with a seperate command[/COLOR] If you want to download the source and do a compile after maybe twinkling with some files do the above but remove the *-b* option then to compile and build a .deb``` sudo dpkg-buildpackage -rfakeroot -uc -b
[*][SIZE=3][COLOR=Indigo]Install
[/COLOR][/SIZE]```
sudo dpkg -i *.deb
[SIZE=3][COLOR=Indigo]How to revert back to the original <package-name>[/COLOR][/SIZE]
sudo apt-get install --reinstall <package-name>
[SIZE=3][COLOR=DarkSlateGray]Packages that might improve your system[/COLOR][/SIZE][INDENT][COLOR=Blue]KDE[/COLOR] kdebase kdelibs libqt3-mt*(These libraries use qmake which uses QMAKE_CFLAGS. Please use option 3.1 and then add your build options to ./qt-x11-free-3.3.4/mkspecs/linux-g++**/qmake.conf)*
[COLOR=Olive]Gnome[/COLOR] (Don't know sorry; Anyone know which the important base packages are?)
[/INDENT][SIZE=3][COLOR=Indigo]Problems[/COLOR][/SIZE][SIZE=3][COLOR=Indigo] with this method[/COLOR][/SIZE] The above howto will not work on all packages since it depends on how they were packaged. If the package doesn't take the systems CFLAGS into account the it won't change a thing. Also packages using qmake won't work. To provide you with a solution to the first problem I will give you this script which I myself use. It solves the above problem by scanning the directoy and replacing occurances of -O2 with $CFLAG (not pretty but it works).
#!/bin/bash
if [ -n "$1" ]
then
echo ":: fetching necessary packages for build"
apt-get build-dep "$@"
echo ":: fetching source"
apt-get source "$@"
fi
ourflags=$CFLAGS
echo :: using $ourflags
for directory in `ls -Al | awk '/^d/ {print $8}'`;
do
echo :: entering directory $directory ...
cd $directory
sed -e 's/-O2/'"${ourflags}"'/g' -i `ls -Al | awk '/^-/ {print $8}'`
cd debian
sed -e 's/-O2/'"${ourflags}"'/g' -i `ls -Al | awk '/^-/ {print $8}'`
cd ..
dpkg-buildpackage -rfakeroot -uc -b
echo :: leaving directory $directory ...
cd ..
done
Make it executable. ``` sudo chmod +x ./recompile
Use it as either **sudo ./recompile <package(s)>**. This will fetch dependencies and source before building. You can also use if for more then one package which is nice.
Or just do a **sudo ./recompile**. This will assume you already have the source and it will only build.
**Note**...use this within a new directory otherwise it will span thrue your other directories and files.
Please note that this is not a discussion about if or not other packages should be available. This is for those who like to have fun with their computer and change it to their own taste. This provides a safe way to do that since reverting back is so easy.