2001-04-09 Andrew MacLeod <amacleod@redhat.com>
[official-gcc.git] / libstdc++-v3 / tests_flags.in
blob3ae640b360eb695c23248438577ef00d05e2d1b0
1 #!/bin/sh
4 # This script computes the various flags needed to run GNU C++ testsuites
5 # (compiler specific as well as library specific). It is based on
6 # the file ./mkcheck.in, which in the long will be removed in favor of a
7 # DejaGnu-based framework.
9 # Written by Gabriel Dos Reis <gdr@codesourcery.com>
13 # Synopsis
14 # * tests_flags --compiler build-dir src-dir
16 # Returns a space-separated list of flags needed to run front-end
17 # specific tests.
19 # * tests_flags --built-library build-dir src-dir
20 # * tests_flags --installed-library build-dir src-dir install-dir
22 # Returns a colon-separated list of space-separated list of flags,
23 # needed to run library specific tests,
24 # BUILD_DIR:SRC_DIR:PREFIX_DIR:CXX:CXXFLAGS:INCLUDES:LIBS
25 # the meaning of which is as follows:
26 # BUILD_DIR libstdc++-v3 build-dir
27 # SRC_DIR libstdc++-v3 src-dir
28 # PREFIX_DIR install-dir (meaningful only with --installed-library)
29 # CXX which C++ compiler is being used
30 # CXXFLAGS special flags to pass to g++
31 # INCLUDES paths to headers
32 # LIBS flags to pass to the linker
36 ## Utility functions
39 # Print a message saying how this script is intended to be invoked
40 print_usage() {
41 cat <<EOF
42 Usage:
43 tests_flags --compiler <build-dir> <src-dir>
44 --built-library <build-dir> <src-dir>
45 --installed-library <build-dir> <src-dir> <install-dir>
46 EOF
47 exit 1
50 # Check for command line option
51 check_options() {
52 # First, check for number of command line arguments
53 if [ \( $1 -ne 3 \) -a \( $1 -ne 4 \) ]; then
54 print_usage;
57 # Then, see if we understand the job we're asked for
58 case $2 in
59 --compiler|--built-library|--installed-library)
60 # OK
62 *)
63 print_usage
65 esac
68 # Directory sanity check
69 check_directory() {
70 if [ ! -d $2 ]; then
71 echo "$1 '$2' directory not found, exiting."
72 exit 1
77 ## Main processing
80 # Command line options sanity check
81 check_options $# $1
83 query=$1
85 # Check for build, source and install directories
86 BUILD_DIR=$2; SRC_DIR=$3
87 check_directory 'Build' ${BUILD_DIR}
88 check_directory 'Source' ${SRC_DIR}
89 case ${query} in
90 --installed-library)
91 PREFIX_DIR=$4
92 check_directory 'Install' ${PREFIX_DIR}
95 PREFIX_DIR=
97 esac
99 # Compute include paths
100 # INCLUDES == include path to new headers for use on gcc command-line
101 C_DIR="`basename @C_INCLUDE_DIR@`"
102 case ${query} in
103 --installed-library)
104 INCLUDES="-I${SRC_DIR}/testsuite"
107 INCLUDES="-nostdinc++ -I${BUILD_DIR}/include -I${SRC_DIR}/include
108 -I${SRC_DIR}/include/std -I${SRC_DIR}/include/$C_DIR
109 -I${SRC_DIR}/libsupc++ -I${SRC_DIR}/libio
110 -I${SRC_DIR}/testsuite"
111 if test x@xcompiling@ = x1; then
112 INCLUDES="${INCLUDES} -I${SRC_DIR}/../newlib/libc/include"
115 esac
117 # If called for compiler tests, just output appropriate include paths
118 case ${query} in
119 --compiler)
120 echo ${INCLUDES} -I${SRC_DIR}/include/backward -I${SRC_DIR}/include/ext
121 exit 0
123 esac
125 # For built or installed libraries, we need to get right OS-specific bits.
126 . ${SRC_DIR}/configure.target
128 # LIB_PATH == where to find the C++ build libraries for libtool's use
129 # GCC_LIB_PATH == where to find the gcc build libraries for libtool's use
130 # CXX == how to invoke the compiler
131 case ${query} in
132 --built-library)
133 LIB_PATH=${BUILD_DIR}/src
134 GCC_LIB_PATH=${BUILD_DIR}/../../gcc
135 CROSS_LIB_PATH=${BUILD_DIR}/../newlib
136 CXX="${BUILD_DIR}/../../gcc/g++ -B${BUILD_DIR}/../../gcc/"
138 --installed-library)
139 LIB_PATH=${PREFIX_DIR}/lib
140 GCC_LIB_PATH=
141 CROSS_LIB_PATH=
142 CXX=${PREFIX_DIR}/bin/g++
144 esac
146 # CXXFLAGS == run the testsuite with any special configuration
147 # flags from the library build.
148 CXXFLAGS="-ggdb3 -DDEBUG_ASSERT @SECTION_FLAGS@ @SECTION_LDFLAGS@"
150 # LIBS == any extra may needed -L switches
151 case ${query} in
152 --built-library)
153 LIBS="${LIB_PATH}/libstdc++.la -no-install -rpath ${GCC_LIB_PATH}"
154 if test x@xcompiling@ = x1; then
155 LIBS="${LIBS} -B${CROSS_LIB_PATH}/"
157 case @target_os@ in
158 *cygwin*)
159 LIBS="${LIBS} -nodefaultlibs -lgcc -lcygwin -luser32
160 -lkernel32 -ladvapi32 -lshell32"
163 LIBS="${LIBS} -nodefaultlibs -lgcc -lc -lgcc"
165 esac
167 --installed-library)
168 LIBS="${LIB_PATH}/libstdc++.la -no-install -rpath ${LIB_PATH}"
170 esac
172 echo ${BUILD_DIR}:${SRC_DIR}:${PREFIX_DIR}:${CXX}:${CXXFLAGS}:${INCLUDES}:${LIBS}
173 exit 0