1#! /bin/sh
2#
3# BEGIN LICENSE BLOCK
4# Version: CMPL 1.1
5#
6# The contents of this file are subject to the Cisco-style Mozilla Public
7# License Version 1.1 (the "License"); you may not use this file except
8# in compliance with the License.  You may obtain a copy of the License
9# at www.eclipse-clp.org/license.
10# 
11# Software distributed under the License is distributed on an "AS IS"
12# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
13# the License for the specific language governing rights and limitations
14# under the License. 
15# 
16# The Original Code is  The ECLiPSe Constraint Logic Programming System. 
17# The Initial Developer of the Original Code is  Cisco Systems, Inc. 
18# Portions created by the Initial Developer are
19# Copyright (C) 1995-2006 Cisco Systems, Inc.  All Rights Reserved.
20# 
21# Contributor(s): IC-Parc, Imperial College London
22# 
23# END LICENSE BLOCK
24#
25# This is a shell script. Run it to install ECLiPSe.
26#
27
28#set -v
29
30usage="\
31Usage: $0 [options]
32Options:
33	--link
34		Link a new executable (don't ask)
35	--no-link
36		Don't link a new executable (don't ask)
37
38	--docs
39		Build the reference documentation (don't ask)
40	--no-docs
41		Don't build the reference documentation (don't ask)
42"
43
44link=no
45docs=ask
46
47while [ $# -gt 0 ]; do
48	case "$1" in
49
50	--link)
51		link=yes ;;
52	--no-link)
53		link=no ;;
54
55	--docs)
56		docs=yes ;;
57	--no-docs)
58		docs=no ;;
59
60	--)
61		shift; break ;;
62	-*)
63		echo "$0: unrecognised option: \`$1'" 1>&2
64		echo "$usage" 1>&2
65		exit 1 ;;
66	*)
67		break ;;
68	esac
69	shift
70done
71
72if [ $# -ne 0 ]; then
73	echo "$0: unexpected arguments: \`$*'" 1>&2
74	echo "$usage" 1>&2
75	exit 1
76fi
77
78if echo -n|grep n >/dev/null; then
79    ECHO_NL=
80else
81    ECHO_NL="-n"
82fi
83
84# ask <prompt> <variable> [<possible_values>]
85# If possible_values is "", then don't reconfirm input
86ask () {
87    eval answer=\$$2
88    accept=
89    while test -z "$accept"; do
90	echo
91	echo "$1 [$answer]? "
92	echo $ECHO_NL "Hit return to accept, or enter new value: "
93	read new
94	if test -z "$new"; then
95	    accept=y
96	else
97	    if test $# = 3; then
98		if  test -z "$3"; then
99		    answer="$new"
100		    break
101		fi
102		for val in $3; do
103		    if test "$new" = "$val"; then
104			answer="$new"
105		        break 2
106		    fi
107		done
108		if test "$new" != "$answer"; then
109		    echo "ERROR: Legal values are:" $3
110		fi
111	    else
112		answer="$new"
113	    fi
114	fi
115    done
116    eval $2=\"$answer\"
117}
118
119
120# test whether this configuration has a java interface
121
122have_java_interface () {
123    test -f "$ECLIPSEDIR"/lib/$ARCH/*ec_java.*
124}
125
126
127TCL_REQUIRED="8.5 8.4 8.3"
128
129usable_tcl() {
130    [	-x "$TCL_WISH" -a \
131    	-d "$TCL_ARCH_LIBRARY" -a \
132    	-f "$TK_LIBRARY/console.tcl" -a \
133	-f "$TCL_LIBRARY/init.tcl" ]
134}
135
136find_tcl() {
137
138    ecl_tcl_arch="$ECLIPSEDIR/tcltk/$ARCH"
139    TCL_WISH=`echo "$ecl_tcl_arch"/bin/wish*`
140    if [ -x "$TCL_WISH" ]; then
141
142	# We have our private Tcl with fixed structure
143	echo Using bundled Tcl/Tk in $ecl_tcl_arch
144
145	TCL_VERSION=`basename "$TCL_WISH" .exe|sed -e 's/wish//'`
146	TCL_ARCH_LIBRARY="$ecl_tcl_arch/lib"
147	TCL_LIBRARY="$ecl_tcl_arch/lib/tcl$TCL_VERSION"
148	TK_LIBRARY="$ecl_tcl_arch/lib/tk$TCL_VERSION"
149
150	TCL_FRAMEWORK="$ecl_tcl_arch/Library/Frameworks"
151	TCL_XWISH=`echo "$ecl_tcl_arch"/bin/xwish*`
152
153	usable_tcl || {
154	    echo "Bundled Tcl/Tk in $ecl_tcl_arch corrupted" && return 1; }
155
156    else
157
158	# Find wish in the path, first for the preferred versions
159
160	TCL_WISH=
161	for TCL_VERSION in $TCL_REQUIRED; do
162	    # caution: not all which's have a useful return code!
163	    TCL_WISH="`which wish$TCL_VERSION 2>/dev/null`" && [ -x "$TCL_WISH" ] && break
164	done || {
165
166	# If nothing found, check without explicit version
167	TCL_WISH=`which wish 2>/dev/null` && [ -x "$TCL_WISH" ] &&
168	TCL_SH=`which tclsh 2>/dev/null` && [ -x "$TCL_SH" ] &&
169	TCL_VERSION=`echo 'puts $tcl_version'|"$TCL_SH"`; } || {
170	
171	echo "Cannot find wish" && return 1; }
172
173	#echo Found tcl version $TCL_VERSION
174	#echo Found $TCL_WISH
175
176	# Look for (shared/static) libraries
177
178	tcl_dirs="/lib /usr/lib /usr/local/lib"
179	tcl_version_nodot=`echo $TCL_VERSION|tr -d .`
180	tcl_libs="libtcl$TCL_VERSION.$OBJECTS_SUFFIX libtcl$TCL_VERSION.a\
181		tcl$TCL_VERSION.OBJECTS_SUFFIX\ tcl$tcl_version_nodot.OBJECTS_SUFFIX"
182
183	for TCL_ARCH_LIBRARY in $tcl_dirs; do
184	    for TCL_LIB in $tcl_libs; do
185	    	[ -f "$TCL_ARCH_LIBRARY/$TCL_LIB" ] && break 2
186	    done
187	done || { echo "Cannot find tcl binary libraries" && return 1; }
188
189	#echo Found $TCL_ARCH_LIBRARY
190
191
192	# Look for the .tcl libraries
193
194	tcl_dirs="$tcl_dirs /usr/share/tcltk"
195	for tcl_dir in $tcl_dirs; do
196	    TCL_LIBRARY="$tcl_dir/tcl$TCL_VERSION"
197	    [ -f "$TCL_LIBRARY/init.tcl" ] && break
198	done &&
199	for tcl_dir in $tcl_dirs; do
200	    TK_LIBRARY="$tcl_dir/tk$TCL_VERSION"
201	    [ -f "$TK_LIBRARY/console.tcl" ] && break
202	done || { echo "Cannot find tcl/tk library directories" && return 1; }
203
204	#echo Found $TCL_LIBRARY and $TK_LIBRARY
205
206
207	# Additional stuff for MacOSX
208
209	case $ARCH in
210	    *_macosx)
211		tcl_dirs="/Library/Frameworks /System/Library/Frameworks"
212		for TCL_FRAMEWORK in $tcl_dirs; do
213		    [ -d "$TCL_FRAMEWORK/Tcl.framework" ] && break
214		done || { echo "ERROR: Cannot find Tcl.framework" && return 1; }
215
216		# There is probably a better way to locate this:
217		TCL_XWISH=`which xwish 2>/dev/null` && [ -x "$TCL_XWISH" ] || TCL_XWISH=
218		;;
219	esac
220
221    fi	
222}
223
224
225specify_tcl() {
226    echo "Specify the Tcl/Tk installation to use."
227
228    case $ARCH in
229	*_macosx)
230	    ask "What is the version number of your Tcl/Tk installation (8.X) \n[Note that 8.5 prior to 8.5.7 was broken for ECLiPSe]"  TCL_VERSION "8.3 8.4 8.5" 
231	    ;;
232	*)
233	    ask "What is the version number of your Tcl/Tk installation (8.X)" TCL_VERSION "8.3 8.4 8.5"
234	    ;;
235    esac
236
237    while true; do
238	ask "What is the full pathname of the wish$TCL_VERSION executable" TCL_WISH ""
239	[ -x "$TCL_WISH" ] && break || echo "ERROR: No such executable: $TCL_WISH"
240    done
241
242    case $ARCH in
243	*_macosx)
244	    echo "On MacOSX, the native Aqua Tcl/Tk is packaged using Frameworks."
245	    ask "In which directory is the Tcl (and Tk) Framework (where Tcl.framework is)" TCL_FRAMEWORK ""
246
247	    echo "MacOSX can also run Tk in the X11 windowing system.  If you want"
248	    echo "to use the X11 version of Tcl/Tk $TCL_VERSION, you can also"
249	    echo "setup xtkeclipse (and xtktools) to run the X11 version of TkECLiPSe."
250	    do_x11="n"
251	    ask "Do you want to do this" do_x11 "y n"
252	    if test "$do_x11" = y; then
253		while true; do
254		    ask "What is the full pathname of the wish$TCL_VERSION executable for X11" TCL_XWISH ""
255		    [ -x "$TCL_XWISH" ] && break || echo "ERROR: No such executable: $TCL_XWISH"
256		done
257		while true; do
258		    ask "Where is the X11 Tcl/Tk objects library directory (.dylib files)" TCL_ARCH_LIBRARY ""
259		    [ -d "$TCL_ARCH_LIBRARY" ] && break || echo "ERROR: No such directory: $TCL_ARCH_LIBRARY"
260		done
261	        TK_ARCH_LIBRARY="$TCL_ARCH_LIBRARY"
262	    fi
263	    ;;
264       *)
265	    while true; do
266		ask "Where is the Tcl/Tk objects library directory (.$OBJECTS_SUFFIX/.a files)" TCL_ARCH_LIBRARY ""
267		[ -d "$TCL_ARCH_LIBRARY" ] && break || echo "ERROR: No such directory: $TCL_ARCH_LIBRARY"
268	    done
269	    TK_ARCH_LIBRARY="$TCL_ARCH_LIBRARY"
270	    ;;
271
272    esac 
273
274    while true; do
275	ask "What is the Tcl library directory (.tcl files)" TCL_LIBRARY ""
276	[ -d "$TCL_LIBRARY" ] && break || echo "ERROR: No such directory: $TCL_LIBRARY"
277    done
278    TK_LIBRARY=`dirname $TCL_LIBRARY`/tk$TCL_VERSION
279    while true; do
280	ask "What is the Tk library directory (.tcl files)" TK_LIBRARY ""
281	[ -d "$TK_LIBRARY" ] && break || echo "ERROR: No such directory: $TK_LIBRARY"
282    done
283}
284
285echo "----------------------------------------------------------------------"
286echo Welcome to the ECLiPSe installation procedure
287echo "----------------------------------------------------------------------"
288
289ARCH_GUESS=`./ARCH`
290
291if test -z "$ARCH"; then
292    if echo $ARCH_GUESS|grep " " >/dev/null; then
293	echo NOTE: This machine supports multiple architectures:
294	for ARCH in $ARCH_GUESS; do
295	    echo $ARCH
296	done
297	# ARCH now set to the last member of ARCH_GUESS
298    else
299	if test "$ARCH_GUESS" = unknown; then
300	    echo WARNING: Unknown machine architecture
301	fi
302	ARCH=$ARCH_GUESS
303    fi
304else
305    if test "$ARCH_GUESS" = unknown; then
306	echo WARNING: Cannot determine machine architecture
307	echo WARNING: Using the value of your ARCH environment variable as default
308    else
309	# If ARCH_GUESS contains multiple values, disambiguate using ARCH
310	for guess in $ARCH_GUESS; do
311	    if test $ARCH = $guess; then
312		break
313	    fi
314	done
315	if test $ARCH != $guess; then
316	    if test $ARCH = i386_macosx -a $guess=x86_64_macosx; then
317		# assume we are building 32 bit on 64 bit Mac OS X
318		ARCH=$ARCH
319	    elif test $ARCH = ppc_macosx -a $guess=ppc64_macosx; then
320		# assume we are building 32 bit on 64 bit Mac OS X
321		ARCH=$ARCH
322	    elif test $ARCH = i386_linux -a $guess=x86_64_linux; then
323		# assume we are building 32 bit on 64 bit (x86) Linux
324		ARCH=$ARCH
325	    else
326	        # An end user's $ARCH may have an unrelated setting - ignore it
327		echo WARNING: Ignoring your ARCH environment variable
328		ARCH=$guess
329	    fi
330	fi
331    fi
332fi
333
334ask "Which machine achitecture (ARCH) are we installing for" ARCH
335
336
337# directory defaults
338ECLIPSEDIR=`pwd`
339EXE_DIR="\$ECLIPSEDIR/bin/$ARCH"
340DAVINCIHOME="${DAVINCIHOME:-\$ECLIPSEDIR/daVinci/$ARCH}"
341USER_OBJECTS=""
342case $ARCH in
343    *_macosx)
344	# name of environment variable for specifying library paths
345	LD_LIB_PATH_NAME=DYLD_LIBRARY_PATH
346	FRAMEWORK_PATH_NAME=DYLD_FRAMEWORK_PATH
347	;;
348    *)
349	LD_LIB_PATH_NAME=LD_LIBRARY_PATH
350	FRAMEWORK_PATH_NAME=""
351	;;
352esac
353
354if test ! -d "lib/$ARCH"; then
355    echo "Aborting: cannot find the directory lib/$ARCH."
356    echo "If you are installing from binaries, make sure you have downloaded"
357    echo "and unpacked the package eclipse_basic_$ARCH."
358    exit 1
359fi
360
361# read the architecture's defaults
362. "lib/$ARCH/INST_PARAMS"
363
364# load the previous installation's settings
365if test -f "lib/$ARCH/SITE_PARAMS"; then
366    . "lib/$ARCH/SITE_PARAMS"
367fi
368
369
370
371echo "----------------------------------------------------------------------"
372echo "You now need to specify the directory path name that eclipse"
373echo "will use to find its libraries and other support files."
374echo "This should be the FULL PATHNAME OF THE CURRENT DIRECTORY."
375echo "If you have a networked file system, you may want to specify"
376echo "a symbolic path under which this directory can be found on all"
377echo "the networked machines."
378ask "What is the current directory (ECLIPSEDIR)" ECLIPSEDIR
379
380while test "`cd \"$ECLIPSEDIR\";/bin/pwd`" != "`/bin/pwd`"; do
381    echo
382    echo "This is not same as the current directory! Please try again:"
383    ask "What is the current (=installation) directory" ECLIPSEDIR ""
384done
385
386LIB_ARCH_DIR="$ECLIPSEDIR/lib/$ARCH"
387
388
389echo "----------------------------------------------------------------------"
390echo "Please specify now where you want the ECLiPSe executables to be"
391echo "installed. This can be within the ECLiPSe directory structure"
392echo "or alternatively in a place where you usually put executables,"
393echo "e.g. a directory that is already in your PATH."
394ask "Where do you want to install executables" EXE_DIR
395
396if test ! -d "$EXE_DIR"; then
397    mkdir -p "$EXE_DIR"
398    chmod 2755 "$EXE_DIR"
399else
400    if test ! -w "$EXE_DIR"; then
401    	echo "You do not have write permission for that directory!"
402    	exit 1
403    fi
404fi
405
406# if default EXE_DIR is used, make sure parent permissions are ok
407if test -d "$ECLIPSEDIR/bin"; then chmod 2755 "$ECLIPSEDIR/bin"; fi
408
409
410echo "----------------------------------------------------------------------"
411echo "For the graphical user interface TkECLiPSe you need Tcl/Tk ($TCL_REQUIRED)."
412
413{ usable_tcl || find_tcl; } && ACCEPT=a || ACCEPT=s
414while true; do
415    echo "We will use the following Tcl/Tk installation:"
416    echo "  TCL_VERSION:      $TCL_VERSION"
417    echo "  TCL_WISH:         $TCL_WISH"
418    echo "  TCL_ARCH_LIBRARY: $TCL_ARCH_LIBRARY"
419    echo "  TCL_LIBRARY:      $TCL_LIBRARY"
420    echo "  TK_LIBRARY:       $TK_LIBRARY"
421case "$ARCH" in
422    *_macosx)
423    echo "  FRAMEWORK_PATH:   $TCL_FRAMEWORK"
424    echo "  TCL_XWISH:        $TCL_XWISH"
425    ;;
426esac
427    ask "Accept (a), find automatically (f), specify manually (m), or skip (s)" ACCEPT "a f m s"
428    case "$ACCEPT" in
429	a) break;;
430	f) find_tcl && ACCEPT=a || ACCEPT=s;;
431	m) specify_tcl; ACCEPT=a;;
432	s) break;;
433    esac
434done
435
436
437#echo "----------------------------------------------------------------------"
438#echo "ECLiPSe can interface to the daVinci graph drawing package"
439#echo "(see http://www.informatik.uni-bremen.de/agbkb/forschung/daVinci)."
440#echo "If you have daVinci installed, or are going to install it later,"
441#echo "please give the directory name here. If you do this, ECLiPSe/daVinci"
442#echo "users will not need to set the DAVINCIHOME environment variable."
443#ask "Where is the daVinci home directory" DAVINCIHOME
444
445echo "----------------------------------------------------------------------"
446if have_java_interface; then
447    echo "ECLiPSe can interface to Java (version 1.2 or later).  If you wish"
448    echo "to make use of this interface, please specify the location of your"
449    echo "Java Runtime Environment (JRE_HOME)."
450    jre="$JRE_HOME"
451    while true; do
452	ask "Where is your Java Runtime Environment installed (s to skip)" jre ""
453	if [ "$jre" = s ]; then break; fi
454	if [ -x "$jre/bin/java" ]; then JRE_HOME="$jre"; break; fi
455	echo "ERROR: Can't find java in $jre"
456	jre=s
457    done
458else
459    echo "Java interface not supported in this configuration, skipping."
460fi
461
462echo "----------------------------------------------------------------------"
463if [ -d "$ECLIPSEDIR/doc/bips/kernel" ] ; then
464    case "$docs" in
465	yes)
466		echo "You have requested generation of the reference documentation."
467		BUILD_DOCS=y ;;
468
469	no)
470		echo "You have requested no generation of the reference documentation."
471		BUILD_DOCS=n ;;
472
473	*)
474		if [ -f "$ECLIPSEDIR/doc/bips/index.html" ] ; then
475			echo "You appear to already have the ECLiPSe reference documentation."
476			ask "Do you wish to regenerate it" REBUILD_DOCS "y n"
477			BUILD_DOCS=$REBUILD_DOCS
478		else
479			echo "You do not appear to have the ECLiPSe reference documentation."
480			echo "It will be generated for you."
481			BUILD_DOCS=y
482		fi
483		;;
484    esac
485else
486    echo "You didn't unpack the ECLiPSe reference documentation."
487    BUILD_DOCS=n
488fi
489
490
491case "$link" in
492	yes)
493		echo "----------------------------------------------------------------------"
494		echo "You have requested a customised configuration of eclipse."
495		SIMPLE=n ;;
496
497	no)
498		echo "----------------------------------------------------------------------"
499		echo "You have requested the default configuration of eclipse."
500		SIMPLE=y ;;
501
502	*)
503		echo "----------------------------------------------------------------------"
504		echo "Now you have the choice between installing"
505		echo ""
506		echo "[y] The default configuration of eclipse:"
507		echo "      This is recommended. It requires no special tools."
508		echo ""
509		echo "[n] A customised configuration of eclipse:"
510		echo "      This allows you to statically link your own object files"
511		echo "      with ECLiPSe.  A linker or C compiler is required."
512
513		ask "Do you want to install the default configuration" SIMPLE "y n"
514		;;
515esac
516
517echo "----------------------------------------------------------------------"
518
519
520case $ARCH in 
521    *_nt)
522	OS_ECLIPSEDIR=`cygpath -m "$ECLIPSEDIR"`
523	OS_TCL_LIBRARY=`cygpath -m "$TCL_LIBRARY"`
524	OS_TK_LIBRARY=`cygpath -m "$TK_LIBRARY"`
525	;;
526    *)
527	OS_ECLIPSEDIR="$ECLIPSEDIR"
528	OS_TCL_LIBRARY="$TCL_LIBRARY"
529	OS_TK_LIBRARY="$TK_LIBRARY"
530	;;
531esac
532
533if test $SIMPLE != y; then
534#--------------------------------------------------------------
535# Customised configuration
536#--------------------------------------------------------------
537
538#ask "Do you want support for parallelism" WANT_PARALLELISM "y n"
539#
540#if test $WANT_PARALLELISM = y; then
541#    ask "Do you want the Tcl/Tk worker manager interface" WANT_TCL_WM "y n"
542#    # we need mps for parallelism
543#    WANT_MPS=y
544#else
545#    ask "Do you want support for message passing" WANT_MPS "y n"
546#fi
547
548ask "Extra object files you want linked with your ECLiPSe" USER_OBJECTS
549
550ask "The compiler/linker to be used for linking" CC
551ask "Extra linker options that might be required" LDFLAGS
552ask "Extra system libraries that might be required" SYSLIBS
553
554ask "Where is the X11 library directory" X_LIBRARIES
555SYSLIBSX="-L\"$TCL_ARCH_LIBRARY\" -ltcl -L\"$TK_ARCH_LIBRARY\" -ltk -L\"$X_LIBRARIES\" -lX11 $SYSLIBS"
556
557echo "----------------------------------------------------------------------"
558
559
560#--------------------------------------------------------------
561# Make a properly configured eclipse executable
562#--------------------------------------------------------------
563
564cd "$LIB_ARCH_DIR"
565
566OBJECTS="standalone.o"
567if test "$OBJECTS_SUFFIX" = "so"; then
568    LIBRARIES="libeclipse.so libgmp.so"
569else
570    LIBRARIES="libeclipse.a libdummies.a libgmp.a libshm.a"
571fi
572
573if test "$WANT_PARALLELISM" = "y"; then
574    echo Installing with parallel option
575    OBJECTS="$OBJECTS parallel.o"
576fi
577
578if test "$WANT_MPS" = "y"; then
579    echo Installing with mps option
580    LIBRARIES="libeclipsemps.a libpds.a $LIBRARIES"
581fi
582
583
584`if [ -r /bin/ranlib -o -r /usr/bin/ranlib ]; then echo ranlib; else echo true; fi` *.a
585
586echo Making executable "$LIB_ARCH_DIR/eclipse.exe"
587$CC $LDFLAGS $OBJECTS $USER_OBJECTS $LIBRARIES $SYSLIBS -o "$LIB_ARCH_DIR/eclipse.exe"
588chmod 755 "$LIB_ARCH_DIR/eclipse.exe"
589
590#--------------------------------------------------------------
591# Make optional executables
592#--------------------------------------------------------------
593
594if test "$WANT_MEGALOG" = "y"; then
595    echo Making "$EXE_DIR/bang_server"
596    $CC $LDFLAGS bang_server.o $LIBRARIES $SYSLIBS -o "$EXE_DIR/bang_server"
597    chmod 755 "$EXE_DIR/bang_server"
598fi
599
600if test "$WANT_MPS" = "y"; then
601    echo Making "$EXE_DIR/nsrv"
602    $CC $LDFLAGS nsrv_server.o $LIBRARIES $SYSLIBS -o "$EXE_DIR/nsrv"
603    chmod 755 "$EXE_DIR/nsrv"
604fi
605
606if test "$WANT_PARALLELISM" = "y"; then
607    rm -f "$EXE_DIR/worker"
608    ln -s eclipse "$EXE_DIR/worker"
609
610    echo Making "$LIB_ARCH_DIR/peclipse.exe"
611    if test "$WANT_TCL_WM"; then
612	$CC $LDFLAGS wm.o wm_interface.o $LIBRARIES $SYSLIBSX -o "$LIB_ARCH_DIR/peclipse.exe"
613    else
614	$CC $LDFLAGS wm.o $LIBRARIES $SYSLIBS -o "$LIB_ARCH_DIR/peclipse.exe"
615    fi
616    chmod 755 "$LIB_ARCH_DIR/peclipse.exe"
617
618    echo Making "$EXE_DIR/peclipse"
619    rm -f "$EXE_DIR/peclipse"
620    cat > "$EXE_DIR/peclipse" <<EOF
621#! /bin/sh
622ECLIPSEDIR="\${ECLIPSEDIR:-$OS_ECLIPSEDIR}"
623TCL_LIBRARY="\${TCL_LIBRARY:-$OS_TCL_LIBRARY}"
624TK_LIBRARY="\${TK_LIBRARY:-$OS_TK_LIBRARY}"
625export ECLIPSEDIR TCL_LIBRARY TK_LIBRARY
626exec "$LIB_ARCH_DIR/peclipse.exe" "\$@"
627EOF
628    chmod 755 "$EXE_DIR/peclipse"
629
630fi
631
632fi
633
634#--------------------------------------------------------------
635# End of customised configuration
636#--------------------------------------------------------------
637
638
639
640#--------------------------------------------------------------
641# Default configuration, just make the eclipse wrapper script
642# TCL_ARCH_LIBRARY is placed last, so search for other libraries
643# will not find them by mistake in TCL_ARCH_LIBRARY 
644#--------------------------------------------------------------
645
646dest="$EXE_DIR/eclipse"
647echo Making "$dest"
648rm -f "$dest"
649cat > "$dest" <<EOF
650#! /bin/sh
651ECLIPSEDIR="\${ECLIPSEDIR:-$OS_ECLIPSEDIR}"
652$LD_LIB_PATH_NAME="\$ECLIPSEDIR/lib/$ARCH:\$$LD_LIB_PATH_NAME"
653DAVINCIHOME="\${DAVINCIHOME:-$DAVINCIHOME}"
654JRE_HOME="\${JRE_HOME:-$JRE_HOME}"
655export ECLIPSEDIR $LD_LIB_PATH_NAME DAVINCIHOME JRE_HOME
656exec "$LIB_ARCH_DIR/eclipse.exe" "\$@"
657EOF
658chmod 755 "$dest"
659
660dest="$EXE_DIR/tkeclipse"
661echo Making "$dest"
662rm -f "$dest"
663case $ARCH in 
664    *_macosx)
665	# For Aqua Tk, don't pass TCL_ARCH_LIBRARY (for X11 only) 
666	cat > "$dest" <<EOF
667#! /bin/sh
668ECLIPSEDIR="\${ECLIPSEDIR:-$OS_ECLIPSEDIR}"
669$LD_LIB_PATH_NAME="\$ECLIPSEDIR/lib/$ARCH:\$$LD_LIB_PATH_NAME"
670$FRAMEWORK_PATH_NAME="$TCL_FRAMEWORK:\$$FRAMEWORK_PATH_NAME"
671EOF
672	;;
673    *)
674	cat > "$dest" <<EOF
675#! /bin/sh
676ECLIPSEDIR="\${ECLIPSEDIR:-$OS_ECLIPSEDIR}"
677$LD_LIB_PATH_NAME="\$ECLIPSEDIR/lib/$ARCH:\$$LD_LIB_PATH_NAME:$TCL_ARCH_LIBRARY"
678EOF
679	;;
680esac
681cat >> "$dest" <<EOF
682TCL_LIBRARY="\${TCL_LIBRARY:-$OS_TCL_LIBRARY}"
683TK_LIBRARY="\${TK_LIBRARY:-$OS_TK_LIBRARY}"
684DAVINCIHOME="\${DAVINCIHOME:-$DAVINCIHOME}"
685JRE_HOME="\${JRE_HOME:-$JRE_HOME}"
686export ECLIPSEDIR TCL_LIBRARY TK_LIBRARY $FRAMEWORK_PATH_NAME $LD_LIB_PATH_NAME DAVINCIHOME JRE_HOME
687exec "$TCL_WISH" "$ECLIPSEDIR/lib_tcl/tkeclipse.tcl" -- "\$@"
688EOF
689chmod 755 "$dest"
690
691#-------------------------------------------------------------------
692# xtkeclipse and xtktools
693#-------------------------------------------------------------------
694
695case $ARCH in
696    *_macosx)
697
698	if test -x "$TCL_XWISH"; then
699
700	    dest="$EXE_DIR/xtkeclipse"
701	    echo Making "$dest"
702	    rm -f "$dest"
703	    cat > "$dest" <<EOF
704#! /bin/sh
705ECLIPSEDIR="\${ECLIPSEDIR:-$OS_ECLIPSEDIR}"
706DYLD_LIBRARY_PATH="\$ECLIPSEDIR/lib/$ARCH:\$DYLD_LIBRARY_PATH:$TCL_ARCH_LIBRARY"
707TCL_LIBRARY="\${TCL_LIBRARY:-$OS_TCL_LIBRARY}"
708TK_LIBRARY="\${TK_LIBRARY:-$OS_TK_LIBRARY}"
709DAVINCIHOME="\${DAVINCIHOME:-$DAVINCIHOME}"
710JRE_HOME="\${JRE_HOME:-$JRE_HOME}"
711export ECLIPSEDIR TCL_LIBRARY TK_LIBRARY DYLD_LIBRARY_PATH DAVINCIHOME JRE_HOME
712exec "$TCL_XWISH" "$ECLIPSEDIR/lib_tcl/tkeclipse.tcl" -- "\$@"
713EOF
714	    chmod 755 "$dest"
715
716	    dest="$EXE_DIR/xtktools"
717	    echo Making "$dest"
718	    rm -f "$dest"
719	    cat > "$dest" <<EOF
720#! /bin/sh
721ECLIPSEDIR="\${ECLIPSEDIR:-$OS_ECLIPSEDIR}"
722DYLD_LIBRARY_PATH="\$ECLIPSEDIR/lib/$ARCH:\$DYLD_LIBRARY_PATH:$TCL_ARCH_LIBRARY"
723TCL_LIBRARY="\${TCL_LIBRARY:-$OS_TCL_LIBRARY}"
724TK_LIBRARY="\${TK_LIBRARY:-$OS_TK_LIBRARY}"
725DAVINCIHOME="\${DAVINCIHOME:-$DAVINCIHOME}"
726export ECLIPSEDIR TCL_LIBRARY TK_LIBRARY DYLD_LIBRARY_PATH DAVINCIHOME
727exec "$TCL_XWISH" "$ECLIPSEDIR/lib_tcl/tktools.tcl" -- "\$@"
728EOF
729	    chmod 755 "$dest"
730
731	fi
732	;;
733esac
734
735#-----------------------------------------------------------------
736
737if have_java_interface; then
738
739    #--------------------------------------------------------------
740    # make the jeclipse script
741    #--------------------------------------------------------------
742
743    #suppresses a java warning which comes up in linux
744
745    JIT_OPTION=""
746    JPSEP=":"
747
748    case $ARCH in
749	*_nt) JPSEP=";" ;;
750	i386_linux) JIT_OPTION="-Djava.compiler=" ;;
751    esac
752    
753    dest="$EXE_DIR/jeclipse"
754    echo Making "$dest"
755    rm -f "$dest"
756    cat > "$dest" <<EOF
757#! /bin/sh
758ECLIPSEDIR="\${ECLIPSEDIR:-$OS_ECLIPSEDIR}"
759EOF
760case $ARCH in
761    *_macosx)
762	cat >> "$dest" <<EOF
763DYLD_LIBRARY_PATH="\$ECLIPSEDIR/lib/$ARCH:\$DYLD_LIBRARY_PATH:$TCL_ARCH_LIBRARY"
764DYLD_FRAMEWORK_PATH="\$TCL_FRAMEWORK:\$DYLD_FRAMEWORK_PATH"
765export DYLD_FRAMEWORK_PATH DYLD_LIBRARY_PATH 
766EOF
767	;;
768    *_nt)
769	;;
770    *)
771	cat >> "$dest" <<EOF
772LD_LIBRARY_PATH="\$ECLIPSEDIR/lib/$ARCH:\$LD_LIBRARY_PATH"
773EOF
774	;;
775esac
776
777cat >> "$dest" <<EOF
778JRE_HOME="\${JRE_HOME:-$JRE_HOME}"
779CLASSPATH="\$ECLIPSEDIR/lib/eclipse.jar${JPSEP}\${JRE_HOME}/lib/rt.jar"
780export ECLIPSEDIR JRE_HOME
781exec "\${JRE_HOME}/bin/java" -Xss2m ${JIT_OPTION} -Declipse.directory="\$ECLIPSEDIR" -classpath "\$CLASSPATH" com.parctechnologies.eclipse.JEclipse "\$@"
782EOF
783    chmod 755 "$dest"
784
785fi
786
787
788#-------------------------------------------------------------------
789# tktools
790#-------------------------------------------------------------------
791
792dest="$EXE_DIR/tktools"
793echo Making "$dest"
794rm -f "$dest"
795case $ARCH in 
796    *_macosx)
797	cat > "$dest" <<EOF
798#! /bin/sh
799ECLIPSEDIR="\${ECLIPSEDIR:-$OS_ECLIPSEDIR}"
800$LD_LIB_PATH_NAME="\$ECLIPSEDIR/lib/$ARCH:\$$LD_LIB_PATH_NAME"
801DYLD_FRAMEWORK_PATH="\$TCL_FRAMEWORK:\$DYLD_FRAMWORK_PATH"
802EOF
803	;;
804    *)
805	cat > "$dest" <<EOF
806#! /bin/sh
807ECLIPSEDIR="\${ECLIPSEDIR:-$OS_ECLIPSEDIR}"
808$LD_LIB_PATH_NAME="\$ECLIPSEDIR/lib/$ARCH:\$$LD_LIB_PATH_NAME:$TCL_ARCH_LIBRARY"
809EOF
810	;;
811esac
812cat >> "$dest" <<EOF
813TCL_LIBRARY="\${TCL_LIBRARY:-$OS_TCL_LIBRARY}"
814TK_LIBRARY="\${TK_LIBRARY:-$OS_TK_LIBRARY}"
815DAVINCIHOME="\${DAVINCIHOME:-$DAVINCIHOME}"
816export ECLIPSEDIR TCL_LIBRARY TK_LIBRARY $FRAMEWORK_PATH_NAME $LD_LIB_PATH_NAME DAVINCIHOME 
817exec "$TCL_WISH" "$ECLIPSEDIR/lib_tcl/tktools.tcl" -- "\$@"
818EOF
819chmod 755 "$dest"
820
821#--------------------------------------------------------------
822# Build the reference documentation
823#--------------------------------------------------------------
824
825if [ "$BUILD_DOCS" = y ] ; then
826	echo "Building reference documentation, please wait."
827	"$EXE_DIR/eclipse" -e 'lib(document),ecis_to_htmls.'
828else
829	echo "Skipping build of reference documentation."
830fi
831
832#--------------------------------------------------------------
833# Save the parameters for the next run
834#--------------------------------------------------------------
835
836dest="$ECLIPSEDIR/lib/$ARCH/SITE_PARAMS"
837rm -f "$dest"
838cat >"$dest" <<EOF
839ECLIPSEDIR='$ECLIPSEDIR'
840EXE_DIR='$EXE_DIR'
841SIMPLE="$SIMPLE"
842WANT_MEGALOG="$WANT_MEGALOG"
843WANT_PARALLELISM="$WANT_PARALLELISM"
844WANT_TCL_WM="$WANT_TCL_WM"
845WANT_MPS="$WANT_MPS"
846REBUILD_DOCS="$REBUILD_DOCS"
847TCL_LIBRARY='$TCL_LIBRARY'
848TK_LIBRARY='$TK_LIBRARY'
849DAVINCIHOME='$DAVINCIHOME'
850TCL_ARCH_LIBRARY='$TCL_ARCH_LIBRARY'
851TCL_WISH='$TCL_WISH'
852TCL_XWISH='$TCL_XWISH'
853TCL_VERSION='$TCL_VERSION'
854TCL_FRAMEWORK='$TCL_FRAMEWORK'
855X_LIBRARIES='$X_LIBRARIES'
856USER_OBJECTS='$USER_OBJECTS'
857JRE_HOME='$JRE_HOME'
858EOF
859chmod a+r "$dest"
860
861
862echo "----------------------------------------------------------------------"
863echo ECLiPSe installation done.
864echo You should now add "$EXE_DIR"
865echo to your PATH environment variable.
866
867exit 0
868
869