mirror of
https://github.com/AdaCore/gtkada.git
synced 2026-02-12 12:26:32 -08:00
* Avoid proposing GNAT install directory as default install dir for GtkAda * Use 'cp -ri' when copying Gtk+ libraries and binaries to avoid overriding files For eng/ide/gtkada#18
184 lines
4.3 KiB
Bash
Executable File
184 lines
4.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
current_dir="`/bin/pwd`"
|
|
|
|
begin_message() {
|
|
clear
|
|
cat <<EOF
|
|
|
|
This script is provided to simplify the installation of GtkAda.
|
|
|
|
You will be asked for confirmation before the actual installation is
|
|
done. You can break out of this script at any time before this.
|
|
|
|
Hit RETURN to continue.
|
|
EOF
|
|
|
|
read x
|
|
}
|
|
|
|
# Checks for the presence of a Gtk+ binary package in gtk-bin/
|
|
check_gtk_bin() {
|
|
gtk_bin_dir="`pwd`/gtk-bin"
|
|
if test ! -d "$gtk_bin_dir"; then
|
|
echo "Gtk+ binary package not found. Aborting the installation process."
|
|
exit
|
|
fi
|
|
}
|
|
|
|
## Read the base directory (absolute path name)
|
|
## Sets the variable $basedir
|
|
ask_basedir() {
|
|
clear
|
|
default_dir=/opt/gtkada
|
|
cat <<EOF
|
|
Enter the name of the directory in which you would like to install GtkAda
|
|
|
|
EOF
|
|
|
|
while [ "$basedir" = "" ]; do
|
|
printf "[$default_dir] "
|
|
read basedir
|
|
if echo "$basedir" | egrep "[ ]" >/dev/null; then
|
|
echo "GtkAda cannot be installed in a path that contains spaces."
|
|
echo "Please enter another directory."
|
|
basedir=""
|
|
else
|
|
if [ "$basedir" = "" ]; then
|
|
basedir="$default_dir"
|
|
fi
|
|
if echo "$basedir" | egrep "^[/~]" >/dev/null; then
|
|
true
|
|
else
|
|
basedir="`pwd`"/"$basedir"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# Suppress the final / in basedir
|
|
basedir="`echo "$basedir" | sed -e 's/\/$//'`"
|
|
|
|
# Check that we have permission to write in $basedir
|
|
if test -d "$basedir"; then
|
|
if test -w "$basedir"; then
|
|
if [ -x "$basedir/bin/gtkada" ]; then
|
|
echo " $basedir/bin/gtkada found."
|
|
printf " Do you want to overwrite existing installation [Y/n] ? "
|
|
read x
|
|
if [ "$x" = "n" -o "$x" = "N" ]; then
|
|
echo "Aborting the installation process"
|
|
exit
|
|
fi
|
|
fi
|
|
else
|
|
echo "You do not have permission to write in $basedir"
|
|
echo "Please check whether you should be root to install in that directory."
|
|
echo "Aborting the installation process"
|
|
exit
|
|
fi
|
|
else
|
|
echo ""
|
|
echo " Directory $basedir does not exist."
|
|
printf " Do you want to create it [Y/n] ? "
|
|
read x
|
|
if [ "$x" = "n" -o "$x" = "N" ]; then
|
|
echo "Aborting the installation process"
|
|
exit
|
|
fi
|
|
mkdir -p "$basedir"
|
|
fi
|
|
|
|
echo ""
|
|
printf " Are you now ready to proceed with the installation [Y/n] ? "
|
|
read x
|
|
if [ "$x" = "n" -o "$x" = "N" ]; then
|
|
echo "Aborting the installation process"
|
|
exit
|
|
fi
|
|
}
|
|
|
|
##################################
|
|
## Do the actual installation
|
|
##################################
|
|
|
|
install_binaries() {
|
|
|
|
echo "Copying the Gtk+ binaries"
|
|
|
|
cp -ri "$gtk_bin_dir"/* "$basedir"
|
|
|
|
echo "Setting up the environment"
|
|
eval `"$basedir"/bin/gtkada-env.sh --print-only`
|
|
|
|
# Update gdkpixbuf loaders cache
|
|
|
|
LD_LIBRARY_PATH=$basedir/lib:$LD_LIBRARY_PATH \
|
|
GDK_PIXBUF_MODULE_FILE=$basedir/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache \
|
|
GDK_PIXBUF_MODULEDIR=$basedir/lib/gdk-pixbuf-2.0/2.10.0/loaders \
|
|
$basedir/bin/gdk-pixbuf-query-loaders --update-cache
|
|
|
|
# Update immodules cache
|
|
|
|
LD_LIBRARY_PATH=$basedir/lib:$LD_LIBRARY_PATH \
|
|
GTK_IM_MODULE_FILE=$basedir/lib/gtk-3.0/3.0.0/immodules.cache \
|
|
GTK_PATH=$basedir/lib/gtk-3.0 \
|
|
$basedir/bin/gtk-query-immodules-3.0 --update-cache
|
|
|
|
echo "Compiling GtkAda"
|
|
./configure --prefix="$basedir" && make all install 2>&1 | \
|
|
tee install.log
|
|
|
|
# Test for the presence of a gtkada.gpr as check that the install succeeded
|
|
if [ ! -f "$basedir/lib/gnat/gtkada.gpr" ]; then
|
|
echo ""
|
|
echo "An error occurred. Please see install.log."""
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
##
|
|
## Write the end message
|
|
##
|
|
end_message() {
|
|
clear
|
|
cat <<EOF
|
|
|
|
GtkAda has now been installed on your machine.
|
|
|
|
You can enter the GtkAda environment by doing:
|
|
|
|
"$basedir/bin/gtkada-env.sh"
|
|
|
|
EOF
|
|
}
|
|
|
|
## Main program
|
|
|
|
if [ $# -eq 1 ]; then
|
|
if [ "$1" = "--help" ]; then
|
|
printf "
|
|
Usage: $0 [install_dir]
|
|
|
|
When no argument is specified, runs the GtkAda installer
|
|
interactively, otherwise installs automatically under install_dir.
|
|
"
|
|
else
|
|
echo "installing GtkAda under $1"
|
|
check_gtk_bin
|
|
basedir="$1"
|
|
mkdir -p $basedir || exit 1
|
|
install_binaries
|
|
end_message
|
|
fi
|
|
exit 0
|
|
fi
|
|
|
|
# Perform interactive install
|
|
|
|
check_gtk_bin
|
|
begin_message
|
|
ask_basedir
|
|
install_binaries
|
|
end_message
|
|
|