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:- autoload(library(apply),[maplist/3]).   43:- autoload(library(lists),[append/3,member/2,subtract/3]).   44:- autoload(library(make),[make/0]).

Installation support predicates

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

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