Page 1 of 3 123 LastLast
Results 1 to 10 of 29

Thread: HOWTO: Recompile packages for your system

  1. #1
    Join Date
    Apr 2005
    Location
    Stockholm, Sweden
    Beans
    331
    Distro
    Kubuntu 7.10 Gutsy Gibbon
    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
    1. Download needed header-files etc for <package-name>
      Code:
      sudo apt-get build-dep <package-name>
    2. 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.
    3. 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
    4. Install
      Code:
      sudo dpkg -i *.deb
    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 system
    KDE
    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.
    Last edited by GoldBuggie; December 20th, 2005 at 02:29 PM.

  2. #2
    Join Date
    Dec 2005
    Beans
    15

    Re: HOWTO: Recompile packages for your system

    Hello, nice howto but...

    ich have done it as described, but when iam compiling
    a package, it does not use my specified cflags at all...

    look here:

    g++ -c -pipe -I/usr/include/mysql -I/usr/include/freetype2 -I/usr/include/postgresql -I/usr/include/postgresql/8.0 -fno-exceptions -Wall -W -g -D_REENTRANT -fPIC -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT -DQT_THREAD_SUPPORT -D_LARGEFILE_SOURCE -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 -DQT_NAS_SUPPORT -DQT_DLOPEN_OPENGL -DQT_NO_IMAGEIO_MNG -DQT_BUILTIN_GIF_READER=1 -DQT_NO_STYLE_MAC -DQT_NO_STYLE_AQUA -DQT_NO_STYLE_CDE -DQT_NO_STYLE_MOTIFPLUS -DQT_NO_STYLE_INTERLACE -DQT_NO_STYLE_PLATINUM -DQT_NO_STYLE_WINDOWSXP -DQT_NO_STYLE_SGI -DQT_NO_STYLE_COMPACT -DQT_NO_STYLE_POCKETPC -DQT_NO_STYLE_WINDOWS -DQT_NO_STYLE_MOTIF -I/home/jan/Work/qt-x11-free-3.3.4/mkspecs/linux-g++ -I. -I/usr/include/freetype2 -I3rdparty/opentype -I../include -I/usr/X11R6/include -I.moc/debug-shared-mt/ -o .obj/debug-shared-mt/qbitmap.o kernel/qbitmap.cpp

    ...but my flags are:
    CFLAGS="-march=athlon-xp -O2 -fomit-frame-pointer -pipe -fvisibility-inlines-hidden"
    CXXFLAGS="-march=athlon-xp -O2 -fomit-frame-pointer -pipe -fvisibility-inlines-hidden"

    so, what can i do?

  3. #3
    Join Date
    May 2005
    Location
    Lecce, Italy
    Beans
    6,168
    Distro
    Ubuntu

    Re: HOWTO: Recompile packages for your system

    XXFLAGS and CFLAGS? They remind me of my previous Gentoo installation. I didn't know it could be done in Ubuntu.
    Thanks for the guide

  4. #4
    Join Date
    Apr 2005
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: HOWTO: Recompile packages for your system

    Nice guide

  5. #5
    Join Date
    Apr 2005
    Location
    Stockholm, Sweden
    Beans
    331
    Distro
    Kubuntu 7.10 Gutsy Gibbon

    Re: HOWTO: Recompile packages for your system

    Updated the howto to include a 3.1 section which first downloads the package then you can look at the files etc maybe change something then start the compile and build of .deb.


    funkyou

    Well I've not come across a package that does not include those options. Would be wrong if they aren't included I think. Anyhow...the flag options should be in the configure file. Do a
    Code:
    cat ./configure | grep FLAGS
    If they are there then you please look if you have exported your variables correctly. Just type echo $CFLAGS to do so.

    Which package are you building...maybe I can take a look.

    Must run now..I'm almost late for a appointment.

  6. #6
    Join Date
    Dec 2005
    Beans
    15

    Re: HOWTO: Recompile packages for your system

    Hello,

    at first, thank you for your help and support, its very appreciated.


    I tried to rebuild libqt3-mt and libqt3-mt-dev.

    this are my cflags and cxxflags:
    jan@agentj:~$ echo $CFLAGS
    -mtune=athlon-xp -O2 -fomit-frame-pointer -pipe -fvisibility-inlines-hidden
    jan@agentj:~$ echo $CXXFLAGS
    -mtune=athlon-xp -O2 -fomit-frame-pointer -pipe -fvisibility-inlines-hidden
    jan@agentj:~$



    The first way (before your section 3.1) does not work on my machine, as
    gcc does not use my flags. So i tried it the other way, first downloading
    the sources with apt, and then modifying the whole thing.

    Well, when i search through the configure script, i find many build options
    with the name cflags... so i tried something different... i looked through the
    qt-source-folder and found this file

    ~/Work/qt-x11-free-3.3.4/mkspecs/linux-g++/qmake.conf

    in which one can place the flags for the compiler on linux/gcc...
    i have modified the following line to:

    QMAKE_CFLAGS = -mtune=athlon-xp -O2 -fomit-frame-pointer -pipe -fvisibility-inlines-hidden


    I think this should work, but when i try to use the command from section
    3.1 of your howto, i get this error message:

    jan@agentj:~/Work$ sudo dpkg-buildpackage -rfakeroot -uc -b
    Password:
    dpkg-parsechangelog: error: cannot open debian/changelog to find format: Datei oder Verzeichnis nicht gefunden
    dpkg-buildpackage: unable to determine source package is


    I tried this in both my work-folder and in the qt-folder itself, but its not working.
    it claims to not find the debian changelog...

  7. #7
    Join Date
    Apr 2005
    Location
    Stockholm, Sweden
    Beans
    331
    Distro
    Kubuntu 7.10 Gutsy Gibbon

    Re: HOWTO: Recompile packages for your system

    the sudo dpkg-buildpackage -rfakeroot -uc -b command should be run in the same folder as you did the apt-get source. Have you installed fakeroot? sudo apt-get install fakeroot. As for not recoqnizing the cflags option that is just strange to my ears. I even compiled the libqt3-mt package and it worked as a charm. hmmmm...*must think*

    but doing it the search important files and chang is also an option. But it can just be to much sometimes so using the flags option is an easy way out.
    Last edited by GoldBuggie; December 13th, 2005 at 05:01 AM.

  8. #8
    Join Date
    Apr 2005
    Location
    Stockholm, Sweden
    Beans
    331
    Distro
    Kubuntu 7.10 Gutsy Gibbon

    Re: HOWTO: Recompile packages for your system

    Ok added a line about QMAKE_C(XX)FLAGS in the KDE section but I haven't made any tests yet. Will do tomorrow!

    But thanks funkyou for pointing it out. I looked thrue the package and noticed that some things are compiled using regular made makefiles and those include CFLAGS etc but since trolltech wants to make things their way(using qmake instead of make) you will have to use the above or change qmake.conf.

  9. #9
    Join Date
    Dec 2005
    Beans
    15

    Re: HOWTO: Recompile packages for your system

    Tried it again, but no succes...

    Didn't had the fakeroot package installed, but when i now try to
    invoke the sudo dpkg-buildpackage -rfakeroot -uc -b command
    at the work-folder (where i downloaded the packages), it gives
    me the same error message as posted below:

    jan@agentj:~/Work$ sudo dpkg-buildpackage -rfakeroot -uc -b
    Password:
    dpkg-parsechangelog: error: cannot open debian/changelog to find format: Datei oder Verzeichnis nicht gefunden
    dpkg-buildpackage: unable to determine source package is

  10. #10
    Join Date
    Apr 2005
    Location
    Stockholm, Sweden
    Beans
    331
    Distro
    Kubuntu 7.10 Gutsy Gibbon

    Re: HOWTO: Recompile packages for your system

    I think you are missing some package. Don't know which it is but I have the following installed
    ii automake1.4 1.4-p6-9 A tool for generating GNU Standards-complian
    ii automake1.6 1.6.3-12 A tool for generating GNU Standards-complian
    ii automake1.7 1.7.9-7 A tool for generating GNU Standards-complian
    ii automake1.8 1.8.5-3 A tool for generating GNU Standards-complian
    ii automake1.9 1.9.5-1 A tool for generating GNU Standards-complian
    ii dpkg 1.13.10ubuntu4 Package maintenance system for Debian
    ii dpkg-dev 1.13.10ubuntu4 Package building tools for Debian
    ii make 3.80-9 The GNU version of the "make" utility


    I think it might have something to do with automake.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •