| 1 |
#!/bin/bash |
|---|
| 2 |
|
|---|
| 3 |
# Script to install Tango on *nix based platforms |
|---|
| 4 |
# Copyright (C) 2006-2008 Gregor Richards, Lars Ivar Igesund |
|---|
| 5 |
# Permission is granted to do anything you please with this software. |
|---|
| 6 |
# This software is provided with no warranty, express or implied, within the |
|---|
| 7 |
# bounds of applicable law. |
|---|
| 8 |
# |
|---|
| 9 |
# Modifications by Alexander Panek |
|---|
| 10 |
|
|---|
| 11 |
die() { |
|---|
| 12 |
echo "$1" |
|---|
| 13 |
exit $2 |
|---|
| 14 |
} |
|---|
| 15 |
|
|---|
| 16 |
usage() { |
|---|
| 17 |
echo 'Usage: install.sh [[option <argument>] ...] <compilername> |
|---|
| 18 |
Options: |
|---|
| 19 |
--prefix: Install to the specified prefix (absolute path), default is |
|---|
| 20 |
/usr/local |
|---|
| 21 |
--userlib: Installs libtango-user-*.a too. It will also be built if it is |
|---|
| 22 |
missing or older than libtango-base-*.a. Note that this is |
|---|
| 23 |
not necessary if you use DSSS or other build tools for the |
|---|
| 24 |
user part of the Tango API |
|---|
| 25 |
--altconf: Use an alternate path component for the DMD conf, "bin" is |
|---|
| 26 |
default, "-" will set it to empty. See also --confprefix |
|---|
| 27 |
--altlib: Use an alternate path component for the library files, "lib" is |
|---|
| 28 |
default, "-" will set it to empty. |
|---|
| 29 |
--altincl: Use an alternate path component for import files, "include" is |
|---|
| 30 |
default, "-" will set it to empty (will install at PREFIX!) |
|---|
| 31 |
--confprefix: Use a specific prefix for where DMD binary resides, otherwise |
|---|
| 32 |
PREFIX is used (absolute path). Note that this combined with |
|---|
| 33 |
--altconf can be used to put dmd.conf somewhere else than |
|---|
| 34 |
together with the binary, either your $HOME or /etc. Note that |
|---|
| 35 |
together with the DMD binary seems most stable. |
|---|
| 36 |
--libprefix: Use a specific prefix for where libs should be installed, |
|---|
| 37 |
otherwise PREFIX is used (absolute path). |
|---|
| 38 |
--inclprefix: Use a specific prefix for where imports should be installed, |
|---|
| 39 |
otherwise PREFIX is used (absolute path). |
|---|
| 40 |
--uninstall: Uninstall Tango, switch back to standard Phobos. |
|---|
| 41 |
--as-phobos: This will install libtango-base-*.a as lib*phobos.a as per old |
|---|
| 42 |
style. This is default for older DMD installations. |
|---|
| 43 |
--verify: Will verify installation. |
|---|
| 44 |
--verbose: Will produce various progress output |
|---|
| 45 |
--help: Will print this help text.' |
|---|
| 46 |
exit 0 |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
INSTALLED=0 |
|---|
| 50 |
BASELIB64=0 |
|---|
| 51 |
PREFIX= |
|---|
| 52 |
VERBOSE=0 |
|---|
| 53 |
USERPREFIX=0 |
|---|
| 54 |
VERIFY=0 |
|---|
| 55 |
|
|---|
| 56 |
# Default values |
|---|
| 57 |
defaultdmd() { |
|---|
| 58 |
UNINSTALL=0 |
|---|
| 59 |
ASPHOBOS=0 |
|---|
| 60 |
CONF="bin" |
|---|
| 61 |
LIB="lib" |
|---|
| 62 |
INCL="include" |
|---|
| 63 |
if [ "$USERPREFIX" = "0" ] |
|---|
| 64 |
then |
|---|
| 65 |
dmdBin=`which dmd` |
|---|
| 66 |
dmdBinDir=`dirname "$dmdBin"` |
|---|
| 67 |
PREFIX=`dirname "$dmdBinDir"` |
|---|
| 68 |
fi |
|---|
| 69 |
CONFPREFIX="$PREFIX" |
|---|
| 70 |
LIBPREFIX="$PREFIX" |
|---|
| 71 |
INCLPREFIX="$PREFIX" |
|---|
| 72 |
BASELIBNAME="libtango-base-dmd.a" |
|---|
| 73 |
USERLIBNAME="libtango-user-dmd.a" |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
defaultgdc() { |
|---|
| 77 |
UNINSTALL=0 |
|---|
| 78 |
ASPHOBOS=1 # Using libgphobos name for now |
|---|
| 79 |
CONF="bin" |
|---|
| 80 |
LIB="lib" |
|---|
| 81 |
INCL="include" |
|---|
| 82 |
|
|---|
| 83 |
if [ "$USERPREFIX" = "0" ] |
|---|
| 84 |
then |
|---|
| 85 |
LIBPREFIX="`${CROSS}gdc -print-file-name=libgphobos.a`" |
|---|
| 86 |
#LIBPREFIX="`readlink -f $LIBPREFIX`" |
|---|
| 87 |
LIBPREFIX="`dirname $LIBPREFIX`/.." |
|---|
| 88 |
|
|---|
| 89 |
# If we have which, use it to get the prefix |
|---|
| 90 |
which ${CROSS}gdc >& /dev/null |
|---|
| 91 |
if [ "$?" = "0" ] |
|---|
| 92 |
then |
|---|
| 93 |
PREFIX="`which ${CROSS}gdc`" |
|---|
| 94 |
PREFIX="`dirname $PREFIX`/.." |
|---|
| 95 |
else |
|---|
| 96 |
PREFIX="$LIBPREFIX" |
|---|
| 97 |
fi |
|---|
| 98 |
|
|---|
| 99 |
if [ -e "$LIB_PREFIX/lib64" ] |
|---|
| 100 |
then |
|---|
| 101 |
BASELIB64=1 |
|---|
| 102 |
fi |
|---|
| 103 |
else |
|---|
| 104 |
LIBPREFIX="$PREFIX" |
|---|
| 105 |
fi |
|---|
| 106 |
|
|---|
| 107 |
CONFPREFIX="$PREFIX" |
|---|
| 108 |
INCLPREFIX="$PREFIX" |
|---|
| 109 |
BASELIBNAME="libgphobos.a" |
|---|
| 110 |
USERLIBNAME="libgtango.a" |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
uninstalldmd() { |
|---|
| 114 |
# Revert to Phobos if earlier evidence of existense is found |
|---|
| 115 |
# Only relevant for pre 0.99.3 installations or --as-phobos installs |
|---|
| 116 |
if [ -e "$LIBPREFIX/$LIB/libphobos.a.phobos" ] |
|---|
| 117 |
then |
|---|
| 118 |
mv $LIBPREFIX/$LIB/libphobos.a.phobos $LIBPREFIX/$LIB/libphobos.a |
|---|
| 119 |
else |
|---|
| 120 |
if [ -e "$LIBPREFIX/$LIB/libphobos.a" ] |
|---|
| 121 |
then |
|---|
| 122 |
rm -f $LIBPREFIX/$LIB/libphobos.a |
|---|
| 123 |
fi |
|---|
| 124 |
fi |
|---|
| 125 |
if [ -e "$INCLPREFIX/$INCL/d/object.d.phobos" ] |
|---|
| 126 |
then |
|---|
| 127 |
mv $INCLPREFIX/$INCL/d/object.d.phobos $INCLPREFIX/$INCL/d/object.d |
|---|
| 128 |
fi |
|---|
| 129 |
if [ -e "$CONFPREFIX/$CONF/dmd.conf.phobos" ] |
|---|
| 130 |
then |
|---|
| 131 |
mv $CONFPREFIX/$CONF/dmd.conf $CONFPREFIX/$CONF/dmd.conf.tango |
|---|
| 132 |
mv $CONFPREFIX/$CONF/dmd.conf.phobos $CONFPREFIX/$CONF/dmd.conf |
|---|
| 133 |
fi |
|---|
| 134 |
# Tango 0.97 installed to this dir |
|---|
| 135 |
if [ -e "$PREFIX/import/v1.012" ] |
|---|
| 136 |
then |
|---|
| 137 |
rm -rf $PREFIX/import/v1.012 |
|---|
| 138 |
fi |
|---|
| 139 |
# Since Tango 0.98 |
|---|
| 140 |
if [ -e "$PREFIX/include/d/tango/object.di" ] |
|---|
| 141 |
then |
|---|
| 142 |
rm -rf $PREFIX/include/d/tango/tango |
|---|
| 143 |
rm -rf $PREFIX/include/d/tango/std |
|---|
| 144 |
rm -f $PREFIX/include/d/tango/object.di |
|---|
| 145 |
fi |
|---|
| 146 |
# Since Tango 0.99 |
|---|
| 147 |
if [ -e "$INCLPREFIX/$INCL/d/object.di" ] |
|---|
| 148 |
then |
|---|
| 149 |
rm -rf $INCLPREFIX/$INCL/d/tango |
|---|
| 150 |
rm -rf $INCLPREFIX/$INCL/d/std |
|---|
| 151 |
rm -f $INCLPREFIX/$INCL/d/object.di |
|---|
| 152 |
fi |
|---|
| 153 |
|
|---|
| 154 |
# Prior to Tango 0.99.3 |
|---|
| 155 |
if [ -e "$PREFIX/$LIB/libtango.a" ] |
|---|
| 156 |
then |
|---|
| 157 |
rm -f $PREFIX/$LIB/libtango.a |
|---|
| 158 |
fi |
|---|
| 159 |
|
|---|
| 160 |
# Since Tango 0.99.3 |
|---|
| 161 |
if [ -e "$LIBPREFIX/$LIB/libtango-base-dmd.a" ] |
|---|
| 162 |
then |
|---|
| 163 |
rm -f $LIBPREFIX/$LIB/libtango-base-dmd.a |
|---|
| 164 |
fi |
|---|
| 165 |
|
|---|
| 166 |
if [ -e "$LIBPREFIX/$LIB/libtango-user-dmd.a" ] |
|---|
| 167 |
then |
|---|
| 168 |
rm -f $LIBPREFIX/$LIB/libtango-user-dmd.a |
|---|
| 169 |
fi |
|---|
| 170 |
} |
|---|
| 171 |
|
|---|
| 172 |
uninstallgdc() { |
|---|
| 173 |
rm -rf $LIBPREFIX/$LIB/libgphobos.a $PREFIX/include/d/$GDC_VER/object.d |
|---|
| 174 |
if [ "$BASELIB_64" = "1" ] |
|---|
| 175 |
then |
|---|
| 176 |
rm -rf $LIBPREFIX/lib64/libgphobos.a |
|---|
| 177 |
if [ -e "$LIBPREFIX/lib64/libgphobos.a.phobos" ] |
|---|
| 178 |
then |
|---|
| 179 |
mv $LIBPREFIX/lib64/libgphobos.a.phobos $LIBPREFIX/lib64/libgphobos.a |
|---|
| 180 |
fi |
|---|
| 181 |
fi |
|---|
| 182 |
if [ -e "$LIBPREFIX/$LIB/libgphobos.a.phobos" ] |
|---|
| 183 |
then |
|---|
| 184 |
mv $PREFIX/include/d/$GDC_VER/object.d.phobos $PREFIX/include/d/$GDC_VER/object.d |
|---|
| 185 |
mv $LIBPREFIX/$LIB/libgphobos.a.phobos $LIBPREFIX/$LIB/libgphobos.a |
|---|
| 186 |
fi |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
backupdmd() { |
|---|
| 190 |
# Back up the original files |
|---|
| 191 |
if [ -e "$INCLPREFIX/$INCL/d/object.d" ] |
|---|
| 192 |
then |
|---|
| 193 |
mv -f $INCLPREFIX/$INCL/d/object.d $INCLPREFIX/$INCL/d/object.d.phobos |
|---|
| 194 |
fi |
|---|
| 195 |
|
|---|
| 196 |
if [ "$ASPHOBOS" = "1" ] |
|---|
| 197 |
then |
|---|
| 198 |
if [ -e "$LIBPREFIX/$LIB/libphobos.a" ] |
|---|
| 199 |
then |
|---|
| 200 |
mv -f $LIBPREFIX/$LIB/libphobos.a $LIBPREFIX/$LIB/libphobos.a.phobos |
|---|
| 201 |
fi |
|---|
| 202 |
fi |
|---|
| 203 |
} |
|---|
| 204 |
|
|---|
| 205 |
backupgdc() { |
|---|
| 206 |
if [ -e "$LIBPREFIX/$LIB/libgphobos.a" -a \ |
|---|
| 207 |
! -e "$LIBPREFIX/$LIB/libgphobos.a.phobos" ] |
|---|
| 208 |
then |
|---|
| 209 |
if [ "$VERBOSE" = "1" ]; then echo "Backing up libgphobos.a to libgphobos.a.phobos"; fi |
|---|
| 210 |
mv -f $LIBPREFIX/$LIB/libgphobos.a $LIBPREFIX/$LIB/libgphobos.a.phobos |
|---|
| 211 |
if [ -e "$PREFIX/include/d/$GDC_VER/object.d" ] |
|---|
| 212 |
then |
|---|
| 213 |
mv -f $PREFIX/include/d/$GDC_VER/object.d $PREFIX/include/d/$GDC_VER/object.d.phobos |
|---|
| 214 |
fi |
|---|
| 215 |
if [ "$BASELIB_64" = "1" ] |
|---|
| 216 |
then |
|---|
| 217 |
if [ -e "$LIBPREFIX/lib64/libgphobos.a" ] |
|---|
| 218 |
then |
|---|
| 219 |
mv -f $LIBPREFIX/lib64/libgphobos.a $LIBPREFIX/lib64/libgphobos.a.phobos |
|---|
| 220 |
fi |
|---|
| 221 |
fi |
|---|
| 222 |
fi |
|---|
| 223 |
} |
|---|
| 224 |
|
|---|
| 225 |
dmdtest() { |
|---|
| 226 |
if [ "$DMDVERSIONMAJ" != "" ] |
|---|
| 227 |
then |
|---|
| 228 |
if [ ! "$DMDVERSIONMAJ" -gt 1 ] |
|---|
| 229 |
then |
|---|
| 230 |
if [ ! "$DMDVERSIONMIN" -gt 21 ] |
|---|
| 231 |
then |
|---|
| 232 |
if [ "$VERBOSE" = "1" ]; then echo "Your version of DMD have no support for -defaultlib flag, using libphobos.a"; fi |
|---|
| 233 |
ASPHOBOS="1" |
|---|
| 234 |
fi |
|---|
| 235 |
fi |
|---|
| 236 |
fi |
|---|
| 237 |
|
|---|
| 238 |
return 0 |
|---|
| 239 |
} |
|---|
| 240 |
|
|---|
| 241 |
gdctest() { |
|---|
| 242 |
# TODO Should test for GDC version since GDC 0.24 and older really isn't usable anymore |
|---|
| 243 |
return 0 |
|---|
| 244 |
} |
|---|
| 245 |
|
|---|
| 246 |
# Create dmd.conf |
|---|
| 247 |
create_dmd_conf() { |
|---|
| 248 |
if [ "$ASPHOBOS" = "1" ] |
|---|
| 249 |
then |
|---|
| 250 |
cat > $CONFPREFIX/$CONF/dmd.conf <<EOF |
|---|
| 251 |
[Environment] |
|---|
| 252 |
DFLAGS=-I$INCLPREFIX/$INCL/d -version=Tango $POSIXFLAG -L-L"$LIBPREFIX/$LIB" |
|---|
| 253 |
EOF |
|---|
| 254 |
else |
|---|
| 255 |
cat > $CONFPREFIX/$CONF/dmd.conf <<EOF |
|---|
| 256 |
[Environment] |
|---|
| 257 |
DFLAGS=-I$INCLPREFIX/$INCL/d -defaultlib=tango-base-dmd -debuglib=tango-base-dmd -version=Tango $POSIXFLAG -L-L"$LIBPREFIX/$LIB" |
|---|
| 258 |
EOF |
|---|
| 259 |
fi |
|---|
| 260 |
} |
|---|
| 261 |
|
|---|
| 262 |
configdmd() { |
|---|
| 263 |
if [ ! -e "$CONFPREFIX/$CONF/dmd.conf" ] |
|---|
| 264 |
then |
|---|
| 265 |
if [ "$VERBOSE" = "1" ]; then echo "Could not find dmd.conf in $CONFPREFIX/$CONF, create a new one."; fi |
|---|
| 266 |
create_dmd_conf |
|---|
| 267 |
else |
|---|
| 268 |
# Is it a phobos conf ? |
|---|
| 269 |
if [ ! "`grep '\-version=Tango' $CONFPREFIX/$CONF/dmd.conf`" ] |
|---|
| 270 |
then |
|---|
| 271 |
if [ "$VERBOSE" = "1" ]; then echo "Backing up dmd.conf to dmd.conf.phobos, creating new dmd.conf"; fi |
|---|
| 272 |
mv $CONFPREFIX/$CONF/dmd.conf $CONFPREFIX/$CONF/dmd.conf.phobos |
|---|
| 273 |
create_dmd_conf |
|---|
| 274 |
elif [ "$ASPHOBOS" = "1" ] |
|---|
| 275 |
then |
|---|
| 276 |
if [ "`grep '\-defaultlib=tango\-base\-dmd' $CONFPREFIX/$CONF/dmd.conf`" ] |
|---|
| 277 |
then |
|---|
| 278 |
if [ "$VERBOSE" = "1" ]; then echo "Removing and re-creating dmd.conf"; fi |
|---|
| 279 |
rm -rf $CONFPREFIX/$CONF/dmd.conf |
|---|
| 280 |
create_dmd_conf |
|---|
| 281 |
fi |
|---|
| 282 |
else |
|---|
| 283 |
if [ ! "`grep '\-defaultlib=tango\-base\-dmd' $CONFPREFIX/$CONF/dmd.conf`" ] |
|---|
| 284 |
then |
|---|
| 285 |
if [ "$VERBOSE" = "1" ]; then echo "Appending -defaultlib switch to DFLAGS"; fi |
|---|
| 286 |
sed -i.bak1 -e 's/^DFLAGS=.*$/& -defaultlib=tango-base-dmd/' $CONFPREFIX/$CONF/dmd.conf |
|---|
| 287 |
if [ ! "`grep '\-debuglib=tango\-base\-dmd' $CONFPREFIX/$CONF/dmd.conf`" ] |
|---|
| 288 |
then |
|---|
| 289 |
if [ "$VERBOSE" = "1" ]; then echo "Appending -debuglib switch to DFLAGS"; fi |
|---|
| 290 |
sed -i.bak2 -e 's/^DFLAGS=.*$/& -debuglib=tango-base-dmd/' $CONFPREFIX/$CONF/dmd.conf |
|---|
| 291 |
fi |
|---|
| 292 |
elif [ "`grep '\-version=Posix' $CONFPREFIX/$CONF/dmd.conf`" -a ! "$POSIXFLAG" ] |
|---|
| 293 |
then |
|---|
| 294 |
if [ "$VERBOSE" = "1" ]; then echo "Removing -version=Posix due to upgraded DMD."; fi |
|---|
| 295 |
sed -i.bak3 -e 's/-version=Posix//g' $CONFPREFIX/$CONF/dmd.conf |
|---|
| 296 |
elif [ ! "`grep '\-version=Posix' $CONFPREFIX/$CONF/dmd.conf`" -a -n "$POSIXFLAG" ] |
|---|
| 297 |
then |
|---|
| 298 |
if [ "$VERBOSE" = "1" ]; then echo "Add missing -version=Posix."; fi |
|---|
| 299 |
sed -i.bak3 -e 's/^DFLAGS=.*$/& -version=Posix/' $CONFPREFIX/$CONF/dmd.conf |
|---|
| 300 |
else |
|---|
| 301 |
if [ "$VERBOSE" = "1" ]; then echo "Found Tango enabled dmd.conf, leave as it is"; fi |
|---|
| 302 |
fi |
|---|
| 303 |
fi |
|---|
| 304 |
fi |
|---|
| 305 |
|
|---|
| 306 |
if [ "$USERLIB" = "1" ] |
|---|
| 307 |
then |
|---|
| 308 |
if [ ! "`grep '\-L\-ltango\-user\-dmd' $CONFPREFIX/$CONF/dmd.conf`" ] |
|---|
| 309 |
then |
|---|
| 310 |
if [ "$VERBOSE" = "1" ]; then echo "Appending user library to dmd.conf"; fi |
|---|
| 311 |
sed -i.bak -e 's/^DFLAGS=.*$/& -L-ltango-user-dmd/' $CONFPREFIX/$CONF/dmd.conf |
|---|
| 312 |
fi |
|---|
| 313 |
fi |
|---|
| 314 |
|
|---|
| 315 |
} |
|---|
| 316 |
|
|---|
| 317 |
configgdc() { |
|---|
| 318 |
# Implement if it makes sense to use GDC spec file (from GDC 0.25?) as we use dmd.conf |
|---|
| 319 |
return 0 |
|---|
| 320 |
} |
|---|
| 321 |
|
|---|
| 322 |
verifydmd() { |
|---|
| 323 |
if [ ! -e "$CONFPREFIX/$CONF/dmd.conf" ] |
|---|
| 324 |
then |
|---|
| 325 |
die "dmd.conf not present in $CONFPREFIX/$CONF" 11 |
|---|
| 326 |
elif [ ! "`grep '\-version=Tango' $CONFPREFIX/$CONF/dmd.conf`" ] |
|---|
| 327 |
then |
|---|
| 328 |
die "dmd.conf not Tango enabled" 12 |
|---|
| 329 |
elif [ ! "`grep '\-defaultlib=tango\-base\-dmd' $CONFPREFIX/$CONF/dmd.conf`" ] |
|---|
| 330 |
then |
|---|
| 331 |
die "dmd.conf don't have -defaultlib switch" 13 |
|---|
| 332 |
elif [ ! "`grep '\-debuglib=tango\-base\-dmd' $CONFPREFIX/$CONF/dmd.conf`" ] |
|---|
| 333 |
then |
|---|
| 334 |
die "dmd.conf don't have -debuglib switch" 14 |
|---|
| 335 |
fi |
|---|
| 336 |
if [ "$USERLIB" = "1" ] |
|---|
| 337 |
then |
|---|
| 338 |
if [ ! "`grep '\-L\-ltango\-user\-dmd' $CONFPREFIX/$CONF/dmd.conf`" ] |
|---|
| 339 |
then |
|---|
| 340 |
die "dmd.conf don't have reference to user library." 15 |
|---|
| 341 |
elif [ ! -e "$LIBPREFIX/$LIB/libtango-user-dmd.a" ] |
|---|
| 342 |
then |
|---|
| 343 |
die "libtango-user-dmd.a not properly installed to $LIBPREFIX/$LIB" 16 |
|---|
| 344 |
fi |
|---|
| 345 |
fi |
|---|
| 346 |
} |
|---|
| 347 |
|
|---|
| 348 |
verifygdc() { |
|---|
| 349 |
return 0 |
|---|
| 350 |
} |
|---|
| 351 |
|
|---|
| 352 |
verify() { |
|---|
| 353 |
if [ "$VERBOSE" = "1" ]; then echo "Verifying installation."; fi |
|---|
| 354 |
if [ ! -e "$INCLPREFIX/$INCL/d/object.di" ] |
|---|
| 355 |
then |
|---|
| 356 |
die "object.di not properly installed to $INCLPREFIX/$INCL/d" 9 |
|---|
| 357 |
fi |
|---|
| 358 |
if [ ! -e "$LIBPREFIX/$LIB/$BASELIB" ] |
|---|
| 359 |
then |
|---|
| 360 |
die "$BASELIB not properly installed to $LIBPREFIX/$LIB" 10 |
|---|
| 361 |
fi |
|---|
| 362 |
if [ "$VERBOSE" = "1" ]; then echo "Installation OK."; fi |
|---|
| 363 |
} |
|---|
| 364 |
|
|---|
| 365 |
install() { |
|---|
| 366 |
if [ "$INSTALLED" = "1" ] |
|---|
| 367 |
then |
|---|
| 368 |
die "Installation is supported for only one compiler per run.", 30 |
|---|
| 369 |
fi |
|---|
| 370 |
INSTALLED=1 |
|---|
| 371 |
|
|---|
| 372 |
default$1 |
|---|
| 373 |
. $1include |
|---|
| 374 |
$1settings |
|---|
| 375 |
|
|---|
| 376 |
if [ "$VERBOSE" = "1" ]; then echo "Prefix was set to $PREFIX"; fi |
|---|
| 377 |
|
|---|
| 378 |
if $1test |
|---|
| 379 |
then |
|---|
| 380 |
if [ "$1" = "dmd" ] |
|---|
| 381 |
then |
|---|
| 382 |
if [ "$ASPHOBOS" = "1" ] |
|---|
| 383 |
then |
|---|
| 384 |
BASELIB="libphobos.a" |
|---|
| 385 |
if [ "$VERBOSE" = "1" ] |
|---|
| 386 |
then |
|---|
| 387 |
echo "Copy libtango-base-dmd.a to libphobos.a" |
|---|
| 388 |
cp -pv libtango-base-dmd.a libphobos.a |
|---|
| 389 |
else |
|---|
| 390 |
cp -p libtango-base-dmd.a libphobos.a |
|---|
| 391 |
fi |
|---|
| 392 |
fi |
|---|
| 393 |
fi |
|---|
| 394 |
|
|---|
| 395 |
if [ "$VERBOSE" = "1" ] |
|---|
| 396 |
then |
|---|
| 397 |
echo "Binary prefix: $CONFPREFIX" |
|---|
| 398 |
echo "Library prefix: $LIBPREFIX" |
|---|
| 399 |
echo "Import prefix: $INCLPREFIX" |
|---|
| 400 |
fi |
|---|
| 401 |
|
|---|
| 402 |
# Verify that PREFIX is absolute |
|---|
| 403 |
if [ "${PREFIX:0:1}" != "/" ] |
|---|
| 404 |
then |
|---|
| 405 |
die "PREFIX needs to be an absolute path, not $PREFIX" 1 |
|---|
| 406 |
elif [ "${CONFPREFIX:0:1}" != "/" ] |
|---|
| 407 |
then |
|---|
| 408 |
die "CONFPREFIX needs to be an absolute path, not $CONFPREFIX" 1 |
|---|
| 409 |
elif [ "${LIBPREFIX:0:1}" != "/" ] |
|---|
| 410 |
then |
|---|
| 411 |
die "LIB needs to be an absolute path, not $LIBPREFIX" 1 |
|---|
| 412 |
elif [ "${INCLPREFIX:0:1}" != "/" ] |
|---|
| 413 |
then |
|---|
| 414 |
die "INCLPREFIX needs to be an absolute path, not $INCLPREFIX" 1 |
|---|
| 415 |
fi |
|---|
| 416 |
|
|---|
| 417 |
# Verify presence of compiler |
|---|
| 418 |
$1 --help >& /dev/null || die "$1 not found on your \$PATH!" 1 |
|---|
| 419 |
|
|---|
| 420 |
# If uninstalling, do that now |
|---|
| 421 |
if [ "$UNINSTALL" = "1" ] |
|---|
| 422 |
then |
|---|
| 423 |
if [ "$VERIFY" = "1" ] |
|---|
| 424 |
then |
|---|
| 425 |
if [ "$VERBOSE" = "1" ]; then echo "Not veryfying uninstall"; fi |
|---|
| 426 |
VERIFY=0 |
|---|
| 427 |
fi |
|---|
| 428 |
|
|---|
| 429 |
uninstall$1 |
|---|
| 430 |
if [ "$VERBOSE" = "1" ]; then echo "Uninstall complete!"; fi |
|---|
| 431 |
exit 0 |
|---|
| 432 |
fi |
|---|
| 433 |
|
|---|
| 434 |
# Build missing libs |
|---|
| 435 |
if [ ! -e $BASELIBNAME ] |
|---|
| 436 |
then |
|---|
| 437 |
if [ "$VERBOSE" = "1" ]; then echo "$BASELIBNAME not found, trying to build it."; fi |
|---|
| 438 |
./build-$1.sh || die "Failed to build $BASELIBNAME, try running build-$1.sh manually." 4 |
|---|
| 439 |
fi |
|---|
| 440 |
|
|---|
| 441 |
if [ "$USERLIB" = "1" ] |
|---|
| 442 |
then |
|---|
| 443 |
if [ "$BASELIBNAME" -nt "$USERLIBNAME" ] |
|---|
| 444 |
then |
|---|
| 445 |
if [ "$VERBOSE" = "1" ] |
|---|
| 446 |
then |
|---|
| 447 |
echo "$USERLIBNAME not found or older than $BASELIBNAME, trying to build it." |
|---|
| 448 |
./build-tango.sh --verbose $1 || die "Failed to build $USERLIBNAME, try running ./build-tango.sh $1 manually." 4 |
|---|
| 449 |
else |
|---|
| 450 |
./build-tango.sh $1 || die "Failed to build $USERLIBNAME, try running ./build-tango.sh $1 manually." 4 |
|---|
| 451 |
fi |
|---|
| 452 |
fi |
|---|
| 453 |
fi |
|---|
| 454 |
|
|---|
| 455 |
backup$1 |
|---|
| 456 |
if [ "$VERBOSE" = "1" ] |
|---|
| 457 |
then |
|---|
| 458 |
echo "Copying files..." |
|---|
| 459 |
echo "Creating directories $INCLPREFIX/$INCL/d, $LIBPREFIX/$LIB and $CONFPREFIX/$CONF" |
|---|
| 460 |
echo " if they don't exist." |
|---|
| 461 |
mkdir -pv $INCLPREFIX/$INCL/d || die "Failed to create $INCL/d (maybe you need root privileges?)" 5 |
|---|
| 462 |
mkdir -pv $LIBPREFIX/$LIB/ || die "Failed to create $LIBPREFIX/$LIB (maybe you need root privileges?)" 5 |
|---|
| 463 |
mkdir -pv $CONFPREFIX/$CONF/ || die "Failed to create $CONFPREFIX/$CONF" 5 |
|---|
| 464 |
echo "Installing $BASELIBNAME to $LIBPREFIX/$LIB" |
|---|
| 465 |
cp -pRvf $BASELIBNAME $LIBPREFIX/$LIB/ || die "Failed to copy base library." 7 |
|---|
| 466 |
echo "Installing object.di to $INCLPREFIX/$INCL/d/" |
|---|
| 467 |
cp -pRvf ../object.di $INCLPREFIX/$INCL/d/object.di || die "Failed to copy source." 8 |
|---|
| 468 |
else |
|---|
| 469 |
mkdir -p $INCLPREFIX/$INCL/d || die "Failed to create $INCL/d (maybe you need root privileges?)" 5 |
|---|
| 470 |
mkdir -p $LIBPREFIX/$LIB/ || die "Failed to create $LIBPREFIX/$LIB (maybe you need root privileges?)" 5 |
|---|
| 471 |
mkdir -p $CONFPREFIX/$CONF/ || die "Failed to create $CONFPREFIX/$CONF" 5 |
|---|
| 472 |
cp -pRf $BASELIBNAME $LIBPREFIX/$LIB/ || die "Failed to copy base library." 7 |
|---|
| 473 |
cp -pRf ../object.di $INCLPREFIX/$INCL/d/object.di || die "Failed to copy source." 8 |
|---|
| 474 |
fi |
|---|
| 475 |
|
|---|
| 476 |
if [ "$USERLIB" = "1" ] |
|---|
| 477 |
then |
|---|
| 478 |
if [ "$VERBOSE" = "1" ] |
|---|
| 479 |
then |
|---|
| 480 |
echo "Installing $USERLIBNAME to $LIBPREFIX/$LIB" |
|---|
| 481 |
cp -pRvf $USERLIBNAME $LIBPREFIX/$LIB/ || die "Failed to copy user library." 8 |
|---|
| 482 |
else |
|---|
| 483 |
cp -pRf $USERLIBNAME $LIBPREFIX/$LIB/ || die "Failed to copy user library." 8 |
|---|
| 484 |
fi |
|---|
| 485 |
cd .. |
|---|
| 486 |
if [ "$VERBOSE" = "1" ]; then echo "Installing import files to $INCLPREFIX/$INCL/d/"; fi |
|---|
| 487 |
for file in `find tango -name '*.di' -o -name '*.d'` |
|---|
| 488 |
do |
|---|
| 489 |
if [ ! -e `dirname $INCLPREFIX/$INCL/d/$file` ] |
|---|
| 490 |
then |
|---|
| 491 |
if [ "$VERBOSE" = "1" ]; then mkdir -pv `dirname $INCLPREFIX/$INCL/d/$file`; |
|---|
| 492 |
else mkdir -p `dirname $INCLPREFIX/$INCL/d/$file`; fi |
|---|
| 493 |
fi |
|---|
| 494 |
if [ "$VERBOSE" = "1" ]; then cp $file -pRvf $INCLPREFIX/$INCL/d/$file; |
|---|
| 495 |
else cp $file -pRf $INCLPREFIX/$INCL/d/$file; fi |
|---|
| 496 |
done |
|---|
| 497 |
fi |
|---|
| 498 |
|
|---|
| 499 |
config$1 |
|---|
| 500 |
|
|---|
| 501 |
# Verify installation |
|---|
| 502 |
if [ "$VERIFY" = "1" ] |
|---|
| 503 |
then |
|---|
| 504 |
verify |
|---|
| 505 |
verify$1 |
|---|
| 506 |
fi |
|---|
| 507 |
|
|---|
| 508 |
fi |
|---|
| 509 |
|
|---|
| 510 |
if [ "$VERBOSE" = "1" ]; then echo "Done installing Tango for $1!"; fi |
|---|
| 511 |
exit 0 |
|---|
| 512 |
} |
|---|
| 513 |
|
|---|
| 514 |
while [ "$#" != "0" ] |
|---|
| 515 |
do |
|---|
| 516 |
|
|---|
| 517 |
case "$1" in |
|---|
| 518 |
--help) |
|---|
| 519 |
usage |
|---|
| 520 |
;; |
|---|
| 521 |
--prefix) |
|---|
| 522 |
shift |
|---|
| 523 |
|
|---|
| 524 |
PREFIX="$1" |
|---|
| 525 |
CONFPREFIX="$PREFIX" |
|---|
| 526 |
LIBPREFIX="$PREFIX" |
|---|
| 527 |
INCLPREFIX="$PREFIX" |
|---|
| 528 |
USERPREFIX=1 |
|---|
| 529 |
;; |
|---|
| 530 |
--altconf) |
|---|
| 531 |
shift |
|---|
| 532 |
|
|---|
| 533 |
if [ "$1" = "-" ] |
|---|
| 534 |
then |
|---|
| 535 |
CONF="" |
|---|
| 536 |
else |
|---|
| 537 |
CONF="$1" |
|---|
| 538 |
fi |
|---|
| 539 |
;; |
|---|
| 540 |
--altlib) |
|---|
| 541 |
shift |
|---|
| 542 |
|
|---|
| 543 |
if [ "$1" = "-" ] |
|---|
| 544 |
then |
|---|
| 545 |
LIB="" |
|---|
| 546 |
else |
|---|
| 547 |
LIB="$1" |
|---|
| 548 |
fi |
|---|
| 549 |
;; |
|---|
| 550 |
--altincl) |
|---|
| 551 |
shift |
|---|
| 552 |
|
|---|
| 553 |
if [ "$1" = "-" ] |
|---|
| 554 |
then |
|---|
| 555 |
INCL="" |
|---|
| 556 |
else |
|---|
| 557 |
INCL="$1" |
|---|
| 558 |
fi |
|---|
| 559 |
;; |
|---|
| 560 |
--confprefix) |
|---|
| 561 |
shift |
|---|
| 562 |
CONFPREFIX="$1" |
|---|
| 563 |
;; |
|---|
| 564 |
--libprefix) |
|---|
| 565 |
shift |
|---|
| 566 |
LIBPREFIX="$1" |
|---|
| 567 |
;; |
|---|
| 568 |
--inclprefix) |
|---|
| 569 |
shift |
|---|
| 570 |
INCLPREFIX="$1" |
|---|
| 571 |
;; |
|---|
| 572 |
--uninstall) |
|---|
| 573 |
UNINSTALL=1 |
|---|
| 574 |
;; |
|---|
| 575 |
--as-phobos) |
|---|
| 576 |
ASPHOBOS=1 |
|---|
| 577 |
;; |
|---|
| 578 |
--verify) |
|---|
| 579 |
VERIFY=1 |
|---|
| 580 |
;; |
|---|
| 581 |
--userlib) |
|---|
| 582 |
USERLIB=1 |
|---|
| 583 |
;; |
|---|
| 584 |
--verbose) |
|---|
| 585 |
VERBOSE=1 |
|---|
| 586 |
;; |
|---|
| 587 |
dmd) |
|---|
| 588 |
install dmd |
|---|
| 589 |
;; |
|---|
| 590 |
gdc) |
|---|
| 591 |
install gdc |
|---|
| 592 |
;; |
|---|
| 593 |
*) |
|---|
| 594 |
usage |
|---|
| 595 |
;; |
|---|
| 596 |
esac |
|---|
| 597 |
shift |
|---|
| 598 |
done |
|---|