/*  plrc,v 1.2 1995/08/16 11:49:09 jan Exp

    Part of SWI-Prolog
    Designed and implemented by Jan Wielemaker
    E-mail: jan@swi.psy.uva.nl

    Copyright (C) 1995 University of Amsterdam. All rights reserved.
*/


/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This file is loaded  on  startup.  Use   it  for  local  (not  personal)
configuration purposes.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

:- initialization op(100, fx,  @).
:- initialization op(150, yfx, ?).
:- initialization op(990, xfx, :=).

:- multifile
	file_search_path/2.

:- dynamic
	pcehomestore_/1.
:- volatile
	pcehomestore_/1.

pcehome_(Home) :-
	pcehomestore_(Home), !.
pcehome_(Home) :-
	(   getenv('XPCEHOME', RawHome)
	;   feature(home, PlHome),
	    (   feature(xpce_version, Version),
		concat('/xpce-', Version, Suffix)
	    ;   Suffix = '/xpce'
	    ),
	    concat(PlHome, Suffix, RawHome)
	),
	exists_directory(RawHome), !,
	absolute_file_name(RawHome, Home),
	asserta(pcehomestore_(Home)).

file_search_path(pce, PceHome) :-
	pcehome_(PceHome).
file_search_path(library, pce('/prolog/lib')).
file_search_path(foreign, pce(ArchLib)) :-
	feature(arch, Arch),
	concat('lib/', Arch, ArchLib).
file_search_path(foreign, pce(lib)).

:-  initialization
    (   \+ feature(saved_program, true),
	pcehome_(PceHome),
	exists_directory(PceHome),
	'$argv'([Proc|Args]),
	(   member('-pce', Args)
	;   '$apropos_match'(pce, Proc)
	)
    ->  object(@pce),			% silent autoload loading
	use_module(library(pce)),	% import all
	flag('$banner_goal', _, pce_welcome)
    ;   true
    ).
