[Contents] [TitleIndex] [WordIndex

Full technical description of the incremental link / dynamic link in Scilab 5

Please note that this description is a developer description. Not a user one!

Description

Thanks to the incremental link in Scilab, anybody can compile sources (Fortran, C, C++...) from Scilab without worrying about Makefile, compiler, flags...

In Scilab 5, this system has been rewritten for GNU Linux/Unix in order to use advantages provided by the autotools.

As automake is not installed everywhere and as we do not want this software as a requirement for Scilab's Incremental Link to work, we had to use a little trick.

How it works ?

This part is for advanced users only who would like to understand how the Scilab Incremental Link works (or does not work).

The creation of the configure (files available in ''modules/incremental_link/src/scripts/'')

configure will be used to detect compilers (free and non-free), flags, linker on the computer which will execute Scilab. This script is generated thanks to autoconf against configure.ac.

Content of configure.ac :

# Initialise autoconf
AC_INIT([scilab],[0],[http://bugzilla.scilab.org/index.cgi])
# Initialise automake (foreign is low strictness)
AM_INIT_AUTOMAKE([foreign])
# Detect C compiler
AC_PROG_CC
# Detect C++ compiler
AC_PROG_CXX
# Detect Fortran Compiler (77 and 90)
AC_PROG_F77
# Initialise libtool
AC_PROG_LIBTOOL
# Specify which Makefile.in should be "adapted"
AC_CONFIG_FILES([Makefile])
# Configure the Makefile
AC_OUTPUT

configure is generated with the command :

autoconf

Note : This should be done only once for all by the Scilab team when releasing Scilab. However, under very special conditions, you may want to adapt this file or regenerate the configure with a more recent version of autoconf.

Creation of Makefile.in

Makefile.am is transformed by automake in order to generate Makefile.in. This file contains the compilation procedures to compile sources (C, C++, fortran).

Content of Makefile.am :

# The name of the library is not important but must remain the same
pkglib_LTLIBRARIES = libsciexternal.la
# Fake sources in order to make believe to the autotool that we are going
# to compile some C/C++, fortran sources.
# Thanks to this, automake will generate compilation targets for
# these 3 languages.
# Don't change name or order
libsciexternal_la_SOURCES = foo.c foo2.f foo3.cxx

By providing these three fake sources (they do not even exist) foo.c foo2.f foo3.cxx, automake will generate rules. For example, as automake detects that foo3.cxx is a C++ file, then, it will add to Makefile.in rules :

CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
        $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
[...]

Note : Just like configure.ac, in theory, nobody should touch this file. You may want to do this in order to manage an other language, if you do so, do not forget to update SCI/modules/incremental_link/src/scripts/scicompile.sh

The lambda user should not care about this. It is totally transparent for him.

Step by Step

The work is done about half in Scilab, the other in shell (sh/bash) :


  1. Detect if Scilab can write in SCI/modules/dynamic_link/src/scripts/. If it is the case, run the configure without any option in order to have a basic Makefile reference (which will be used most of the time)

  2. Copy all mandatory files into the temporary directory (configure.ac configure Makefile.am libtool Makefile.in config.sub config.guess depcomp install-sh ltmain.sh missing aclocal.m4). config.status will be also copied if the previous point has been executed.

  3. If no flags have been set (CFLAGS, FFLAGS, CC, LDFLAGS) and if ./configure has been executed, copy Makefile.orig into the temporary directory. Else, run the ./configure into the TMPDIR in order to check if the CC is valid, and/or give the flags to the Makefile (compilerDetection.sh is doing this task).

  4. Copy all the user sources into from the working into the temporary directory (We don't copy files ending by ".lo",".la",".lai")

  5. Adapt the template Makefile.orig with the library name and file list provided by the user. (scicompile.sh is doing this task) :

    1. Check if the files provided by the user do exist.
    2. Replaces file list (foo.c foo2.f foo3.cxx => <file 1> <file 2> ...)

    3. Replaces source file extension (.c .cxx .f) to .lo (libtool object file) in order to provide to am_libsciexternal_la_OBJECTS what it is waiting for.

    4. Replaces the library name (libsciexternal => lib<user library>) everywhere

    5. Removes *.Plo include directives (dependencies computed, not mandatory)
  6. Detect where the libstdc++ is located (thanks to the command gcc -print-search-dirs|grep ^install:|awk '{print $2} - since Scilab 5.3.2).

  7. Call the Makefile with the command make CFLAGS=-I"+SCI+"/modules/core/includes/ (this will be extended in the future)

  8. Copy the library back to the working directory (pwd)

2022-09-08 09:27