1#############################################################################
2##
3#W environment.gi 			 polymaking Package		 Marc Roeder
4##
5##
6
7##
8##
9#Y	 Copyright (C) 2006 Marc Roeder
10#Y
11#Y This program is free software; you can redistribute it and/or
12#Y modify it under the terms of the GNU General Public License
13#Y as published by the Free Software Foundation; either version 2
14#Y of the License, or (at your option) any later version.
15#Y
16#Y This program is distributed in the hope that it will be useful,
17#Y but WITHOUT ANY WARRANTY; without even the implied warranty of
18#Y MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19#Y GNU General Public License for more details.
20#Y
21#Y You should have received a copy of the GNU General Public License
22#Y along with this program; if not, write to the Free Software
23#Y Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24##
25SetInfoLevel(InfoPolymaking,1);
26
27# give the command which calles polymake. You may need to include the full path
28####
29
30if not IsBound(POLYMAKE_COMMAND)
31   then
32    POLYMAKE_COMMAND:=Filename( DirectoriesSystemPrograms( ), "polymake" );
33fi;
34if POLYMAKE_COMMAND=fail
35   or not IsExecutableFile(POLYMAKE_COMMAND)
36   then
37    Info(InfoWarning,1,"polymake command not found. Please set POLYMAKE_COMMAND by hand");
38else
39    MakeReadOnlyGlobal("POLYMAKE_COMMAND");
40fi;
41
42InstallMethod(SetPolymakeCommand,[IsString],
43        function(command)
44    if not IsExecutableFile(command)
45       then
46        Error("polymake command must exist and be executable.");
47    else
48        MakeReadWriteGlobal("POLYMAKE_COMMAND");
49        POLYMAKE_COMMAND:=command;
50        MakeReadOnlyGlobal("POLYMAKE_COMMAND");
51    fi;
52end);
53
54
55#
56# This directory will hold the files generated for polymake
57# It can be changed using "SetPolymakeDataDirectory"
58###
59if not IsBound(POLYMAKE_DATA_DIR)
60   then
61    POLYMAKE_DATA_DIR:=DirectoryTemporary();
62fi;
63MakeReadOnlyGlobal("POLYMAKE_DATA_DIR");
64
65
66InstallMethod(SetPolymakeDataDirectory,[IsDirectory],
67        function(dir)
68    MakeReadWriteGlobal("POLYMAKE_DATA_DIR");
69    POLYMAKE_DATA_DIR:=dir;
70    MakeReadOnlyGlobal("POLYMAKE_DATA_DIR");
71end);
72
73
74
75####
76###
77##  Handling of last fail reason:
78#
79InstallValue(POLYMAKE_LAST_FAIL_REASON,"");
80
81InstallMethod(UpdatePolymakeFailReason,[IsString],
82        function(reason)
83    MakeReadWriteGlobal("POLYMAKE_LAST_FAIL_REASON");
84    POLYMAKE_LAST_FAIL_REASON:=reason;
85    MakeReadOnlyGlobal("POLYMAKE_LAST_FAIL_REASON");
86end);
87
88