Doesn't Not Compute

My log of experiences with GNU/Linux and computers in general.

Change the CFLAGS When Building a Debian Package from Source

I’m still having trouble figuring out the individual Debian packaging utilites (dh_buildpackage, dh_gencontrol, etc), but I’ve figured out a slightly inconvinent way to do what I want: get the program source, and build as a .deb package that I can uninstall with apt.

1. Download the stuff the program I want to compile requires — for example, links2, the graphics-capable version of links.

$ sudo apt-get install build-essential debhelper \
  && sudo apt-get build-dep links2  --no-install-recommends

2. Make a subdirectory in my home directory:

$ mkdir build

3. Download the program source code & available patches, extract from archive, and apply patches in one easy step (note that you don’t have to be, and should not be, root):

$ apt-get source links2

4. Change to the created directory:

    $ cd links2*

5. Edit the rules file, which will determine what commands are sent to the compiler. I think. Seems to work, anyway.

    $ nano Debian/rules

Scroll down to CFLAGS, and add the following (for a Pentium 3)

	-march=pentium3 -mtune=pentium3 -O2 -pipe -fomit-frame-pointer -funroll-loops

You can also add -ffast-math, but don’t come crying to me if something doesn’t work right as a result. It’s considered unsafe. That said, I haven’t seen a problem on this paticular program. has a list of safe CFLAGS, and has a list of flags that are less safe. These links will open in a new window, btw, if your browser  doesn’t support tabbed browsing.

6. Now package it. The resulting .deb files will be created in the directory above where you are now.

      $ fakeroot dpkg-buildpackage

7. Change directory to where the new packages are, and install the links2 package.

      $ cd .. && sudo dpkg -i links2*.deb

Works for me. Unfortunately, this only changes what compiler flags the package is made with; this is great for optimizing the software to your paticular processor, without giving up Debian’s wonderful package system, but does nothing for tell what options of the software itself to compile with those optimizations. For example, when I compile links2, I don’t want the atheos or pmshell graphic drivers. I don’t even know what those are :shock:. If I install it using the ./configure -> make -> sudo make install process, I can tell it to disable those capabilites, but I don’t get a nice, neat little .deb package.

I need to read more in the Debian wiki, I guess. Hopefully, w3m posts this correctly, because I don’t have Iceweasel installed, am sick of Kazehakase crashing whenever I watch more than 2 or 3 Flash videos in a row (irregardless of what player I use), don’t have Midori available, and can’t get links2 or elinks-lite to work with WordPress yet.

EDIT: It posted, but there were formatting errors. w3m sent me into Nano to create the post, so hitting Enter at the end of a line did not translate into a line-wrap in the post. Using the HTML tag for bold text did, however, so I just have to look up the tag for line-wrap and everything should be fine.

Speaking of w3m, if you use it with a framebuffer or on an X server on Debian, I recommend the w3m-img package. Strangely, the images don’t show up if you page-up to them, but work just fine if you page-down to them. Hmm…I should see if there’s a bug-report on that.


4 responses to “Change the CFLAGS When Building a Debian Package from Source

  1. Pingback: New Pages « Doesn't Not Compute

  2. flashtech October 21, 2016 at 6:22 pm

    You could definitely see your skills within the work you write.
    The world hopes for even more passionate writers such as you who aren’t afraid to say how they believe.
    All the time follow your heart.

  3. blog o podkladkach February 22, 2017 at 8:16 am

    I am regular reader, how are you everybody?
    This post posted aat this web page is genuinely good.

  4. Maestroteca.Com July 26, 2017 at 2:52 pm

    Awesome! Its truly remarkable piece of writing, I have got much clear idea on the topic of from
    this article.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: