1#! /bin/sh
2# This is called as
3#    run directory-it-is-in appname scriptname args
4# args can start with some mix of --fox, --wx etc and those
5# are used to select a variant of the code to use, so in particular
6# --degug will select the (slower) debugging version and some of the
7# other options activate experimental development versions.
8#
9here="$1"
10ap="$2"
11scr="$3"
12shift
13shift
14shift
15
16# If you need to debug this script alter maybe_echo so it displays stuff!
17#maybe_echo=echo
18maybe_echo=:
19
20# The options here are only really relevent to hard-core CSL hackers. They
21# make it possible to launch versions of the system that have been built
22# with various experimental and debugging options. There are here to make
23# it possible for those who are working on such developments to run their
24# special version of the code in a way that makes it easy for them to switch
25# between that and the standard version, and hence easy to compare output and
26# performance.
27while :
28do
29  $maybe_echo First arg: ${1:-nothing}
30  case ${1:-nothing} in
31  --debug)
32    debug="-debug"
33    shift
34    ;;
35  --fox)
36    fox="-fox"
37    shift
38    ;;
39  --wx)
40    wx="-wx"
41    shift
42    ;;
43  --arithlib)
44    arithlib="-arithlib"
45    shift
46    ;;
47  --conservative)
48    conservative="-conservative"
49    shift
50    ;;
51  *)
52    break
53    ;;
54  esac
55done
56
57version="$fox$wx$arithlib$conservative$debug"
58
59$maybe_echo Operating system: x$OS
60case "x$OS" in
61xWindows_NT)
62# Now I will want to check which variant of reduce to use...
63  pre=""
64  suffix=".com"
65
66  for x in $*
67  do
68    $maybe_echo Arg to executable: $x
69    if test "$x" = "--nogui" ||
70       test "$x" = "-w-" ||
71       test "$x" = "-w"
72    then
73      withgui="no"
74      break
75    fi
76  done
77# On Cygwin (and here I have the cygwin64 case) I will behave as follows:
78#    --nogui or -w or -w- present on the command line: these indicate
79# that a console style use of Reduce is required. So run the explicitly
80# cygwin64 variant so it knows how to interact with a cygwin console.
81# Also if the --nogui option is not selected so a GUI is requested and
82# if DISPLAY is set also use the cygwin64 version that will use X11 for its
83# display.
84  $maybe_echo withgui=$withgui DISPLAY=$DISPLAY
85  if test "$withgui" = "no" || ! test -z "$DISPLAY"
86  then
87    pre="cygwin64-"
88    suffix=".exe"
89    cygwin="yes"
90# Otherwise the request was for the default behaviour, which is to use
91# the GUI, and the Windows-native version should be the one used.
92  fi
93
94  $maybe_echo ap=$ap
95  if test "x$ap" = "xbootstrapreduce"
96  then
97    suffix=".exe"
98  fi
99
100# If I have built anything using the "new layout" I will try that!
101  $maybe_echo test for new dir structure case $here/cslbuild/intel-pc-windows*
102  case $here/cslbuild/intel-pc-windows*
103  in
104  \*)
105    ;;
106  *)
107    pre=""
108    suffix=""
109    ;;
110  esac
111
112# I put an ordered list of preferences here. I put 64-bit release
113# versions first: FOX-based, wxWidgets-based and a version without a GUI
114# at all. These (if available) will support large memory and might (I hope)
115# run fastest. If none of those
116# are present I try for the same varieties but with debug builds. I will use
117# the first of these where I find a built version...
118# I now put "intel-pc-windows" first and that is the name used by my
119# "new layout" - when it is in general use I can withdraw a load of the
120# rest of the complication that is here!
121  $maybe_echo cygwin=$cygwin
122  if test "x$cygwin" = "xyes"
123  then
124    versions="intel-pc-windows \
125              x86_64-pc-cygwin"
126  else
127    versions="intel-pc-windows \
128              x86_64-pc-windows \
129              x86_64-pc-cygwin"
130  fi
131  $maybe_echo version=$versions
132  for hx in $versions
133  do
134    $maybe_echo Try: $here/../cslbuild/$hx$version/csl/$pre$ap$suffix
135    if test -x $here/../cslbuild/$hx$version/csl/$pre$ap$suffix
136    then
137      $maybe_echo exec $here/../cslbuild/$hx$version/csl/$pre$ap$suffix $xtra $CSLFLAGS $*
138      exec $here/../cslbuild/$hx$version/csl/$pre$ap$suffix $xtra $CSLFLAGS $*
139      exit 0
140    fi
141    $maybe_echo Try: $here/..cslbuild/$hx$version/$pre$ap$suffix
142    if test -x $here/../cslbuild/$hx$version/$pre$ap$suffix
143    then
144      $maybe_echo exec $here/../cslbuild/$hx$version/$pre$ap$suffix $xtra $CSLFLAGS $*
145      exec $here/../cslbuild/$hx$version/$pre$ap$suffix $xtra $CSLFLAGS $*
146      exit 0
147    fi
148  done
149# If only a cygwin version has been built this next fragment (which looks
150# for eg reduce.exe rather than either cygwin-reduce.exe or reduce.com)
151# may sometimes help.
152  for hx in $versions
153  do
154    $maybe_echo Try: $here/../cslbuild/$hx$version/csl/$ap.exe
155    if test -x $here/../cslbuild/$hx$version/csl/$ap.exe
156    then
157      $maybe_echo exec $here/../cslbuild/$hx$version/csl/$ap.exe $xtra $CSLFLAGS $*
158      exec $here/../cslbuild/$hx$version/csl/$ap.exe $xtra $CSLFLAGS $*
159      exit 0
160    fi
161  done
162  ;;
163*)
164  host0=`$here/../config.guess`
165  host=`$here/findhost.sh $host0`
166  $maybe_echo if test -x $here/../cslbuild/$host$version/csl/$ap
167  if test -x $here/../cslbuild/$host$version/csl/$ap
168  then
169    $maybe_echo exec $here/../cslbuild/$host$version/csl/$ap $CSLFLAGS $*
170    exec $here/../cslbuild/$host$version/csl/$ap $CSLFLAGS $*
171    exit 0
172  fi
173  ;;
174esac
175
176# Here a there does not seem to be a version made for the EXACT operating
177# system version that we are running on at present.
178
179echo Failed to find a version of $ap that you have built
180echo try "./configure; make" to build one.
181
182exit 1
183