summaryrefslogtreecommitdiff
path: root/libstdc++-v3/tests_flags.in
blob: 2e2e59b983d17f4d9b5ee300d05b0950e709ddfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/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 ./mkcheck.in, which in the long will be removed in favor of a
# DejaGnu-base 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:LTCXX:LIBS:LTEXE:CXX:CXXFLAGS 
#      the meaning of which is as follows:
#        BUILD_DIR   build-dir
#        SRC_DIR     src-dir
#        PREFIX_DIR  install-dir (meaningful only with --installed-library)
#        LTCXX       libtoolized command to compile a C++ program
#        LIBS        flags to pass to the linker
#        LTEXE       libtoolized command to run a compiled C++ program
#	 CXX         which C++ compiler is being used
#        CXXFLAGS    special C++ flags used
#

##
## Utility functions
##

# Print a message saying how this script is intended to be invoked
print_usage() {
    cat <<EOF
Usage: 
  tests_fags --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 [ ! $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

# This is LIBTOOL=@LIBTOOL@ piped through a bit of sanity that we can
# assume for this script (by the time we run this).
LIBTOOL="${BUILD_DIR}/libtool"
chmod u+x ${LIBTOOL}

# Compute include paths
# INC_PATH == include path to new headers for use on gcc command-line
top_srcdir=@top_srcdir@
C_DIR="`basename  @C_INCLUDE_DIR@`"
case ${query} in
    --installed-library)
    INC_PATH="-I${SRC_DIR}/testsuite"
    ;;
    *)
    INC_PATH="-nostdinc++ @CSHADOW_FLAGS@ -I${BUILD_DIR}/include
	      -I${SRC_DIR}/include/std  -I${SRC_DIR}/include/$C_DIR
	      -I${SRC_DIR}/include -I${SRC_DIR}/libsupc++ -I${SRC_DIR}/libio 
	      -I${SRC_DIR}/testsuite"
    ;;
esac

# If called for compiler tests, just output include paths
case ${query} in
    --compiler)
    echo ${INC_PATH} -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.
. ${top_srcdir}/configure.target

# LIB_PATH == where to find the build libraries for libtool's use
# CXX == how to call the compiler
case ${query} in
    --built-library)
    LIB_PATH=${BUILD_DIR}/src
    CXX="${BUILD_DIR}/../../gcc/g++ -B${BUILD_DIR}/../../gcc/"
    ;;
    --installed-library)
    LIB_PATH=${PREFIX_DIR}/lib
    CXX=${PREFIX_DIR}/bin/g++
    ;;
esac

# gcc compiler flags (maybe use glibcpp_cxxflags from configure.target,
# but thst's really meant for building the library itself, not using it)
CXXFLAGS="-ggdb3 -DDEBUG_ASSERT @SECTION_FLAGS@ @SECTION_LDFLAGS@"

# LTCXX == how to call libtool when creating an executable
# LIBS == any extra needed -l switches, etc (may need more libs, lose lose)
case ${query} in
    --built-library)
    LTCXX="${LIBTOOL} --tag=CXX --mode=link ${CXX} ${CXXFLAGS} ${INC_PATH} 
	   ${LIB_PATH}/../libsupc++/libsupc++.la  ${LIB_PATH}/libstdc++.la
	   -no-install"
    LTEXE="${LIBTOOL} --mode=execute"
    LIBS="-nodefaultlibs -lc -lgcc -lc"
    ;;
    --installed-library)
    # For the installed version, we really only need to use libtool and
    # the .la file to get correct rpaths.
    LTCXX="${LIBTOOL} --tag=CXX --mode=link ${CXX} ${CXXFLAGS} ${INC_PATH}
	   -L${LIB_PATH} ${LIB_PATH}/libstdc++.la -no-install 
	   -rpath ${LIB_PATH}"
    LTEXE="${LIBTOOL} --mode=execute"
    LIBS=
    ;;
esac

echo ${BUILD_DIR}:${SRC_DIR}:${PREFIX_DIR}:${LTCXX}:${LIBS}:${LTEXE}:${CXX}:${CXXFLAGS}
exit 0