View source with raw comments or as raw
    1/*  Part of SWI-Prolog
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@vu.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (c)  2014-2018, VU University Amsterdam
    7                              CWI, Amsterdam
    8    All rights reserved.
    9
   10    Redistribution and use in source and binary forms, with or without
   11    modification, are permitted provided that the following conditions
   12    are met:
   13
   14    1. Redistributions of source code must retain the above copyright
   15       notice, this list of conditions and the following disclaimer.
   16
   17    2. Redistributions in binary form must reproduce the above copyright
   18       notice, this list of conditions and the following disclaimer in
   19       the documentation and/or other materials provided with the
   20       distribution.
   21
   22    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   23    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   24    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   25    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   26    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   27    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   28    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   29    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   30    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   32    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   33    POSSIBILITY OF SUCH DAMAGE.
   34*/
   35
   36:- module(prolog_install,
   37          [ qcompile_libraries/0,
   38            cmake_qcompile/0,
   39            cmake_qcompile/2,                   % +File, +Deps
   40            cmake_save_man_index/0
   41          ]).   42:- use_module(library(make)).   43:- use_module(library(apply)).   44:- use_module(library(lists)).

Installation support predicates

This module provides helper predicates for build and install steps. */

 qcompile_libraries
Quick-load compilation of the Prolog libraries.
   55qcompile_libraries :-
   56    make,                           % update library index
   57    qcompile_xpce.
   58
   59qcompile_xpce :-                        % no XPCE around
   60    \+ absolute_file_name(swi(xpce),
   61                          [ access(exist),
   62                            file_type(directory),
   63                            file_errors(fail)
   64                          ], _),
   65    !,
   66    print_message(informational, qcompile(no(xpce))).
   67qcompile_xpce :-
   68    (   absolute_file_name(swi('swipl-win.rc'), _,
   69                           [ access(read),
   70                             file_errors(fail)
   71                           ])
   72    ->  use_module(swi('swipl-win.rc'))
   73    ;   true
   74    ),
   75    qcompile_libs.
   76
   77
   78                 /*******************************
   79                 *       PRECOMPILED PARTS      *
   80                 *******************************/
   81
   82qmodule(pce, library(pce)).
   83qmodule(lib, library(pce_manual)).
   84qmodule(lib, library(pcedraw)).
   85qmodule(lib, library('emacs/emacs')).
   86qmodule(lib, library('dialog/dialog')).
   87qmodule(lib, library('trace/trace')).
   88qmodule(lib, library('cql/cql')).
   89
   90qcompile_libs :-
   91    forall(qmodule(_Type, Module),
   92           (   exists_source(Module)
   93           ->  print_message(informational, qcompile(Module)),
   94               qcompile(Module)
   95           ;   print_message(informational, qcompile(no(Module)))
   96           )).
   97
   98		 /*******************************
   99		 *   QLF COMPILATION FOR BUILD	*
  100		 *******************************/
 cmake_qcompile(+File, +Deps) is det
Qcompile on behalf of CMAKE installation. File is the file to be qcompiled. Deps is the dependencies as CMAKE believes to be true. Reports on inconsistent dependencies
  108cmake_qcompile :-
  109    current_prolog_flag(argv, ['--compile', File, '--qlfdeps' | Rest]),
  110    (   append(Deps, ['--preload'|Preload], Rest)
  111    ->  true
  112    ;   Deps = Rest,
  113        Preload = []
  114    ),
  115    forall(member(X, Preload), preload(X)),
  116    cmake_qcompile(File, Deps).
  117
  118preload(X) :-
  119    atom_concat('lib:', File, X),
  120    !,
  121    use_module(user:library(File)).
  122preload(X) :-
  123    use_module(user:X).
  124
  125
  126cmake_qcompile(File, Deps) :-
  127    qcompile(File),
  128    file_name_extension(File, qlf, QlfFile),
  129    '$qlf_sources'(QlfFile, Files),
  130    maplist(absolute_file_name, Deps, Canonical),
  131    subtract(Files, Canonical, Missing),
  132    subtract(Canonical, Files, Extra),
  133    (   Missing == []
  134    ->  true
  135    ;   print_message(warning, qcompile(missing, File, Missing))
  136    ),
  137    (   Extra == []
  138    ->  true
  139    ;   print_message(warning, qcompile(extra, File, Extra))
  140    ).
  141
  142		 /*******************************
  143		 *        MANUAL SUPPORT	*
  144		 *******************************/
 cmake_save_man_index
Create swi('doc/manindex.db') during the build process.
  150cmake_save_man_index :-
  151    use_module(library(pldoc/man_index)),
  152    save_man_index.
  153
  154
  155                 /*******************************
  156                 *            MESSAGES          *
  157                 *******************************/
  158
  159:- multifile prolog:message//1.  160
  161prolog:message(qcompile(no(What))) -->
  162    [ 'Cannot find ~w'-[What] ].
  163prolog:message(qcompile(library(Lib))) -->
  164    [ nl, '~*c'-[64, 0'*], nl ],
  165    [ 'Qcompile library ~q'-[Lib], nl ],
  166    [ '~*c'-[64, 0'*] ].
  167prolog:message(qcompile(missing, File, Dependencies)) -->
  168    [ 'The following dependencies for ~p are not listed'-[File] ],
  169    deps(Dependencies).
  170prolog:message(qcompile(extra, File, Dependencies)) -->
  171    [ 'The following dependencies for ~p are not needed'-[File] ],
  172    deps(Dependencies).
  173
  174deps([]) -->
  175    [].
  176deps([H|T]) -->
  177    [ nl, '  ~p'-[H] ],
  178    deps(T)