mirror of https://github.com/CGAL/cgal
3812 lines
96 KiB
Bash
Executable File
3812 lines
96 KiB
Bash
Executable File
#!/bin/sh
|
|
# ---------------------------------------------------------------------
|
|
# A CGAL Installation Script Prototype
|
|
# $Id$
|
|
# ---------------------------------------------------------------------
|
|
|
|
# ---------------------------------------------------------------------
|
|
# some important global variables
|
|
# ---------------------------------------------------------------------
|
|
|
|
# ---------------------------------------------
|
|
# CGAL specific:
|
|
|
|
CGAL_VERSION=0.9
|
|
CGAL_INSTALL_VERSION='$Revision$'
|
|
CGAL_DIR=`pwd`
|
|
CGAL_EXAMPLE_DIR=${CGAL_DIR}/examples
|
|
CGAL_INCL_DIR=${CGAL_DIR}/include
|
|
CGAL_LIB_DIR=${CGAL_DIR}/lib
|
|
CGAL_MAKE_DIR=${CGAL_DIR}/make
|
|
CGAL_SRC_DIR=${CGAL_DIR}/src
|
|
CGAL_TEST_DIR=${CGAL_DIR}/test
|
|
CGAL_CONF_DIR=${CGAL_DIR}/config
|
|
CGAL_AUX_DIR=${CGAL_DIR}/auxiliary
|
|
CGAL_LIB_NAME='libCGAL'
|
|
CGAL_DIRFILE=${CGAL_DIR}/make/CGAL_directories
|
|
CGAL_TESTFILE=${CGAL_TEST_DIR}/cgal_test
|
|
# logfile for testsuite:
|
|
TEST_LOGFILE=${CGAL_TEST_DIR}/error.txt
|
|
# set to non-empty, if you want to view the logs of
|
|
# ALL failed tests
|
|
INSTALL_VERBOSE=''
|
|
# set to empty string, if you want to disable testsuite
|
|
CGAL_TESTSUITE=''
|
|
|
|
|
|
# ---------------------------------------------
|
|
# LEDA specific:
|
|
#
|
|
|
|
# suffix for include makefile:
|
|
# toggles the use of LEDA: ('' - no LEDA, '_LEDA' - LEDA)
|
|
LEDA_SUPPORT=''
|
|
|
|
# directories for LEDA
|
|
LEDA_INCL_DIR=''
|
|
LEDA_LIB_DIR=''
|
|
|
|
# do we have to provide extra incl/lib flags for LEDA('y')
|
|
# is it installed in standard system dirs(''),
|
|
# or do we want to provide extra incl/lib flags, although it is
|
|
# installed in sysdirs ('x')?
|
|
# set to 'n', if this has not been tested yet
|
|
NEED_EXTRA_LEDA_IDIR='y'
|
|
NEED_EXTRA_LEDA_LDIR='y'
|
|
|
|
# did LEDA tests succeed ('' - no, 'y' - yep)
|
|
LEDA_TEST_PASSED=''
|
|
|
|
|
|
# ---------------------------------------------
|
|
# STL specific:
|
|
#
|
|
|
|
# specifies STL setting (since this is compiler specific,
|
|
# it will be updated each time a compiler is chosen)
|
|
# 'e' means an extra STL is needed and
|
|
# 'b' means compiler is shipped with an STL (and it should be used)
|
|
# while 'x' means to use an extra STL anyway
|
|
STL_STATUS='b'
|
|
STL_DIR=''
|
|
|
|
# type of STL: (see test_stl_version below)
|
|
CGAL_STL_VERSION='CGAL_STL_UNKNOWN'
|
|
|
|
# did STL tests succeed ('' - no, 'y' - yep)
|
|
STL_TEST_PASSED=''
|
|
|
|
|
|
# ---------------------------------------------
|
|
# GCC specific:
|
|
#
|
|
|
|
# toggles use of gcc rtti patch ('' - no, '-rtti' - use it)
|
|
GCC_RTTI_PATCH_SUPPORT=''
|
|
GCC_RTTI_PATCH_DIR=''
|
|
|
|
# did RTTI tests succeed ('' - no, 'y' - yep)
|
|
RTTI_TEST_PASSED=''
|
|
|
|
|
|
# ---------------------------------------------
|
|
# GMP specific:
|
|
#
|
|
|
|
# version of gmp shipped with CGAL:
|
|
GMP_VERSION='gmp-2.0.2'
|
|
|
|
# toggles use of GMP ('' - no, '_GMP' - use it)
|
|
GMP_SUPPORT=''
|
|
|
|
# indicate whether GMP is installed
|
|
# ('' - no,
|
|
# 's' - in sysdirs, no flags necessary,
|
|
# 'e' - we need compiler/linker flags and GMP_INCL_DIR/GMP_LIB_DIR for this,
|
|
# 'x' - in sysdirs, but specify GMP_INCL_DIR/GMP_LIB_DIR anyway
|
|
# 'c' - in the cgal tree,
|
|
# 'z' - in the cgal tree, but specify GMP_INCL_DIR/GMP_LIB_DIR anyway)
|
|
GMP_INSTALLATION=''
|
|
GMP_INCL_DIR=''
|
|
GMP_LIB_DIR=''
|
|
|
|
# did GMP tests succeed ('' - no, 'y' - yep)
|
|
GMP_TEST_PASSED=''
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# internal variables
|
|
# ---------------------------------------------------------------------
|
|
|
|
# width of menu screen / 10 (in characters)
|
|
_MENU_WIDTH=6
|
|
|
|
# left indentation of menu
|
|
_LEFTSPACE=' '
|
|
|
|
# installation logfile (verbose)
|
|
INSTALL_LOGFILE="${CGAL_DIR}/install.log"
|
|
INSTALL_LOGFILE_REDIRECTION='>/dev/null'
|
|
|
|
# installation logfile (only completed compile/test runs)
|
|
# (Really Important Stuff)
|
|
INSTALL_RIS_LOGFILE=${CGAL_DIR}/install.completed
|
|
|
|
# compilation logfile
|
|
COMPILE_LOGFILE=${CGAL_DIR}/compile.log
|
|
|
|
# logfile for temporary use (e.g. compiler tests)
|
|
TMP_LOGFILE=${CGAL_DIR}/tmptmp.log
|
|
|
|
# temporary file for confidence tests
|
|
TMP_CXX_FILE=${CGAL_DIR}/tmp_test
|
|
|
|
# compiler to be used
|
|
COMPILER=''
|
|
|
|
# string defining OS and compiler
|
|
# (used for naming makefiles and lib directories)
|
|
CGAL_OS_COMPILER=''
|
|
|
|
# can we start building the libs?
|
|
SETUP_COMPLETE=''
|
|
|
|
# does there exist a CGALlib for this compiler?
|
|
LIB_COMPILED=''
|
|
|
|
# Was there any successfull compile run during this session?
|
|
ANY_LIB_COMPILED=''
|
|
|
|
# custom options for compiler/linker:
|
|
CUSTOM_CXXFLAGS=''
|
|
CUSTOM_LDFLAGS=''
|
|
|
|
# ---------------------------------------------------------------------
|
|
# system related functions:
|
|
# ---------------------------------------------------------------------
|
|
|
|
# print the value of variable $1
|
|
value_of()
|
|
{
|
|
_value=`eval "${_printf} '$'$1"`
|
|
eval "${_printf} \"$_value\""
|
|
}
|
|
|
|
# (/usr)/bin/which is completely STUPID
|
|
# it looks at ~/.cshrc and reports aliases
|
|
# that do not exist, if you run a shell other than csh
|
|
# so it's us who have to do the work again :)
|
|
# needs awk!
|
|
real_which()
|
|
{
|
|
_t=0
|
|
for i in `echo ${PATH} | ${_awk} 'BEGIN {RS=":"}{print $0}'`; do
|
|
if [ ${_t} = 0 -a -x ${i}/$1 ]; then
|
|
echo ${i}/$1
|
|
_t=1
|
|
fi
|
|
done
|
|
}
|
|
|
|
# print to logfile
|
|
log_print()
|
|
{
|
|
eval "${_printf} \"$*\n\" ${INSTALL_LOGFILE_REDIRECTION}"
|
|
}
|
|
|
|
# checks for existency of program $1
|
|
# and set variable _$3 to its full path
|
|
# ($3 defaults to $1 if not specified)
|
|
# (if $2 is 'y', exit if it is not existent,
|
|
# otherwise return 0, iff it exists)
|
|
_check_for_util()
|
|
{
|
|
_tmp=`$_which $1`
|
|
if [ -x "${_tmp}" ]; then
|
|
eval "_${3:-$1}=${_tmp}"
|
|
elif [ "$2" = "y" ]; then
|
|
echo
|
|
echo "ERROR: Couldn't find $1, exiting."
|
|
exit 1
|
|
else
|
|
log_print "WARNING: Couldn't find $1."
|
|
return 1
|
|
fi
|
|
_tmp="echo $\_`echo ${3:-$1}`"
|
|
_tmp=`eval "${_tmp}"`
|
|
_tmp=`eval "echo ${_tmp}"`
|
|
log_print "$1 is ${_tmp}."
|
|
return 0
|
|
}
|
|
|
|
# same as _check_for_util above except that it searches
|
|
# in /bin and /usr/bin first
|
|
_check_for_sysutil()
|
|
{
|
|
if [ -x /bin/$1 ]; then
|
|
eval "_$1=/bin/$1"
|
|
elif [ -x /usr/bin/$1 ]; then
|
|
eval "_$1=/usr/bin/$1"
|
|
else
|
|
_check_for_util $*
|
|
return $?
|
|
fi
|
|
_tmp="echo $\_`echo ${3:-$1}`"
|
|
_tmp=`eval "${_tmp}"`
|
|
_tmp=`eval "echo ${_tmp}"`
|
|
log_print "$1 is ${_tmp}."
|
|
return 0
|
|
}
|
|
|
|
# exit, if there is no directory $1 or it is not readable and executable
|
|
_check_dir_exists()
|
|
{
|
|
if [ ! -d $1 ]; then
|
|
echo
|
|
echo "ERROR: Directory $1 does not exist, exiting."
|
|
exit 1
|
|
fi
|
|
if [ ! -r $1 ]; then
|
|
echo
|
|
echo "ERROR: Cannot read from directory $1, exiting."
|
|
exit 1
|
|
fi
|
|
if [ ! -x $1 ]; then
|
|
echo
|
|
echo "ERROR: No execute permission for directory $1, exiting."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# exit, if there is no directory $1 or it is not readable and executable
|
|
_check_file_exists()
|
|
{
|
|
if [ ! -r $1 ]; then
|
|
echo
|
|
echo "ERROR: Cannot find file $1, exiting."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# exit, if there is no directory $1 or it is not readable and executable
|
|
_check_file_execute()
|
|
{
|
|
if [ ! -x $1 ]; then
|
|
echo
|
|
echo "ERROR: Cannot execute file $1, exiting."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# exit, if you can't write to directory/file $1
|
|
_check_write()
|
|
{
|
|
if [ ! -w $1 ]; then
|
|
echo
|
|
echo "ERROR: Cannot write to $1, exiting."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# initialize the logfiles
|
|
init_logfiles()
|
|
{
|
|
_check_dir_exists ${CGAL_DIR}
|
|
_check_write ${CGAL_DIR}
|
|
if [ -f ${INSTALL_RIS_LOGFILE} -a ! -w ${INSTALL_RIS_LOGFILE} ]; then
|
|
/bin/rm -f ${INSTALL_RIS_LOGFILE}
|
|
fi
|
|
if [ -f ${INSTALL_LOGFILE} -a ! -w ${INSTALL_LOGFILE} ]; then
|
|
/bin/rm -f ${INSTALL_LOGFILE}
|
|
fi
|
|
_check_for_sysutil printf y
|
|
${_printf} "----------------------------------------------------------\n" \
|
|
>${INSTALL_LOGFILE}
|
|
log_print "log of $0 $*"
|
|
log_print "called by $LOGNAME on `date`"
|
|
log_print "CGAL_DIR is ${CGAL_DIR}"
|
|
log_print "----------------------------------------------------------"
|
|
${_printf} "${_LEFTSPACE}----------------------------------------------------------\n" \
|
|
>${INSTALL_RIS_LOGFILE}
|
|
${_printf} "${_LEFTSPACE}You built CGAL ${CGAL_VERSION} on:\n" \
|
|
>>${INSTALL_RIS_LOGFILE}
|
|
${_printf} "${_LEFTSPACE}----------------------------------------------------------\n" \
|
|
>>${INSTALL_RIS_LOGFILE}
|
|
}
|
|
|
|
# first do a confidence test, if ${CGAL_DIR} is really
|
|
# the CGAL directory
|
|
# check ${CGAL_CONF_DIR}: create it, if not existent
|
|
check_conf_dir()
|
|
{
|
|
# confidence tests
|
|
case `$_basename ${CGAL_DIR}` in
|
|
CGAL*)
|
|
log_print "Confidence test passed.";;
|
|
*)
|
|
${_printf} "\nERROR: The name of this directory\n"
|
|
${_printf} " does not start with \"CGAL\", exiting.\n"
|
|
exit 1;;
|
|
esac
|
|
_check_dir_exists ${CGAL_MAKE_DIR}
|
|
_check_dir_exists ${CGAL_SRC_DIR}
|
|
_check_dir_exists ${CGAL_INCL_DIR}
|
|
_check_dir_exists ${CGAL_LIB_DIR}
|
|
|
|
# test for ${CGAL_CONF_DIR}
|
|
if [ ! -d ${CGAL_CONF_DIR} ]; then
|
|
log_print \
|
|
"WARNING: ${CGAL_CONF_DIR} does not exist, it will be created."
|
|
mkdir ${CGAL_CONF_DIR}
|
|
fi
|
|
_check_write ${CGAL_CONF_DIR}
|
|
}
|
|
|
|
# print the version number of this file
|
|
# (in an RCS Revision string this is field nr two)
|
|
_install_version_number()
|
|
{
|
|
${_printf} "${CGAL_INSTALL_VERSION}" | ${_awk} '{print $2}'
|
|
}
|
|
|
|
# check, if all needed utility programs are available
|
|
# (they should be on a unix system, but ...)
|
|
check_for_utils()
|
|
{
|
|
_which='which'
|
|
_check_for_sysutil awk y
|
|
_check_for_sysutil basename y
|
|
_which=real_which
|
|
_check_for_sysutil uname y
|
|
_check_for_sysutil cat y
|
|
_check_for_sysutil rm y
|
|
_check_for_sysutil cp y
|
|
_check_for_sysutil mv y
|
|
_check_for_sysutil ln y
|
|
_check_for_sysutil ls y
|
|
_check_for_sysutil chmod y
|
|
_check_for_sysutil mkdir y
|
|
_check_for_sysutil tput y
|
|
_check_for_sysutil fgrep y
|
|
_check_for_sysutil sed y
|
|
if [ -n "${PAGER}" -a ! -x "${PAGER}" ]; then
|
|
_check_for_sysutil `$_basename ${PAGER}` y
|
|
PAGER=`eval "echo \$\_$PAGER"`
|
|
PAGER=`eval "echo ${PAGER}"`
|
|
fi
|
|
CGAL_INSTALL_VERSION=`_install_version_number`
|
|
log_print "This is `basename $0` version ${CGAL_INSTALL_VERSION}."
|
|
}
|
|
|
|
# guess operating system, write logs via $1
|
|
# set SYST to [architecture]_[os][os-version]
|
|
# try to get architecture from uname -p,
|
|
# if this fails (e.g. on some linux systems), try uname -m
|
|
# if this also fails, leave architecture blank
|
|
guess_os()
|
|
{
|
|
_tmp=`${_uname} -p 2>/dev/null`
|
|
if [ -z "${_tmp}" ]; then
|
|
_tmp=`${_uname} -m 2>/dev/null`
|
|
fi
|
|
if [ -n "${_tmp}" ]; then
|
|
_tmp=${_tmp}"_"
|
|
else
|
|
$1 "WARNING: Could not determine architecture."
|
|
fi
|
|
SYST="${_tmp}`${_uname} -s`-`${_uname} -r`"
|
|
$1 "OS is \"${SYST}\"."
|
|
}
|
|
|
|
# ---------------------------------------------------------------------
|
|
# compiler related functions:
|
|
# ---------------------------------------------------------------------
|
|
|
|
# give version numbers for GNU GCC
|
|
# NB: truncated to *.*.* (three numbers)
|
|
# since we don't want to make a difference between 2.7.2.*
|
|
_gpp_version()
|
|
{
|
|
${_printf} "`\`compiler_bin\` --version 2>&1 | ${_awk} '{print $1}' | \
|
|
${_awk} 'BEGIN {FS=\".\"}
|
|
{print $1\".\"$2\".\"$3}'`"
|
|
}
|
|
|
|
# give version numbers for SUNPRO CC
|
|
_sunpro_version()
|
|
{
|
|
${_printf} "`\`compiler_bin\` -V 2>&1 | $_fgrep \"C++\" | \
|
|
${_awk} '{print $NF}'`"
|
|
}
|
|
|
|
# give version numbers for IRIX MIPSPRO CC
|
|
_sgi_version()
|
|
{
|
|
${_printf} "`$_showprods -nM | $_fgrep \"C++,\" | $_fgrep c++_dev | \
|
|
${_awk} '{print $5}'`"
|
|
}
|
|
|
|
# map description to executable of C++ compiler with full path
|
|
# (e.g. "GNU g++ 2.7.2.1" to "/usr/local/bin/g++")
|
|
compiler_bin()
|
|
{
|
|
${_printf} "`value_of _\`compiler_variable\``"
|
|
}
|
|
|
|
# map description to executable of C compiler with full path
|
|
# (e.g. "GNU g++ 2.7.2.1" to "/usr/local/bin/g++")
|
|
c_compiler_bin()
|
|
{
|
|
case ${COMPILER} in
|
|
GNU*)
|
|
${_printf} "${_gcc}";;
|
|
SUN*|IRIX*)
|
|
${_printf} "${_cc}";;
|
|
*)
|
|
${_printf} "undefined";;
|
|
esac
|
|
}
|
|
|
|
# return the cmdline-switch to set the runtime linker path
|
|
# for ${COMPILER}
|
|
rpath_directive()
|
|
{
|
|
case ${COMPILER} in
|
|
IRIX*) ${_printf} "-rpath ";;
|
|
GNU*) ${_printf} "-Xlinker -R";;
|
|
*) ${_printf} "-R";;
|
|
esac
|
|
}
|
|
|
|
#---------------------------------------------------------
|
|
# flags for CGAL
|
|
|
|
# print message used to remind the user of setting
|
|
# his DIR variables correctly
|
|
_where_is()
|
|
{
|
|
${_printf} " Where is your ${1} ? "
|
|
}
|
|
|
|
cgal_cxxflags()
|
|
{
|
|
${_printf} \
|
|
"-I${CGAL_INCL_DIR:-`_where_is 'CGAL_INCL_DIR'`} "
|
|
}
|
|
|
|
cgal_ldflags()
|
|
{
|
|
${_printf} \
|
|
"-L${CGAL_LIB_DIR:-`_where_is 'CGAL_LIB_DIR'`}/`full_ostype` "
|
|
${_printf} \
|
|
"`rpath_directive`${CGAL_LIB_DIR:-`_where_is 'CGAL_LIB_DIR'`}/"
|
|
${_printf} "`full_ostype` "
|
|
}
|
|
|
|
#---------------------------------------------------------
|
|
# flags for GMP
|
|
|
|
gmp_cxxflags()
|
|
{
|
|
if [ -n "${GMP_SUPPORT}" -a \
|
|
"${GMP_INSTALLATION}" != 'c' -a \
|
|
"${GMP_INSTALLATION}" != 's' ]; then
|
|
${_printf} "-I${GMP_INCL_DIR:-`_where_is 'GMP_INCL_DIR'`} "
|
|
fi
|
|
}
|
|
|
|
gmp_ldflags()
|
|
{
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
if [ "${GMP_INSTALLATION}" != 'c' -a \
|
|
"${GMP_INSTALLATION}" != 's' ]; then
|
|
${_printf} "-L${GMP_LIB_DIR:-`_where_is 'GMP_LIB_DIR'`} "
|
|
${_printf} "`rpath_directive`"
|
|
${_printf} "${GMP_LIB_DIR:-`_where_is 'GMP_LIB_DIR'`} "
|
|
fi
|
|
${_printf} "-lgmp "
|
|
fi
|
|
}
|
|
|
|
#---------------------------------------------------------
|
|
# flags for STL
|
|
|
|
stl_cxxflags()
|
|
{
|
|
if [ "${STL_STATUS}" != "b" ]; then
|
|
${_printf} "-I${STL_DIR:-`_where_is 'STL_DIR'`} "
|
|
fi
|
|
}
|
|
|
|
#---------------------------------------------------------
|
|
# flags for LEDA
|
|
leda_cxxflags()
|
|
{
|
|
if [ -n "${LEDA_SUPPORT}" -a -n "${NEED_EXTRA_LEDA_IDIR}" ]; then
|
|
${_printf} "-I${LEDA_INCL_DIR:-`_where_is 'LEDA_INCL_DIR'`} "
|
|
fi
|
|
}
|
|
|
|
leda_ldflags()
|
|
{
|
|
if [ -n "${LEDA_SUPPORT}" ]; then
|
|
if [ -n "${NEED_EXTRA_LEDA_LDIR}" ]; then
|
|
${_printf} "-L${LEDA_LIB_DIR:-`_where_is 'LEDA_LIB_DIR'`} "
|
|
${_printf} "`rpath_directive`"
|
|
${_printf} "${LEDA_LIB_DIR:-`_where_is 'LEDA_LIB_DIR'`} "
|
|
fi
|
|
${_printf} "-lP -lG -lL "
|
|
fi
|
|
}
|
|
|
|
#---------------------------------------------------------
|
|
# flags for GCC RTTI patch
|
|
|
|
# return currently needed compiler flags for gcc rtti patch
|
|
rtti_patch_cxxflags()
|
|
{
|
|
if [ -n "${GCC_RTTI_PATCH_SUPPORT}" ]; then
|
|
${_printf} "-frtti "
|
|
fi
|
|
}
|
|
|
|
# return currently needed linker flags for gcc rtti patch
|
|
rtti_patch_ldflags()
|
|
{
|
|
if [ -n "${GCC_RTTI_PATCH_SUPPORT}" ]; then
|
|
${_printf} \
|
|
"-L${GCC_RTTI_PATCH_DIR:-`_where_is 'GCC_RTTI_PATCH_DIR'`} "
|
|
${_printf} "`rpath_directive`"
|
|
${_printf} "${GCC_RTTI_PATCH_DIR:-`_where_is 'GCC_RTTI_PATCH_DIR'`} "
|
|
${_printf} "-nodefaultlibs -lstdc++ -liberty -lg++ -lgcc -lc "
|
|
fi
|
|
}
|
|
|
|
#---------------------------------------------------------
|
|
# all flags
|
|
|
|
# print cxxflags for current setting
|
|
compiler_flags()
|
|
{
|
|
${_printf} "${CUSTOM_CXXFLAGS} `rtti_patch_cxxflags``cgal_cxxflags``stl_cxxflags``leda_cxxflags``gmp_cxxflags`"
|
|
}
|
|
|
|
# print ldflags for current setting
|
|
linker_flags()
|
|
{
|
|
${_printf} "${CUSTOM_LDFLAGS} `cgal_ldflags`-lCGAL `leda_ldflags``rtti_patch_ldflags``gmp_ldflags` -lm"
|
|
}
|
|
|
|
# print ldflags for current setting (do not link with cgal lib,
|
|
# used for test before lib is compiled)
|
|
linker_flags_no_cgal_lib()
|
|
{
|
|
${_printf} "${CUSTOM_LDFLAGS} `cgal_ldflags``leda_ldflags``rtti_patch_ldflags``gmp_ldflags` -lm"
|
|
}
|
|
|
|
# give basename of ${COMPILER}s executable
|
|
# (assumed to be the second record of ${COMPILER})
|
|
compiler_basename()
|
|
{
|
|
${_printf} "${COMPILER}" | ${_awk} '{print $2}'
|
|
}
|
|
|
|
# append a version number to ${COMPILER}, if possible
|
|
compute_compiler_version()
|
|
{
|
|
case `compiler_basename` in
|
|
*CC*)
|
|
case ${SYST} in
|
|
*IRIX*) _check_for_sysutil showprods y
|
|
COMPILER="${COMPILER} `_sgi_version`"
|
|
log_print "SGI CC version is `_sgi_version`.";;
|
|
*SunOS*) COMPILER="${COMPILER} `_sunpro_version`"
|
|
log_print "SUNPRO CC version is `_sunpro_version`.";;
|
|
*) COMPILER="${COMPILER}";;
|
|
esac;;
|
|
*g++*)
|
|
COMPILER="${COMPILER} `_gpp_version`"
|
|
log_print "GNU g++ version is `_gpp_version`.";;
|
|
*)
|
|
COMPILER="${COMPILER}";;
|
|
esac
|
|
}
|
|
|
|
# give version of ${COMPILER}
|
|
# assumes this is the third component of ${COMPILER}
|
|
compiler_version()
|
|
{
|
|
${_printf} "${COMPILER}" | ${_awk} '{print $3}'
|
|
}
|
|
|
|
# give a literal description for compiler $1
|
|
# (e.g. $1 = CC, g++, ...)
|
|
compiler_description()
|
|
{
|
|
case $1 in
|
|
*CC*)
|
|
case ${SYST} in
|
|
*IRIX*) ${_printf} "IRIX CC";;
|
|
*SunOS*) ${_printf} "SUNPRO CC";;
|
|
*) ${_printf} "unknown CC";;
|
|
esac;;
|
|
*g++*)
|
|
${_printf} "GNU g++";;
|
|
*)
|
|
${_printf} "unknown $1";;
|
|
esac
|
|
}
|
|
|
|
# return 0, iff current compiler needs rtti patch
|
|
# (gcc2.7.2.*)
|
|
show_rtti_options()
|
|
{
|
|
if [ "`compiler_basename`" = "g++" -a \
|
|
"`compiler_version`" = "2.7.2" ]; then
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
# search for compiler
|
|
# $1 is the basename of the C compiler executable (e.g. cc)
|
|
# $2 is the basename of the C++ compiler executable (e.g. CC)
|
|
_search_compiler()
|
|
{
|
|
if _check_for_util "$2" n `compiler_variable $2`; then
|
|
_check_for_util "$1" n "$1"
|
|
COMPILER="`compiler_description $2`"
|
|
compute_compiler_version `compiler_bin ${COMPILER}`
|
|
eval "_COMPILER_$_COMPILER_NUMBER=\"${COMPILER}\""
|
|
COMPILER=''
|
|
eval "$_EXPR $_COMPILER_NUMBER + 1"
|
|
_COMPILER_NUMBER=$_result
|
|
fi
|
|
}
|
|
|
|
# set COMPILER to the compiler with full path $1
|
|
set_compiler_absolute()
|
|
{
|
|
eval "_`compiler_variable \`${_basename} $1\``=\"$1\""
|
|
COMPILER="`compiler_description \`${_basename} $1\``"
|
|
}
|
|
|
|
# give the variable name corresponding to compiler $1
|
|
# (necessary for g++, since '+' must not be part of a variable name)
|
|
compiler_variable()
|
|
{
|
|
case ${1:-${COMPILER}} in
|
|
*CC*) ${_printf} "CC";;
|
|
*) ${_printf} "gpp";;
|
|
esac
|
|
}
|
|
|
|
# search for compilers
|
|
# NB: The declarativ strings must have the version number as
|
|
# their third component, since this is used later to extract it)
|
|
search_for_compilers()
|
|
{
|
|
guess_os log_print
|
|
_COMPILER_NUMBER=1
|
|
case ${SYST} in
|
|
*IRIX*|*SunOS*)
|
|
_search_compiler cc CC
|
|
_search_compiler gcc g++
|
|
;;
|
|
*)
|
|
_search_compiler gcc g++
|
|
;;
|
|
esac
|
|
if [ ${_COMPILER_NUMBER} = 1 ]; then
|
|
${_printf} "\nERROR: Couldn't find any compiler, exiting.\n"
|
|
exit 1
|
|
fi
|
|
_set_compiler 1
|
|
write_buffer "\n\n${_LEFTSPACE}Choosing compiler ${COMPILER}.\n"
|
|
flush_buffer
|
|
_choose_compiler
|
|
}
|
|
|
|
# ---------------------------------------------------------------------
|
|
# arithmetic functions
|
|
# ---------------------------------------------------------------------
|
|
|
|
# since this great shell does not generally support
|
|
# arithmetics, we have to use a supplement in some cases.
|
|
# this may be expr or bc.
|
|
|
|
# evaluate expression $1 $2 $3 using shell let
|
|
# and store result in _result
|
|
_let_expr()
|
|
{
|
|
if ! eval "let _result=$1$2$3"; then
|
|
${_printf} "\nERROR: cannot evaluate $1$2$3 in _let_expr()\n"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# evaluate expression $1 $2 $3 using expr
|
|
# and store result in _result
|
|
_expr_expr()
|
|
{
|
|
# we have to do the indirection in three steps
|
|
# (since there can be only one `...` expression level)
|
|
eval "_result=`/bin/expr $1 \"$2\" $3`"
|
|
if [ $? != 0 ]; then
|
|
${_printf} "\nERROR: cannot evaluate $1 in _expr_expr()\n"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# evaluate expression $1 $2 $3 using bc
|
|
# and store result in _result
|
|
_bc_expr()
|
|
{
|
|
# we have to do the indirection in three steps
|
|
# (since there can be only one `...` expression level)
|
|
eval "_result=`echo $1 \"$2\" $3 | /bin/bc`"
|
|
if [ $? != 0 ]; then
|
|
${_printf} "\nERROR: cannot evaluate $1 in _bc_expr()\n"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# set _EXPR such that eval "$_EXPR op1 op op2" evaluates
|
|
# the expression and stores the result in _result
|
|
set_expr()
|
|
{
|
|
# first try shell let, then expr, bc, dc and csh
|
|
if /bin/sh -tc 'e=0; let e+=1' 2>/dev/null; then
|
|
_EXPR=_let_expr
|
|
elif [ -x /bin/expr ]; then
|
|
_EXPR=_expr_expr
|
|
elif [ -x /bin/bc ]; then
|
|
_EXPR=_bc_expr
|
|
else
|
|
${_printf} "\nERROR: cannot find either of bc, dc and csh\n"
|
|
${_printf} " nor does /bin/sh support let.\n"
|
|
exit 1
|
|
fi
|
|
log_print "use $_EXPR() for evaluating arithmetic expressions."
|
|
}
|
|
|
|
# ---------------------------------------------------------------------
|
|
# terminal related functions
|
|
# ---------------------------------------------------------------------
|
|
|
|
# ---------------------------------------------------------------------
|
|
# read an input string
|
|
# (since 'read' breaks its input according to field separator IFS
|
|
# (normally including space), we have to change IFS to be able
|
|
# to read multiword strings like needed for the custom compiler options)
|
|
_read()
|
|
{
|
|
_tmp=${IFS}
|
|
IFS='\n'
|
|
read KEY
|
|
IFS=${_tmp}
|
|
}
|
|
|
|
# ---------------------------------------------------------------------
|
|
# BUFFERED OUTPUT:
|
|
# for the sake of efficiency we buffer all output
|
|
|
|
clear_buffer()
|
|
{
|
|
_BUF=''
|
|
}
|
|
|
|
# print buffer
|
|
flush_buffer()
|
|
{
|
|
${_printf} "$_BUF"
|
|
clear_buffer
|
|
}
|
|
|
|
# write $* to buffer
|
|
write_buffer()
|
|
{
|
|
_BUF="$_BUF$*"
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# STRING FUNCTIONS:
|
|
|
|
print_with_indent()
|
|
{
|
|
if [ -z "$*" ]; then
|
|
_read
|
|
${_printf} "${_LEFTSPACE}${KEY}\n"
|
|
else
|
|
${_printf} "${_LEFTSPACE}$*\n"
|
|
fi
|
|
}
|
|
|
|
# print $2 times string $1 ($1 must not contain '@'!)
|
|
string_n_print()
|
|
{
|
|
_tmp=`eval "printf \"\`${_printf} \"$1@$2\" | ${_awk} 'BEGIN {FS=\"@\"}
|
|
{ for ( i=0; i<$2; ++i) printf $1}'\`\""`
|
|
write_buffer "${_tmp}"
|
|
}
|
|
|
|
# count length of variable $1 (in characters)
|
|
length()
|
|
{
|
|
# first try ${#var} substitution, if that fails wc
|
|
# if neither succeeds, we just return 30
|
|
# (this function is used to layout the menus,
|
|
# so worst case it just looks a little bit ugly ;)
|
|
|
|
if /bin/sh -tc 'echo ${#1} >/dev/null' 2>/dev/null
|
|
then
|
|
return ${#1}
|
|
elif [ -x /bin/wc ]; then
|
|
return `${_printf} "$1" | /bin/wc -c`
|
|
else
|
|
return 30
|
|
fi
|
|
}
|
|
|
|
# ---------------------------------------------------------------------
|
|
# FUNCTIONS FOR MENUS:
|
|
|
|
clear_screen()
|
|
{
|
|
write_buffer "$_clear_screen\n"
|
|
}
|
|
|
|
# moves cursor up $1 lines
|
|
go_up_lines()
|
|
{
|
|
string_n_print '${_line_up}' $1
|
|
write_buffer "\r"
|
|
}
|
|
|
|
# moves cursor down $1 lines
|
|
go_down_lines()
|
|
{
|
|
string_n_print '\\\\\\n' $1
|
|
}
|
|
|
|
# print a line containing string $1
|
|
# bounded by two stars on each side
|
|
print_line()
|
|
{
|
|
write_buffer "$_MENU_LINE_EMPTY\r${_LEFTSPACE}** $1\n"
|
|
}
|
|
|
|
# print string $1 on possibly several lines
|
|
# bounded by two stars on each side
|
|
# (the lines are indented by 5 more chars, since this
|
|
# is only used for displaying the custom options)
|
|
print_multi_line()
|
|
{
|
|
_tmp=`${_printf} "$1" | \
|
|
eval "${_awk} \`${_printf} \"${_MULTILINE_LAYOUT_AWK_PROG}\"\`"`
|
|
write_buffer "${_tmp}"
|
|
}
|
|
|
|
# print an empty line bounded by two stars on each side
|
|
print_empty_line()
|
|
{
|
|
write_buffer "$_MENU_LINE_EMPTY\n"
|
|
}
|
|
|
|
# print a line filled with stars
|
|
print_filled_line()
|
|
{
|
|
write_buffer "$_MENU_LINE_FILLED\n"
|
|
}
|
|
|
|
# give a prompt with text $1
|
|
print_prompt()
|
|
{
|
|
write_buffer "$_MENU_LINE_EMPTY\r${_LEFTSPACE}** $1"
|
|
flush_buffer
|
|
}
|
|
|
|
# print a centered line with text $1
|
|
print_center_line()
|
|
{
|
|
length "`echo "$1"`"
|
|
l=$?
|
|
eval "$_EXPR $_MENU_WIDTH \* 10"
|
|
eval "$_EXPR $_result - $l"
|
|
eval "$_EXPR $_result / 2"
|
|
write_buffer "$_MENU_LINE_EMPTY\r${_LEFTSPACE}**"
|
|
string_n_print " " $_result
|
|
write_buffer "$1\n"
|
|
}
|
|
|
|
# print a headline with text $1
|
|
print_headline()
|
|
{
|
|
length "`echo "$1"`"
|
|
l=$?
|
|
eval "$_EXPR $_MENU_WIDTH \* 10"
|
|
eval "$_EXPR $_result - $l"
|
|
eval "$_EXPR $_result / 2"
|
|
write_buffer "$_MENU_LINE_EMPTY\r${_LEFTSPACE}**"
|
|
string_n_print " " $_result
|
|
write_buffer "$1\n"
|
|
write_buffer "$_MENU_LINE_EMPTY\r${_LEFTSPACE}**"
|
|
string_n_print " " $_result
|
|
string_n_print "-" $l
|
|
write_buffer "\n"
|
|
print_empty_line
|
|
}
|
|
|
|
# wait until enter is pressed
|
|
wait_for_enter()
|
|
{
|
|
print_center_line "Please press <ENTER> to continue."
|
|
print_filled_line
|
|
flush_buffer
|
|
read dummy
|
|
}
|
|
|
|
# setup two strings for printing the menu
|
|
set_menu_lines()
|
|
{
|
|
_MENU_LINE_FILLED="${_LEFTSPACE}**"
|
|
_MENU_LINE_EMPTY="${_LEFTSPACE}**"
|
|
clear_buffer
|
|
string_n_print "**********" ${_MENU_WIDTH}
|
|
_MENU_LINE_FILLED=${_MENU_LINE_FILLED}${_BUF}"**"
|
|
clear_buffer
|
|
string_n_print " " ${_MENU_WIDTH}
|
|
_MENU_LINE_EMPTY=${_MENU_LINE_EMPTY}${_BUF}"**"
|
|
clear_buffer
|
|
eval "${_EXPR} ${_MENU_WIDTH} \* 10"
|
|
eval "${_EXPR} ${_result} - 10"
|
|
_MULTILINE_LAYOUT_AWK_PROG="'{ for (i=1; i <= length(\$0); i+=${_result}) printf \"${_MENU_LINE_EMPTY}"'\\r'"${_LEFTSPACE}** "'%%s''\\''\\n'"\",substr(\$0,i,${_result})}'"
|
|
}
|
|
|
|
# set some variables for output
|
|
set_terminal_variables()
|
|
{
|
|
${_tput} smcup # turn on cup (see man terminfo)
|
|
_line_up=`${_tput} cuu1`"\r"
|
|
_bold_on=`${_tput} bold`
|
|
_bold_off=`${_tput} sgr0`
|
|
_clear_screen=`${_tput} clear`
|
|
_clear_end_of_display=`${_tput} ed`
|
|
eval "${_EXPR} ${_MENU_WIDTH} \* 10"
|
|
length "${_LEFTSPACE}"
|
|
eval "${_EXPR} ${_result} + $?"
|
|
# for two-star('**') border
|
|
eval "${_EXPR} ${_result} + 4"
|
|
if [ `${_tput} cols` -lt ${_result} ]; then
|
|
print_filled_line
|
|
print_line \
|
|
"${_bold_on}WARNING${_bold_off}: Your terminal screen is too narrow."
|
|
print_line "It should have at least ${_result} columns."
|
|
print_filled_line
|
|
wait_for_enter
|
|
fi
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# FILE / DIR FUNCTIONS:
|
|
|
|
# some confidence test for the directories
|
|
# (return 0, iff problem - output with command $1)
|
|
check_GMP_SUPPORT()
|
|
{
|
|
if [ "${GMP_SUPPORT}" != "" -a "${GMP_SUPPORT}" != "_GMP" ]; then
|
|
$1 "WARNING: GMP_SUPPORT is not set correctly."
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
check_GMP_INSTALLATION()
|
|
{
|
|
if [ -n "${GMP_INSTALLATION}" -a \
|
|
"${GMP_INSTALLATION}" != 'x' -a \
|
|
"${GMP_INSTALLATION}" != 'c' -a \
|
|
"${GMP_INSTALLATION}" != 'z' -a \
|
|
"${GMP_INSTALLATION}" != 'e' -a \
|
|
"${GMP_INSTALLATION}" != 's' ]; then
|
|
$1 "WARNING: GMP_INSTALLATION should be \"e\", \"z\","
|
|
$1 " \"c\", \"x\", \"s\" or empty."
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
check_GMP_INCL_DIR()
|
|
{
|
|
if [ -n "${GMP_INCL_DIR}" ]; then
|
|
if [ ! -r ${GMP_INCL_DIR}/gmp.h ]; then
|
|
$1 "WARNING: GMP_INCL_DIR should contain"
|
|
$1 " gmp.h."
|
|
else
|
|
return 1
|
|
fi
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
check_GMP_LIB_DIR()
|
|
{
|
|
if [ -n "${GMP_LIB_DIR}" ]; then
|
|
if [ ! -r ${GMP_LIB_DIR}/libgmp.a -a \
|
|
! -r ${GMP_LIB_DIR}/libgmp.so ]; then
|
|
$1 "WARNING: GMP_LIB_DIR should contain"
|
|
$1 " libgmp.a or libgmp.so."
|
|
else
|
|
return 1
|
|
fi
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
# user's business
|
|
check_CUSTOM_CXXFLAGS()
|
|
{
|
|
return 1
|
|
}
|
|
|
|
# user's business
|
|
check_CUSTOM_LDFLAGS()
|
|
{
|
|
return 1
|
|
}
|
|
|
|
check_NEED_EXTRA_LEDA_IDIR()
|
|
{
|
|
if [ -n "${NEED_EXTRA_LEDA_IDIR}" -a \
|
|
"${NEED_EXTRA_LEDA_IDIR}" != 'y' -a \
|
|
"${NEED_EXTRA_LEDA_IDIR}" != 'x' ]; then
|
|
$1 "WARNING: NEED_EXTRA_LEDA_IDIR should be \"x\", \"y\" or empty."
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
check_NEED_EXTRA_LEDA_LDIR()
|
|
{
|
|
if [ -n "${NEED_EXTRA_LEDA_LDIR}" -a \
|
|
"${NEED_EXTRA_LEDA_LDIR}" != 'y' -a \
|
|
"${NEED_EXTRA_LEDA_LDIR}" != 'x' ]; then
|
|
$1 "WARNING: NEED_EXTRA_LEDA_LDIR should be \"x\", \"y\" or empty."
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
check_LEDA_INCL_DIR()
|
|
{
|
|
if [ -n "${LEDA_INCL_DIR}" ]; then
|
|
if [ ! -d $LEDA_INCL_DIR/LEDA ]; then
|
|
$1 "WARNING: LEDA_INCL_DIR should contain"
|
|
$1 " a subdirectory LEDA."
|
|
elif [ ! -r $LEDA_INCL_DIR/LEDA/basic.h ]; then
|
|
$1 "WARNING: LEDA_INCL_DIR should contain"
|
|
$1 " LEDA/basic.h."
|
|
else
|
|
return 1
|
|
fi
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
check_LEDA_LIB_DIR()
|
|
{
|
|
if [ -n "${LEDA_LIB_DIR}" ]; then
|
|
if [ ! -r $LEDA_LIB_DIR/libL.a -a ! -r $LEDA_LIB_DIR/libL.so ]; then
|
|
$1 "WARNING: LEDA_LIB_DIR should contain libL.a or libL.so."
|
|
else
|
|
return 1
|
|
fi
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
check_STL_DIR()
|
|
{
|
|
if [ -n "${STL_DIR}" ]; then
|
|
if [ ! -r $STL_DIR/iterator.h ]; then
|
|
$1 "WARNING: STL_DIR should contain iterator.h."
|
|
else
|
|
return 1
|
|
fi
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
check_GCC_RTTI_PATCH_DIR()
|
|
{
|
|
if [ -n "${GCC_RTTI_PATCH_DIR}" ]; then
|
|
if [ ! -r $GCC_RTTI_PATCH_DIR/libg++.a ]; then
|
|
$1 "WARNING: GCC_RTTI_PATCH_DIR"
|
|
$1 " should contain libg++.a."
|
|
else
|
|
return 1
|
|
fi
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
check_GCC_RTTI_PATCH_SUPPORT()
|
|
{
|
|
if [ "${GCC_RTTI_PATCH_SUPPORT}" != "" -a \
|
|
"${GCC_RTTI_PATCH_SUPPORT}" != "-rtti" ]; then
|
|
$1 "WARNING: GCC_RTTI_PATCH_SUPPORT"
|
|
$1 " is not set correctly."
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
check_LEDA_SUPPORT()
|
|
{
|
|
if [ "${LEDA_SUPPORT}" != "" -a "${LEDA_SUPPORT}" != "_LEDA" ]; then
|
|
$1 "WARNING: LEDA_SUPPORT is not set correctly."
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
check_STL_STATUS()
|
|
{
|
|
if [ "${STL_STATUS}" != "b" -a "${STL_STATUS}" != "x" \
|
|
-a "${STL_STATUS}" != "e" ]; then
|
|
$1 "WARNING: STL_STATUS is not set correctly."
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
check_CGAL_STL_VERSION()
|
|
{
|
|
case ${CGAL_STL_VERSION} in
|
|
CGAL_STL_GCC|CGAL_STL_HP|CGAL_STL_SGI_WWW|CGAL_STL_SGI_WWW_OLD|\
|
|
CGAL_STL_SGI_CC|CGAL_STL_WITH_ITERATOR_TRAITS|CGAL_STL_UNKNOWN)
|
|
return 1;;
|
|
*)
|
|
$1 "WARNING: CGAL_STL_VERSION is not set correctly."
|
|
return 0;;
|
|
esac
|
|
}
|
|
|
|
check_CGAL_INSTALL_VERSION()
|
|
{
|
|
case ${CGAL_INSTALL_VERSION} in
|
|
*.*) return 1;;
|
|
*) $1 "WARNING: CGAL_INSTALL_VERSION is not set correctly."
|
|
return 0;;
|
|
esac
|
|
}
|
|
|
|
# try to read variable $1 from file $2
|
|
# (usually this is $CGAL_DIRECTORY_FILE)
|
|
# (and run "check_$1", if you got it)
|
|
# return 0, iff something went wrong
|
|
try_to_get_var_from_file()
|
|
{
|
|
if [ -r $2 ]; then
|
|
_awkprg="/$1/"'{printf $1}'
|
|
_tmp=`${_awk} "${_awkprg}" $2`
|
|
if [ -n "${_tmp}" ]; then
|
|
_awkprg="/$1/"'{printf $3}'
|
|
_tmp=`${_awk} "${_awkprg}" $2`
|
|
log_print "got $1 from config/`$_basename $2`.\nset to <${_tmp}>."
|
|
_tmp=\'${_tmp}\'
|
|
eval $1="${_tmp}"
|
|
eval "check_$1 log_print"
|
|
return $?
|
|
else
|
|
log_print "WARNING: cannot find field $1 in file."
|
|
fi
|
|
else
|
|
log_print "WARNING: cannot find file $2."
|
|
fi
|
|
# delete previous value of $1
|
|
eval $1=''
|
|
return 0
|
|
}
|
|
|
|
# ---------------------------------------------------------------------
|
|
# THE MENUS:
|
|
# ---------------------------------------------------------------------
|
|
|
|
# ---------------------------------------------------------------------
|
|
# compiler menu
|
|
#
|
|
|
|
# cleanup after compilation
|
|
# (this is not called by _compile_test but has to be called
|
|
# by the caller of _compile_test,
|
|
# since it is not clear whether the files are still needed
|
|
# for linking or not)
|
|
cleanup_after_compile()
|
|
{
|
|
# remove tmp C++ file
|
|
${_rm} -f ${TMP_CXX_FILE}.C
|
|
# remove sunpro template database
|
|
${_rm} -rf Templates.DB
|
|
# remove irix mipspro template database
|
|
${_rm} -rf ii_files
|
|
# remove tmp object file
|
|
${_rm} -f ${TMP_CXX_FILE}.o
|
|
# remove log file
|
|
${_rm} -f ${TMP_LOGFILE}
|
|
}
|
|
|
|
# run a compiler test named $1, return 0, iff ok
|
|
# if $2 is empty, use standard compiler flags
|
|
# if $2 is non-empty, use it as compiler flags
|
|
# if $3 is non-zero, inform about eventually occurring problems
|
|
_compile_test()
|
|
{
|
|
# add newlines to ${TMP_CXX_FILE}.C (ANSI)
|
|
${_printf} "\n\n" >> ${TMP_CXX_FILE}.C
|
|
${_printf} "${_LEFTSPACE}Testing for $1 ..."
|
|
|
|
# set flags
|
|
if [ -z "$2" ]; then
|
|
_flags="`compiler_flags` -c ${TMP_CXX_FILE}.C"
|
|
else
|
|
_flags="$2 -c ${TMP_CXX_FILE}.C"
|
|
fi
|
|
|
|
# compile
|
|
${_printf} 'Compiler call:\n--------------\n' >${TMP_LOGFILE}
|
|
${_printf} "`compiler_bin` ${_flags}" >>${TMP_LOGFILE}
|
|
${_printf} "\n\nGot the following error messages:\n" >>${TMP_LOGFILE}
|
|
${_printf} "---------------------------------\n" >>${TMP_LOGFILE}
|
|
eval "`compiler_bin` ${_flags} >>${TMP_LOGFILE} 2>&1"
|
|
if [ $? = 0 ]; then
|
|
log_print "$1 test compiled."
|
|
return 0
|
|
else
|
|
if [ -n "$3" ]; then
|
|
if [ -n "${INSTALL_INTERACTIVE}" ]; then
|
|
log_print "ERROR: $1 test did NOT compile."
|
|
write_buffer "\n"
|
|
print_filled_line
|
|
print_empty_line
|
|
print_headline "Compilation failed"
|
|
print_center_line "You will be shown a log now ..."
|
|
wait_for_enter
|
|
${_cat} ${TMP_LOGFILE} | ${PAGER:-${_cat}}
|
|
write_buffer "\n"
|
|
print_filled_line
|
|
wait_for_enter
|
|
else
|
|
${_printf} " compilation failed.\n\n"
|
|
${_cat} ${TMP_LOGFILE}
|
|
printf \
|
|
"--------------------------------------------------------\n\n"
|
|
fi
|
|
else
|
|
log_print "remark: $1 test did not compile."
|
|
${_printf} " no.\n"
|
|
fi
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# cleanup after compilation
|
|
cleanup_after_link_run()
|
|
{
|
|
cleanup_after_compile
|
|
# remove executable and core
|
|
${_rm} -f ${TMP_CXX_FILE} core
|
|
}
|
|
|
|
# run a link&run test named $1, return 0, iff ok
|
|
# if $2 is empty, use standard linker flags
|
|
# if $2 is non-empty, use it as linker flags
|
|
# if $3 is non-zero, inform about eventually occurring problems
|
|
_link_run_test()
|
|
{
|
|
# set flags
|
|
if [ -z "$2" ]; then
|
|
_flags="`linker_flags_no_cgal_lib`"
|
|
else
|
|
_flags="$2"
|
|
fi
|
|
_flags="-o ${TMP_CXX_FILE} ${TMP_CXX_FILE}.o ${_flags}"
|
|
|
|
# link
|
|
${_printf} 'Linker call:\n--------------\n' >${TMP_LOGFILE}
|
|
${_printf} "`compiler_bin` ${_flags}" >>${TMP_LOGFILE}
|
|
${_printf} "\n\nGot the following error messages:\n" >>${TMP_LOGFILE}
|
|
${_printf} "---------------------------------\n" >>${TMP_LOGFILE}
|
|
eval "`compiler_bin` ${_flags} >>${TMP_LOGFILE} 2>&1"
|
|
i=$?
|
|
j=1
|
|
if [ $i = 0 ]; then
|
|
log_print "$1 test linking succeeded."
|
|
# run
|
|
${_printf} \
|
|
"Run program `${_basename} ${TMP_CXX_FILE}`:\n" >>${TMP_LOGFILE}
|
|
${_printf} \
|
|
"----------------------\n" >>${TMP_LOGFILE}
|
|
${_printf} "\n\nGot the following output:\n" >>${TMP_LOGFILE}
|
|
${_printf} "---------------------------------\n" >>${TMP_LOGFILE}
|
|
${TMP_CXX_FILE} >>${TMP_LOGFILE} 2>&1
|
|
j=$?
|
|
if [ $j = 0 ]; then
|
|
log_print "$1 test execution succeeded."
|
|
else
|
|
if [ -n "$3" ]; then
|
|
log_print "ERROR: $1 test execution FAILED."
|
|
else
|
|
log_print "remark: $1 test execution failed."
|
|
fi
|
|
fi
|
|
else
|
|
if [ -n "$3" ]; then
|
|
log_print "ERROR: $1 test linking FAILED."
|
|
else
|
|
log_print "remark: $1 test linking failed."
|
|
fi
|
|
fi
|
|
if [ $j = 0 -a $i = 0 ]; then
|
|
${_printf} " ok.\n"
|
|
cleanup_after_link_run
|
|
return 0
|
|
else
|
|
if [ -n "$3" ]; then
|
|
if [ -n "${INSTALL_INTERACTIVE}" ]; then
|
|
log_print "ERROR: $1 test FAILED."
|
|
write_buffer "\n"
|
|
print_filled_line
|
|
print_empty_line
|
|
print_headline "Linking or execution failed"
|
|
print_center_line "You will be shown a log now ..."
|
|
wait_for_enter
|
|
$_cat ${TMP_LOGFILE} | ${PAGER:-$_cat}
|
|
write_buffer "\n"
|
|
print_filled_line
|
|
wait_for_enter
|
|
else
|
|
${_printf} " linking or execution failed.\n\n"
|
|
${_cat} ${TMP_LOGFILE}
|
|
printf \
|
|
"--------------------------------------------------------\n\n"
|
|
fi
|
|
else
|
|
${_printf} " no.\n"
|
|
fi
|
|
cleanup_after_link_run
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# LEDA TEST:
|
|
|
|
# test if leda header files are in some sys include dir
|
|
# and sets NEED_EXTRA_LEDA_IDIR correspondingly
|
|
# ($1 nonzero indicates verbosity)
|
|
# [ checks for the existence of <LEDA/bool.h>, since this
|
|
# is a file where no LEDA lib has to be linked in order to
|
|
# produce an executable; <LEDA/basic.h> needs some
|
|
# mem_manager stuff ... ]
|
|
test_for_leda_incl_in_sys_incl()
|
|
{
|
|
${_printf} '
|
|
#include <LEDA/basic.h>
|
|
int main() {
|
|
return 0;
|
|
}\n' > ${TMP_CXX_FILE}.C
|
|
if _compile_test "LEDA sysincl" "${CUSTOM_CXXFLAGS} " "$1"; then
|
|
cleanup_after_compile
|
|
${_printf} " ok.\n"
|
|
NEED_EXTRA_LEDA_IDIR=''
|
|
return 0
|
|
fi
|
|
cleanup_after_compile
|
|
NEED_EXTRA_LEDA_IDIR='y'
|
|
return 1
|
|
}
|
|
|
|
# test if leda libs are in some sys lib dir
|
|
# and sets NEED_EXTRA_LEDA_LDIR correspondingly
|
|
# ($1 nonzero indicates verbosity)
|
|
test_for_leda_lib_in_sys_lib()
|
|
{
|
|
${_printf} '
|
|
int main() {
|
|
return 0;
|
|
}' > ${TMP_CXX_FILE}.C
|
|
if _compile_test "LEDA syslibs" "${CUSTOM_CXXFLAGS} " "$1"; then
|
|
if _link_run_test "LEDA syslibs" \
|
|
"${CUSTOM_LDFLAGS} -lP -lG -lL -lm" "$1"; then
|
|
NEED_EXTRA_LEDA_LDIR=''
|
|
return 0
|
|
fi
|
|
fi
|
|
NEED_EXTRA_LEDA_LDIR='y'
|
|
return 1
|
|
}
|
|
|
|
# test if LEDA setting works (return 0, iff ok)
|
|
# ($1 nonzero indicates verbosity)
|
|
test_leda()
|
|
{
|
|
if [ -n "${LEDA_SUPPORT}" ]; then
|
|
${_printf} "\n" > ${TMP_CXX_FILE}.C
|
|
if [ -n "${GCC_RTTI_PATCH_SUPPORT}" ]; then
|
|
${_printf} "#include <typeinfo>\n" >> ${TMP_CXX_FILE}.C
|
|
fi
|
|
${_printf} '
|
|
#include <iostream.h>
|
|
#include <assert.h>
|
|
#include <LEDA/integer.h>
|
|
#include <LEDA/REDEFINE_NAMES.h>
|
|
typedef integer I;
|
|
#include <LEDA/UNDEFINE_NAMES.h>
|
|
int main() {
|
|
I a( 123456);
|
|
I b( 456789);
|
|
|
|
assert( a + b == I( 580245));
|
|
assert( a - b == I( -333333));
|
|
return 0;
|
|
}' >> ${TMP_CXX_FILE}.C
|
|
|
|
if _compile_test LEDA '' $1 && _link_run_test LEDA '' $1; then
|
|
LEDA_TEST_PASSED='y'
|
|
return 0
|
|
else
|
|
LEDA_TEST_PASSED=''
|
|
return 1
|
|
fi
|
|
else
|
|
return 0
|
|
fi
|
|
}
|
|
|
|
# ---------------------------------------------------------------------
|
|
# STL TESTS:
|
|
# (I use "@error" instead of "#error" to indicate an error,
|
|
# since sunpro CC treats the latter as warnings ...)
|
|
|
|
# print cxxflags for current setting
|
|
stl_test_cxxflags()
|
|
{
|
|
${_printf} "${CUSTOM_CXXFLAGS} `rtti_patch_cxxflags``stl_cxxflags`"
|
|
}
|
|
|
|
# print ldflags for current setting
|
|
stl_test_ldflags()
|
|
{
|
|
${_printf} "${CUSTOM_LDFLAGS} `rtti_patch_ldflags` -lm"
|
|
}
|
|
|
|
# test, if STL is original HP from 1994 (or compatible?)
|
|
# (return 0, iff it is)
|
|
# (test program due to Lutz Kettner)
|
|
# ($1 nonzero indicates verbosity)
|
|
_test_hp_1994_stl()
|
|
{
|
|
${_printf} '
|
|
#include <assert.h>
|
|
#include <defalloc.h>
|
|
#include <iterator.h>
|
|
#define Allocator allocator
|
|
#include <list.h>
|
|
|
|
#ifndef LIST_H
|
|
@error Program does not use the HP STL from 1994.
|
|
#endif
|
|
|
|
#ifdef Allocator
|
|
@error Program does not use the HP STL from 1994.
|
|
#endif
|
|
|
|
int main() {
|
|
list<int> l;
|
|
l.push_back(42);
|
|
assert( 42 == *(l.begin()));
|
|
return 0;
|
|
}' > ${TMP_CXX_FILE}.C
|
|
|
|
_compile_test "HP STL" "`stl_test_cxxflags` " $1 && \
|
|
_link_run_test "HP STL" "`stl_test_ldflags` " $1
|
|
return $?
|
|
}
|
|
|
|
# test, if STL is SGI STL from 1996 (or compatible?)
|
|
# (return 0, iff it is)
|
|
# (test program due to Lutz Kettner)
|
|
# ($1 nonzero indicates verbosity)
|
|
_test_sgi_1996_stl()
|
|
{
|
|
${_printf} '
|
|
#include <assert.h>
|
|
#include <defalloc.h>
|
|
#include <iterator.h>
|
|
#define Allocator allocator
|
|
#include <list.h>
|
|
|
|
#ifndef __SGI_STL_LIST_H
|
|
@error Program does not use the old SGI STL from the web from 1996.
|
|
#endif
|
|
|
|
#ifndef Allocator
|
|
@error Program does not use the old SGI STL from the web from 1996.
|
|
#endif
|
|
|
|
template< class T> inline
|
|
int check( const __list_const_iterator<T>&){
|
|
return 1;
|
|
}
|
|
|
|
int main() {
|
|
const list<int> l;
|
|
assert( check( l.begin()));
|
|
return 0;
|
|
}' > ${TMP_CXX_FILE}.C
|
|
|
|
_compile_test "SGI 1996 STL" "`stl_test_cxxflags` " $1 && \
|
|
_link_run_test "SGI 1996 STL" "`stl_test_ldflags` " $1
|
|
return $?
|
|
}
|
|
|
|
# test, if STL is SGI STL supplied with compiler (or compatible?)
|
|
# (return 0, iff it is)
|
|
# (test program due to Lutz Kettner)
|
|
# ($1 nonzero indicates verbosity)
|
|
_test_sgi_cc_stl()
|
|
{
|
|
${_printf} '
|
|
#include <assert.h>
|
|
#include <defalloc.h>
|
|
#include <iterator.h>
|
|
#define Allocator allocator
|
|
#include <list.h>
|
|
|
|
#ifndef LIST_H
|
|
@error Program does not use the SGI STL shipped with C++ from 1996.
|
|
#endif
|
|
|
|
#ifndef Allocator
|
|
@error Program does not use the SGI STL shipped with C++ from 1996.
|
|
#endif
|
|
|
|
int main() {
|
|
list<int> l;
|
|
l.push_back(42);
|
|
assert( 42 == *(l.begin()));
|
|
return 0;
|
|
}' > ${TMP_CXX_FILE}.C
|
|
|
|
_compile_test "SGI CC STL" "`stl_test_cxxflags` " $1 && \
|
|
_link_run_test "SGI CC STL" "`stl_test_ldflags` " $1
|
|
return $?
|
|
}
|
|
|
|
# test, if STL supports iterator traits
|
|
# (return 0, iff it is)
|
|
# (test program due to Lutz Kettner)
|
|
# ($1 nonzero indicates verbosity)
|
|
_test_stl_iterator_traits()
|
|
{
|
|
${_printf} '
|
|
#include <assert.h>
|
|
#include <iterator.h>
|
|
#include <list.h>
|
|
|
|
template <class Iterator>
|
|
struct Get_val {
|
|
typedef typename iterator_traits<Iterator>::value_type value_type;
|
|
value_type operator()( Iterator i) { return *i;}
|
|
};
|
|
|
|
template <class Iterator>
|
|
typename iterator_traits<Iterator>::value_type get_val( Iterator i) {
|
|
return *i;
|
|
}
|
|
|
|
int main() {
|
|
list<int> l;
|
|
l.push_back(42);
|
|
l.push_back(13);
|
|
assert( 42 == Get_val<list<int>::iterator>()( l.begin()));
|
|
assert( 42 == get_val( l.begin()));
|
|
return 0;
|
|
}' > ${TMP_CXX_FILE}.C
|
|
|
|
_compile_test "ITERATOR TRAITS" "`stl_test_cxxflags` " $1 && \
|
|
_link_run_test "ITERATOR TRAITS" "`stl_test_ldflags` " $1
|
|
return $?
|
|
}
|
|
|
|
# test, if STL is SGI STL from June 1997 (or compatible?)
|
|
# (return 0, iff it is)
|
|
# (test program due to Lutz Kettner)
|
|
# ($1 nonzero indicates verbosity)
|
|
_test_sgi_june_1997_stl()
|
|
{
|
|
${_printf} '#include <assert.h>
|
|
#include <defalloc.h>
|
|
#include <iterator.h>
|
|
#define Allocator allocator
|
|
#include <list.h>
|
|
|
|
#ifndef __SGI_STL_LIST_H
|
|
@error Program does not use the SGI STL from June 13, 1997.
|
|
#endif
|
|
|
|
#ifndef Allocator
|
|
@error Program does not use the SGI STL from June 13, 1997.
|
|
#endif
|
|
|
|
template< class T, class Ref> inline
|
|
int check( const __list_iterator<T,Ref>&){
|
|
return 1;
|
|
}
|
|
|
|
int main() {
|
|
list<int> l;
|
|
assert( check( l.begin()));
|
|
return 0;
|
|
}' > ${TMP_CXX_FILE}.C
|
|
|
|
_compile_test "SGI 6/97 STL" "`stl_test_cxxflags` " $1 && \
|
|
_link_run_test "SGI 6/97 STL" "`stl_test_ldflags` " $1
|
|
return $?
|
|
}
|
|
|
|
# test, if STL works
|
|
# (return 0, iff it is)
|
|
# (test program due to Lutz Kettner)
|
|
# ($1 nonzero indicates verbosity)
|
|
# ($2 gives comment for _compile_test)
|
|
test_stl_general()
|
|
{
|
|
if [ -n "${GCC_RTTI_PATCH_SUPPORT}" ]; then
|
|
${_printf} '#include <typeinfo>' > ${TMP_CXX_FILE}.C
|
|
else
|
|
${_printf} "\n" > ${TMP_CXX_FILE}.C
|
|
fi
|
|
|
|
${_printf} '
|
|
#include <iostream.h>
|
|
#include <algo.h>
|
|
#include <vector.h>
|
|
#include <list.h>
|
|
#include <iterator.h>
|
|
#include <assert.h>
|
|
|
|
list<char> lst( char* s) {
|
|
list<char> x;
|
|
while (*s != '\0') x.push_back( *s++);
|
|
return x;
|
|
}
|
|
|
|
int main() {
|
|
list<char> list1 = lst( "mark twain");
|
|
reverse( list1.begin(), list1.end());
|
|
assert( list1 == lst( "niawt kram"));
|
|
return 0;
|
|
}' >> ${TMP_CXX_FILE}.C
|
|
|
|
if [ -z "$1" ]; then
|
|
_compile_test "${2}" "${CUSTOM_CXXFLAGS} " '' && \
|
|
_link_run_test "${2}" "${CUSTOM_LDFLAGS} " ''
|
|
else
|
|
_compile_test "${2}" "`stl_test_cxxflags` " $1 && \
|
|
_link_run_test "${2}" "`stl_test_ldflags` " $1
|
|
fi
|
|
return $?
|
|
}
|
|
|
|
# determine which STL version is used
|
|
# ($1 nonzero indicates verbosity)
|
|
# we have the following different types:
|
|
# CGAL_STL_GCC
|
|
# CGAL_STL_HP
|
|
# CGAL_STL_SGI_WWW
|
|
# CGAL_STL_SGI_WWW_OLD
|
|
# CGAL_STL_SGI_CC
|
|
# CGAL_STL_WITH_ITERATOR_TRAITS
|
|
# CGAL_STL_UNKNOWN
|
|
set_stl_version()
|
|
{
|
|
if [ "`compiler_basename`" = "g++" ]; then
|
|
CGAL_STL_VERSION='CGAL_STL_GCC'
|
|
elif _test_stl_iterator_traits $1; then
|
|
CGAL_STL_VERSION='CGAL_STL_WITH_ITERATOR_TRAITS'
|
|
elif _test_sgi_june_1997_stl $1; then
|
|
CGAL_STL_VERSION='CGAL_STL_SGI_WWW'
|
|
elif _test_sgi_1996_stl $1; then
|
|
CGAL_STL_VERSION='CGAL_STL_SGI_WWW_OLD'
|
|
elif _test_sgi_cc_stl $1; then
|
|
CGAL_STL_VERSION='CGAL_STL_SGI_CC'
|
|
elif _test_hp_1994_stl $1; then
|
|
CGAL_STL_VERSION='CGAL_STL_HP'
|
|
else
|
|
CGAL_STL_VERSION='CGAL_STL_UNKNOWN'
|
|
fi
|
|
log_print "STL type seems to be ${CGAL_STL_VERSION}."
|
|
}
|
|
|
|
# checks, if current compiler has a builtin STL
|
|
# (iff so, return 0) and sets STL_STATUS
|
|
# (and CGAL_STL_VERSION) correspondingly
|
|
test_for_builtin_stl()
|
|
{
|
|
STL_STATUS='b'
|
|
if test_stl_general "${INSTALL_VERBOSE}" 'builtin STL'; then
|
|
log_print "${COMPILER} seems to have builtin STL."
|
|
set_stl_version "${INSTALL_VERBOSE}"
|
|
STL_TEST_PASSED='y'
|
|
return 0
|
|
else
|
|
log_print "${COMPILER} seems NOT to have builtin STL."
|
|
STL_STATUS='e'
|
|
STL_TEST_PASSED=''
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# test, if STL works
|
|
# return 0, if it does, return 1 otherwise
|
|
test_stl()
|
|
{
|
|
if test_stl_general 'v' 'STL'; then
|
|
set_stl_version "${INSTALL_VERBOSE}"
|
|
STL_TEST_PASSED='y'
|
|
return 0
|
|
fi
|
|
STL_TEST_PASSED=''
|
|
return 1
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# GCC RTTI PATCH TEST:
|
|
# test, if RTTI patch works
|
|
# (return 0, iff it does)
|
|
# ($1 nonzero indicates verbosity)
|
|
test_gcc_rtti_patch()
|
|
{
|
|
if [ -n "${GCC_RTTI_PATCH_SUPPORT}" ]; then
|
|
${_printf} '
|
|
#include <typeinfo>
|
|
#include <fstream.h>
|
|
#include <iostream.h>
|
|
|
|
int main() {
|
|
ifstream t;
|
|
t.open( "README");
|
|
int i;
|
|
cout << "If you have LEDA support enabled,\n"
|
|
<< "make sure the LEDA libs in LEDA_LIB_DIR\n"
|
|
<< "are also compiled with rtti support."
|
|
<< endl;
|
|
cout << "If this is the last line you see, "
|
|
<< "the test failed." << endl;
|
|
t >> i;
|
|
cout << "test ok" << endl;
|
|
return 0;
|
|
}' > ${TMP_CXX_FILE}.C
|
|
|
|
if _compile_test 'RTTI patch' '' $1 && \
|
|
_link_run_test 'RTTI patch' '' $1; then
|
|
RTTI_TEST_PASSED='y'
|
|
return 0
|
|
else
|
|
RTTI_TEST_PASSED=''
|
|
return 1
|
|
fi
|
|
else
|
|
return 0
|
|
fi
|
|
}
|
|
|
|
# ---------------------------------------------------------------------
|
|
# GNU GMP TEST:
|
|
|
|
# gmp test from the gmp/README
|
|
# (return 0, iff it works)
|
|
# ($1 is either 'GMP' or 'GMP syslib')
|
|
# ($2 nonzero indicates verbosity)
|
|
test_gmp()
|
|
{
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
if [ -n "${GCC_RTTI_PATCH_SUPPORT}" ]; then
|
|
${_printf} '#include <typeinfo>' > ${TMP_CXX_FILE}.C
|
|
else
|
|
${_printf} "\n" > ${TMP_CXX_FILE}.C
|
|
fi
|
|
${_printf} '
|
|
#include <stdio.h>
|
|
#include "gmp.h"
|
|
int
|
|
main ()
|
|
{
|
|
mpz_t b, p;
|
|
mpz_init (p);
|
|
mpz_init_set_str (b, "31", 0);
|
|
mpz_mul_ui (p, b, 75); /* generate product */
|
|
mpz_out_str (stdout, 10, p); /* print number without newline */
|
|
puts (""); /* print newline */
|
|
return 0;
|
|
}' >> ${TMP_CXX_FILE}.C
|
|
if [ "$1" = "GMP syslib" ]; then
|
|
_compile_test "$1" "${CUSTOM_CXXFLAGS} " "$2" && \
|
|
_link_run_test "$1" "${CUSTOM_LDFLAGS} -lgmp" "$2"
|
|
else
|
|
_compile_test "$1" '' "$2" && \
|
|
_link_run_test "$1" '' "$2"
|
|
fi
|
|
if [ $? = 0 ]; then
|
|
GMP_TEST_PASSED='y'
|
|
return 0
|
|
else
|
|
GMP_TEST_PASSED=''
|
|
return 1
|
|
fi
|
|
else
|
|
return 0
|
|
fi
|
|
}
|
|
|
|
# set variable CGAL_OS_COMPILER according to the current
|
|
# compiler settings
|
|
set_ostype()
|
|
{
|
|
if [ -n "`compiler_version`" ]; then
|
|
CGAL_OS_COMPILER="${SYST}_`compiler_basename`-`compiler_version`"
|
|
else
|
|
CGAL_OS_COMPILER="${SYST}_`compiler_basename`"
|
|
fi
|
|
}
|
|
|
|
# return the full os/compiler string
|
|
# (i.e. including LEDA and RTTI extension)
|
|
full_ostype()
|
|
{
|
|
${_printf} "${CGAL_OS_COMPILER}${GCC_RTTI_PATCH_SUPPORT}${LEDA_SUPPORT}"
|
|
}
|
|
|
|
# print the current os/compiler in a readable fashion
|
|
print_os_setting()
|
|
{
|
|
${_printf} "${_LEFTSPACE}OS:\t\t${SYST}\n"
|
|
${_printf} "${_LEFTSPACE}COMPILER:\t${COMPILER}\n"
|
|
${_printf} "${_LEFTSPACE}STL:\t\t${CGAL_STL_VERSION}\n"
|
|
_set_tmp_to_not_or_not "${LEDA_SUPPORT}"
|
|
${_printf} "${_LEFTSPACE}LEDA:\t\t${_tmp}supported\n"
|
|
_set_tmp_to_not_or_not "${GMP_SUPPORT}"
|
|
${_printf} "${_LEFTSPACE}GMP:\t\t${_tmp}supported\n"
|
|
if show_rtti_options; then
|
|
_set_tmp_to_not_or_not "${GCC_RTTI_PATCH_SUPPORT}"
|
|
${_printf} "${_LEFTSPACE}RTTI:\t\t${_tmp}supported\n"
|
|
fi
|
|
}
|
|
|
|
set_lib_compiled_flag()
|
|
{
|
|
# does there exist a lib for this os/compiler?
|
|
if [ -r ${CGAL_LIB_DIR}/`full_ostype`/${CGAL_LIB_NAME}.a ]; then
|
|
LIB_COMPILED='ok'
|
|
else
|
|
LIB_COMPILED=''
|
|
fi
|
|
}
|
|
|
|
# set GMP_INSTALLATION
|
|
# first check for sysdir installation, then in CGAL tree,
|
|
# finally an external installation
|
|
# return 0, iff one of these test succeeded
|
|
# ($1 non-empty indicates verbosity)
|
|
search_gmp()
|
|
{
|
|
# test, if GMP is installed in CGAL tree
|
|
make_lib_dir
|
|
GMP_INSTALLATION='c'
|
|
if test_gmp 'GMP CGAL' "$1"; then
|
|
log_print "remark: GMP is installed in CGAL tree."
|
|
else
|
|
GMP_INSTALLATION='s'
|
|
if test_gmp 'GMP syslib' "$1"; then
|
|
log_print "remark: GMP is installed in sysdirs."
|
|
else
|
|
GMP_INSTALLATION='e'
|
|
if test_gmp 'GMP' "$1"; then
|
|
log_print "remark: GMP is installed in extra dir."
|
|
else
|
|
GMP_INSTALLATION=''
|
|
log_print "remark: GMP is not installed."
|
|
return 1
|
|
fi
|
|
fi
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# compiler related functions
|
|
#
|
|
|
|
# try to retrieve the compiler specific settings from
|
|
# file ${CGAL_CONF_DIR}/${CGAL_OS_COMPILER}
|
|
retrieve_compiler_settings()
|
|
{
|
|
_file="${CGAL_CONF_DIR}/${CGAL_OS_COMPILER}"
|
|
_tmp_version=${CGAL_INSTALL_VERSION}
|
|
if try_to_get_var_from_file CGAL_INSTALL_VERSION "${_file}"; then
|
|
SETUP_COMPLETE=''
|
|
CGAL_INSTALL_VERSION=${_tmp_version}
|
|
elif [ "${_tmp_version}" != "${CGAL_INSTALL_VERSION}" ]; then
|
|
# this config file was generated by an older install
|
|
log_print "WARNING: config file `$_basename ${_file}`"
|
|
log_print " was generated by another `$_basename $0` version."
|
|
SETUP_COMPLETE=''
|
|
CGAL_INSTALL_VERSION=${_tmp_version}
|
|
else
|
|
SETUP_COMPLETE='y'
|
|
fi
|
|
|
|
# these two have to be ok:
|
|
if try_to_get_var_from_file LEDA_SUPPORT "${_file}"; then
|
|
LEDA_SUPPORT=''
|
|
fi
|
|
if try_to_get_var_from_file GCC_RTTI_PATCH_SUPPORT "${_file}"; then
|
|
GCC_RTTI_PATCH_SUPPORT=''
|
|
fi
|
|
|
|
# LEDA specific stuff:
|
|
if try_to_get_var_from_file NEED_EXTRA_LEDA_IDIR "${_file}" || \
|
|
try_to_get_var_from_file NEED_EXTRA_LEDA_LDIR "${_file}"; then
|
|
if [ -n "${LEDA_SUPPORT}" ]; then
|
|
LEDA_SUPPORT=''
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
NEED_EXTRA_LEDA_IDIR='n'
|
|
NEED_EXTRA_LEDA_LDIR='n'
|
|
fi
|
|
if try_to_get_var_from_file LEDA_INCL_DIR "${_file}"; then
|
|
if [ -n "${LEDA_SUPPORT}" -a -n "${NEED_EXTRA_LEDA_IDIR}" ]; then
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
fi
|
|
if try_to_get_var_from_file LEDA_LIB_DIR "${_file}"; then
|
|
if [ -n "${LEDA_SUPPORT}" -a -n "${NEED_EXTRA_LEDA_LDIR}" ]; then
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
fi
|
|
|
|
# GCC specific stuff:
|
|
if try_to_get_var_from_file GCC_RTTI_PATCH_DIR "${_file}"; then
|
|
if [ -n "${GCC_RTTI_PATCH_SUPPORT}" ]; then
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
GCC_RTTI_PATCH_SUPPORT=''
|
|
fi
|
|
|
|
# STL specific stuff:
|
|
if try_to_get_var_from_file STL_STATUS "${_file}"; then
|
|
# couldn't get STL_STATUS
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
if try_to_get_var_from_file STL_DIR "${_file}"; then
|
|
if [ "${STL_STATUS}" != "b" ]; then
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
fi
|
|
if try_to_get_var_from_file CGAL_STL_VERSION "${_file}"; then
|
|
# couldn't get CGAL_STL_VERSION
|
|
CGAL_STL_VERSION='CGAL_STL_UNKNOWN'
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
|
|
if try_to_get_var_from_file CUSTOM_CXXFLAGS "${_file}"; then
|
|
CUSTOM_CXXFLAGS=''
|
|
fi
|
|
if try_to_get_var_from_file CUSTOM_LDFLAGS "${_file}"; then
|
|
CUSTOM_LDFLAGS=''
|
|
fi
|
|
|
|
# GMP specific stuff:
|
|
if try_to_get_var_from_file GMP_SUPPORT "${_file}" ||\
|
|
try_to_get_var_from_file GMP_INSTALLATION "${_file}"; then
|
|
search_gmp "${INSTALL_VERBOSE}"
|
|
GMP_SUPPORT=''
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
if try_to_get_var_from_file GMP_INCL_DIR "${_file}"; then
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
if [ "${GMP_INSTALLATION}" = 'x' -o \
|
|
"${GMP_INSTALLATION}" = 'z' -o \
|
|
"${GMP_INSTALLATION}" = 'e' ]; then
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
fi
|
|
fi
|
|
if try_to_get_var_from_file GMP_LIB_DIR "${_file}"; then
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
if [ "${GMP_INSTALLATION}" = 'x' -o \
|
|
"${GMP_INSTALLATION}" = 'z' -o \
|
|
"${GMP_INSTALLATION}" = 'e' ]; then
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
set_lib_compiled_flag
|
|
}
|
|
|
|
# store the actual compiler specific settings to the
|
|
# file ${CGAL_CONF_DIR}/${CGAL_OS_COMPILER}
|
|
store_compiler_settings()
|
|
{
|
|
_file="${CGAL_CONF_DIR}/${CGAL_OS_COMPILER}"
|
|
${_printf} "# file: `$_basename ${_file}`\n" >${_file}
|
|
${_printf} "# Configuration file for ${COMPILER} on ${SYST}\n" >>${_file}
|
|
${_printf} "# Automatically created by $0.\n" >>${_file}
|
|
${_printf} "# Please do not edit.\n" >>${_file}
|
|
${_printf} "CGAL_INSTALL_VERSION = ${CGAL_INSTALL_VERSION}\n" >>${_file}
|
|
${_printf} "STL_STATUS = ${STL_STATUS}\n" >>${_file}
|
|
${_printf} "CGAL_STL_VERSION = ${CGAL_STL_VERSION}\n" >>${_file}
|
|
${_printf} "STL_DIR = ${STL_DIR}\n" >>${_file}
|
|
${_printf} "LEDA_SUPPORT = ${LEDA_SUPPORT}\n" >>${_file}
|
|
${_printf} "NEED_EXTRA_LEDA_IDIR = ${NEED_EXTRA_LEDA_IDIR}\n" >>${_file}
|
|
${_printf} "LEDA_INCL_DIR = ${LEDA_INCL_DIR}\n" >>${_file}
|
|
${_printf} "NEED_EXTRA_LEDA_LDIR = ${NEED_EXTRA_LEDA_LDIR}\n" >>${_file}
|
|
${_printf} "LEDA_LIB_DIR = ${LEDA_LIB_DIR}\n" >>${_file}
|
|
${_printf} "GMP_SUPPORT = ${GMP_SUPPORT}\n" >>${_file}
|
|
${_printf} "GMP_INSTALLATION = ${GMP_INSTALLATION}\n" >>${_file}
|
|
${_printf} "GMP_INCL_DIR = ${GMP_INCL_DIR}\n" >>${_file}
|
|
${_printf} "GMP_LIB_DIR = ${GMP_LIB_DIR}\n" >>${_file}
|
|
${_printf} "GCC_RTTI_PATCH_SUPPORT = ${GCC_RTTI_PATCH_SUPPORT}\n" >>${_file}
|
|
${_printf} "GCC_RTTI_PATCH_DIR = ${GCC_RTTI_PATCH_DIR}\n" >>${_file}
|
|
${_printf} "CUSTOM_CXXFLAGS = ${CUSTOM_CXXFLAGS}\n" >>${_file}
|
|
${_printf} "CUSTOM_LDFLAGS = ${CUSTOM_LDFLAGS}\n" >>${_file}
|
|
log_print "Settings stored in ${_file}."
|
|
}
|
|
|
|
# just a tiny message template for test_setup
|
|
_passed_message()
|
|
{
|
|
${_printf} "${_LEFTSPACE}$1 test has already been passed.\n"
|
|
}
|
|
|
|
# test current setup and set SETUP_COMPLETE
|
|
# return 0, iff setup is ok
|
|
test_setup()
|
|
{
|
|
SETUP_COMPLETE=''
|
|
make_lib_dir
|
|
# STL
|
|
if [ -z "${STL_TEST_PASSED}" ]; then
|
|
test_stl
|
|
if [ $? = 1 ]; then
|
|
return 1
|
|
fi
|
|
else
|
|
_passed_message 'STL'
|
|
fi
|
|
|
|
# LEDA
|
|
if [ -z "${LEDA_TEST_PASSED}" ]; then
|
|
test_leda 'v'
|
|
if [ $? = 1 ]; then
|
|
return 1
|
|
fi
|
|
else
|
|
_passed_message 'LEDA'
|
|
fi
|
|
|
|
# GMP
|
|
if [ -z "${GMP_TEST_PASSED}" ]; then
|
|
test_gmp 'GMP' 'v'
|
|
if [ $? = 1 ]; then
|
|
return 1
|
|
fi
|
|
else
|
|
_passed_message 'GMP'
|
|
fi
|
|
|
|
# RTTI Patch
|
|
if [ -z "${RTTI_TEST_PASSED}" ]; then
|
|
test_gcc_rtti_patch 'v'
|
|
if [ $? = 1 ]; then
|
|
return 1
|
|
fi
|
|
else
|
|
_passed_message 'RTTI'
|
|
fi
|
|
|
|
SETUP_COMPLETE='y'
|
|
${_printf} "${_LEFTSPACE}Saving current setup ..."
|
|
store_compiler_settings
|
|
${_printf} " done.\n"
|
|
return 0
|
|
}
|
|
|
|
# called when the setup has been changed dramatically
|
|
# such that all previous test results are invalidated
|
|
reset_all_test_variables()
|
|
{
|
|
STL_TEST_PASSED=''
|
|
LEDA_TEST_PASSED=''
|
|
GMP_TEST_PASSED=''
|
|
RTTI_TEST_PASSED=''
|
|
}
|
|
|
|
# load the settings for ${COMPILER},
|
|
# if a config file exists, otherwise check for "builtin" STL
|
|
# and set STL_STATUS accordingly
|
|
_choose_compiler()
|
|
{
|
|
log_print "Choosing ${COMPILER} as compiler."
|
|
set_ostype
|
|
retrieve_compiler_settings
|
|
if [ -z "${SETUP_COMPLETE}" ]; then
|
|
# reset all TEST_PASSED variables
|
|
reset_all_test_variables
|
|
test_for_builtin_stl
|
|
if [ $? = 0 -o -n "${STL_DIR}" ]; then
|
|
test_setup
|
|
else
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
else
|
|
# reset all TEST_PASSED variables
|
|
STL_TEST_PASSED='y'
|
|
if [ -n "${LEDA_SUPPORT}" ]; then
|
|
LEDA_TEST_PASSED='y'
|
|
else
|
|
LEDA_TEST_PASSED=''
|
|
fi
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
GMP_TEST_PASSED='y'
|
|
else
|
|
GMP_TEST_PASSED=''
|
|
fi
|
|
if [ -n "${GCC_RTTI_PATCH_SUPPORT}" ]; then
|
|
RTTI_TEST_PASSED='y'
|
|
else
|
|
RTTI_TEST_PASSED=''
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# set COMPILER to ${COMPILER}_$1 (for $1 in {1..${_COMPILER_NUMBER}-1})
|
|
_set_compiler()
|
|
{
|
|
if [ $1 -ge ${_COMPILER_NUMBER} ]; then
|
|
${_printf} "\nERROR: argument greater than expexted\n"
|
|
${_printf} " ($1 >= ${_COMPILER_NUMBER}) in _set_compiler\n"
|
|
exit 1
|
|
fi
|
|
_tmp=`eval "echo '$'_COMPILER_$1"`
|
|
_tmp=`eval "echo ${_tmp}"`
|
|
COMPILER=${_tmp}
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# functions common to all menus
|
|
#
|
|
|
|
# print current setup status, $1 is menu-name
|
|
menu_header()
|
|
{
|
|
clear_screen
|
|
print_filled_line
|
|
print_headline "CGAL $CGAL_VERSION Installation ${1} Menu"
|
|
print_line "OS: ${SYST}"
|
|
print_line "Compiler: ${COMPILER:-<undefined>}"
|
|
if [ "${STL_STATUS}" = "x" ]; then
|
|
print_line "Builtin STL: not used."
|
|
elif [ "${STL_STATUS}" = "b" ]; then
|
|
print_line "Builtin STL: used."
|
|
fi
|
|
if [ "${STL_STATUS}" != 'b' -a -z "${STL_DIR}" ]; then
|
|
print_line "STL_DIR: please configure!!!"
|
|
else
|
|
print_line "STL_VERSION: ${CGAL_STL_VERSION}"
|
|
fi
|
|
if show_rtti_options; then
|
|
_set_tmp_to_not_or_not "${GCC_RTTI_PATCH_SUPPORT}"
|
|
print_line "RTTI-patched libg++: ${_tmp}used."
|
|
fi
|
|
_set_tmp_to_not_or_not "${LEDA_SUPPORT}"
|
|
print_line "LEDA: ${_tmp}supported."
|
|
_set_tmp_to_not_or_not "${GMP_SUPPORT}"
|
|
print_line "GMP: ${_tmp}supported."
|
|
print_empty_line
|
|
if [ -z "${SETUP_COMPLETE}" ]; then
|
|
print_line "The setup has ${_bold_on}not${_bold_off} been tested."
|
|
else
|
|
print_line "The setup has been tested ${_bold_on}ok${_bold_off}."
|
|
fi
|
|
print_empty_line
|
|
}
|
|
|
|
# bottom lines for all menus, $1 is name of next-top menu
|
|
menu_tailer()
|
|
{
|
|
print_empty_line
|
|
print_line "${_bold_on}<Q>${_bold_off} Back to ${1}"
|
|
print_empty_line
|
|
print_empty_line
|
|
print_empty_line
|
|
print_filled_line
|
|
go_up_lines 3
|
|
print_prompt "Your Choice: "
|
|
_read
|
|
}
|
|
|
|
# read a new value for variable $1
|
|
# and store old value in _tmp
|
|
change_value()
|
|
{
|
|
go_up_lines 1
|
|
print_prompt "New $1: "
|
|
_read
|
|
# store old value
|
|
_oldvalue=`eval "echo '$'$1"`
|
|
_oldvalue=\'`eval "echo $_oldvalue"`\'
|
|
eval "$1=\"${KEY}\""
|
|
}
|
|
|
|
# read a new directory value for variable $1
|
|
# check input for
|
|
# 1) no whitespaces
|
|
# 2) existence of the directory
|
|
# and run the corresponding check function (check_$1)
|
|
# return 0, if successful and return 1, if not
|
|
change_dir()
|
|
{
|
|
change_value $1
|
|
if [ "${_oldvalue}" = "`value_of $1`" ]; then
|
|
return 1
|
|
else
|
|
# make sure $1 is just one word:
|
|
go_down_lines 1
|
|
if [ -n "`${_printf} \"\`value_of $1\`\" | ${_awk} '{printf $2}'`" ]; then
|
|
print_filled_line
|
|
print_center_line "ERROR: String contains whitespaces."
|
|
else
|
|
print_filled_line
|
|
if [ ! -d "`value_of $1`" ]; then
|
|
print_center_line "ERROR: Directory does not exist."
|
|
else
|
|
eval "check_$1 print_line"
|
|
if [ $? != 0 ]; then
|
|
return 0
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# restore old value
|
|
eval $1="$_oldvalue"
|
|
wait_for_enter
|
|
return 1
|
|
}
|
|
|
|
# set _tmp to 'not', if $1 is an empty string
|
|
# otherwise set _tmp to ''
|
|
_set_tmp_to_not_or_not()
|
|
{
|
|
if [ -z "$1" ]; then
|
|
_tmp='not '
|
|
else
|
|
_tmp=''
|
|
fi
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# compiler_menu to setup compiler and STL options
|
|
#
|
|
|
|
compiler_choose_menu()
|
|
{
|
|
_OLD_COMPILER=${COMPILER}
|
|
while [ 0 ]; do
|
|
menu_header 'Choose Compiler'
|
|
i=1
|
|
while [ $i -lt ${_COMPILER_NUMBER} ]; do
|
|
_tmp=`eval "echo '$'_COMPILER_$i"`
|
|
_tmp=`eval "echo ${_tmp}"`
|
|
print_line "${_bold_on}<${i}>${_bold_off} ${_tmp}"
|
|
eval "${_EXPR} ${i} + 1"
|
|
i=${_result}
|
|
done
|
|
menu_tailer 'Compiler Menu'
|
|
|
|
case ${KEY} in
|
|
1|2|3|4|5|6|7|8|9)
|
|
if [ ${KEY} -lt ${_COMPILER_NUMBER} ]; then
|
|
_set_compiler ${KEY}
|
|
if [ "${_OLD_COMPILER}" != "${COMPILER}" ]; then
|
|
go_down_lines 3
|
|
flush_buffer
|
|
_choose_compiler
|
|
fi
|
|
return
|
|
fi
|
|
;;
|
|
q|Q|b|B)
|
|
return
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
compiler_menu()
|
|
{
|
|
while [ 0 ]; do
|
|
menu_header 'Compiler'
|
|
print_line "${_bold_on}<C>${_bold_off} Choose compiler"
|
|
if [ "${STL_STATUS}" != "e" ]; then
|
|
print_line "${_bold_on}<S>${_bold_off} Toggle use of builtin STL"
|
|
fi
|
|
if [ "${STL_STATUS}" != "b" ]; then
|
|
print_line "${_bold_on}<I>${_bold_off} STL include directory"
|
|
print_line " ${STL_DIR:-<undefined>}"
|
|
fi
|
|
print_line "${_bold_on}<F>${_bold_off} Set custom compiler flags"
|
|
print_multi_line "${CUSTOM_CXXFLAGS:-<none>}"
|
|
print_line "${_bold_on}<L>${_bold_off} Set custom linker flags"
|
|
print_multi_line "${CUSTOM_LDFLAGS:-<none>}"
|
|
if show_rtti_options; then
|
|
print_line "${_bold_on}<R>${_bold_off} Toggle RTTI-patch use"
|
|
if [ -n "${GCC_RTTI_PATCH_SUPPORT}" ]; then
|
|
print_line "${_bold_on}<P>${_bold_off} g++ RTTI-patch directory"
|
|
print_line " ${GCC_RTTI_PATCH_DIR:-<undefined>}"
|
|
fi
|
|
fi
|
|
print_line "${_bold_on}<T>${_bold_off} Test (and save) setup"
|
|
menu_tailer 'Main Menu'
|
|
|
|
case ${KEY} in
|
|
c|C)
|
|
compiler_choose_menu
|
|
;;
|
|
s|S)
|
|
if [ "${STL_STATUS}" = "x" ]; then
|
|
STL_STATUS="b"
|
|
STL_TEST_PASSED='y'
|
|
elif [ "${STL_STATUS}" = "b" ]; then
|
|
STL_STATUS="x"
|
|
STL_TEST_PASSED=''
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
;;
|
|
i|I)
|
|
if [ "${STL_STATUS}" != "b" ]; then
|
|
if change_dir STL_DIR; then
|
|
go_down_lines 1
|
|
flush_buffer
|
|
test_stl 'v'
|
|
fi
|
|
fi
|
|
;;
|
|
f|F)
|
|
change_value CUSTOM_CXXFLAGS
|
|
reset_all_test_variables
|
|
SETUP_COMPLETE=''
|
|
;;
|
|
l|L)
|
|
change_value CUSTOM_LDFLAGS
|
|
reset_all_test_variables
|
|
SETUP_COMPLETE=''
|
|
;;
|
|
r|R)
|
|
if show_rtti_options; then
|
|
if [ -z "${GCC_RTTI_PATCH_SUPPORT}" ]; then
|
|
GCC_RTTI_PATCH_SUPPORT='-rtti'
|
|
else
|
|
GCC_RTTI_PATCH_SUPPORT=''
|
|
fi
|
|
# need another LEDA lib
|
|
LEDA_TEST_PASSED=''
|
|
# GMP might be in another CGAL_LIB_DIR
|
|
GMP_TEST_PASSED=''
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
;;
|
|
p|P)
|
|
if show_rtti_options; then
|
|
if [ -n "${GCC_RTTI_PATCH_SUPPORT}" ]; then
|
|
if change_dir GCC_RTTI_PATCH_DIR; then
|
|
LEDA_TEST_PASSED=''
|
|
SETUP_COMPLETE=''
|
|
go_down_lines 1
|
|
flush_buffer
|
|
test_gcc_rtti_patch 'v'
|
|
fi
|
|
fi
|
|
fi
|
|
;;
|
|
t|T)
|
|
go_down_lines 3
|
|
flush_buffer
|
|
test_setup
|
|
;;
|
|
q|Q|b|B)
|
|
return
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# leda_menu to setup LEDA
|
|
#
|
|
|
|
leda_menu()
|
|
{
|
|
while [ 0 ]; do
|
|
menu_header 'LEDA'
|
|
print_line "${_bold_on}<E>${_bold_off} Toggle LEDA support"
|
|
if [ -n "${LEDA_SUPPORT}" ]; then
|
|
print_line "${_bold_on}<I>${_bold_off} LEDA include directory"
|
|
if [ -n "${NEED_EXTRA_LEDA_IDIR}" ]; then
|
|
print_line " ${LEDA_INCL_DIR:-<undefined>}"
|
|
if [ "${NEED_EXTRA_LEDA_IDIR}" = "x" ]; then
|
|
print_line \
|
|
"${_bold_on}<J>${_bold_off} Use LEDA headers from system include."
|
|
fi
|
|
else
|
|
print_line " <system include directory>"
|
|
fi
|
|
print_line "${_bold_on}<L>${_bold_off} LEDA lib directory"
|
|
if [ -n "${NEED_EXTRA_LEDA_LDIR}" ]; then
|
|
print_line " ${LEDA_LIB_DIR:-<undefined>}"
|
|
if [ "${NEED_EXTRA_LEDA_LDIR}" = "x" ]; then
|
|
print_line \
|
|
"${_bold_on}<M>${_bold_off} Use LEDA libs from system libdir."
|
|
fi
|
|
else
|
|
print_line " <system lib directory>"
|
|
fi
|
|
fi
|
|
print_line "${_bold_on}<T>${_bold_off} Test (and save) setup"
|
|
menu_tailer 'Main Menu'
|
|
case ${KEY} in
|
|
e|E)
|
|
if [ -z "${LEDA_SUPPORT}" ]; then
|
|
LEDA_SUPPORT='_LEDA'
|
|
SETUP_COMPLETE=''
|
|
# test for LEDA sysincl/-lib, if this was not done before
|
|
if [ "${NEED_EXTRA_LEDA_IDIR}" = 'n' -o \
|
|
"${NEED_EXTRA_LEDA_LDIR}" = 'n' ]; then
|
|
go_down_lines 3
|
|
flush_buffer
|
|
test_for_leda_incl_in_sys_incl "${INSTALL_VERBOSE}"
|
|
test_for_leda_lib_in_sys_lib "${INSTALL_VERBOSE}"
|
|
fi
|
|
else
|
|
LEDA_SUPPORT=''
|
|
fi
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
if [ "${GMP_INSTALLATION}" = 'c' -o \
|
|
"${GMP_INSTALLATION}" = 'z' ]; then
|
|
# GMP might be in another CGAL_LIB_DIR
|
|
GMP_TEST_PASSED=''
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
fi
|
|
;;
|
|
i|I)
|
|
if [ -n "${LEDA_SUPPORT}" ]; then
|
|
if [ -z "${NEED_EXTRA_LEDA_IDIR}" ]; then
|
|
NEED_EXTRA_LEDA_IDIR='x'
|
|
fi
|
|
if change_dir LEDA_INCL_DIR; then
|
|
if [ -z "${NEED_EXTRA_LEDA_IDIR}" ]; then
|
|
NEED_EXTRA_LEDA_IDIR='x'
|
|
fi
|
|
LEDA_TEST_PASSED=''
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
fi
|
|
;;
|
|
j|J)
|
|
if [ "${NEED_EXTRA_LEDA_IDIR}" = "x" ]; then
|
|
NEED_EXTRA_LEDA_IDIR=''
|
|
LEDA_TEST_PASSED=''
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
;;
|
|
l|L)
|
|
if [ -n "${LEDA_SUPPORT}" ]; then
|
|
if change_dir LEDA_LIB_DIR; then
|
|
if [ -z "${NEED_EXTRA_LEDA_LDIR}" ]; then
|
|
NEED_EXTRA_LEDA_LDIR='x'
|
|
fi
|
|
LEDA_TEST_PASSED=''
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
fi
|
|
;;
|
|
m|M)
|
|
if [ "${NEED_EXTRA_LEDA_LDIR}" = "x" ]; then
|
|
NEED_EXTRA_LEDA_LDIR=''
|
|
LEDA_TEST_PASSED=''
|
|
SETUP_COMPLETE=''
|
|
fi
|
|
;;
|
|
t|T)
|
|
go_down_lines 3
|
|
flush_buffer
|
|
test_setup;;
|
|
q|Q|b|B)
|
|
return;;
|
|
*);;
|
|
esac
|
|
done
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# gmp_menu to setup GMP
|
|
#
|
|
|
|
gmp_menu()
|
|
{
|
|
while [ 0 ]; do
|
|
menu_header 'GMP'
|
|
print_line "${_bold_on}<C>${_bold_off} Install GMP in CGAL tree"
|
|
print_line "${_bold_on}<G>${_bold_off} Toggle GMP support"
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
print_line "${_bold_on}<I>${_bold_off} GMP include directory"
|
|
case ${GMP_INSTALLATION} in
|
|
c) _tmp='<CGAL include directory>';;
|
|
s) _tmp='<system include directory>';;
|
|
*) _tmp="${GMP_INCL_DIR}";;
|
|
esac
|
|
print_line " ${_tmp:-<undefined>}"
|
|
print_line "${_bold_on}<L>${_bold_off} GMP lib directory"
|
|
case ${GMP_INSTALLATION} in
|
|
c) _tmp='<CGAL lib directory>';;
|
|
s) _tmp='<system lib directory>';;
|
|
*) _tmp="${GMP_LIB_DIR}";;
|
|
esac
|
|
print_line " ${_tmp:-<undefined>}"
|
|
if [ "${GMP_INSTALLATION}" = 'z' ]; then
|
|
print_line \
|
|
"${_bold_on}<C>${_bold_off} Use GMP installation in CGAL tree"
|
|
fi
|
|
if [ "${GMP_INSTALLATION}" = 'x' ]; then
|
|
print_line \
|
|
"${_bold_on}<S>${_bold_off} Use GMP installation in system dirs"
|
|
fi
|
|
fi
|
|
print_line "${_bold_on}<T>${_bold_off} Test (and save) setup"
|
|
menu_tailer 'Main Menu'
|
|
|
|
case $KEY in
|
|
c|C)
|
|
install_gmp
|
|
;;
|
|
g|G)
|
|
if [ -z "${GMP_SUPPORT}" ]; then
|
|
SETUP_COMPLETE=''
|
|
GMP_SUPPORT='_GMP'
|
|
else
|
|
GMP_SUPPORT=''
|
|
fi
|
|
;;
|
|
i|I)
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
if change_dir GMP_INCL_DIR; then
|
|
GMP_TEST_PASSED=''
|
|
SETUP_COMPLETE=''
|
|
case ${GMP_INSTALLATION} in
|
|
c|z) GMP_INSTALLATION='z';;
|
|
s|x) GMP_INSTALLATION='x';;
|
|
*) GMP_INSTALLATION='e';;
|
|
esac
|
|
fi
|
|
fi
|
|
;;
|
|
l|L)
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
if change_dir GMP_LIB_DIR; then
|
|
GMP_TEST_PASSED=''
|
|
SETUP_COMPLETE=''
|
|
case ${GMP_INSTALLATION} in
|
|
c|z) GMP_INSTALLATION='z';;
|
|
s|x) GMP_INSTALLATION='x';;
|
|
*) GMP_INSTALLATION='e';;
|
|
esac
|
|
fi
|
|
fi
|
|
;;
|
|
c|C)
|
|
if [ -n "${GMP_SUPPORT}" -a \
|
|
"${GMP_INSTALLATION}" = 'z' ]; then
|
|
GMP_TEST_PASSED='y'
|
|
GMP_INSTALLATION='c'
|
|
fi
|
|
;;
|
|
t|T)
|
|
go_down_lines 3
|
|
flush_buffer
|
|
test_setup
|
|
;;
|
|
s|S)
|
|
if [ "${GMP_SUPPORT}" -a \
|
|
"${GMP_INSTALLATION}" = 'x' ]; then
|
|
GMP_TEST_PASSED='y'
|
|
GMP_INSTALLATION='s'
|
|
fi
|
|
;;
|
|
q|Q|b|B)
|
|
return;;
|
|
*);;
|
|
esac
|
|
done
|
|
}
|
|
|
|
# ---------------------------------------------------------------------
|
|
# GNU GMP installation
|
|
#
|
|
|
|
# $1 is the command to execute and $2 its description
|
|
# if the command fails, exit with an error message
|
|
_do_command()
|
|
{
|
|
${_printf} "${_LEFTSPACE}$2 ..."
|
|
if $1 >${TMP_LOGFILE} 2>&1; then
|
|
log_print "\"$2\" succeeded."
|
|
${_printf} " done.\n"
|
|
$_rm -f ${TMP_LOGFILE}
|
|
else
|
|
log_print "ERROR: \"$2\" failed."
|
|
$_cat ${TMP_LOGFILE} | ${PAGER:-$_cat}
|
|
$_rm -f ${TMP_LOGFILE}
|
|
echo
|
|
echo "FATAL ERROR: \"$2\" failed."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# $1 is the command to execute and $2 its description
|
|
# if the command fails, show the log and return 1,
|
|
# otherwise return 0
|
|
_do_command_may_fail()
|
|
{
|
|
${_printf} "${_LEFTSPACE}$2 ..."
|
|
if $1 >${TMP_LOGFILE} 2>&1; then
|
|
log_print "\"$2\" succeeded."
|
|
${_printf} " done.\n"
|
|
$_rm -f ${TMP_LOGFILE}
|
|
return 0
|
|
else
|
|
log_print "ERROR: \"$2\" failed."
|
|
${_printf} "\n${_LEFTSPACE}\"$2\" failed.\n"
|
|
${_printf} "${_LEFTSPACE}You will be shown a log now ...\n"
|
|
print_filled_line
|
|
wait_for_enter
|
|
$_cat ${TMP_LOGFILE} | ${PAGER:-$_cat}
|
|
$_rm -f ${TMP_LOGFILE}
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# used by install_gmp
|
|
# ($1 is a suffix to CGAL_OS_COMPILER)
|
|
link_gmp()
|
|
{
|
|
if [ -d "${CGAL_LIB_DIR}/${CGAL_OS_COMPILER}$1" ]; then
|
|
if ${_ln} -s ${CGAL_LIB_DIR}/`full_ostype`/libgmp.* \
|
|
${CGAL_LIB_DIR}/${CGAL_OS_COMPILER}$1 >/dev/null 2>&1
|
|
then
|
|
log_print "remark: linked libgmp to ${CGAL_OS_COMPILER}$1."
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# install GNU GMP in the CGAL directory tree
|
|
install_gmp()
|
|
{
|
|
make_lib_dir
|
|
if [ -r ${CGAL_LIB_DIR}/${CGAL_OS_COMPILER}/libgmp.a -o \
|
|
-r ${CGAL_LIB_DIR}/${CGAL_OS_COMPILER}/libgmp.so ]; then
|
|
go_down_lines 2
|
|
print_line "There already exists a GMP installation"
|
|
print_line "for this os/compiler in the CGAL tree."
|
|
print_empty_line
|
|
print_empty_line
|
|
print_filled_line
|
|
go_up_lines 2
|
|
print_prompt "Do you want to proceed anyway (y/N)? "
|
|
_read
|
|
if [ "${KEY}" != 'y' ]; then
|
|
return
|
|
fi
|
|
fi
|
|
|
|
# remove all os/compiler specific stuff
|
|
SAVE_LEDA="${LEDA_SUPPORT}"
|
|
SAVE_GCC_RTTI="${GCC_RTTI_PATCH_SUPPORT}"
|
|
LEDA_SUPPORT=''
|
|
GCC_RTTI_PATCH_SUPPORT=''
|
|
make_lib_dir
|
|
|
|
clear_screen
|
|
print_filled_line
|
|
print_empty_line
|
|
print_headline "Installing GNU GMP in the CGAL tree"
|
|
print_filled_line
|
|
write_buffer "\n"
|
|
flush_buffer
|
|
${_printf} "${_LEFTSPACE}OS:\t\t${SYST}\n"
|
|
${_printf} "${_LEFTSPACE}COMPILER:\t${COMPILER}\n\n"
|
|
|
|
if [ ! -d ${GMP_VERSION} ]; then
|
|
# unzip
|
|
gmpfile=${CGAL_AUX_DIR}/${GMP_VERSION}.tar.gz
|
|
_check_file_exists ${gmpfile}
|
|
_check_write ${CGAL_AUX_DIR}
|
|
_check_for_sysutil gunzip y
|
|
_do_command "$_gunzip ${gmpfile}" "Unzip"
|
|
|
|
# untar
|
|
gmpfile=${CGAL_AUX_DIR}/${GMP_VERSION}.tar
|
|
_check_file_exists ${gmpfile}
|
|
_check_for_sysutil tar y
|
|
_do_command "$_tar xf ${gmpfile}" "Untar"
|
|
|
|
# re-zip
|
|
_check_for_sysutil gzip y
|
|
_do_command "$_gzip -9 ${gmpfile}" "Re-zip"
|
|
fi
|
|
|
|
cd ${GMP_VERSION}
|
|
case $SYST in
|
|
*IRIX6*)
|
|
# gmp-2.0.2 build fails on irix6
|
|
_host=mips-sgi-irix5;;
|
|
*)
|
|
_host='';;
|
|
esac
|
|
if _do_command_may_fail "./configure ${_host}" Configuring; then
|
|
if _do_command_may_fail "make CC=`c_compiler_bin`" Building; then
|
|
${_printf} "${_LEFTSPACE}Installing ..."
|
|
_check_write ${CGAL_INCL_DIR}
|
|
$_cp gmp.h ${CGAL_INCL_DIR}
|
|
$_mv libgmp.* ${CGAL_LIB_DIR}/`full_ostype`
|
|
${_printf} " done.\n"
|
|
_do_command "make clean" "Cleaning"
|
|
GMP_INSTALLATION='c'
|
|
link_gmp '_LEDA'
|
|
link_gmp '-rtti'
|
|
link_gmp '-rtti_LEDA'
|
|
fi
|
|
fi
|
|
cd ..
|
|
write_buffer "\n"
|
|
print_filled_line
|
|
wait_for_enter
|
|
|
|
# restore os/compiler stuff
|
|
LEDA_SUPPORT="${SAVE_LEDA}"
|
|
GCC_RTTI_PATCH_SUPPORT="${SAVE_GCC_RTTI}"
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# lib menu
|
|
#
|
|
|
|
#################### (begin) from old cgal_install ############################
|
|
|
|
# ---------------------------------------------------------------------
|
|
# create include makefile
|
|
# these makefiles are placed in ${CGAL_MAKE_DIR}
|
|
# and define compiler/os specific flags
|
|
# they should be included in any CGAL makefile
|
|
# when compiling on this compiler/os
|
|
# ---------------------------------------------------------------------
|
|
# (this is taken from scripts/create_include_makefiles)
|
|
# ---------------------------------------------------------------------
|
|
|
|
header()
|
|
{
|
|
echo "#---------------------------------------------------------------------#"
|
|
echo "# $1"
|
|
echo "#---------------------------------------------------------------------#"
|
|
}
|
|
|
|
write_compiler_flags()
|
|
{
|
|
header "compiler flags" >> $FILE
|
|
echo "# For more information about the compiler flags see the installation guide." >> $FILE
|
|
echo >> $FILE
|
|
|
|
echo "CGAL_STL_VERSION = CGAL_STL_UNKNOWN" >> $FILE
|
|
echo "# *** Fill in your STL include directory ***" >> $FILE
|
|
echo "# (including the -I directive)" >> $FILE
|
|
echo "# (e.g. -I/usr/local/STL)" >> $FILE
|
|
echo "CGAL_STL_INCLUDE_DIRECTIVE =" >> $FILE
|
|
if [ ! -z "$USE_LEDA" -a -n "${NEED_EXTRA_LEDA_IDIR}" ] ; then
|
|
echo "# *** Fill in your LEDA include directory ***" >> $FILE
|
|
echo "LEDA_INCL_DIR =" >> $FILE
|
|
fi
|
|
echo >> $FILE
|
|
|
|
echo "# *** Fill in any additional compiler flags you need ***" >> $FILE
|
|
echo "CUSTOM_CXXFLAGS = ${CUSTOM_CXXFLAGS}" >> $FILE
|
|
echo >> $FILE
|
|
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
if [ "${GMP_INSTALLATION}" = 'x' -o \
|
|
"${GMP_INSTALLATION}" = 'z' -o \
|
|
"${GMP_INSTALLATION}" = 'e' ]; then
|
|
echo "# *** Fill in your GMP include directory ***" >> $FILE
|
|
echo "GMP_INCL_DIR = \\" >> $FILE
|
|
echo " ${GMP_INCL_DIR}" >> $FILE
|
|
echo >> $FILE
|
|
fi
|
|
fi
|
|
|
|
echo "CGAL_CXXFLAGS = \\" >> $FILE
|
|
echo " \$(CUSTOM_CXXFLAGS) \\" >> $FILE
|
|
echo " -D${CGAL_COMPILER} \\" >> $FILE
|
|
echo " -D\$(CGAL_STL_VERSION) \\" >> $FILE
|
|
if [ ! -z "$USE_LEDA" ] ; then
|
|
echo " -DCGAL_USE_LEDA_BOOL \\" >> $FILE
|
|
fi
|
|
if [ ! -z "$USE_RTTI_PATCH" ] ; then
|
|
echo " -frtti \\" >> $FILE
|
|
echo " -DRTTI_PATCH \\" >> $FILE
|
|
fi
|
|
if [ ! -z "$USE_STDEXCEPT" ] ; then
|
|
echo " -D__STDEXCEPT__ \\" >> $FILE
|
|
fi
|
|
if [ ! -z "$ADDITIONAL_CXXFLAGS" ] ; then
|
|
echo " $ADDITIONAL_CXXFLAGS \\" >> $FILE
|
|
fi
|
|
echo " \$(CGAL_STL_INCLUDE_DIRECTIVE) \\" >> $FILE
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
if [ "${GMP_INSTALLATION}" = 'x' -o \
|
|
"${GMP_INSTALLATION}" = 'z' -o \
|
|
"${GMP_INSTALLATION}" = 'e' ]; then
|
|
echo " -I\$(GMP_INCL_DIR) \\" >> $FILE
|
|
fi
|
|
fi
|
|
if [ ! -z "$USE_LEDA" -a -n "${NEED_EXTRA_LEDA_IDIR}" ] ; then
|
|
echo " -I\$(CGAL_INCL_DIR) \\" >> $FILE
|
|
echo " -I\$(LEDA_INCL_DIR)" >> $FILE
|
|
else
|
|
echo " -I\$(CGAL_INCL_DIR)" >> $FILE
|
|
fi
|
|
echo >> $FILE
|
|
}
|
|
|
|
write_linker_flags()
|
|
{
|
|
header "linker flags" >> $FILE
|
|
echo >> $FILE
|
|
|
|
if [ ! -z "$USE_LEDA" -a -n "${NEED_EXTRA_LEDA_LDIR}" ] ; then
|
|
echo "# *** Fill in your LEDA_lib_directory ***" >> $FILE
|
|
echo "LEDA_LIB_DIR =" >> $FILE
|
|
echo >> $FILE
|
|
fi
|
|
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
if [ "${GMP_INSTALLATION}" = 'x' -o \
|
|
"${GMP_INSTALLATION}" = 'z' -o \
|
|
"${GMP_INSTALLATION}" = 'e' ]; then
|
|
echo "# *** Fill in your GMP lib directory ***" >> $FILE
|
|
echo "GMP_LIB_DIR = \\" >> $FILE
|
|
echo " ${GMP_LIB_DIR}" >> $FILE
|
|
echo >> $FILE
|
|
fi
|
|
fi
|
|
|
|
if [ ! -z "$USE_RTTI_PATCH" ] ; then
|
|
echo "# *** Fill in your g++_rttipatch_directory ***" >> $FILE
|
|
echo "GCC_RTTI_PATCH_DIR =" >> $FILE
|
|
echo >> $FILE
|
|
fi
|
|
|
|
echo "# *** Fill in any additional linker flags you need ***" >> $FILE
|
|
echo "CUSTOM_LDFLAGS = ${CUSTOM_LDFLAGS}" >> $FILE
|
|
echo >> $FILE
|
|
|
|
LIB_PATH="-L\$(CGAL_LIB_DIR)/\$(CGAL_OS_COMPILER)"
|
|
RUNTIME_LIB_PATH="\$(CGAL_LIB_DIR)/\$(CGAL_OS_COMPILER)"
|
|
LIBS="-lCGAL"
|
|
WLIBS="-lCGAL"
|
|
if [ ! -z "$USE_LEDA" ] ; then
|
|
if [ -n "${NEED_EXTRA_LEDA_LDIR}" ]; then
|
|
LIB_PATH="${LIB_PATH} -L\$(LEDA_LIB_DIR)"
|
|
RUNTIME_LIB_PATH="${RUNTIME_LIB_PATH}:\$(LEDA_LIB_DIR)"
|
|
fi
|
|
LIBS="${LIBS} -lP -lG -lL"
|
|
WLIBS="${WLIBS} -lW -lP -lG -lL -lX11"
|
|
fi
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
if [ "${GMP_INSTALLATION}" = 'x' -o \
|
|
"${GMP_INSTALLATION}" = 'z' -o \
|
|
"${GMP_INSTALLATION}" = 'e' ]; then
|
|
LIB_PATH="${LIB_PATH} -L\$(GMP_LIB_DIR)"
|
|
RUNTIME_LIB_PATH="${RUNTIME_LIB_PATH}:\$(GMP_LIB_DIR)"
|
|
fi
|
|
LIBS="${LIBS} -lgmp"
|
|
WLIBS="${WLIBS} -lgmp"
|
|
fi
|
|
LIBS="${LIBS} -lm"
|
|
WLIBS="${WLIBS} -lm"
|
|
if [ ! -z "$USE_RTTI_PATCH" ] ; then
|
|
LIB_PATH="${LIB_PATH} -L\$(GCC_RTTI_PATCH_DIR)"
|
|
RUNTIME_LIB_PATH="${RUNTIME_LIB_PATH}:\$(GCC_RTTI_PATCH_DIR)"
|
|
LIBS="${LIBS} \\\\\n -nodefaultlibs -lstdc++ -liberty -lg++ -lgcc -lc"
|
|
WLIBS="${WLIBS} \\\\\n -nodefaultlibs -lstdc++ -liberty -lg++ -lgcc -lc"
|
|
fi
|
|
|
|
echo "CGAL_LDFLAGS = \\" >> $FILE
|
|
echo " \$(CUSTOM_LDFLAGS) \\" >> $FILE
|
|
echo " $LIB_PATH \\" >> $FILE
|
|
if [ ! -z "$RUNTIME_FLAG" ] ; then
|
|
echo " ${RUNTIME_FLAG}${RUNTIME_LIB_PATH} \\" >> $FILE
|
|
fi
|
|
echo " ${LIBS}" >> $FILE
|
|
echo >> $FILE
|
|
|
|
if [ ! -z "$USE_LEDA" ] ; then
|
|
LIB_PATH="${LIB_PATH} -L$WINDOW_DIR"
|
|
RUNTIME_LIB_PATH="${RUNTIME_LIB_PATH}:$WINDOW_DIR"
|
|
echo "CGAL_WINDOW_LDFLAGS = \\" >> $FILE
|
|
echo " ${CUSTOM_LDFLAGS} \\" >> $FILE
|
|
echo " $LIB_PATH \\" >> $FILE
|
|
if [ ! -z "$RUNTIME_FLAG" ] ; then
|
|
echo " ${RUNTIME_FLAG}${RUNTIME_LIB_PATH} \\" >> $FILE
|
|
fi
|
|
echo " ${WLIBS}" >> $FILE
|
|
echo >> $FILE
|
|
fi
|
|
}
|
|
|
|
create_include_makefile()
|
|
{
|
|
FILE=$CGAL_MAKEFILE
|
|
|
|
if [ -z "${LEDA_SUPPORT}" ] ; then
|
|
USE_LEDA=
|
|
else
|
|
USE_LEDA=Y
|
|
fi
|
|
|
|
if [ -z "$GCC_RTTI_PATCH_SUPPORT" ] ; then
|
|
USE_RTTI_PATCH=
|
|
if show_rtti_options; then
|
|
USE_STDEXCEPT=Y
|
|
else
|
|
USE_STDEXCEPT=
|
|
fi
|
|
else
|
|
USE_RTTI_PATCH=Y
|
|
USE_STDEXCEPT=
|
|
fi
|
|
|
|
echo "# This file contains CGAL makefile settings for the following platform:" >> $FILE
|
|
echo "# operating system: $OPERATING_SYSTEM" >> $FILE
|
|
if [ ! -z "$USE_RTTI_PATCH" ] ; then
|
|
echo "# compiler: ${COMPILER:-<unknown>} (with rtti patch)" >> $FILE
|
|
else
|
|
echo "# compiler: ${COMPILER:-<unknown>}" >> $FILE
|
|
fi
|
|
if [ ! -z "$USE_LEDA" ] ; then
|
|
echo "# with LEDA" >> $FILE
|
|
else
|
|
echo "# without LEDA" >> $FILE
|
|
fi
|
|
echo >> $FILE
|
|
|
|
header "include directory settings" >> $FILE
|
|
echo >> $FILE
|
|
echo "CGAL_DIRECTORIES =" >> $FILE
|
|
echo "include \$(CGAL_DIRECTORIES)" >> $FILE
|
|
echo >> $FILE
|
|
|
|
header "os/compiler description" >> $FILE
|
|
echo >> $FILE
|
|
echo "CGAL_OS_COMPILER = ${CGAL_OS_COMPILER}" >> $FILE
|
|
echo >> $FILE
|
|
|
|
header "compiler" >> $FILE
|
|
echo >> $FILE
|
|
echo "CGAL_CXX = $CGAL_CXX" >> $FILE
|
|
echo >> $FILE
|
|
|
|
write_compiler_flags
|
|
write_linker_flags
|
|
|
|
header "commands and flags for creating libraries" >> $FILE
|
|
echo >> $FILE
|
|
echo "CGAL_LIB = libCGAL.a" >> $FILE
|
|
echo "CGAL_LIB_CXXFLAGS = \$(CGAL_CXXFLAGS) $CGAL_LIB_CXXFLAGS" >> $FILE
|
|
echo "CGAL_LIB_LDFLAGS = $CGAL_LIB_LDFLAGS" >> $FILE
|
|
echo "CGAL_LIB_CREATE = $CGAL_LIB_CREATE" >> $FILE
|
|
echo >> $FILE
|
|
echo "CGAL_SHARED_LIB = libCGAL.so" >> $FILE
|
|
echo "CGAL_SHARED_LIB_CXXFLAGS = \$(CGAL_CXXFLAGS) $CGAL_SHARED_LIB_CXXFLAGS" >> $FILE
|
|
if [ -z "$USE_LEDA" -o -z "${NEED_EXTRA_LEDA_LDIR}" ] ; then
|
|
echo "CGAL_SHARED_LIB_LDFLAGS = $CGAL_SHARED_LIB_LDFLAGS" >> $FILE
|
|
else
|
|
if [ ! -z "$RUNTIME_FLAG" ] ; then
|
|
echo "CGAL_SHARED_LIB_LDFLAGS = -L\$(LEDA_LIB_DIR) ${RUNTIME_FLAG}\$(LEDA_LIB_DIR) -lL $CGAL_SHARED_LIB_LDFLAGS" >> $FILE
|
|
else
|
|
echo "CGAL_SHARED_LIB_LDFLAGS = -L\$(LEDA_LIB_DIR) -lL $CGAL_SHARED_LIB_LDFLAGS" >> $FILE
|
|
fi
|
|
fi
|
|
if [ -z "$GCC_RTTI_PATCH_SUPPORT" ] ; then
|
|
echo "CGAL_SHARED_LIB_CREATE = ${CGAL_SHARED_LIB_CREATE} -o" >> $FILE
|
|
else
|
|
echo "CGAL_SHARED_LIB_CREATE = ${CGAL_SHARED_LIB_CREATE} -L\$(GCC_RTTI_PATCH_DIR) -o" >> $FILE
|
|
fi
|
|
echo >> $FILE
|
|
}
|
|
|
|
# --------------------------------------------------------------------
|
|
# Now the new function to create the include makefile
|
|
# for compiler/os combination CGAL_OS_COMPILER
|
|
set_compiler_flags()
|
|
{
|
|
# first, set some compiler/os specific variables
|
|
CGAL_CXX="`compiler_bin`"
|
|
case ${CGAL_OS_COMPILER} in
|
|
*IRIX*5.*CC*)
|
|
#### settings for sgi mipspro compiler on irix5
|
|
OPERATING_SYSTEM="IRIX 5.3"
|
|
CGAL_COMPILER="CGAL_SGI_MIPSPRO_CC_40"
|
|
ADDITIONAL_CXXFLAGS=
|
|
CGAL_LIB_CXXFLAGS=
|
|
CGAL_LIB_LDFLAGS=
|
|
CGAL_LIB_CREATE="ar cr"
|
|
CGAL_SHARED_LIB_CXXFLAGS=
|
|
CGAL_SHARED_LIB_LDFLAGS="-lm"
|
|
CGAL_SHARED_LIB_CREATE="\${CGAL_CXX} -shared"
|
|
WINDOW_DIR="/usr/lib/X11"
|
|
RUNTIME_FLAG="-rpath "
|
|
;;
|
|
*IRIX*6.*CC*)
|
|
#### settings for sgi mipspro compiler on irix6
|
|
OPERATING_SYSTEM="IRIX 6.2"
|
|
CGAL_COMPILER="CGAL_SGI_MIPSPRO_CC_71"
|
|
ADDITIONAL_CXXFLAGS=
|
|
CGAL_LIB_CXXFLAGS=
|
|
CGAL_LIB_LDFLAGS=
|
|
CGAL_LIB_CREATE="ar cr"
|
|
CGAL_SHARED_LIB_CXXFLAGS=
|
|
CGAL_SHARED_LIB_LDFLAGS="-lm"
|
|
CGAL_SHARED_LIB_CREATE="\${CGAL_CXX} -shared"
|
|
WINDOW_DIR="/usr/lib/X11"
|
|
RUNTIME_FLAG="-rpath "
|
|
;;
|
|
*IRIX*g++*)
|
|
#### settings for GNU compiler on irix
|
|
OPERATING_SYSTEM="IRIX ?.?"
|
|
CGAL_COMPILER="CGAL_GNU_GCC_272"
|
|
ADDITIONAL_CXXFLAGS=
|
|
CGAL_LIB_CXXFLAGS=
|
|
CGAL_LIB_LDFLAGS=
|
|
CGAL_LIB_CREATE="ar cr"
|
|
CGAL_SHARED_LIB_CXXFLAGS="-fpic"
|
|
CGAL_SHARED_LIB_LDFLAGS="-lm"
|
|
CGAL_SHARED_LIB_CREATE="\${CGAL_CXX} -shared"
|
|
WINDOW_DIR="/usr/lib/X11"
|
|
RUNTIME_FLAG=
|
|
;;
|
|
*SunOS*5.*CC*)
|
|
#### settings for sunpro compiler on solaris
|
|
OPERATING_SYSTEM="Sun Solaris 2.5"
|
|
CGAL_COMPILER="CGAL_SUNPRO_CC_41"
|
|
ADDITIONAL_CXXFLAGS="-pto"
|
|
CGAL_LIB_CXXFLAGS=
|
|
CGAL_LIB_LDFLAGS=
|
|
CGAL_LIB_CREATE="\${CGAL_CXX} -xar -o"
|
|
CGAL_SHARED_LIB_CXXFLAGS="-pic"
|
|
CGAL_SHARED_LIB_LDFLAGS=""
|
|
CGAL_SHARED_LIB_CREATE="\${CGAL_CXX} -G"
|
|
WINDOW_DIR="/usr/openwin/lib"
|
|
RUNTIME_FLAG="-R "
|
|
;;
|
|
*SunOS*5.*g++*)
|
|
#### settings for GNU compiler on solaris
|
|
OPERATING_SYSTEM="Sun Solaris 2.5"
|
|
CGAL_COMPILER="CGAL_GNU_GCC_272"
|
|
ADDITIONAL_CXXFLAGS=
|
|
CGAL_LIB_CXXFLAGS=
|
|
CGAL_LIB_LDFLAGS=
|
|
CGAL_LIB_CREATE="ar cr"
|
|
CGAL_SHARED_LIB_CXXFLAGS="-fpic"
|
|
CGAL_SHARED_LIB_LDFLAGS=""
|
|
CGAL_SHARED_LIB_CREATE="\${CGAL_CXX} -G"
|
|
WINDOW_DIR="/usr/openwin/lib"
|
|
RUNTIME_FLAG="-R "
|
|
;;
|
|
*Linux*g++*)
|
|
#### settings for GNU compiler on linux
|
|
OPERATING_SYSTEM="Linux"
|
|
CGAL_COMPILER="CGAL_GNU_GCC_272"
|
|
ADDITIONAL_CXXFLAGS=
|
|
CGAL_LIB_CXXFLAGS=
|
|
CGAL_LIB_LDFLAGS=
|
|
CGAL_LIB_CREATE="ar cr"
|
|
CGAL_SHARED_LIB_CXXFLAGS="-fpic"
|
|
CGAL_SHARED_LIB_LDFLAGS=""
|
|
CGAL_SHARED_LIB_CREATE="\${CGAL_CXX} -Xlinker -shared"
|
|
WINDOW_DIR="/usr/lib/X11"
|
|
RUNTIME_FLAG=
|
|
;;
|
|
*)
|
|
#### settings for unknown compiler
|
|
OPERATING_SYSTEM="${SYST}"
|
|
CGAL_COMPILER="CGAL_UNKNOWN_COMPILER"
|
|
ADDITIONAL_CXXFLAGS=
|
|
CGAL_LIB_CXXFLAGS=
|
|
CGAL_LIB_LDFLAGS=
|
|
CGAL_LIB_CREATE="ar cr"
|
|
CGAL_SHARED_LIB_CXXFLAGS="-fpic"
|
|
CGAL_SHARED_LIB_LDFLAGS=""
|
|
CGAL_SHARED_LIB_CREATE="${COMPILER} -G"
|
|
WINDOW_DIR="/usr/lib/X11"
|
|
RUNTIME_FLAG=
|
|
;;
|
|
esac
|
|
}
|
|
|
|
|
|
#---------------------------------------------------------------------------#
|
|
# replace_line <file> <string> <replacement>
|
|
# replaces all the lines in <file> that start with <string> with <replacement>
|
|
#---------------------------------------------------------------------------#
|
|
|
|
replace_line()
|
|
{
|
|
if [ ! -f $1 ] ; then
|
|
echo "Error: could not open file $1 in replace_line()"
|
|
return
|
|
fi
|
|
if eval '$_sed -e "/^$2/c\\
|
|
$3" $1 > $1.TEMP' ; then
|
|
$_mv $1.TEMP $1
|
|
else
|
|
echo "Error sed replacement failed in replace_line()"
|
|
fi
|
|
}
|
|
|
|
# log via $1
|
|
generatemakefiles()
|
|
{
|
|
_check_dir_exists ${CGAL_MAKE_DIR}
|
|
_check_write ${CGAL_MAKE_DIR}
|
|
_check_file_exists ${CGAL_DIRFILE}
|
|
_check_write ${CGAL_DIRFILE}
|
|
|
|
replace_line $CGAL_DIRFILE CGAL_INCL_DIR "CGAL_INCL_DIR = $CGAL_INCL_DIR"
|
|
replace_line $CGAL_DIRFILE CGAL_LIB_DIR "CGAL_LIB_DIR = $CGAL_LIB_DIR"
|
|
|
|
# create ${CGAL_MAKEFILE}, if it does not exist
|
|
if [ ! -r ${CGAL_MAKEFILE} ]; then
|
|
$1 "remark: `$_basename ${CGAL_MAKEFILE}` does not exist,"
|
|
$1 " creating."
|
|
set_compiler_flags
|
|
create_include_makefile
|
|
else
|
|
$1 "remark: `$_basename ${CGAL_MAKEFILE}` already exists,"
|
|
$1 " saving as \".bak\"."
|
|
$_mv ${CGAL_MAKEFILE} ${CGAL_MAKEFILE}.bak
|
|
set_compiler_flags
|
|
create_include_makefile
|
|
fi
|
|
|
|
replace_line $CGAL_MAKEFILE CGAL_DIRECTORIES "CGAL_DIRECTORIES = ${CGAL_DIRFILE}"
|
|
replace_line $CGAL_MAKEFILE CGAL_OS_COMPILER \
|
|
"CGAL_OS_COMPILER = ${CGAL_OS_COMPILER}${GCC_RTTI_PATCH_SUPPORT}${LEDA_SUPPORT}"
|
|
|
|
if [ -n "$LEDA_INCL_DIR" ] ; then
|
|
replace_line $CGAL_MAKEFILE LEDA_INCL_DIR "LEDA_INCL_DIR = $LEDA_INCL_DIR"
|
|
fi
|
|
|
|
if [ -n "$LEDA_LIB_DIR" ] ; then
|
|
replace_line $CGAL_MAKEFILE LEDA_LIB_DIR "LEDA_LIB_DIR = $LEDA_LIB_DIR"
|
|
fi
|
|
|
|
replace_line $CGAL_MAKEFILE CGAL_STL_VERSION "CGAL_STL_VERSION = $CGAL_STL_VERSION"
|
|
|
|
if [ -z "${STL_DIR}" -o "${STL_STATUS}" = "b" ] ; then
|
|
replace_line $CGAL_MAKEFILE CGAL_STL_INCLUDE_DIRECTIVE "CGAL_STL_INCLUDE_DIRECTIVE ="
|
|
else
|
|
replace_line $CGAL_MAKEFILE CGAL_STL_INCLUDE_DIRECTIVE "CGAL_STL_INCLUDE_DIRECTIVE = -I$STL_DIR"
|
|
fi
|
|
|
|
if [ -n "$GCC_RTTI_PATCH_DIR" ] ; then
|
|
replace_line $CGAL_MAKEFILE GCC_RTTI_PATCH_DIR "GCC_RTTI_PATCH_DIR = $GCC_RTTI_PATCH_DIR"
|
|
fi
|
|
|
|
FILE=${CGAL_SRC_DIR}/makefile_lib
|
|
replace_line $FILE CGAL_MAKEFILE "CGAL_MAKEFILE = ${CGAL_MAKEFILE}"
|
|
|
|
FILE=${CGAL_SRC_DIR}/makefile_sharedlib
|
|
replace_line $FILE CGAL_MAKEFILE "CGAL_MAKEFILE = ${CGAL_MAKEFILE}"
|
|
|
|
FILE=${CGAL_EXAMPLE_DIR}/makefile
|
|
replace_line $FILE CGAL_MAKEFILE "CGAL_MAKEFILE = ${CGAL_MAKEFILE}"
|
|
|
|
if [ -n "${CGAL_TESTSUITE}" ]; then
|
|
FILE=${CGAL_TEST_DIR}/cgal_test
|
|
replace_line $FILE CGAL_MAKE_DIR "CGAL_MAKE_DIR=${CGAL_MAKE_DIR}"
|
|
$_chmod 744 $FILE
|
|
|
|
for FILE in `/bin/ls ${CGAL_TEST_DIR}/*/makefile` ; do
|
|
replace_line $FILE CGAL_MAKEFILE "CGAL_MAKEFILE = ${CGAL_MAKEFILE}"
|
|
done
|
|
fi
|
|
|
|
}
|
|
|
|
#################### (end) from old cgal_install ############################
|
|
|
|
# compile $1 (= lib or sharedlib)
|
|
# return 0, iff success
|
|
_do_compile()
|
|
{
|
|
${_printf} "${_LEFTSPACE}Building CGAL_$1 ..."
|
|
if [ -f ${COMPILE_LOGFILE} -a ! -w ${COMPILE_LOGFILE} ]; then
|
|
/bin/rm -f ${COMPILE_LOGFILE}
|
|
fi
|
|
if make -f makefile_$1 >${COMPILE_LOGFILE} 2>&1; then
|
|
log_print "Compilation of $1 ${_libname} succeeded."
|
|
${_printf} " done.\n"
|
|
ANY_LIB_COMPILED='y'
|
|
return 0
|
|
else
|
|
log_print "Compilation of $1 ${_libname} failed."
|
|
${_printf} "\n${_LEFTSPACE}Compilation of CGAL_$1 failed.\n"
|
|
${_printf} "${_LEFTSPACE}You will be shown a log now ...\n"
|
|
print_filled_line
|
|
wait_for_enter
|
|
$_cat ${COMPILE_LOGFILE} | ${PAGER:-$_cat}
|
|
write_buffer "\n"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# used by make_lib_dir. ($1 is 'a' or 'so')
|
|
check_for_gmp_links()
|
|
{
|
|
if [ ! -r ${CGAL_LIB_DIR}/`full_ostype`/libgmp.$1 -a \
|
|
-r ${CGAL_LIB_DIR}/${CGAL_OS_COMPILER}/libgmp.$1 ]; then
|
|
${_ln} -s ${CGAL_LIB_DIR}/${CGAL_OS_COMPILER}/libgmp.$1 \
|
|
${CGAL_LIB_DIR}/`full_ostype`
|
|
log_print "remark: libgmp.$1 linked from ${CGAL_OS_COMPILER}."
|
|
fi
|
|
}
|
|
|
|
# make lib dir
|
|
make_lib_dir()
|
|
{
|
|
_libname=${CGAL_LIB_DIR}/`full_ostype`
|
|
if [ ! -d ${_libname} ]; then
|
|
${_mkdir} ${_libname}
|
|
# check, if GMP is installed for this os/compiler
|
|
# in the CGAL directory tree
|
|
check_for_gmp_links 'a'
|
|
check_for_gmp_links 'so'
|
|
fi
|
|
_check_dir_exists ${_libname}
|
|
_check_write ${_libname}
|
|
_libname=`${_basename} ${_libname}`
|
|
|
|
}
|
|
|
|
# create appropriate dirs and makefiles
|
|
make_makefiles()
|
|
{
|
|
# generate directoryfile and makefile:
|
|
${_printf} "${_LEFTSPACE}Generating Makefiles ..."
|
|
CGAL_MAKEFILE=${CGAL_MAKE_DIR}/makefile_${_libname}
|
|
generatemakefiles log_print
|
|
${_printf} " done.\n"
|
|
}
|
|
|
|
write_menu_information()
|
|
{
|
|
clear_screen
|
|
print_filled_line
|
|
print_empty_line
|
|
print_headline "$1 CGAL ${CGAL_VERSION}"
|
|
print_filled_line
|
|
write_buffer "\n"
|
|
flush_buffer
|
|
print_os_setting
|
|
${_printf} "\n"
|
|
}
|
|
|
|
lib_menu()
|
|
{
|
|
write_menu_information "Compiling"
|
|
|
|
make_lib_dir
|
|
make_makefiles
|
|
|
|
# build the libs:
|
|
cd ${CGAL_SRC_DIR}
|
|
if _do_compile lib; then
|
|
LIB_COMPILED='ok'
|
|
${_printf} "`print_os_setting`" >>${INSTALL_RIS_LOGFILE}
|
|
${_printf} \
|
|
"\n${_LEFTSPACE}----------------------------------------------------------\n" \
|
|
>>${INSTALL_RIS_LOGFILE}
|
|
_do_compile sharedlib
|
|
fi
|
|
write_buffer "\n"
|
|
print_filled_line
|
|
wait_for_enter
|
|
cd ${CGAL_DIR}
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# test menu
|
|
#
|
|
|
|
test_menu()
|
|
{
|
|
write_menu_information "Testing"
|
|
|
|
${_printf} "${_LEFTSPACE}Updating `$_basename ${CGAL_TESTFILE}` ..."
|
|
_check_write ${CGAL_TESTFILE}
|
|
replace_line ${CGAL_TESTFILE} PLATFORM "PLATFORM=`full_ostype`; testplatform"
|
|
$_chmod 744 ${CGAL_TESTFILE}
|
|
${_printf} " done.\n"
|
|
|
|
${_printf} "${_LEFTSPACE}Starting ${CGAL_TESTFILE} ...\n"
|
|
cd ${CGAL_TEST_DIR}
|
|
cgal_test
|
|
cleanup_after_compile
|
|
log_print "Test completed."
|
|
print_filled_line
|
|
print_empty_line
|
|
print_headline "Test completed."
|
|
print_center_line "You will be shown a log now ..."
|
|
wait_for_enter
|
|
$_cat ${TEST_LOGFILE} | ${PAGER:-$_cat}
|
|
write_buffer "\n"
|
|
print_filled_line
|
|
cd ${CGAL_DIR}
|
|
wait_for_enter
|
|
return
|
|
}
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# main menu
|
|
#
|
|
|
|
# get timestamp of file $1 via ls
|
|
# (assumed to be in columns 6-8)
|
|
_get_timestamp()
|
|
{
|
|
$_ls -l $1 | ${_awk} '{printf "%s %s %s",$7,$6,$8}'
|
|
}
|
|
|
|
main_menu()
|
|
{
|
|
while [ 0 ]; do
|
|
menu_header 'Main'
|
|
if [ -r ${CGAL_LIB_DIR}/`full_ostype`/${CGAL_LIB_NAME}.a ]; then
|
|
print_line "Libs built: `_get_timestamp ${CGAL_LIB_DIR}/\`full_ostype\`/${CGAL_LIB_NAME}.a`"
|
|
else
|
|
print_line "There are no libs for this os/compiler."
|
|
fi
|
|
print_empty_line
|
|
print_line "${_bold_on}<C>${_bold_off} Compiler Menu"
|
|
print_line "${_bold_on}<L>${_bold_off} LEDA Menu"
|
|
print_line "${_bold_on}<G>${_bold_off} GMP Menu"
|
|
print_line "${_bold_on}<T>${_bold_off} Test (and save) setup"
|
|
print_line "${_bold_on}<A>${_bold_off} Run all setup tests (no cache)"
|
|
print_empty_line
|
|
print_line "${_bold_on}<B>${_bold_off} Build CGAL Libraries"
|
|
if [ -n "${CGAL_TESTSUITE}" -a -n "${LIB_COMPILED}" ]; then
|
|
print_line "${_bold_on}<S>${_bold_off} Run CGAL testsuite"
|
|
fi
|
|
menu_tailer 'OS'
|
|
|
|
case $KEY in
|
|
c|C) compiler_menu;;
|
|
l|L) leda_menu;;
|
|
g|G) gmp_menu;;
|
|
b|B) lib_menu;;
|
|
a|A)
|
|
reset_all_test_variables
|
|
go_down_lines 3
|
|
flush_buffer
|
|
if [ -n "${LEDA_SUPPORT}" ]; then
|
|
test_for_leda_incl_in_sys_incl "${INSTALL_VERBOSE}"
|
|
test_for_leda_lib_in_sys_lib "${INSTALL_VERBOSE}"
|
|
fi
|
|
if [ -n "${GMP_SUPPORT}" ]; then
|
|
search_gmp
|
|
fi
|
|
test_for_builtin_stl
|
|
test_setup;;
|
|
t|T)
|
|
go_down_lines 3
|
|
flush_buffer
|
|
test_setup;;
|
|
s|S)
|
|
if [ -n "${CGAL_TESTSUITE}" -a -n "${LIB_COMPILED}" ]; then
|
|
test_menu
|
|
fi
|
|
;;
|
|
q|Q)
|
|
if [ -z "${ANY_LIB_COMPILED}" ]; then
|
|
go_down_lines 1
|
|
print_filled_line
|
|
print_line \
|
|
"WARNING: You did not build any libs during this session."
|
|
else
|
|
go_down_lines 3
|
|
flush_buffer
|
|
$_cat ${INSTALL_RIS_LOGFILE}
|
|
print_filled_line
|
|
print_center_line "`$_basename $0` completed."
|
|
fi
|
|
print_center_line "If something went wrong, (or maybe also, if not:)"
|
|
print_center_line "have a look at `$_basename ${INSTALL_LOGFILE}`."
|
|
print_filled_line
|
|
flush_buffer
|
|
return;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
# ---------------------------------------------------------------------
|
|
# MAIN BODY
|
|
#
|
|
|
|
# for command line parsing: check if $* is really a compiler
|
|
# with its full path and set _tmp to its basename
|
|
_check_comp_executable()
|
|
{
|
|
_tmp=`${_basename} $* 2>/dev/null`
|
|
if [ -z "${_tmp}" ]; then
|
|
echo
|
|
echo "ERROR: basename returned empty string, exiting."
|
|
exit 1
|
|
elif [ -z "$*" ]; then
|
|
echo
|
|
echo "ERROR: Missing argument, exiting."
|
|
echo "Try: `$_basename $0` --help"
|
|
exit 1
|
|
elif [ ! -x $* ]; then
|
|
# that was not an absolute path -> try which
|
|
if [ ! -x `real_which $*` ]; then
|
|
echo
|
|
echo "ERROR: Cannot execute $*, exiting."
|
|
echo "Try: `$_basename $0` --help"
|
|
exit 1
|
|
fi
|
|
log_print "$* is \"`real_which $*`\"."
|
|
fi
|
|
}
|
|
|
|
cgal_install_header()
|
|
{
|
|
printf "\n--------------------------------------------------------\n"
|
|
echo " This is the install script for CGAL ${CGAL_VERSION}."
|
|
echo "--------------------------------------------------------"
|
|
echo
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
# command line parsing
|
|
#
|
|
|
|
# for variable setting:
|
|
# checks if $2 contains '='
|
|
# if so, sets variable $1 to the substring of $2 to the right of '='
|
|
# and returns 1
|
|
# otherwise sets variable $1 to $3 and returns 0
|
|
set_variable_from_command_line()
|
|
{
|
|
_tmp=`${_printf} "$2" | ${_awk} 'BEGIN {FS="="} {printf $2}'`
|
|
if [ -n "${_tmp}" ]; then
|
|
eval "$1=\"${_tmp}\""
|
|
write_buffer "${_LEFTSPACE}Set $1 to \"`value_of $1`\".\n"
|
|
return 1
|
|
else
|
|
eval "$1=\"$3\""
|
|
write_buffer "${_LEFTSPACE}Set $1 to \"`value_of $1`\".\n"
|
|
return 0
|
|
fi
|
|
}
|
|
|
|
|
|
_WHAT_TO_DO=''
|
|
_CONFLICT=''
|
|
_check_for_sysutil printf y
|
|
_check_for_sysutil awk y
|
|
while [ $# -gt 0 ]; do
|
|
case $* in
|
|
--stl_dir*|--STL_DIR*|-STL_DIR*|-stl_dir*)
|
|
if set_variable_from_command_line 'STL_DIR' "$1" "$2"; then
|
|
shift
|
|
fi
|
|
STL_STATUS='e'
|
|
;;
|
|
--leda_sys_incl*|--LEDA_SYS_INCL*|--leda-sys-incl*|--LEDA-SYS-INCL*|\
|
|
-leda_sys_incl*|-LEDA_SYS_INCL*|-leda-sys-incl*|-LEDA-SYS-INCL*)
|
|
NEED_EXTRA_LEDA_IDIR=''
|
|
;;
|
|
--leda_incl_dir*|--LEDA_INCL_DIR*|-LEDA_INCL_DIR*|-leda_incl_dir*)
|
|
if set_variable_from_command_line 'LEDA_INCL_DIR' "$1" "$2"; then
|
|
shift
|
|
fi
|
|
;;
|
|
--leda_sys_lib*|--LEDA_SYS_LIB*|--leda-sys-lib*|--LEDA-SYS-LIB*|\
|
|
-leda_sys_lib*|-LEDA_SYS_LIB*|-leda-sys-lib*|-LEDA-SYS-LIB*)
|
|
NEED_EXTRA_LEDA_LDIR=''
|
|
;;
|
|
--leda_lib_dir*|--LEDA_LIB_DIR*|-LEDA_LIB_DIR*|-leda_lib_dir*)
|
|
if set_variable_from_command_line 'LEDA_LIB_DIR' "$1" "$2"; then
|
|
shift
|
|
fi
|
|
;;
|
|
--gcc_rtti_patch_dir*|--GCC_RTTI_PATCH_DIR*|\
|
|
-gcc_rtti_patch_dir*|-GCC_RTTI_PATCH_DIR*)
|
|
if set_variable_from_command_line 'GCC_RTTI_PATCH_DIR' "$1" "$2"; then
|
|
shift
|
|
fi
|
|
;;
|
|
--gmp_incl_dir*|--GMP_INCL_DIR*|-GMP_INCL_DIR*|-gmp_incl_dir*)
|
|
if set_variable_from_command_line 'GMP_INCL_DIR' "$1" "$2"; then
|
|
shift
|
|
fi
|
|
;;
|
|
--gmp_lib_dir*|--GMP_LIB_DIR*|-GMP_LIB_DIR*|-gmp_lib_dir*)
|
|
if set_variable_from_command_line 'GMP_LIB_DIR' "$1" "$2"; then
|
|
shift
|
|
fi
|
|
;;
|
|
-LEDA*|-leda*|--leda*|--LEDA*)
|
|
LEDA_SUPPORT='_LEDA'
|
|
write_buffer "${_LEFTSPACE}Enable LEDA support.\n"
|
|
;;
|
|
-gcc-rtti*|-GCC-RTTI*|--gcc-rtti*|--GCC-RTTI*|-GCC-rtti*|\
|
|
-gcc-RTTI*|--GCC-rtti*|--gcc-RTTI*)
|
|
GCC_RTTI_PATCH_SUPPORT='-rtti'
|
|
write_buffer "${_LEFTSPACE}Enable support of GCC RTTI patch.\n"
|
|
;;
|
|
-gmp*|-GMP*|--gmp*|--GMP*)
|
|
GMP_SUPPORT='_GMP'
|
|
write_buffer "${_LEFTSPACE}Enable GMP support.\n"
|
|
;;
|
|
-os*|-OS*)
|
|
if [ -n "${_WHAT_TO_DO}" ]; then
|
|
_CONFLICT='y'
|
|
fi
|
|
_WHAT_TO_DO='ostype'
|
|
COMPILER=$2
|
|
shift
|
|
;;
|
|
-ni*)
|
|
if [ -n "${_WHAT_TO_DO}" ]; then
|
|
_CONFLICT='y'
|
|
fi
|
|
_WHAT_TO_DO='non-interactive'
|
|
COMPILER=$2
|
|
shift
|
|
;;
|
|
--interactive*|-i*|-I*)
|
|
if [ -n "${_WHAT_TO_DO}" ]; then
|
|
_CONFLICT='y'
|
|
fi
|
|
_WHAT_TO_DO='interactive'
|
|
;;
|
|
--verbose*|-verbose*)
|
|
INSTALL_VERBOSE='y'
|
|
;;
|
|
*--version*|-V*|-v*)
|
|
# version
|
|
echo "`basename $0` is ${CGAL_INSTALL_VERSION}."
|
|
exit 0
|
|
;;
|
|
*)
|
|
_WHAT_TO_DO='help'
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [ -n "${_CONFLICT}" ]; then
|
|
_WHAT_TO_DO='help'
|
|
fi
|
|
|
|
case ${_WHAT_TO_DO} in
|
|
*non-interactive*)
|
|
cgal_install_header
|
|
echo "running non interactive mode ..."
|
|
INSTALL_INTERACTIVE=''
|
|
case ${COMPILER} in
|
|
*" "*)
|
|
echo
|
|
echo "ERROR: Too many arguments, exiting."
|
|
echo "Try: `basename $0` --help"
|
|
exit 1;;
|
|
*)
|
|
INSTALL_LOGFILE_REDIRECTION='|print_with_indent'
|
|
printf \
|
|
"\n--------------------------------------------------------\n"
|
|
echo "Locating Utilities:"
|
|
echo "--------------------------------------------------------"
|
|
check_for_utils
|
|
guess_os 'print_with_indent'
|
|
_check_comp_executable ${COMPILER}
|
|
set_compiler_absolute "${COMPILER}"
|
|
compute_compiler_version "${COMPILER}"
|
|
set_ostype
|
|
printf \
|
|
"\n--------------------------------------------------------\n"
|
|
echo "Settings from Command Line:"
|
|
printf \
|
|
"--------------------------------------------------------\n"
|
|
flush_buffer
|
|
printf \
|
|
"\n--------------------------------------------------------\n"
|
|
echo "Determining STL Version:"
|
|
printf \
|
|
"--------------------------------------------------------\n"
|
|
INSTALL_LOGFILE_REDIRECTION='>/dev/null'
|
|
set_stl_version "${INSTALL_VERBOSE}"
|
|
INSTALL_LOGFILE_REDIRECTION='|print_with_indent'
|
|
printf \
|
|
"\n--------------------------------------------------------\n"
|
|
echo "Show Setup:"
|
|
printf \
|
|
"--------------------------------------------------------\n"
|
|
print_os_setting
|
|
printf \
|
|
"\n--------------------------------------------------------\n"
|
|
echo "Creating Directories and Makefiles:"
|
|
printf \
|
|
"--------------------------------------------------------\n"
|
|
make_lib_dir
|
|
CGAL_MAKEFILE=${CGAL_MAKE_DIR}/makefile_`full_ostype`
|
|
generatemakefiles echo
|
|
|
|
printf \
|
|
"\n--------------------------------------------------------\n"
|
|
echo "-- DONE, please read the documentation --"
|
|
echo "-- on how to proceed --"
|
|
echo "--------------------------------------------------------"
|
|
;;
|
|
esac
|
|
;;
|
|
*interactive*)
|
|
cgal_install_header
|
|
# start interactive part
|
|
echo "starting interactive mode - one moment, please"
|
|
INSTALL_INTERACTIVE='y'
|
|
INSTALL_LOGFILE_REDIRECTION=">>${INSTALL_LOGFILE}"
|
|
if [ -n "${_BUF}" ]; then
|
|
echo
|
|
echo "WARNING: In interactive mode all command line options"
|
|
echo " except for \"-i\" are ignored."
|
|
echo
|
|
clear_buffer
|
|
fi
|
|
init_logfiles
|
|
${_printf} "."
|
|
check_for_utils
|
|
${_printf} "."
|
|
check_conf_dir
|
|
${_printf} "."
|
|
set_expr
|
|
${_printf} "."
|
|
set_menu_lines
|
|
${_printf} "."
|
|
set_terminal_variables
|
|
${_printf} "."
|
|
search_for_compilers
|
|
${_printf} "."
|
|
|
|
main_menu
|
|
exit 0
|
|
;;
|
|
*ostype*)
|
|
case ${COMPILER} in
|
|
*" "*)
|
|
echo
|
|
echo "ERROR: Too many arguments, exiting."
|
|
echo "Try: `basename $0` --help"
|
|
exit 1
|
|
;;
|
|
*)
|
|
# architecture/os key
|
|
_printf=printf
|
|
_uname=uname
|
|
_basename=basename
|
|
_awk=awk
|
|
_fgrep=fgrep
|
|
_which=real_which
|
|
eval "guess_os echo" >/dev/null
|
|
_check_comp_executable ${COMPILER}
|
|
set_compiler_absolute "${COMPILER}"
|
|
compute_compiler_version "${COMPILER}"
|
|
set_ostype
|
|
echo `full_ostype`
|
|
;;
|
|
esac
|
|
;;
|
|
*)
|
|
cgal_install_header
|
|
echo "Just type \"`basename $0` -i\" and follow the menus."
|
|
echo "Please read the documentation."
|
|
echo
|
|
echo "usage: `basename $0`"' [-leda] [-gcc-rtti] [-gmp] [--verbose]'
|
|
echo ' [--help | --version | -i | --interactive |'
|
|
echo ' -ni <comp> | --non-interactive <comp> | -os <comp>]'
|
|
echo ' [--LEDA_INCL_DIR <dir>] [--LEDA_INCL_DIR <dir>]'
|
|
echo ' [--leda-sys-incl] [--leda-sys-lib]'
|
|
echo ' [--STL_DIR <dir>] [--GCC_RTTI_PATCH_DIR <dir>]'
|
|
echo ' [--GMP_INCL_DIR <dir>] [--GMP_LIB_DIR <dir>]'
|
|
echo
|
|
echo ' -leda enables LEDA support'
|
|
echo ' -gcc-rtti enables support for GCC RTTI patch'
|
|
echo ' -gmp enables support for GNU GMP'
|
|
echo ' --verbose give report for each test that fails'
|
|
echo ' (not generally recommended)'
|
|
echo ' --help gives this message'
|
|
echo " --version prints `basename $0` version number"
|
|
echo ' --interactive'
|
|
echo ' runs the script in interactive mode'
|
|
echo ' (other options are ignored)'
|
|
echo ' --non-interactive <comp>'
|
|
echo ' runs the script in non-interactive mode'
|
|
echo ' i.e. makefiles are generated for C++ compiler'
|
|
echo ' specified by <comp>.'
|
|
echo ' For the rest you are on your own.'
|
|
echo ' (Have a look at the README file.)'
|
|
echo ' -os <comp> prints architecture/os/compiler spec'
|
|
echo
|
|
exit 0
|
|
;;
|
|
esac
|
|
exit 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|