Building kconfig-frontends in Linux

Preparing kconfig-frontends for Linux is a fast and simple process, similar (if not identical) to preparation of any software using autotools. Typically the whole process will require you to only download the source tarball, extract it somewhere and run ./configure && make && sudo make install in extracted folder. But if you want to understand what exactly is going on or if you have some problems with this simplistic approach – read on, as the rest of this article will go into the details of the process.

0. Prerequisites

kconfig-fronteds has only a few dependencies, which may already be present on your system. If they are not, make sure to install them before proceeding. Generally – apart from the obvious things like make, gcc, binutils and coreutils – you need:

  • bison or yacc,
  • flex,
  • gawk,
  • gperf,
  • ncurses library.

1. Download and extract the source tarball

This step is pretty obvious and requires no detailed explanation. Just open project’s website, download latest release with your browser and extract it anywhere using the tools available in your system. Alternatively you can do the same in your shell (which requires curl and tar, but these tools are most likely already present in your system):

$ curl -O http://ymorin.is-a-geek.org/download/kconfig-frontends/kconfig-frontends-3.12.0.0.tar.xz
$ tar -xf kconfig-frontends-3.12.0.0.tar.xz

2. Configure

Now open your shell and cd into the package you extracted in previous step:

$ cd kconfig-frontends-3.12.0.0

kconfig-frontend‘s configure script has a lot of options – if you are very curious, just execute ./configure --help. Below I’ll cover only the most important ones.

The first thing you should know is that there are multiple frontends available in the kconfig-frontends package:

  • conf – which is a “frontend” using only stdin and stdout, it asks you a question and you answer it with your keyboard by pressing y, n, 0, 1, etc., it can also be used to update existing configurations with default values of all new options;
  • mconf – which is the “traditional” frontend using ncurses;
  • nconf – “modern” frontend using ncurses;
  • gconf – graphical frontend using GTK+ libraries;
  • qconf – graphical frontend using Qt libraries;

For distortos you only need conf and mconf, so its a good idea to explicitly enable them in configure script with --enable-conf --enable-mconf. This way configure script will quit with an error if it’s not possible to build them – possibly due to missing dependency, which should tell you which one it was. Don’t worry about other frontends – they are not required for distortos and they will still be compiled if only their dependencies are present on your system.

To make things simpler, it is a good idea to enable static linking of binaries with --disable-shared --enable-static. This way the library which deals with parsing Kconfig files – libkconfig-parser – will be statically linked into each frontend which uses it. This obviously increases the size of compiled binaries, but we are talking about a few hundred kilobytes for each binary, so this really makes no difference nowadays (;

The last important option is --prefix. Default value of this option is /usr/local, which should be ok on most systems out there. If you need to adjust that, just add --prefix=/your/new/path/for/prefix to the invocation of configure script. Do note that for the compiled files to be usable, bin/ subfolder of that path (/usr/local/bin if you did not specify that option or /your/new/path/for/prefix/bin otherwise) should be in the PATH environment variable of your system.

So the recommended set of options to configure kconfig-frontends for use with distortos would be:

$ ./configure --enable-conf --enable-mconf --disable-shared --enable-static

If everything worked correctly, after a few seconds you should see something like this in your console:

configure: Configured with:
configure: - parser library : static
configure: - root-menu prompt : Configuration
configure: - config prefix : CONFIG_
configure: - frontends : conf gconf mconf nconf qconf
configure: - transform name : s&^&kconfig-&
configure: - localised : yes
configure: - install utilities : yes
configure: - CFLAGS CXXFLAGS : -Wall

The list of enabled frontends may be different, but it must have conf and mconf.

3. Compile and install

There is not much to say about last two steps – just compile and install the package in the standard way:

$ make
$ sudo make install

These two steps should both take less than a minute.

At the very end you may strip the installed executables to make them smaller – this step is not required, so you may as well skip it.

$ sudo strip /usr/local/bin/kconfig-*

Obviously you need to adjust the path if you selected another one with --prefix during package configuration.

Don’t worry if this produces a few “File format not recognized” errors – some of the files are shell scripts and cannot be stripped, this is normal and nothing to worry about.

Summary

Below you may find all shell commands listed in the paragraphs above. These should be all you need to do – just paste them into your shell, one by one.

$ curl -O http://ymorin.is-a-geek.org/download/kconfig-frontends/kconfig-frontends-3.12.0.0.tar.xz
$ tar -xf kconfig-frontends-3.12.0.0.tar.xz
$ cd kconfig-frontends-3.12.0.0
$ ./configure --enable-conf --enable-mconf --disable-shared --enable-static
$ make
$ sudo make install
$ sudo strip /usr/local/bin/kconfig-*