35
36:- module(prolog_config,
37 [ prolog_dump_runtime_variables/0,
38 apple_bundle_libdir/1
39 ]). 40
46
47:- multifile
48 prolog:runtime_config/2. 49
55
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(open_shared_object, 'PLSHARED', Format),
73 print_flag(threads, 'PLTHREADS', Format).
74
75print_flag(Flag, Var, Format) :-
76 ( prolog:runtime_config(Flag, Value)
77 -> print_config(Format, Var, Value)
78 ; flag_value(Flag, Value)
79 -> print_config(Format, Var, Value)
80 ; true
81 ).
82
83flag_value(Flag, Value) :-
84 boolean_flag(Flag),
85 ( current_prolog_flag(Flag, true)
86 -> Value = yes
87 ; Value = no
88 ).
89flag_value(c_libdir, Value) :-
90 current_prolog_flag(home, Home),
91 ( current_prolog_flag(c_libdir, Rel)
92 -> atomic_list_concat([Home, Rel], /, Value)
93 ; current_prolog_flag(windows, true)
94 -> atomic_list_concat([Home, bin], /, Value)
95 ; apple_bundle_libdir(LibDir)
96 -> Value = LibDir
97 ; current_prolog_flag(arch, Arch)
98 -> atomic_list_concat([Home, lib, Arch], /, Value)
99 ).
100flag_value(c_lib, '-lswipl').
101flag_value(Flag, Value) :-
102 current_prolog_flag(Flag, Value).
103
109
110apple_bundle_libdir(LibDir) :-
111 current_prolog_flag(apple, true),
112 current_prolog_flag(executable, Exe),
113 file_directory_name(Exe, ExeDir),
114 file_base_name(ExeDir, 'MacOS'),
115 file_directory_name(ExeDir, ContentsDir),
116 file_base_name(ContentsDir, 'Contents'),
117 atomic_list_concat([ContentsDir, 'Frameworks'], /, LibDir),
118 exists_directory(LibDir).
119
120boolean_flag(threads).
121boolean_flag(open_shared_object).
122
123print_config(sh, Var, Value) :-
124 format('~w=\"~w\";~n', [Var, Value]).
125print_config(cmd, Var, Value) :-
126 ( file_var(Var)
127 -> prolog_to_os_filename(Value, OSValue),
128 format('SET ~w=~w~n', [Var, OSValue])
129 ; format('SET ~w=~w~n', [Var, Value])
130 ).
131
132file_var('PLBASE')