36
37:- module(prolog_config,
38 [ prolog_dump_runtime_variables/0,
39 prolog_config/2
40 ]).
48:- multifile
49 prolog:runtime_config/2.
57prolog_dump_runtime_variables :-
58 ( '$cmd_option_val'(config, Format),
59 Format \== ''
60 -> prolog_dump_runtime_variables(Format)
61 ; prolog_dump_runtime_variables(sh)
62 ).
63
64prolog_dump_runtime_variables(Format) :-
65 print_flag(home, 'PLBASE', Format),
66 print_flag(pack_path, 'SWIPL_PACK_PATH', Format),
67 print_flag(arch, 'PLARCH', Format),
68 print_flag(address_bits, 'PLBITS', Format),
69 print_flag(version, 'PLVERSION', Format),
70 print_flag(shared_object_extension, 'PLSOEXT', Format),
71 print_flag(shared_object_search_path, 'PLSOPATH', Format),
72 print_flag(c_libdir, 'PLLIBDIR', Format),
73 print_flag(c_lib, 'PLLIB', Format),
74 print_flag(libswipl, 'PLLIBSWIPL', Format),
75 print_flag(open_shared_object, 'PLSHARED', Format),
76 print_flag(threads, 'PLTHREADS', Format).
77
78print_flag(Flag, Var, Format) :-
79 ( prolog:runtime_config(Flag, Value)
80 -> print_config(Format, Var, Value)
81 ; prolog_config(Flag, Value)
82 -> print_config(Format, Var, Value)
83 ; true
84 ).
91prolog_config(Flag, Value) :-
92 boolean_flag(Flag),
93 ( current_prolog_flag(Flag, true)
94 -> Value = yes
95 ; Value = no
96 ).
97prolog_config(c_libdir, Value) :-
98 current_prolog_flag(home, Home),
99 ( current_prolog_flag(c_libdir, Rel)
100 -> atomic_list_concat([Home, Rel], /, Value)
101 ; current_prolog_flag(msys2, true)
102 -> current_prolog_flag(arch, Arch),
103 atomic_list_concat([Home, bin, Arch], /, Value)
104 ; current_prolog_flag(windows, true)
105 -> atomic_list_concat([Home, bin], /, Value)
106 ; apple_bundle_libdir(LibDir)
107 -> Value = LibDir
108 ; current_prolog_flag(arch, Arch)
109 -> atomic_list_concat([Home, lib, Arch], /, Value)
110 ).
111prolog_config(apple_bundle_libdir, LibDir) :-
112 apple_bundle_libdir(LibDir).
113prolog_config(c_lib, '-lswipl').
114prolog_config(pack_path, Value) :-
115 findall(Dir, absolute_file_name(pack(.), Dir,
116 [ file_errors(fail),
117 solutions(all)
118 ]),
119 Dirs),
120 maplist(prolog_to_os_filename, Dirs, OSDirs),
121 current_prolog_flag(path_sep, Sep),
122 atomic_list_concat(OSDirs, Sep, Value).
123prolog_config(Flag, Value) :-
124 current_prolog_flag(Flag, Value).
132apple_bundle_libdir(LibDir) :-
133 current_prolog_flag(apple, true),
134 current_prolog_flag(executable, Exe),
135 file_directory_name(Exe, ExeDir),
136 file_base_name(ExeDir, 'MacOS'),
137 file_directory_name(ExeDir, ContentsDir),
138 file_base_name(ContentsDir, 'Contents'),
139 atomic_list_concat([ContentsDir, 'Frameworks'], /, LibDir),
140 exists_directory(LibDir).
141
142boolean_flag(threads).
143boolean_flag(open_shared_object).
144
145print_config(sh, Var, Value) :-
146 format('~w=\"~w\";~n', [Var, Value]).
147print_config(cmd, Var, Value) :-
148 ( file_var(Var)
149 -> prolog_to_os_filename(Value, OSValue),
150 format('SET ~w=~w~n', [Var, OSValue])
151 ; format('SET ~w=~w~n', [Var, Value])
152 ).
153
154file_var('PLBASE')
Provide configuration information
This module provides information about the configuration to facilitate linking against Prolog, embedding Prolog or calling Prolog. */