Note: This article applies only to distortos v0.1.0 – v0.6.0.
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.
kconfig-frontends has 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:
- autoconf (optional),
- bison or yacc,
- curl (optional),
- ncurses library,
- patch (optional),
- tar (optional).
1. Download and extract the source tarball
This step is pretty obvious and requires no detailed explanation. Just open your shell and execute following commands.
$ curl -O http://ymorin.is-a-geek.org/download/kconfig-frontends/kconfig-frontends-184.108.40.206.tar.xz $ tar -xf kconfig-frontends-220.127.116.11.tar.xz
Alternatively you can do the same by opening project’s website, downloading latest release with your browser and extracting it anywhere using the tools available in your system.
Before proceeding with the following steps,
cd into the extracted kconfig-frontends package with your shell.
$ cd kconfig-frontends-18.104.22.168
2. Patch (optional)
If your system has gperf 3.0.4 or earlier, you may safely skip this chapter.
gperf 3.1 (released on 5th January of 2017) changed the type used as length argument in generated functions from
unsigned int to
size_t. This will cause your build to fail with following error message:
CC libkconfig_parser_la-yconf.lo In file included from yconf.c:234:0: hconf.gperf:141:1: error: conflicting types for 'kconf_id_lookup' hconf.gperf:12:31: note: previous declaration of 'kconf_id_lookup' was here static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); ^~~~~~~~~~~~~~~ make: *** [Makefile:456: libkconfig_parser_la-yconf.lo] Error 1 make: *** [Makefile:350: all] Error 2 make: *** [Makefile:334: all-recursive] Error 1 make: *** [Makefile:385: all-recursive] Error 1
The procedure to fix it is pretty straightforward – it requires patching kconfig-frontends and regenerating configure & build scripts.
First download the patch file using curl.
$ curl -O https://gist.githubusercontent.com/KamilSzczygiel/d16a5d88075939578f7bd8fadd0907aa/raw/1928495cfb6a6141365d545a23d66203222d28c0/kconfig-frontends.patch
We can now apply the patch to the kconfig-frontends.
$ patch -p1 -i kconfig-frontends.patch
As the patch modifies sources of configuration and build files, they have to be regenerated.
$ autoreconf -fi
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.
4. 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.
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-22.214.171.124.tar.xz $ tar -xf kconfig-frontends-126.96.36.199.tar.xz $ cd kconfig-frontends-188.8.131.52 # -- begin optional - required only for gperf 3.1 or newer -- $ curl -O https://gist.githubusercontent.com/KamilSzczygiel/d16a5d88075939578f7bd8fadd0907aa/raw/1928495cfb6a6141365d545a23d66203222d28c0/kconfig-frontends.patch $ patch -p1 -i kconfig-frontends.patch $ autoreconf -fi # -- end optional -- $ ./configure --enable-conf --enable-mconf --disable-shared --enable-static $ make $ sudo make install $ sudo strip /usr/local/bin/kconfig-*
One thought on “Building kconfig-frontends in Linux”
Hey man great catch. I saw the same issue, but soon found myself running down a rabbit chasing the references. Thank you for teaching me how to patch and to fix that error. You da best 🙂
Comments are closed.