OSDN Git Service

* parse.y (nomods_initdcl0): Properly set things up for
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / tests_flags.in
1 #!/bin/sh
2
3 #
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 ./mkcheck.in, which in the long will be removed in favor of a
7 # DejaGnu-base framework.
8 #
9 # Written by Gabriel Dos Reis <gdr@codesourcery.com>
10 #
11
12 #
13 # Synopsis
14 #   * tests_flags --compiler build-dir src-dir
15 #
16 #      Returns a space-separated list of flags needed to run front-end
17 #      specific tests.
18
19 #   * tests_flags --built-library build-dir src-dir
20 #   * tests_flags --installed-library build-dir src-dir install-dir
21 #     
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:LTCXX:LIBS:LTEXE:CXX:CXXFLAGS 
25 #      the meaning of which is as follows:
26 #        BUILD_DIR   build-dir
27 #        SRC_DIR     src-dir
28 #        PREFIX_DIR  install-dir (meaningful only with --installed-library)
29 #        LTCXX       libtoolized command to compile a C++ program
30 #        LIBS        flags to pass to the linker
31 #        LTEXE       libtoolized command to run a compiled C++ program
32 #        CXX         which C++ compiler is being used
33 #        CXXFLAGS    special C++ flags used
34 #
35
36 ##
37 ## Utility functions
38 ##
39
40 # Print a message saying how this script is intended to be invoked
41 print_usage() {
42     cat <<EOF
43 Usage: 
44   tests_flags --compiler <build-dir> <src-dir>
45              --built-library <build-dir>  <src-dir>
46              --installed-library <build-dir> <src-dir> <install-dir>
47 EOF
48     exit 1
49 }
50
51 # Check for command line option
52 check_options() {
53     # First, check for number of command line arguments
54     if [ \( $1 -ne 3 \) -a \( $1 -ne 4 \) ]; then
55         print_usage;
56     fi
57     
58     # Then, see if we understand the job we're asked for
59     case $2 in
60         --compiler|--built-library|--installed-library)
61         # OK
62         ;;
63         *) 
64         print_usage
65         ;;
66     esac
67 }
68
69 # Directory sanity check
70 check_directory() {
71     if [ ! -d $2 ]; then
72         echo "$1 '$2' directory not found, exiting."
73         exit 1
74     fi
75 }
76
77 ##
78 ## Main processing
79 ##
80
81 # Command line options sanity check
82 check_options $# $1
83
84 query=$1
85
86 # Check for build, source and install directories
87 BUILD_DIR=$2; SRC_DIR=$3
88 check_directory 'Build' ${BUILD_DIR}
89 check_directory 'Source' ${SRC_DIR}
90 case ${query} in
91     --installed-library)
92     PREFIX_DIR=$4
93     check_directory 'Install' ${PREFIX_DIR}
94     ;;
95     *)
96     PREFIX_DIR=
97     ;;
98 esac
99
100 # This is LIBTOOL=@LIBTOOL@ piped through a bit of sanity that we can
101 # assume for this script (by the time we run this).
102 LIBTOOL="${BUILD_DIR}/libtool"
103 chmod u+x ${LIBTOOL}
104
105 # Compute include paths
106 # INC_PATH == include path to new headers for use on gcc command-line
107 top_srcdir=@top_srcdir@
108 C_DIR="`basename  @C_INCLUDE_DIR@`"
109 case ${query} in
110     --installed-library)
111     INC_PATH="-I${SRC_DIR}/testsuite"
112     ;;
113     *)
114     INC_PATH="-nostdinc++ @CSHADOW_FLAGS@ -I${BUILD_DIR}/include
115               -I${SRC_DIR}/include/std  -I${SRC_DIR}/include/$C_DIR
116               -I${SRC_DIR}/include -I${SRC_DIR}/libsupc++ -I${SRC_DIR}/libio 
117               -I${SRC_DIR}/testsuite"
118     ;;
119 esac
120
121 # If called for compiler tests, just output include paths
122 case ${query} in
123     --compiler)
124     echo ${INC_PATH} -I${SRC_DIR}/include/backward -I${SRC_DIR}/include/ext
125     exit 0
126     ;;
127 esac
128
129 # For built or installed libraries, we need to get right OS-specific bits.
130 . ${top_srcdir}/configure.target
131
132 # LIB_PATH == where to find the build libraries for libtool's use
133 # CXX == how to call the compiler
134 case ${query} in
135     --built-library)
136     LIB_PATH=${BUILD_DIR}/src
137     CXX="${BUILD_DIR}/../../gcc/g++ -B${BUILD_DIR}/../../gcc/"
138     ;;
139     --installed-library)
140     LIB_PATH=${PREFIX_DIR}/lib
141     CXX=${PREFIX_DIR}/bin/g++
142     ;;
143 esac
144
145 # gcc compiler flags (maybe use glibcpp_cxxflags from configure.target,
146 # but thst's really meant for building the library itself, not using it)
147 CXXFLAGS="-ggdb3 -DDEBUG_ASSERT @SECTION_FLAGS@ @SECTION_LDFLAGS@"
148
149 # LTCXX == how to call libtool when creating an executable
150 # LIBS == any extra needed -l switches, etc (may need more libs, lose lose)
151 case ${query} in
152     --built-library)
153     LTCXX="${LIBTOOL} --tag=CXX --mode=link ${CXX} ${CXXFLAGS} ${INC_PATH} 
154            ${LIB_PATH}/../libsupc++/libsupc++.la  ${LIB_PATH}/libstdc++.la
155            -no-install"
156     LTEXE="${LIBTOOL} --mode=execute"
157     case @target_os@ in
158         *cygwin*)  LIBS="-nodefaultlibs -lgcc -lcygwin -luser32
159                          -lkernel32 -ladvapi32 -lshell32" ;;
160         *)         LIBS="-nodefaultlibs -lc -lgcc -lc" ;;
161     esac
162     ;;
163     --installed-library)
164     # For the installed version, we really only need to use libtool and
165     # the .la file to get correct rpaths.
166     LTCXX="${LIBTOOL} --tag=CXX --mode=link ${CXX} ${CXXFLAGS} ${INC_PATH}
167            -L${LIB_PATH} ${LIB_PATH}/libstdc++.la -no-install 
168            -rpath ${LIB_PATH}"
169     LTEXE="${LIBTOOL} --mode=execute"
170     LIBS=
171     ;;
172 esac
173
174 echo ${BUILD_DIR}:${SRC_DIR}:${PREFIX_DIR}:${LTCXX}:${LIBS}:${LTEXE}:${CXX}:${CXXFLAGS}
175 exit 0