Hello, again (and quicker than last time) !
When it comes to solving a problem, much is said about the value of knowing precisely which screws to twist, rather than being capable of twisting a lot of screws. But what we normally neglect is that first you need to know how to use a screwdriver !
Well, it seems like that is a good analogy for software development of a certain magnitude.
Scilab surely is a complex project, and even the tools used to automate much of its code development, maintenance and compilation also end up being of a little complex usage.
At least at first sight.
If you are somehow familiar with Linux and building programs from source, you most probably already faced this [maybe infamous] installation pattern on your terminal:
The make command always look for a file named Makefile, located in the current shell folder. Makefiles are something used on many platforms (like Linux, Windows and MacOS) to automate the process of calling the right platform compiler (gcc, clang, msvc, etc.) and linker, setting the compiler/linker flags and listing all the sources and libraries involved on the build of your project. Without it, you would have to define all that stuff by hand every time.
The problem is that writing a Makefile could become laborious and error prone, as your project gets to big or subject to some variability (“What if I could have implementations X and Y of the same library interface”).
That’s when tools to automatically generate those build files (“makemakes”) come to rescue, being almost mandatory if one wishes to keep its sanity.
Maybe you already heard about projects like CMake, SCons, qmake or whatever, which are cross-platform and somehow modern programs intended for that purpose. But before them, on Linux, there was autotools.
The configure script we run before the actual building (make) process is the autotools Makefile generator. Which is in turn generated from the configure.ac definition file.
Seriously ?
Actually, there is more to it.
Autotools is a set of 3 different applications, used in sequence before and during the building operations. In each step, simpler input configuration files is used to generate more complex and specific ones.
According to Scilab’s Wiki:
-
automake takes all Makefile.am handwritten files listed in configure.ac and generates corresponding Makefile.in files.
-
autoconf takes configure.ac to generate the configure script, used to produce a Makefile for each Makefile.in.
-
libtool is used during compilation (running make) to build the internal project libraries, if any.
Learning how those work, at least superficially, was essential for adding my jupyter module to the whole Scilab’s build.
Firstly, each module folder contains its own Makefile.am, for creating the module’s internal libray. I copied as little as needed (or slightly more than that) from other existing modules to write mine:
- SCI/modules/jupyter/Makefile.am
Then, we include the new file in the configure.ac list. As the jupyter module addition would require extra dependencies (ZeroMQ and native UUID library), it’s possible to allow its disablement by creating a new configuration option, and check for their existance in the running operating system.
- SCI/configure.ac
After that, we conditionally add our module library to the linking process:
- SCI/modules/Makefile.am
Finally, we add a new executable target to the base Makefile.am, from now, based on the scilab-cli-bin one (no graphical features).
- SCI/Makefile.am
With all that done, we can recreate the automatically generated files by calling, in sequence, from the base (SCI) folder:
Or simply, automating things a little more:
Now we can run our new and shiny configure script and then call make, in the hopes that we didn’t break anything…
It kinda worked here. I had some execution issues that I need to investigate, but building went until the end (Yay!).
To be fair, I’m probably still behind schedule, since last month kept requiring more academic effort then expected (I can’t get proper vacations, for goodness sake !). But assimilating the necessary tools to successfully integrate my project to Scilab’s’ main tree was definitely an important milestone in delivering a functional product.
I believe I can move faster without this obstacle, and we still have 15 days to the start of the deadline. So let’s move on…
See you next time !!