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.
Code:
mkdir recompileUbuntuPackages
cd recompileUbuntuPackages
- Download needed header-files etc for <package-name>
Code:
sudo apt-get build-dep <package-name>
- Add your own compiling flags
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....002d64-Options
Add these flags to your environment file.
Code:
sudo kate /etc/environment
and add for example(note that this is a pentium3; change for your own cpu type.)
Code:
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. - Download <package-name> and compile it to a deb-package
Code:
sudo apt-get -b source <package-name>
3.1 Download & Compile with a seperate command
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
Code:
sudo dpkg-buildpackage -rfakeroot -uc -b
- Install
The <package-name> will have everything similar to the original except the change when compiling. So after you have installed the package you will still be able to see when new packages have arrived from ubuntu. In fact since you have changed the original package and installed it you will see them as available for update. But if you check the version you will see that they are the same.
How to revert back to the original <package-name>
Code:
sudo apt-get install --reinstall <package-name>
Packages that might improve your systemKDE
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)
Gnome
(Don't know sorry; Anyone know which the important base packages are?)
Problems with this method
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).
Code:
#!/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
Copy the script to a file; I named mine recompile.
Make it executable.
Code:
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.