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 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
|
#!/bin/sh
##############################################################################
#
# Configuration script for otags III
#
# Hendrik Tews Copyright (C) 2010 - 2017
#
# This file is part of "Otags III".
#
# "Otags III" is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# "Otags III" is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License in file COPYING in this or one of the parent
# directories for more details.
#
# You should have received a copy of the GNU General Public License
# along with "Otags III". If not, see
# <http://www.gnu.org/licenses/>.
#
##############################################################################
set -e
REQUIRED_OCAML_VERSION=4.05
OTAGS_VERSION=1
root=/usr/local
bindir=$root/bin
mandir=$root/share/man
native=
native_goals=
byterequest=0
versioncheck=1
ocamlbindir=
usage (){
echo "Usage:"
echo "./configure [OPTION]..."
echo
echo "Recognized options are:"
echo " --prefix <path> installation prefix [/usr/local]"
echo " --bindir <path> user executables [PREFIX/bin]"
echo " --mandir <path> man pages [PREFIX/share/man]"
echo " --bytecode don't use native compiler (for testing only)"
echo " --no-version-check don't check for correct ocaml version (not recommended)"
# echo " --ocaml <path> location of ocaml binaries [searched in PATH]"
}
while : ; do
case "$1" in
"") break;;
-help|--help) usage; exit 2;;
-prefix|--prefix) bindir=$2/bin
mandir=$2/share/man
shift;;
-bindir|--bindir) bindir=$2
shift;;
-mandir|--mandir) mandir=$2
shift;;
-bytecode|--bytecode) byterequest=1;;
-no-version-check|--no-version-check)
versioncheck=0;;
-ocaml|--ocaml) ocamlbindir="$2/";
shift;;
# The following option is only here for simplifying the
# make-distribution script.
-abra-print-version)
echo $REQUIRED_OCAML_VERSION.$OTAGS_VERSION;
exit 0;;
*) echo "Unknown option \"$1\"." 1>&2; usage; exit 2;;
esac
shift
done
# disable error checking
set +e
# check for ocaml
ocbv=$(${ocamlbindir}ocamlc -version)
if [ $? -ne 0 ] ; then
set -e
echo compiler ${ocamlbindir}ocamlc not found.
echo Please adjust \$PATH or use --ocaml
exit 1
else
set -e
echo ${ocamlbindir}ocamlc version $ocbv found.
fi
# check ocamlc version
if [ $versioncheck = 1 ] ; then
if [ "$ocbv" \< $REQUIRED_OCAML_VERSION ] ; then
echo This version of otags needs at least OCaml $REQUIRED_OCAML_VERSION.x.
echo Aborting.
exit 1
fi
if [ "$ocbv" \> $REQUIRED_OCAML_VERSION".99" ] ; then
cat - <<EOF
WARNING: You attempt to compile otags with a more recent OCaml version than
it was released for. (This version of otags was released for OCaml $REQUIRED_OCAML_VERSION.x.)
If it compiles without errors, otags should just ignore the new OCaml
features (if there are any). If you only see errors in the file
tags.ml you may get a working version by deleting the offending match
cases in tags.ml. For other errors I don't have any generic advice to
share. Good luck!
EOF
fi
fi
# disable error checking
set +e
# check for ocamlopt.opt
ocvo=$(${ocamlbindir}ocamlopt.opt -version)
if [ $? -eq 0 ] ; then
set -e
if [ $ocbv != $ocvo ] ; then
echo ${ocamlbindir}ocamlc and ${ocamlbindir}ocamlopt.opt have different versions.
echo Please check your installation!
echo Aborting.
exit 1
fi
echo ${ocamlbindir}ocamlopt.opt version $ocvo found.
if ${ocamlbindir}ocamlopt.opt -o /dev/null \
unix.cmxa dynlink.cmxa ;
then
echo Native compilation enabled.
native=true
else
echo ocamlopt.opt unix.cmxa dynlink.cmxa failed.
echo Native compilation disabled.
native=false
fi
else
set -e
echo ocamlopt.opt not found. Native compilation disabled.
native=false
fi
if [ $byterequest = 1 ] ; then
native=false
fi
if [ $native = "true" ] ; then
ocamldep=${ocamlbindir}ocamldep.opt
ocamlc=${ocamlbindir}ocamlc.opt
ocamlopt=${ocamlbindir}ocamlopt.opt
otags=otags.opt
else
ocamldep=${ocamlbindir}ocamldep
ocamlc=${ocamlbindir}ocamlc
ocamlopt=false
otags=otags.byte
fi
if [ $native = "true" ] ; then
# disable error checking
set +e
# check ocamlc.opt if native detected
ocvo=$(${ocamlc} -vnum)
if [ $? -ne 0 ] ; then
set -e
echo $ocamlopt exists but $ocamlc not.
echo Please check your ocaml installation!
echo Aborting.
exit 1
elif [ $ocvo != $ocbv ] ; then
set -e
echo $ocamlc and $ocamlopt have different versions!
echo Please check your installation!
echo Aborting.
exit 1
else
set -e
echo ${ocamlc} version $ocvo found.
fi
fi
# disable error checking
set +e
# check ocamldep
ocdepv=$($ocamldep -vnum)
if [ $? -ne 0 -o $ocdepv != $ocbv ] ; then
set -e
echo $ocamlc exists but $ocamldep not.
echo Please check your ocaml installation!
echo Aborting.
exit 1
else
set -e
fi
if [ $ocdepv != $ocbv ] ; then
echo $ocamlc and $ocamldep have different versions.
echo Please check your ocaml installation!
echo Aborting.
exit 1
fi
# Summary of the configuration
echo
echo " Configuration summary:"
echo " binaries will be installed in $bindir"
echo " man pages will be installed in $mandir"
if [ $native = "true" ] ; then
echo " native-code compilation enabled"
else
echo " native-code compilation disabled"
fi
# Make conf.ml
sed -e "s|@REQUIRED_OCAML_VERSION@|$REQUIRED_OCAML_VERSION|" \
-e "s|@OTAGS_VERSION@|$OTAGS_VERSION|" \
conf.ml.in > conf.ml
# Make the Makefile
sed -e "s|@BINDIR@|$bindir|" \
-e "s|@MANDIR@|$mandir|" \
-e "s|@OTAGS@|$otags|" \
-e "s|@OCAMLC@|$ocamlc|" \
-e "s|@OCAMLOPT@|$ocamlopt|" \
-e "s|@OCAMLDEP@|$ocamldep|" \
Makefile.in > Makefile
|