aboutsummaryrefslogtreecommitdiff
path: root/src/scripts/axiom.in
blob: 3b1b7c3cb45c6740e51cca6d34cfaeed57a2fff6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/bin/sh

# Start everything for Axiom.
#
# axiom
#      [-ht   |-noht]	    whether to use HyperDoc
#      [-gr   |-nogr]	    whether to use Graphics
#      [-clef |-noclef]	    whether to use Clef
#      [-nag |-nonag]	    whether to use NAG
#      [-iw   |-noiw]	    start in interpreter window
#      [-ihere|-noihere]    start an interpreter buffer in the original window
#      [-nox]		    don't use X Windows
#      [-go  |-nogo]	    whether to start system
#      [-ws wsname]	    use named workspace
#      [-list]		    list workspaces only
#      [-grprog fname]	    use named program for Graphics
#      [-nagprog fname]	    use named program for Nag
#      [-htprog fname]	    use named program for HyperDoc
#      [-clefprog fname]    use named program for Clef
#      [-sessionprog fname] use named program for session
#      [-clientprog fname]  use named program for spadclient
#      [-h]		    show usage
#
#

## Where The Axiom system resides
prefix=@prefix@
exec_prefix=@exec_prefix@
AXIOM=@libdir@/axiom/target/@target@
export AXIOM

## We adjust the value of PATH here because, currently, some Axiom 
## programs are called from the executing shell, and relying on the 
## fact that the executables are reachable from the PATH.
PATH=$AXIOM/bin:$PATH

## If the system is built without Superman support, there is
## no point in trying to forcefully use Superman
use_sman=@axiom_use_sman@


MALLOCTYPE=3.1
export MALLOCTYPE

# NAGMAN needs to know the hostname
HOST=`hostname`
export HOST

# 0. Basic utilities

ciao() {
	echo "Goodbye."
	exit 1
}

needsubopt () {
	echo "The $1 option requires an argument."
	ciao
}


showuse() {
echo "axiom"
echo "     [-ht   |-noht]       whether to use HyperDoc"
echo "     [-gr   |-nogr]       whether to use Graphics"
echo "     [-clef |-noclef]     whether to use Clef"
echo "     [-nag |-nonag]       whether to use NAG"
echo "     [-iw   |-noiw]       start in interpreter window"
echo "     [-ihere|-noihere]    start an interpreter buffer in the original window."
echo "     [-nox]               don't use X Windows"
echo "     [-go  |-nogo]        whether to start system"
echo "     [-ws wsname]         use named workspace"
echo "     [-list]              list workspaces only"
#echo "     [-grprog fname]      use named program for Graphics"
#echo "     [-nagprog fname]      use named program for Nag"
#echo "     [-htprog fname]      use named program for HyperDoc"
#echo "     [-clefprog fname]    use named program for Clef"
#echo "     [-sessionprog fname] use named program for session"
#echo "     [-clientprog fname]  use named program for spadclient"
echo "     [-h]                 show usage"
}

# 1. Ensure the environment is set.

# Just process '-h'

if [ "$*" = "-h" ] ; then
     showuse
fi

if [ "$SPAD" = "" ] ; then
  if [ "$AXIOM" = "" ] ; then
    echo "AXIOM variable is not set"
    exit 1
  else
    SPAD=$AXIOM
  fi
  export SPAD
else
  if [ "$AXIOM" = "" ] ; then
    echo "AXIOM variable is not set"
    echo "but SPAD = $SPAD"
    echo "Using AXIOM = $SPAD"
    AXIOM=$SPAD
    export AXIOM
  else
    if [ ! "$SPAD" = "$AXIOM" ] ; then
       echo "ignoring SPAD variable"
       SPAD=$AXIOM
    fi
  fi
fi

if [ "$AXIOMXLROOT" = "" ] ; then 
AXIOMXLROOT=${AXIOM}/compiler
fi
export AXIOMXLROOT
PATH=$AXIOMXLROOT/bin:${PATH}
export PATH



if [ ! -d "$SPAD" ] ; then
  echo "The directory for Axiom, $SPAD, does not exist."
  ciao
fi

# Name the workspace directories.
rootwsdir=$SPAD/bin

# 2. Process command line arguments.

# Defaults for command-line arguments.
list=no
go=yes
wsname=AXIOMsys

otheropts=""

while [ "$*" != "" ] ; do

	case $1 in
        -list)  list=yes
                go=no;;
	-go)	go=yes ;;
	-nogo)	go=no ;;

	-ws)
		if [ "$2" = "" ] ; then needsubopt "$1" ; fi
		shift
		wsname="$1"
		;;

	-nagprog|-grprog|-htprog|-clefprog|-sessionprog|-clientprog|-paste|-rm|-rv)
		if [ "$2" = "" ] ; then needsubopt "$1" ; fi
		otheropts="$otheropts  $1 $2"
		shift
		;;
	-clef|-noclef|-gr|-nogr|-ht|-noht|-iw|-noiw|-ihere|-noihere|-nox|-nag|-nonag)
		otheropts="$otheropts $1"
		;;

	-h)
		go=no
		;;


	*)	echo "Unknown option: $1"
		echo "To use a specific workspace use, e.g.: spad -ws $1"
		ciao
		;;
	esac

	shift
done

# 3. List the available workspaces, if asked

listwspaces()
{
        echo "$1"
        ls -l $2 | grep "sys$"
        echo ""
}

if [ $list = yes ] ; then
          listwspaces "AXIOM workspaces in \$AXIOM/bin = $rootwsdir: " $rootwsdir
fi

# 5. Try to ensure a suitable workspace on this host.

if [ `expr $wsname : '.*/.*'` = 0 ] ; then
	serverws=$rootwsdir/$wsname
else
	serverws=$wsname
fi

if [ ! -f $serverws ] ; then
	showuse
	ciao
fi

# 6. Start processes

if [ $go = no ] ; then
	echo "Would now start the processes."
	echo exec $SPAD/bin/sman $otheropts -ws $serverws
	exit 0
fi

if [ $use_sman = "yes" ]; then
    exec $SPAD/bin/sman $otheropts -ws $serverws
else
    exec $serverws
fi