35
36:- module(prolog_config,
37 [ prolog_dump_runtime_variables/0,
38 apple_bundle_libdir/1
39 ]).
47:- multifile
48 prolog:runtime_config/2.
56prolog_dump_runtime_variables :-
57 ( '$cmd_option_val'(config, Format),
58 Format \== ''
59 -> prolog_dump_runtime_variables(Format)
60 ; prolog_dump_runtime_variables(sh)
61 ).
62
63prolog_dump_runtime_variables(Format) :-
64 print_flag(home, 'PLBASE', Format),
65 print_flag(arch, 'PLARCH', Format),
66 print_flag(address_bits, 'PLBITS', Format),
67 print_flag(version, 'PLVERSION', Format),
68 print_flag(shared_object_extension, 'PLSOEXT', Format),
69 print_flag(shared_object_search_path, 'PLSOPATH', Format),
70 print_flag(c_libdir, 'PLLIBDIR', Format),
71 print_flag(c_lib, 'PLLIB', Format),
72 print_flag(libswipl, 'PLLIBSWIPL', Format),
73 print_flag(open_shared_object, 'PLSHARED', Format),
74 print_flag(threads, 'PLTHREADS', Format).
75
76print_flag(Flag, Var, Format) :-
77 ( prolog:runtime_config(Flag, Value)
78 -> print_config(Format, Var, Value)
79 ; flag_value(Flag, Value)
80 -> print_config(Format, Var, Value)
81 ; true
82 ).
83
84flag_value(Flag, Value) :-
85 boolean_flag(Flag),
86 ( current_prolog_flag(Flag, true)
87 -> Value = yes
88 ; Value = no
89 ).
90flag_value(c_libdir, Value) :-
91 current_prolog_flag(home, Home),
92 ( current_prolog_flag(c_libdir, Rel)
93 -> atomic_list_concat([Home, Rel], /, Value)
94 ; current_prolog_flag(windows, true)
95 -> atomic_list_concat([Home, bin], /, Value)
96 ; apple_bundle_libdir(LibDir)
97 -> Value = LibDir
98 ; current_prolog_flag(arch, Arch)
99 -> atomic_list_concat([Home, lib, Arch], /, Value)
100 ).
101flag_value(c_lib, '-lswipl').
102flag_value(Flag, Value) :-
103 current_prolog_flag(Flag, Value).
111apple_bundle_libdir(LibDir) :-
112 current_prolog_flag(apple, true),
113 current_prolog_flag(executable, Exe),
114 file_directory_name(Exe, ExeDir),
115 file_base_name(ExeDir, 'MacOS'),
116 file_directory_name(ExeDir, ContentsDir),
117 file_base_name(ContentsDir, 'Contents'),
118 atomic_list_concat([ContentsDir, 'Frameworks'], /, LibDir),
119 exists_directory(LibDir).
120
121boolean_flag(threads).
122boolean_flag(open_shared_object).
123
124print_config(sh, Var, Value) :-
125 format('~w=\"~w\";~n', [Var, Value]).
126print_config(cmd, Var, Value) :-
127 ( file_var(Var)
128 -> prolog_to_os_filename(Value, OSValue),
129 format('SET ~w=~w~n', [Var, OSValue])
130 ; format('SET ~w=~w~n', [Var, Value])
131 ).
132
133file_var('PLBASE')
Provide configuration information
This module provides information about the configuration to facilitate linking against Prolog, embedding Prolog or calling Prolog. */