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.eclipseclp.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# Make ECLiPSe binary release tarfiles
26#
27
28# IMPORTANT: PLEASE UPDATE NSIS_<*> VARIABLES WITH LATEST i386_nt 
29#            SOLVER, TCL/TK, GRAPHVIZ AND OTHER PACKAGES
30
31#set -x
32
33usage="\
34Usage: $0 [options] architectures
35Options:
36	--dest-dir <path>
37		Destination directory for the archives.
38
39	--common-only
40		Build only architecture-independent archives.
41
42	--arch-only
43		Build only architecture-specific archives.
44
45        --no-rpm
46                Do not build RPM packages
47
48        --no-nsis
49                Do not build NSIS Windows installer
50
51	--version-num
52		Specifies the ECLiPSe version number.
53
54	--build-num
55		Specifies the ECLiPSe build number.
56"
57
58# Default destination location for built archives
59DEST_DIR=archive
60
61# List of *all known* architectures (not just the ones we want to pack).
62# This is used for excluding files from other architectures.
63ALLARCHS="
64	sun4 \
65	i386_linux \
66	sparc_sunos5 \
67	i386_sunos5 \
68	x86_64_sunos5 \
69	alpha_linux \
70	ppc_macosx \
71	i386_macosx \
72	x86_64_macosx \
73	x86_64_linux \
74	x86_64_nt \
75	i386_nt
76"
77
78# List of all directories which may end up in the archives.
79# This is used for fixing the file permissions.
80ALLDIRS="include legal lib lib_tcl lib_public doc man tcltk"
81
82
83# Eplex interfaces
84# NOTE: PLEASE UPDATE I386NT_<solver>_PACKAGE WITH LATEST i386_nt 
85#       SOLVER INTERFACES
86I386NT_CPLEX_SOLVER="cplex122"
87I386NT_XPRESS_SOLVER="xpress2000"
88I386NT_CLPCBC_SOLVER="osiclpcbc"
89I386NT_GUROBI_SOLVER="gurobi50"
90EPLEX_SOLVERS="\
91	$I386NT_CLPCBC_SOLVER \
92	$I386NT_XPRESS_SOLVER \
93	$I386NT_GUROBI_SOLVER \
94	osisymclp \
95"
96PRIVATE_EPLEX_SOLVERS="\
97	cplex71 \
98	cplex75 \
99	cplex81 \
100        cplex90 \
101	cplex102 \
102	cplex110 \
103	cplex121 \
104	$I386NT_CPLEX_SOLVER \
105	xpress1427 \
106	xpress1427icp \
107	xpress1326icp \
108	xpress2000 \
109"
110
111# Eplex interfaces for runtime versions only
112EPLEX_SOLVERS_PT="\
113"
114
115
116# Windoze installer packages
117NSIS_GRAPHVIZ_EXE="graphviz-1.10.exe"
118NSIS_CPLEX_PACKAGE="if_$I386NT_CPLEX_SOLVER"
119NSIS_XPRESS_PACKAGE="if_$I386NT_XPRESS_SOLVER"
120NSIS_CLPCBC_PACKAGE="if_$I386NT_CLPCBC_SOLVER"
121NSIS_GUROBI_PACKAGE="if_$I386NT_GUROBI_SOLVER"
122NSIS_PACKAGES=" \
123	eclipse_basic \
124	eclipse_misc \
125	eclipse_doc \
126	$NSIS_CPLEX_PACKAGE \
127	$NSIS_XPRESS_PACKAGE \
128	$NSIS_CLPCBC_PACKAGE \
129	$NSIS_GUROBI_PACKAGE \
130	tcltk
131"
132
133
134pack_common=yes
135pack_archs=yes
136pack_rpm=yes
137pack_nsis_installer=maybe
138
139# This isn't used systematically yet
140everything_ok=0
141
142ECLIPSE_VERSION="X.X"
143BUILD_NUMBER="X"
144
145while [ $# -gt 0 ]; do
146        case "$1" in
147
148	--dest-dir)
149		DEST_DIR=$2 ; shift ;;
150
151	--common-only)
152		pack_common=yes
153		pack_archs=no 
154		pack_nsis_installer=no ;;
155
156	--arch-only)
157		pack_common=no
158		pack_archs=yes
159		pack_nsis_installer=no ;;
160
161	--version-num)
162		ECLIPSE_VERSION=$2 ; shift ;;
163
164	--build-num)
165		BUILD_NUMBER=$2 ; shift ;;
166
167        --no-rpm)
168                pack_rpm=no;;
169
170        --no-nsis)
171                pack_nsis_installer=no;;
172	--)
173		shift; break ;;
174	-*)
175		echo "$0: unrecognised option: \`$1'" 1>&2
176		echo "$usage" 1>&2
177		exit 1 ;;
178	*)
179		break ;;
180	esac
181	shift
182done
183
184# Architectures to build for
185if [ $# -gt 0 ]; then
186	ARCHITECTURES="$*"
187else
188	echo "$0: no architectures specified" 1>&2
189	echo "$usage" 1>&2
190	exit 1
191fi
192
193# Test for Windows architectures
194winarch () {
195    case $1 in
196	*_nt) true ;;
197	*) false ;;
198    esac
199}
200
201# Enable NSIS only for Windows
202if [ "$pack_nsis_installer" = maybe ] ; then
203    pack_nsis_installer=no
204    for arch in $ARCHITECTURES; do
205	if winarch $arch ; then
206	    pack_nsis_installer=yes
207	fi
208    done
209fi
210nsis_spec_created=no
211
212
213TAR=tar
214
215ALLFILES=/tmp/allfiles$$
216EXCLUDEFILES=/tmp/excludefiles$$
217SELECTEDFILES=/tmp/selectedfiles$$
218RPM_SELECTEDFILES=/tmp/rpm_selectedfiles$$
219EXCLUDED_ECOS=/tmp/excluded_eco_files$$
220NSIS_SELECTED_FILES=/tmp/nsis_files$$
221
222TMPFILES="\
223	$ALLFILES $EXCLUDEFILES $SELECTEDFILES \
224	$RPM_SELECTEDFILES \
225	$EXCLUDED_ECOS $NSIS_SELECTED_FILES \
226"
227trap "rm -f $TMPFILES ; exit 1" 1 2 3 9 14 15
228
229
230# Auxliliary function which reads a file and expand patterns
231# and shell variables. The result goes to stdout.
232
233expand_file_list ()	# $1=listfile
234{
235    (
236	while read f_template; do
237	    # the next line expands glob patterns and shell variables
238	    # (ARCH,DYNLIB) that may occur in the .lst file
239	    eval f_subst=$f_template
240	    if [ -n "$f_subst" ]; then
241		for f in $f_subst; do
242		    echo $f
243		done
244	    fi
245	done
246    ) < $1
247}
248
249# subdir is the subdirectory to pack into. Currently this is either ""
250# (i.e. no subdir) or private
251packarch ()	# $1=arch $2=name $3=subdir $4=files $5=excludedfiles $6=excludepatterns $7=tar_option
252{
253    echo
254    echo Now packing $3/$1/$2 
255    echo $4
256
257    # make list of all the files
258    find $4 -follow -print | sort -u > $ALLFILES
259
260    # make the list of excluded files
261    (
262	# remove some common junk
263	grep -w CVS $ALLFILES
264	grep "\.#" $ALLFILES
265	grep "\.stamp" $ALLFILES
266	#grep build_log $ALLFILES
267
268	# remove all files in the list excludedfiles
269	if test -n "$5"; then
270	    for file in $5; do
271		echo $file
272	    done
273	fi
274
275	# remove all files that contain one of the excludepatterns
276	if test -n "$6"; then
277	    for pattern in $6; do
278		grep $pattern $ALLFILES
279	    done
280	fi
281
282	# remove all files for the other architectures
283	for otherarch in $ALLARCHS; do
284	    if test $otherarch \!= $1; then
285		grep -w $otherarch $ALLFILES
286	    fi 
287	done
288
289    ) | sort -u > $EXCLUDEFILES
290
291    # subtract EXCLUDEFILES from ALLFILES giving SELECTEDFILES
292    comm -23 $ALLFILES $EXCLUDEFILES > $SELECTEDFILES
293
294    # create destination directory
295    mkdir -p $DEST_DIR/$3/$1
296
297    # Now tar all the SELECTEDFILES.
298    # We used to work with exclude-files here (X option) but that proved
299    # to be buggy in several versions of tar.
300    # We use --no-recursion option to include directories without their
301    # contents. When this option is not available, the directories must
302    # be excluded from the file list (add ! -type d in the find above),
303    # but then we cannot preserve the directory permissions in the tar.
304    # The tar h-option can be added optionally as $7, this is useful
305    # e.g. to avoid multiple copies of libgmp.so*
306    $TAR czfT$7 $DEST_DIR/$3/$1/$2.tgz $SELECTEDFILES --no-recursion
307
308    # Generate the NSIS Windoze installer script
309    if [ "$pack_nsis_installer" = yes -a "$3" != private ] ; then 
310	if [ "$1" = common ] ; then
311	    for ARCH in $ARCHITECTURES; do
312		nsispack $2 $SELECTEDFILES $ARCH
313	    done
314	else
315	    nsispack $2 $SELECTEDFILES $1
316	fi
317    fi
318
319    if [ "$pack_rpm" = yes ] && ! winarch $1 ; then
320
321        # write DEST_DIR into the ".mymacros" file
322        echo "%_topdir $DEST_DIR/$3" > .mymacros
323
324        # make the RPMS directory structure
325        mkdir -p $DEST_DIR/$3/RPMS
326        mkdir -p $DEST_DIR/$3/BUILD
327
328        # make the rpm build root
329        BUILD_ROOT=/tmp/eclipse_rpm_build_root
330
331        mkdir $BUILD_ROOT
332
333        ECLIPSE_ROOT=$BUILD_ROOT/usr/lib/eclipse$ECLIPSE_VERSION
334        mkdir -p $BUILD_ROOT/usr/lib
335        rm -f $ECLIPSE_ROOT
336        ln -s $PWD $ECLIPSE_ROOT
337
338        # Append the default install path to the front of all files,
339        # and remove explicit directory references (as RPM does NOT
340        # need them and will infact include all files therein, unlike
341        # tar).
342        TOP_DIR=eclipse$ECLIPSE_VERSION
343        rm -f $RPM_SELECTEDFILES
344        for X in `cat $SELECTEDFILES`; do
345            if test -f $X; then
346                (echo "$X" | sed -e "s/^/\/usr\/lib\/$TOP_DIR\//g") >> $RPM_SELECTEDFILES
347            fi
348            if test -d $X; then
349                (echo "$X" | sed -e "s/^/%dir \/usr\/lib\/$TOP_DIR\//g") >> $RPM_SELECTEDFILES
350            fi
351        done
352
353        # strip off the OS part of the ARCH_OS variable, and replace
354        # "common" or "private" with "noarch"
355        TARGET=`echo $1 | sed "s/_.*//" | sed "s/\(common\)\|\(private\)/noarch/"`
356
357        # Make the name of the package
358        NAME="ECLiPSe_"`echo $2 | sed "s/eclipse_//"`
359
360        RPM_SPEC_NAME=$NAME-$ECLIPSE_VERSION-$BUILD_NUMBER.spec
361
362        # Set the post install and post un-install scripts for the
363        # main packages
364
365        POST_SPEC=""
366        if test ! -z `echo $2 | grep "eclipse_\(rt\)\|\(basic\)"`; then
367            POST_SPEC="\
368%post
369cd \$RPM_INSTALL_PREFIX/$TOP_DIR
370yes '' | sh ./RUNME
371for X in eclipse tkeclipse jeclipse tktools ; do
372  ln -s \$RPM_INSTALL_PREFIX/$TOP_DIR/bin/$1/\$X /usr/bin/\$X
373done
374
375%preun
376rm -rf \$RPM_INSTALL_PREFIX/$TOP_DIR/bin \$RPM_INSTALL_PREFIX/$TOP_DIR/lib/$1/SITE_PARAMS 
377for X in eclipse tkeclipse jeclipse tktools ; do
378  rm -f /usr/bin/\$X
379done
380
381%postun
382#rmdir \$RPM_INSTALL_PREFIX/$TOP_DIR
383
384"
385        fi
386
387        echo "Now generating RPM spec file:$RPM_SPEC_NAME"
388        echo "\
389Summary: ECLiPSe Constraint Logic Programming System ($NAME)
390Name: $NAME
391Version: $ECLIPSE_VERSION
392Release: $BUILD_NUMBER
393License: Cisco Systems, Inc 
394Group: Development/Languages
395Source: http://eclipseclp.org
396BuildRoot: $BUILD_ROOT
397Prefix: /usr/lib
398
399%description
400ECLiPSe is a software system for the cost-effective development and
401deployment of constraint programming applications, e.g. in the areas
402of planning, scheduling, resource allocation, timetabling, transport
403etc. It is also ideal for teaching most aspects of combinatorial
404problem solving, e.g. problem modelling, constraint programming,
405mathematical programming, and search techniques. It contains several
406constraint solver libraries, a high-level modelling and control
407language, interfaces to third-party solvers, an integrated development
408environment and interfaces for embedding into host environments.
409
410
411%build
412
413%install
414
415$POST_SPEC
416
417%files
418%defattr(-,root,root)
419
420`cat $RPM_SELECTEDFILES`
421" > "$RPM_SPEC_NAME"
422        rpmbuild --rcfile /usr/lib/rpm/rpmrc:.rpmrc --target=$TARGET -bb "$RPM_SPEC_NAME"
423        rm -f $RPM_SELECTEDFILES
424    fi
425    rm -f $EXCLUDEFILES $ALLFILES $SELECTEDFILES
426    rm -rf $BUILD_ROOT
427}
428
429nsispack ()	# $1=name $2=selectedfiles $3=arch
430{
431    if [ "$pack_nsis_installer" = no ] || ! winarch $3 ; then
432    	return 0
433    fi
434
435    nsis_spec_created=yes
436
437    for NSIS_PACKAGE in $NSIS_PACKAGES ; do
438        if [ $NSIS_PACKAGE = $1 ] ; then
439	    echo
440	    echo Generating NSIS Windoze install script for $1 package
441
442	    NSIS_DIR=""
443
444	    for NSIS_FILE_LINE in `cat $2` ; do
445		if test -f $NSIS_FILE_LINE ; then
446		    # Work out the directory to spit the file to
447		    NSIS_TMP_DIR=`echo $NSIS_FILE_LINE | sed -e 's/\\(^.*\\)\/[^\\/]*/\\1/'`
448		    if test -d $NSIS_TMP_DIR && [ "$NSIS_DIR" != "$NSIS_TMP_DIR" ] ; then
449			NSIS_DIR=$NSIS_TMP_DIR
450			echo "  SetOutPath \$8/$NSIS_DIR" >> $NSIS_SELECTED_FILES
451		    fi
452		    # Incorporate the file
453		    echo "  File $NSIS_FILE_LINE" >> $NSIS_SELECTED_FILES
454		fi
455	    done
456
457	    case $NSIS_PACKAGE in
458		eclipse_basic) 
459		    echo \
460"Section \"ECLiPSe Development Environment (required)\" secDevelopmentEnv
461  SectionIn 1 2 3 4 RO
462  DetailPrint \"Extracting ECLiPSe Development environment...\"
463  SetOutPath \$8
464  SetDetailsPrint textonly" ;;
465		eclipse_misc) 
466		    echo \
467"Section \"3rd Party Libraries\" SecContrib
468  SectionIn 1 2 3
469  DetailPrint \"Extracting 3rd party libraries...\"
470  SetOutPath \$8
471  SetDetailsPrint textonly" ;;
472		eclipse_doc)
473		    echo \
474"Section \"Documentation\" SecDoc
475  SectionIn 1 2 3
476  DetailPrint \"Extracting documentation...\"
477  SetOutPath \$8
478  SetDetailsPrint textonly" ;;
479		$NSIS_CPLEX_PACKAGE)
480		    echo \
481"Section \"CPLEX Interface\" SecCPLEX
482  SectionIn 3
483  DetailPrint \"Extracting CPLEX interface...\"
484  SetOutPath \$8
485  SetDetailsPrint textonly" ;;
486		$NSIS_GUROBI_PACKAGE)
487		    echo \
488"Section \"GUROBI Interface\" SecGUROBI
489  SectionIn 3
490  DetailPrint \"Extracting GUROBI interface...\"
491  SetOutPath \$8
492  SetDetailsPrint textonly" ;;
493		$NSIS_XPRESS_PACKAGE)
494		    echo \
495"Section \"XPRESS-MP Interface\" SecXPRESS
496  SectionIn 3
497  DetailPrint \"Extracting XPRESS-MP interface...\"
498  SetOutPath \$8
499  SetDetailsPrint textonly" ;;
500		$NSIS_CLPCBC_PACKAGE)
501		    echo \
502"Section \"COIN-OR CLP/CBC Interface\" SecCLPCBC
503  SectionIn 1 2 3
504  DetailPrint \"Extracting COIN-OR CLP/CBC interface...\"
505  SetOutPath \$8
506  SetDetailsPrint textonly" ;;
507		tcltk)
508		    echo \
509"Section \"Use bundled Tcl/Tk\" SecTclTk
510  SectionIn 1 2 3
511  DetailPrint \"Extracting Tcl/Tk....\"
512  SetOutPath \$8
513  SetDetailsPrint textonly" ;;
514	    esac >> ECLiPSe_${ECLIPSE_VERSION}_${BUILD_NUMBER}_$3.nsi
515	    # Specify the files with Windoze path delimiters
516	    cat $NSIS_SELECTED_FILES | sed -e 's/\//\\/g' \
517			>> ECLiPSe_${ECLIPSE_VERSION}_${BUILD_NUMBER}_$3.nsi
518	    echo -e "  SetDetailsPrint both\nSectionEnd\n" \
519			>> ECLiPSe_${ECLIPSE_VERSION}_${BUILD_NUMBER}_$3.nsi
520	    break
521	fi
522
523    done
524
525    rm -f $NSIS_SELECTED_FILES
526}
527
528nsisheader()	# $1=arch
529{
530    if [ "$pack_nsis_installer" = no ] || ! winarch $1 ; then
531    	return 0
532    fi
533
534    case $1 in
535    	i386_nt)
536	    WORDLEN=32
537	    PROGFILES="\$PROGRAMFILES"
538	    ;;
539    	x86_64_nt)
540	    WORDLEN=64
541	    PROGFILES="\$PROGRAMFILES64"
542	    ;;
543	*)
544	    return 0
545	    ;;
546    esac
547
548    echo \
549";NSIS Setup Script for ECLiPSe Constraint Logic Programming System
550 
551!define VER_MAJOR $ECLIPSE_VERSION
552!define VER_MINOR $BUILD_NUMBER
553!define VER_WORDLEN $WORDLEN
554!define MY_PROGRAMFILES $PROGFILES
555!define ARCH $1
556
557;--------------------------------
558;Configuration
559 
560Name \"ECLiPSe \${VER_MAJOR}\"
561Caption \"ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit) Setup\"
562
563InstallDir \"\${MY_PROGRAMFILES}\\ECLiPSe \${VER_MAJOR}\\\"
564OutFile ECLiPSe_\${VER_MAJOR}_\${VER_MINOR}_\${ARCH}.exe
565SetCompressor /SOLID lzma
566 
567InstType \"Typical\"
568InstType \"Reinstall\"
569InstType \"Full\"
570InstType \"Lite\"
571 
572ShowInstDetails show
573ShowUninstDetails show
574SetDateSave on
575 
576;--------------------------------
577; Header Files
578 
579!include \"MUI.nsh\"
580!include \"LogicLib.nsh\"
581!include \"Sections.nsh\"
582!include \"x64.nsh\"
583
584;--------------------------------
585; User Interface Configuration
586
587!define MUI_ABORTWARNING
588
589!define MUI_ICON \"\${NSISDIR}\\Contrib\\Graphics\\Icons\\modern-install-blue.ico\"
590!define MUI_UNICON \"\${NSISDIR}\\Contrib\\Graphics\\Icons\\modern-uninstall-blue.ico\"
591!define MUI_HEADERIMAGE
592!define MUI_HEADERIMAGE_BITMAP \"\${NSISDIR}\\Contrib\\Graphics\\Header\\orange.bmp\"
593!define MUI_HEADERIMAGE_UNBITMAP \"\${NSISDIR}\\Contrib\\Graphics\\Header\\orange-uninstall.bmp\"
594!define MUI_WELCOMEFINISHPAGE_BITMAP \"\${NSISDIR}\\Contrib\\Graphics\\Wizard\\orange.bmp\"
595!define MUI_UNWELCOMEFINISHPAGE_BITMAP \"\${NSISDIR}\\Contrib\\Graphics\\Wizard\\orange-uninstall.bmp\"
596
597!define MUI_BGCOLOR FFFFFF
598
599!define MUI_COMPONENTSPAGE_SMALLDESC
600
601!define MUI_WELCOMEPAGE_TITLE \"Welcome to the ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit) Setup Wizard\"
602
603!define MUI_WELCOMEPAGE_TEXT \"ECLiPSe is a software system for the cost-effective development and deployment of constraint programming applications. In addition, it is ideal for teaching most aspects of combinatorial problem solving, for example, problem modelling, constraint programming, mathematical programming, and search techniques.\\r\\n\\r\\nThe system contains several constraint solver libraries, a high-level modelling and control language, interfaces to third-party solvers, an integrated development environment and interfaces for embedding into host environments.\\r\\n\\r\\nThis wizard will guide you through the installation of ECLiPSe \${VER_MAJOR}.\\r\\n\\r\\n\$_CLICK\"
604
605!insertmacro MUI_PAGE_WELCOME
606!insertmacro MUI_PAGE_LICENSE \"legal\\cmpl.txt\"
607!insertmacro MUI_PAGE_COMPONENTS
608!define MUI_PAGE_CUSTOMFUNCTION_SHOW InstallDirectoryShow
609!define MUI_PAGE_CUSTOMFUNCTION_LEAVE InstallDirectoryLeave
610!insertmacro MUI_PAGE_DIRECTORY
611!define MUI_PAGE_CUSTOMFUNCTION_SHOW WorkDirectoryShow
612!define MUI_PAGE_CUSTOMFUNCTION_LEAVE WorkDirectoryLeave
613!insertmacro MUI_PAGE_DIRECTORY
614!insertmacro MUI_PAGE_INSTFILES
615
616!define MUI_FINISHPAGE_LINK \"Visit the ECLiPSe site for the latest news, FAQs and support\"
617!define MUI_FINISHPAGE_LINK_LOCATION \"http://eclipseclp.org\"
618!define MUI_FINISHPAGE_SHOWREADME \"\$8\\README_WIN.TXT\"
619!define MUI_FINISHPAGE_NOREBOOTSUPPORT
620!insertmacro MUI_PAGE_FINISH
621
622!insertmacro MUI_UNPAGE_CONFIRM
623!insertmacro MUI_UNPAGE_INSTFILES 
624
625;--------------------------------
626;Languages
627
628!insertmacro MUI_LANGUAGE \"English\" 
629  
630;--------------------------------
631;Reserve Files
632 
633!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
634
635;--------------------------------
636;Data
637 
638LicenseText \"ECLiPSe III Software Release Agreement\"
639LicenseData \"legal\\cmpl.txt\"
640 
641;--------------------------------
642;Installer Sections 
643
644" > ECLiPSe_${ECLIPSE_VERSION}_${BUILD_NUMBER}_$1.nsi
645}
646
647nsisfinish()	# $1=arch
648{
649    if [ "$pack_nsis_installer" = no ] || ! winarch $1 ; then
650    	return 0
651    fi
652
653    echo \
654"
655Section \"Install GraphViz\" SecGraphviz
656  SectionIn 1 3
657  DetailPrint \"Extracting Graphviz....\"
658  SetDetailsPrint textonly
659  SetOutPath \$8
660  File /nonfatal $NSIS_GRAPHVIZ_EXE
661  SetDetailsPrint both
662SectionEnd
663
664!ifndef NO_STARTMENUSHORTCUTS
665Section \"Start Menu + Desktop Shortcuts\" SecShortcuts
666!else
667Section \"Desktop Shortcut\" SecShortcuts
668!endif
669  SectionIn 1 2 3 4
670  SetOutPath \$8
671!ifndef NO_STARTMENUSHORTCUTS
672  SetShellVarContext all
673  CreateDirectory \"\$SMPROGRAMS\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\"
674  CreateShortCut \"\$SMPROGRAMS\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\\Readme.lnk\" \"\$8\\README_WIN.TXT\"
675
676  WriteINIStr \"\$SMPROGRAMS\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\ECLiPSe Homepage.url\" \"InternetShortcut\" \"URL\" \"http://eclipseclp.org\"
677  CreateShortCut \"\$SMPROGRAMS\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\\Uninstall ECLiPSe \${VER_MAJOR}.lnk\" \"\$8\\uninst-eclipse.exe\"
678
679  SectionGetFlags \${SecDoc} \$R0
680  IntOp \$R0 \$R0 & \${SF_SELECTED}
681  IntCmp \$R0 \${SF_SELECTED} \"\" lbl_no_online_doc lbl_no_online_doc
682  CreateShortCut \"\$SMPROGRAMS\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\\Documentation.lnk\" \"\$8\\doc\\index.html\"
683
684  lbl_no_online_doc:
685  SetOutPath \$7
686  CreateShortCut \"\$SMPROGRAMS\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\\DosEclipse.lnk\" \"\$8\\lib\\\${ARCH}\\eclipse.exe\"
687  ; If selected, use bundled Tcl/Tk, otherwise rely on installed one
688  SectionGetFlags \${SecTclTk} \$R0
689  IntOp \$R0 \$R0 & \${SF_SELECTED}
690  IntCmp \$R0 \${SF_SELECTED} 0 +4 +4
691  CreateShortCut \"\$SMPROGRAMS\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\\TkEclipse.lnk\" \"\$8\\tcltk\\\${ARCH}\\bin\\wish85.exe\" '\"\$8\\lib_tcl\\tkeclipse.tcl\"'
692  CreateShortCut \"\$SMPROGRAMS\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\\TkRemoteTools.lnk\" \"\$8\\tcltk\\\${ARCH}\\bin\\wish85.exe\" '\"\$8\\lib_tcl\\tktools.tcl\"'
693  Goto +3
694  CreateShortCut \"\$SMPROGRAMS\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\\TkEclipse.lnk\" \"\$8\\lib_tcl\\tkeclipse.tcl\"
695  CreateShortCut \"\$SMPROGRAMS\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\\TkRemoteTools.lnk\" \"\$8\\lib_tcl\\tktools.tcl\"
696!endif
697  
698SectionEnd
699
700Section -post
701
702  SetOutPath \$8
703
704  SetRegView \${VER_WORDLEN}  
705  DeleteRegKey HKLM \"Software\\IC-Parc\\Eclipse\\\${VER_MAJOR}\"
706  WriteRegStr HKLM \"Software\\IC-Parc\\Eclipse\\\${VER_MAJOR}\" ECLIPSEDIR \"\$8\"
707  DeleteRegKey HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\"
708  WriteRegExpandStr HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\" \"UninstallString\" \"\$8\\uninst-eclipse.exe\"
709  WriteRegExpandStr HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\" \"InstallLocation\" \"\$8\"
710  WriteRegStr HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\" \"DisplayName\" \"ECLiPSe Constraint Logic Programming System Version \${VER_MAJOR} (\${VER_WORDLEN} bit)\"
711  WriteRegStr HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\" \"DisplayIcon\" \"\$8\\lib\\\${ARCH}\\eclipse.exe,0\"
712  WriteRegStr HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\" \"DisplayVersion\" \"\${VER_MAJOR} #\${VER_MINOR}\"
713  WriteRegDWORD HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\" \"NoModify\" \"1\"
714  WriteRegDWORD HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\" \"NoRepair\" \"1\"
715
716  ; make the registry entries for the .ecl file class
717  DeleteRegKey HKCR .ecl
718  DeleteRegKey HKCR ECLiPSeSource
719  WriteRegStr HKCR .ecl \"\" \"ECLiPSeSource\"
720  WriteRegStr HKCR ECLiPSeSource \"\" \"ECLiPSe Source\"
721  WriteRegStr HKCR ECLiPSeSource\\shell\\Edit\\command \"\" \"notepad %1\"
722  WriteRegStr HKCR ECLiPSeSource\\shell\\Compile\\command \"\" \"\$8\\lib\\\${ARCH}\\eclipse.exe -b %1\"
723
724  ; delete obsolete preferences to avoid warnings
725  DeleteRegValue HKCU Software\\IC-Parc\\ECLiPSe\\tkeclipserc sharedsize
726
727  ; Set JRE_HOME
728  StrCpy \$R3 \"Software\\JavaSoft\\Java Runtime Environment\"
729  ReadRegStr \$R0 HKLM \$R3 CurrentVersion
730 
731  StrCmp \$R0 \"\" lbl_try_jdk
732
733  StrCpy \$R4 \"\"
734  Goto lbl_chk_jre
735
736  lbl_try_jdk:
737
738  StrCpy \$R3 \"Software\\JavaSoft\\Java Development Kit\"
739  ReadRegStr \$R0 HKLM \$R3 CurrentVersion
740 
741  StrCmp \$R0 \"\" lbl_no_jre
742  StrCpy \$R4 \"jre\\\"
743
744  lbl_chk_jre:
745 
746  ; Assume JRE is fine if it's 1.2 or greater
747  StrCpy \$R1 \$R0 1
748 
749  ; If leading version number > 1 then JRE is fine
750  ; If it's less, not fine, if it's equal, compare the minor version number
751  IntCmp \$R1 1 lbl_cmp_jre_minor_ver lbl_no_jre lbl_set_jre_home
752 
753  ; Specify a max string length (it's really a dummy so we can specify 4th arg)
754  lbl_cmp_jre_minor_ver:
755  StrLen \$R2 \$R0
756 
757  ; Copy from '.' onwards
758  StrCpy \$R1 \$R0 \$R2 2
759 
760  IntCmp \$R1 2 lbl_set_jre_home lbl_no_jre lbl_set_jre_home
761 
762  lbl_set_jre_home:
763  ReadRegStr \$R1 HKLM \"\$R3\\\$R0\" JavaHome
764  WriteRegStr HKLM \"Software\\IC-Parc\\Eclipse\\\${VER_MAJOR}\" JRE_HOME \$R1\$R4
765 
766  lbl_no_jre:
767  ; create working directory
768  CreateDirectory \$7
769
770  SetDetailsPrint lastused
771 
772  Delete \$8\\uninst-eclipse.exe
773  WriteUninstaller \$8\\uninst-eclipse.exe
774
775  SectionGetFlags \${SecGraphviz} \$R0
776  IntOp \$R0 \$R0 & \${SF_SELECTED}
777  IntCmp \$R0 \${SF_SELECTED} \"\" lbl_no_graphviz
778
779  Exec \"\$8\\$NSIS_GRAPHVIZ_EXE\"
780
781  lbl_no_graphviz:
782 
783SectionEnd
784 
785;--------------------------------
786;Uninstaller Section
787 
788Section Uninstall
789  IfFileExists \$INSTDIR\\lib\\\${ARCH}\\eclipse.exe skip_confirmation
790    MessageBox MB_YESNO \"It does not appear that ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit) is installed in the directory '\$INSTDIR'.\$\\r\$\\nContinue anyway (not recommended)\" IDYES skip_confirmation
791    Abort \"Uninstall aborted by user\"
792  skip_confirmation:
793  SetRegView \${VER_WORDLEN}  
794  DeleteRegKey HKLM \"Software\\IC-Parc\\Eclipse\\\${VER_MAJOR}\"
795  DeleteRegKey HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ECLiPSe \${VER_MAJOR}\"
796  DeleteRegKey /ifempty HKLM \"Software\\IC-Parc\\Eclipse\"
797  IfErrors lbl_other_versions_exist
798  DeleteRegKey HKCR \".ecl\"
799  DeleteRegKey HKCR ECLiPSeSource
800  lbl_other_versions_exist:
801  SetShellVarContext all
802  RMDir /r \"\$SMPROGRAMS\\ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit)\"
803  MessageBox MB_YESNO \"Delete directory '\$INSTDIR'.\$\\r\$\\nPlease ensure you have no source files you wish to retain!\" IDYES lbl_delete_instdir
804    Abort \"Uninstall aborted by user\"
805  lbl_delete_instdir:
806  RMDir /r \$INSTDIR
807
808SectionEnd
809
810;--------------------------------
811;Installer Functions
812
813Function InstallDirectoryShow
814  !insertmacro MUI_INNERDIALOG_TEXT 1041 \"Destination Folder\"
815  !insertmacro MUI_INNERDIALOG_TEXT 1019 \"\${MY_PROGRAMFILES}\\ECLiPSe \${VER_MAJOR}\\\"
816  !insertmacro MUI_INNERDIALOG_TEXT 1006 \"Setup will install ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit) in the following folder.\$\\r\$\\n\$\\r\$\\nTo install in a different folder, click Browse and select another folder.\$\\r\$\\n\$\\r\$\\nClick Next to continue.\"
817FunctionEnd
818
819Function InstallDirectoryLeave
820  StrCpy \$8 \$INSTDIR
821FunctionEnd
822
823Function WorkDirectoryShow
824  !insertmacro MUI_HEADER_TEXT \"Choose Working Folder Location\" \"Choose the working folder for when ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit) starts up.\"
825  !insertmacro MUI_INNERDIALOG_TEXT 1041 \"Working Folder\"
826  IfFileExists \$DOCUMENTS lbl_doc_exists lbl_doc_no_exists
827  lbl_doc_exists:
828  !insertmacro MUI_INNERDIALOG_TEXT 1019 \"\$DOCUMENTS\"
829  Goto +2
830  lbl_doc_no_exists:
831  !insertmacro MUI_INNERDIALOG_TEXT 1019 \"\$TEMP\"
832  !insertmacro MUI_INNERDIALOG_TEXT 1006 \"Setup will configure the following folder as the working directory for ECLiPSe \${VER_MAJOR} (\${VER_WORDLEN} bit) start up.\$\\r\$\\n\$\\r\$\\nTo configure an alternative folder, click Browse and select another folder.\$\\r\$\\n\$\\r\$\\nClick Install to start the installation.\"
833FunctionEnd
834
835Function WorkDirectoryLeave
836  StrCpy \$7 \$INSTDIR
837FunctionEnd
838" >> ECLiPSe_${ECLIPSE_VERSION}_${BUILD_NUMBER}_$1.nsi
839
840# x86_64_nt's initialisation checks that it is not running on Win32
841    if [ "$1" = x86_64_nt ] ; then 
842	echo \
843"
844Function .onInit
845 ; Only allow a single instance of the installer
846 System::Call 'kernel32::CreateMutexA(i 0, i 0, t \"ECLiPSeInstallMutex\") i .r1 ?e'
847 Pop \$R0
848
849 StrCmp \$R0 0 +3
850   MessageBox MB_OK|MB_ICONEXCLAMATION \"The ECLiPSe installer is already running.\"
851   Abort
852\${IfNot} \${RunningX64}
853   MessageBox MB_OK|MB_ICONEXCLAMATION \"You appear to be running a 32 bit Windows. This ECLiPSe is for 64 bit Windows only.\"
854     Abort 
855\${EndIf}
856FunctionEnd
857" >>  ECLiPSe_${ECLIPSE_VERSION}_${BUILD_NUMBER}_$1.nsi
858
859    else
860	echo \
861"
862Function .onInit
863 ; Only allow a single instance of the installer
864 System::Call 'kernel32::CreateMutexA(i 0, i 0, t \"ECLiPSeInstallMutex\") i .r1 ?e'
865 Pop \$R0
866
867 StrCmp \$R0 0 +3
868   MessageBox MB_OK|MB_ICONEXCLAMATION \"The ECLiPSe installer is already running.\"
869   Abort
870FunctionEnd
871" >>  ECLiPSe_${ECLIPSE_VERSION}_${BUILD_NUMBER}_$1.nsi
872
873    fi
874}
875
876echo Fixing permissions ...
877find $ALLDIRS \! -perm -a+r -print -exec chmod a+r {} \;
878find $ALLDIRS -perm -u+x \! -perm -a+x -print -exec chmod a+x {} \;
879find $ALLDIRS -perm -go+w -print -exec chmod go-w {} \;
880chmod a+rx UNPACK ARCH RUNME ecl_inst.js
881chmod a+r README_UNIX README_MACOSX README_WIN.TXT 
882chmod go-w UNPACK ARCH RUNME ecl_inst.js README_UNIX README_MACOSX README_WIN.TXT
883rm -f lib/*/SITE_PARAMS
884
885
886PRIVATE_FILES=`expand_file_list eclipse_private.lst`
887
888
889
890if [ "$pack_archs" = yes ] ; then
891    for arch in $ARCHITECTURES; do
892
893	# Create several file lists:
894	#
895	# RT_FILES	all files that go into eclipse_rt
896	#
897	# PRIVATE_FILES	all files that go into eclipse_private
898	#
899
900	# Definition of variables that can be used inside the .lst files
901	ARCH=$arch
902	case $ARCH in
903	    *_nt)
904		LIBPREFIX=
905		LIBSUFFIX=dll
906		SOSUFFIX=dll
907		AUXOBJ=
908		INSTALL_FILES="README_WIN.TXT ecl_inst.js"
909		INSTALL_FILES_RT="ecl_inst.js"
910		;;
911	    sun4)
912		LIBPREFIX=lib
913		LIBSUFFIX=a
914		SOSUFFIX=o
915		AUXOBJ=lib/$ARCH/auxiliary.o
916		INSTALL_FILES="README_UNIX ARCH RUNME lib/$ARCH/INST_PARAMS"
917		INSTALL_FILES_RT="ARCH RUNME lib/$ARCH/INST_PARAMS"
918		;;
919	    *_macosx)	
920		LIBPREFIX=lib
921		LIBSUFFIX=dylib
922		SOSUFFIX=dylib
923		AUXOBJ=
924		INSTALL_FILES="README_MACOSX ARCH RUNME lib/$ARCH/INST_PARAMS"
925		INSTALL_FILES_RT="ARCH RUNME lib/$ARCH/INST_PARAMS"
926		;;
927	    *)	
928		LIBPREFIX=lib
929		LIBSUFFIX=so
930		SOSUFFIX=so
931		AUXOBJ=
932		INSTALL_FILES="README_UNIX ARCH RUNME lib/$ARCH/INST_PARAMS"
933		INSTALL_FILES_RT="ARCH RUNME lib/$ARCH/INST_PARAMS"
934		;;
935	esac
936
937	RT_FILES=`expand_file_list eclipse_rt.lst`
938
939	nsisheader $arch
940
941	# The "basic" (development) package: everything with the exception
942	# of eplex (packed separately) and some sources.
943	# Don't include UNPACK (might be running during unpacking)
944	packarch $arch eclipse_basic "" \
945		"lib include lib_tcl $INSTALL_FILES legal" \
946		"$PRIVATE_FILES" "eplex seosi cplex gurobi xpress xpopt mp-opt pteclipse"
947
948
949	# The "runtime" package (eclipse_basic without development stuff,
950	# and no sources)
951	# The content of this package is defined in eclipse_rt.lst
952	packarch $arch eclipse_rt "" "$INSTALL_FILES_RT $RT_FILES"
953
954
955	# use tar h option to follow symbolic link
956	packarch $arch tcltk ""	"tcltk"	"$PRIVATE_FILES" "" h
957
958
959	# Pack the different eplex interfaces, each consisting of:
960	# - the machine-independent *eplex* files
961	# - the dynamic library $arch/e${SOLVER}.{so,dll}
962	# - optional support files (licence files, auxiliary libs)
963	#   in the subdirectory $arch/e${SOLVER}
964	for SOLVER in $EPLEX_SOLVERS; do
965	    if test -r lib/$arch/se${SOLVER}.*; then
966		# Note: the solver auxiliary files in $arch/e$SOLVER/ are not packed (not ours!)
967		packarch $arch if_${SOLVER} "" "lib/*eplex* lib/$arch/e${SOLVER}.* lib/$arch/se${SOLVER}.*" "$PRIVATE_FILES"
968	    fi
969	done
970
971	for SOLVER in $PRIVATE_EPLEX_SOLVERS; do
972	    if test -r lib/$arch/se${SOLVER}.*; then
973		# Note: find is used to find a related subdirectory with aux files, if any
974		packarch $arch if_${SOLVER} private "lib/*eplex* lib/$arch/*${SOLVER}.* `find lib/$arch -name e${SOLVER}`" "$PRIVATE_FILES"
975	    fi
976	done
977
978	# Similar, but without the eplex_lic_info file
979	for SOLVER in $EPLEX_SOLVERS_PT; do
980	    if test -r lib/$arch/se${SOLVER}.*; then
981		# Note: find is used to find a related subdirectory with aux files, if any
982		packarch $arch if_${SOLVER} private "lib/*eplex* lib/$arch/e${SOLVER}.* lib/$arch/se${SOLVER}.* lib/$arch/${SOLVER}.* `find lib/$arch -name e${SOLVER}`" "lib/eplex_lic_info.ecl $PRIVATE_FILES"
983	    fi
984	done
985
986    done
987fi
988
989if [ "$pack_common" = yes ] ; then
990    arch=common
991	packarch $arch eclipse_misc ""		"lib_public"
992	packarch $arch eclipse_doc ""	"doc man"	"$PRIVATE_FILES" "" h
993
994    arch=private
995	# The content of this package is defined in eclipse_private.lst
996        # this still assumes that this package is architecture independent
997	packarch common eclipse_private private		"$PRIVATE_FILES"
998
999    cp README_UNIX README_MACOSX README_WIN.TXT UNPACK $DEST_DIR/common
1000fi
1001
1002if [ "$nsis_spec_created" = yes ] ; then
1003    for arch in $ARCHITECTURES; do
1004	if winarch $arch ; then
1005	    nsisfinish $arch
1006	    echo "Building NSIS Windoze installer"
1007	    nsis_basename=ECLiPSe_${ECLIPSE_VERSION}_${BUILD_NUMBER}_${arch}
1008	    makensis -V4 -OECLiPSe_NSIS_${arch}.log $nsis_basename.nsi &&
1009		# +x needed by Vista!
1010		chmod a+x $nsis_basename.exe &&
1011		mv $nsis_basename.exe $DEST_DIR/$arch \
1012	    || everything_ok=1
1013	fi
1014    done
1015fi
1016
1017exit $everything_ok
1018
1019