## E.3 Software support to keep track of license conditions

Given the above, it is possible that SWI-Prolog packages and extensions will rely on the GPL.168On the Unix version, the default toplevel uses the GNU readline library for command line editing. This library is distributed under the GPL. In practice this problem is small as most final applications have Prolog embedded, without direct access to the command line and therefore without need for `libreadline`. The predicates below allow for registering license requirements for Prolog files and foreign modules. The predicate eval_license/0 reports which components from the currently configured system are distributed under copy-left and open source enforcing licenses (the GPL) and therefore must be replaced before distributing linked applications under non-free license conditions.

eval_license
  Evaluate the license conditions of all loaded components. If the system contains one or more components that are licenced under GPL-like restrictions the system indicates this program may only be distributed under the `GPL` license as well as which components prohibit the use of other license conditions.
license(+LicenseId, +Component)
  Register the fact that Component is distributed under a license identified by LicenseId. The most important LicenseId's are:
  swipl
    Indicates this module is distributed under the GNU General Public License (GPL) with the SWI-Prolog exception:169This exception is a straight re-phrasing of the license used for `libgcc`, the GNU C runtime library facing similar technical issues.

    > As a special exception, if you link this library with other files, compiled with SWI-Prolog, to produce an executable, this library does not by itself cause the resulting executable to be covered by the GNU General Public License. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License.

    This should be the default for software contributed to the SWI-Prolog project as it allows the community to prosper both in the free and non-free world. Still, people using SWI-Prolog to create non-free applications must contribute sources to improvements they make to the community.

  lgpl
    This is the default license for foreign libraries linked with SWI-Prolog. Use PL_license() to register the condition from foreign code.
  gpl
    Indicates this module is strictly Free Software, which implies it cannot be used together with any module that is incompatible with the GPL. Please only use these conditions when forced by other code used in the component.

  Other licenses known to the system are `guile`, `gnu_ada`, `x11`, `expat`, `sml`, `public_domain`, `cryptix`, `bsd`, `zlib`, `lgpl_compatible` and `gpl_compatible`. New licenses can be defined by adding clauses for the multifile predicate license:license/3. Below is an example. The second argument is either `gpl` or `lgpl` to indicate compatibility with these licenses. Other values cause the license to be interpreted as proprietary. Proprietary licenses are reported by eval_license/0. See the file `boot/license.pl` for details.

      :- multifile license:license/3.

      license:license(mylicense, lgpl,
                      [ comment('My personal license'),
                        url('http://www.mine.org/license.html')
                      ]).

      :- license(mylicense).

license(+LicenseId)
  Intended as a directive in Prolog source files. It takes the current filename and calls license/2.
void PL_license(const char *LicenseId, const char *Component)
  Intended for the install() procedure of foreign libraries. This call can be made before PL_initialise().