1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
#!/bin/bash
#
# Configure script, for most users only needed for backwards compatibility with
# pqiv 1.0 (pre-gtk3). I still recommend to use it in automated builds to
# ensure continued compatibility.
#
tempdir() {
NAME=tmp_${RANDOM}
while [ -d $NAME ]; do
NAME=tmp_${RANDOM}
done
mkdir ${NAME}
echo ${NAME}
}
PREFIX=/usr
DESTDIR=
GTK_VERSION=0
CROSS=
BINARY_EXTENSION=
CFLAGS=
MANDIR=
PKG_CONFIG=pkg-config
# Help and options
help() {
cat >&2 <<EOF
pqiv configuration
options:
--prefix=.. Set the prefix for installed files
--destdir=.. Set the destdir for installed files (for package maintainers)
--gtk-version=2 Use GTK+-2.0 even if GTK+-3.0 is available
--cross=.. Set a cross-compiler prefix (e.g. \`i686-pc-mingw32-')
EOF
}
while [ $# -gt 0 ]; do
PARAMETER=${1%=*}
VALUE=${1#*=}
case $PARAMETER in
--prefix)
PREFIX=$VALUE
;;
--destdir)
DESTDIR=$VALUE
;;
--gtk-version)
GTK_VERSION=$VALUE
;;
-h)
help
exit 0
;;
--help)
help
exit 0
;;
--cross)
CROSS=$VALUE
if [ "${CROSS: -1}" != "-" ]; then
CROSS="$CROSS-"
fi
;;
# Undocumented options for autoconf (esp. dh_auto_configure) compatibility
--build)
CROSS=${VALUE}-
;;
--mandir)
MANDIR=${VALUE}
MANDIR="${MANDIR//{/(}"
MANDIR="${MANDIR//\}/)}"
MANDIR="${MANDIR//prefix/PREFIX}"
echo "Use of autoconf option --mandir is discouraged, because support is incomplete. Rewrote \`$VALUE' to \`$MANDIR' and used that as the MANDIR Make variable." >&2
;;
--includedir | --infodir | --sysconfdir | --localstatedir | --libdir | --libexecdir | --disable-maintainer-mode | --disable-dependency-tracking)
echo "autoconf option ${PARAMETER} ignored" >&2
;;
--no-sorting | --no-compositing | --no-fading | --no-commands | --no-config-file | --no-inotify | --no-animations | --binary-name)
echo "obsolete 1.0 option ${PARAMETER} ignored" >&2
;;
*)
echo "Unknown option: $1" >&2
shift
continue
help
exit 1
esac
shift
done
# If cross-compiling, check if cc is present (usually it's not)
if [ -n "$CROSS" -a -z "$CC" ]; then
echo -n "Checking for cross-compiler cc.. "
if ! which ${CROSS}cc >/dev/null 2>&1; then
if which ${CROSS}clang >/dev/null 2>&1; then
export CC=clang
elif which ${CROSS}gcc >/dev/null 2>&1; then
export CC=gcc
else
echo
echo
echo "No compiler found. Please set the appropriate CC environment variable." >&2
exit 1
fi
echo "using ${CROSS}${CC}"
else
echo "ok"
fi
fi
# Determine binary extension (for Windows)
echo -n "Determining executable extension.. "
DIR=`tempdir`
cd $DIR
echo 'int main(int argc, char *argv[]) { return 0; }' > test.c
${CROSS}${CC:-cc} test.c
RV=$?
rm -f test.c
EXECUTABLE=`ls`
rm -f $EXECUTABLE
cd ..
rmdir $DIR
if [ "$RV" != 0 ]; then
echo "The compiler can't compile executables!?" >&2
echo
exit 1
fi
EXECUTABLE_EXTENSION=${EXECUTABLE#a}
if [ "$EXECUTABLE_EXTENSION" = ".out" ]; then
EXECUTABLE_EXTENSION=
fi
echo ${EXECUTABLE_EXTENSION:-(none)}
# Do a rudimental prerequisites check to have user-friendlier error messages
while read -r LINE; do
for VAR in LIBS_GTK3 LIBS_GTK2; do
if [ "${LINE#$VAR=}" != "${LINE}" ]; then
eval ${VAR}=\"${LINE#$VAR=}\"
fi
done
done < Makefile
if [ -n "${CROSS}" ]; then
echo -n "Checking for pkg-config.. "
PKG_CONFIG=${CROSS}pkg-config
if ! which ${PKG_CONFIG} >/dev/null 2>&1; then
echo
echo "Did not find a specialized tool ${CROSS}pkg-config, defaulting to pkg-config" >&2
echo "If you really ARE cross-compiling, the build might therefore fail!" >&2
echo
PKG_CONFIG=pkg-config
else
echo "${PKG_CONFIG}"
fi
fi
echo -n "Checking if GTK, cairo and glib are installed.. "
if $PKG_CONFIG --exists "$LIBS_GTK3"; then
echo "ok"
else
if $PKG_CONFIG --exists "$LIBS_GTK2"; then
if [ "$GTK_VERSION" = 3 ]; then
echo "failed."
echo
echo "GTK 2 was found, but you manually specified --gtk-version=3, which was not found." >&2
echo "If you want GTK3, install the development packages for" >&2
echo " ${LIBS_GTK3}" >&2
exit 1
fi
echo "ok, found GTK 2"
GTK_VERSION=2
else
echo "failed."
echo
echo "Please install either the development packages for " >&2
echo " ${LIBS_GTK3}" >&2
echo "or for" >&2
echo " ${LIBS_GTK2}" >&2
exit 1
fi
fi
echo "Writing config.make."
(
cat <<EOF
DESTDIR=$DESTDIR
PREFIX=$PREFIX
GTK_VERSION=$GTK_VERSION
CROSS=$CROSS
EXECUTABLE_EXTENSION=$EXECUTABLE_EXTENSION
PKG_CONFIG=$PKG_CONFIG
EOF
if [ -n "$CFLAGS" ]; then
echo "CFLAGS+=$CFLAGS"
fi
if [ -n "$MANDIR" ]; then
echo "MANDIR=$MANDIR"
fi
) > config.make
[ -n "${CC}" ] && echo "CC=${CC}" >> config.make
echo
echo "Done. Run \`make install' to install pqiv."
exit 0
|