gcc/libstdc++-v3/tests_flags.in
Zack Weinberg aa9de837a8 tests_flags.in: Use test a = b, not test a == b which is not portable.
* tests_flags.in: Use test a = b, not test a == b which is not
	portable.

From-SVN: r40986
2001-04-01 19:19:57 +00:00

169 lines
4.4 KiB
Bash

#!/bin/sh
#
# This script computes the various flags needed to run GNU C++ testsuites
# (compiler specific as well as library specific). It is based on
# the file ./mkcheck.in, which in the long will be removed in favor of a
# DejaGnu-based framework.
#
# Written by Gabriel Dos Reis <gdr@codesourcery.com>
#
#
# Synopsis
# * tests_flags --compiler build-dir src-dir
#
# Returns a space-separated list of flags needed to run front-end
# specific tests.
#
# * tests_flags --built-library build-dir src-dir
# * tests_flags --installed-library build-dir src-dir install-dir
#
# Returns a colon-separated list of space-separated list of flags,
# needed to run library specific tests,
# BUILD_DIR:SRC_DIR:PREFIX_DIR:CXX:CXXFLAGS:INCLUDES:LIBS
# the meaning of which is as follows:
# BUILD_DIR libstdc++-v3 build-dir
# SRC_DIR libstdc++-v3 src-dir
# PREFIX_DIR install-dir (meaningful only with --installed-library)
# CXX which C++ compiler is being used
# CXXFLAGS special flags to pass to g++
# INCLUDES paths to headers
# LIBS flags to pass to the linker
#
##
## Utility functions
##
# Print a message saying how this script is intended to be invoked
print_usage() {
cat <<EOF
Usage:
tests_flags --compiler <build-dir> <src-dir>
--built-library <build-dir> <src-dir>
--installed-library <build-dir> <src-dir> <install-dir>
EOF
exit 1
}
# Check for command line option
check_options() {
# First, check for number of command line arguments
if [ \( $1 -ne 3 \) -a \( $1 -ne 4 \) ]; then
print_usage;
fi
# Then, see if we understand the job we're asked for
case $2 in
--compiler|--built-library|--installed-library)
# OK
;;
*)
print_usage
;;
esac
}
# Directory sanity check
check_directory() {
if [ ! -d $2 ]; then
echo "$1 '$2' directory not found, exiting."
exit 1
fi
}
##
## Main processing
##
# Command line options sanity check
check_options $# $1
query=$1
# Check for build, source and install directories
BUILD_DIR=$2; SRC_DIR=$3
check_directory 'Build' ${BUILD_DIR}
check_directory 'Source' ${SRC_DIR}
case ${query} in
--installed-library)
PREFIX_DIR=$4
check_directory 'Install' ${PREFIX_DIR}
;;
*)
PREFIX_DIR=
;;
esac
# Compute include paths
# INCLUDES == include path to new headers for use on gcc command-line
C_DIR="`basename @C_INCLUDE_DIR@`"
case ${query} in
--installed-library)
INCLUDES="-I${SRC_DIR}/testsuite"
;;
*)
INCLUDES="-nostdinc++ -I${BUILD_DIR}/include -I${SRC_DIR}/include
-I${SRC_DIR}/include/std -I${SRC_DIR}/include/$C_DIR
-I${SRC_DIR}/libsupc++ -I${SRC_DIR}/libio
-I${SRC_DIR}/testsuite"
if test x@xcompiling@ = x1; then
INCLUDES="${INCLUDES} -I${SRC_DIR}/../newlib/libc/include"
fi
;;
esac
# If called for compiler tests, just output appropriate include paths
case ${query} in
--compiler)
echo ${INCLUDES} -I${SRC_DIR}/include/backward -I${SRC_DIR}/include/ext
exit 0
;;
esac
# For built or installed libraries, we need to get right OS-specific bits.
. ${SRC_DIR}/configure.target
# LIB_PATH == where to find the C++ build libraries for libtool's use
# GCC_LIB_PATH == where to find the gcc build libraries for libtool's use
# CXX == how to invoke the compiler
case ${query} in
--built-library)
LIB_PATH=${BUILD_DIR}/src
GCC_LIB_PATH=${BUILD_DIR}/../../gcc
CXX="${BUILD_DIR}/../../gcc/g++ -B${BUILD_DIR}/../../gcc/"
;;
--installed-library)
LIB_PATH=${PREFIX_DIR}/lib
GCC_LIB_PATH=
CXX=${PREFIX_DIR}/bin/g++
;;
esac
# CXXFLAGS == run the testsuite with any special configuration
# flags from the library build.
CXXFLAGS="-ggdb3 -DDEBUG_ASSERT @SECTION_FLAGS@ @SECTION_LDFLAGS@"
# LIBS == any extra may needed -L switches
case ${query} in
--built-library)
LIBS="${LIB_PATH}/libstdc++.la -no-install -rpath ${GCC_LIB_PATH}"
case @target_os@ in
*cygwin*)
LIBS="${LIBS} -nodefaultlibs -lgcc -lcygwin -luser32
-lkernel32 -ladvapi32 -lshell32"
;;
*)
LIBS="${LIBS} -nodefaultlibs -lgcc -lc -lgcc"
;;
esac
;;
--installed-library)
LIBS="${LIB_PATH}/libstdc++.la -no-install -rpath ${LIB_PATH}"
;;
esac
echo ${BUILD_DIR}:${SRC_DIR}:${PREFIX_DIR}:${CXX}:${CXXFLAGS}:${INCLUDES}:${LIBS}
exit 0