OSDN Git Service

Remove obstacks.
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / mkcheck.in
index 5dacf27..1050de2 100755 (executable)
@@ -1,7 +1,5 @@
 #!/usr/bin/env bash
 
-# 2000-05-17 bkoz 
-
 # Script to do automated testing and data collection
 # for various test files, so that we don't have to do this by hand on
 # every test file.  It attempts to collect some diagnostic info about
 # shared linkage.
 
 # Invocation 
-# mkcheck [01] (path to build) (path to src) (path to install)
-
-if [ $# != 3 ] && [ $# != 4 ]; then
-    echo 'Usage: mkcheck 0 (path to build) (path to src)'
-    echo '       mkcheck 1 (path to build) (path to src) (path to install)'
-    exit 1
-fi
-echo "running mkcheck"
+# mkcheck [012] (path to build) (path to src) (path to install)
 
 #
 # 1: variables
 #
-# WHICH determines if you are testing the installed binary and headers, or
-# the build binary and headers.
+# WHICH determines if you are
+# (0) testing the build binary and headers, or
+# (1) testing the installed binary and headers, or
+# (2) testing under dejagnu (just print the standard flags needed).
 WHICH=$1
-if [ $WHICH != "1" ]; then
-  WHICH=0
+if [ "$WHICH"x = 0x ] && [ $# -eq 3 ]; then
+  echo "running mkcheck"
   echo "$0: testing the build directory"
-elif [ $WHICH -eq 1 ]; then
-  echo "$0: testing the install directory $1"
+elif [ "$WHICH"x = 1x ] && [ $# -eq 4 ]; then
+  echo "running mkcheck"
+  echo "$0: testing the install directory $4"
+elif [ "$WHICH"x = 2x ] && [ $# -eq 3 ]; then
+  true
+else
+  echo 'Usage: mkcheck 0 (path to build) (path to src)'
+  echo '       mkcheck 1 (path to build) (path to src) (path to install)'
+  echo '       mkcheck 2 (path to build) (path to src)'
+  exit 1;
 fi
-
+  
 BUILD_DIR=$2
 if [ ! -d "$BUILD_DIR" ]; then
   echo "build directory $BUILD_DIR not found, exiting."
@@ -53,34 +54,41 @@ if [ $WHICH -eq 1 ]; then
 fi
 
 # INC_PATH == include path to new headers for use on gcc command-line
+C_DIR="`basename @C_INCLUDE_DIR@`"
 if [ $WHICH != "1" ]; then
-  INC_PATH="-I$BUILD_DIR -I$BUILD_DIR/libio -I$SRC_DIR/@ctype_include_dir@ -I$SRC_DIR/@cpu_include_dir@  -I$SRC_DIR/std -I$SRC_DIR -I$SRC_DIR/libio"
+  INC_PATH="@CSHADOW_FLAGS@ -I$BUILD_DIR -I$BUILD_DIR/libio \
+    -I$SRC_DIR/include/std  -I$SRC_DIR/include/$C_DIR \
+    -I$SRC_DIR/include -I$SRC_DIR/libsupc++/include -I$SRC_DIR/libio \
+    -I$SRC_DIR/testsuite"
 elif [ $WHICH -eq 1 ]; then
-  INC_PATH=""
+  INC_PATH="-I$SRC_DIR/testsuite"
+fi
+
+if [ $WHICH -eq 2 ]; then
+  echo $INC_PATH -I$SRC_DIR/backward -I$SRC_DIR/ext
+  exit 0;
 fi
 
 #LIB_PATH == where to find the build library binaries.
 if [ $WHICH != "1" ]; then
-  LIB_PATH="-L$BUILD_DIR/src/.libs"
-# BSD seems to want this
-#  LIB_PATH="-L$BUILD_DIR/src/.libs -R$BUILD_DIR/src/.libs"
-  CXX="../../gcc/g++ -B../../gcc/"
+  LIB_PATH="$BUILD_DIR/src/.libs"
+  CXX="../../gcc/g++"
+  CXX_BASE="-B../../gcc/"
 elif [ $WHICH -eq 1 ]; then
-  LIB_PATH="-L$PREFIX_DIR/lib"
-# BSD seems to want this
-#  LIB_PATH="-L$PREFIX_DIR/lib -R$PREFIX_DIR/lib"
+  LIB_PATH="$PREFIX_DIR/lib"
   CXX="$PREFIX_DIR/bin/g++"
+  CXX_BASE=""
 fi
 
 # gcc compiler flags
 #CXX_FLAG="-fsquangle -fhonor-std -fnew-exceptions -g -O2 -DDEBUG_ASSERT "
 #CXX_FLAG="-g -O2 -DDEBUG_ASSERT "
-CXX_FLAG="-g -DDEBUG_ASSERT "
+CXX_FLAG="-g $CXX_BASE -DDEBUG_ASSERT @SECTION_FLAGS@ @SECTION_LDFLAGS@"
 
-# a specific flag to force the use of shared libraries, if any
+# a specific flag(s) to force the use of shared libraries, if any
 SH_FLAG=""
 
-# a specific flag to force the use of static libraries, if any
+# a specific flag(s) to force the use of static libraries, if any
 ST_FLAG="-static"
 
 # Set up the testing directory, which should be in a directory called
@@ -139,10 +147,12 @@ rm -rf ./*core
 # Copy over the data files for filebufs in read-only mode
 cp $SRC_DIR/testsuite/27_io/*.txt $TEST_DIR
 cp $SRC_DIR/testsuite/27_io/*.tst $TEST_DIR
+chmod u+w $TEST_DIR/*.txt
+chmod u+w $TEST_DIR/*.tst
 
 # Emit useful info about compiler and platform
 echo "host: $(uname -mrsv)" >> $RESULTS_FILE
-echo "compiler: $($CXX --version)" >> $RESULTS_FILE
+echo "compiler: $($CXX -v 2>&1 | tail -1)" >> $RESULTS_FILE
 echo "compiler flags: $CXX_FLAG" >> $RESULTS_FILE
 echo "date: $(date +%Y%m%d)" >> $RESULTS_FILE
 echo "" >> $RESULTS_FILE
@@ -153,8 +163,8 @@ echo "etime == time for executable to run" >> $RESULTS_FILE
 echo "text == size of the executable text section" >> $RESULTS_FILE
 echo "data == size of the executable data section" >> $RESULTS_FILE
 echo "total == size of the executable" >> $RESULTS_FILE
-echo "(First static, then shared.)" >> $RESULTS_FILE
 echo "" >> $RESULTS_FILE
+echo "(First static, then shared.)" >> $RESULTS_FILE
 
 echo "p" | awk '{printf("%s ", $1)}' >> $RESULTS_FILE
 echo "ctime" "etime" | awk '{printf("%s\t%s\t", $1, $2)}' >> $RESULTS_FILE
@@ -171,10 +181,13 @@ test_file()
 {
     # NB: S_FLAG has to be last argument because it may be null, and
     # error checking hasn't been invented yet.
-    FILENAME=$1
+    NAME=$1
     EXENAME=$2
     S_FLAG=$3
 
+    SRC_NAME="$SRC_DIR/testsuite/$1"
+    TEST_NAME="$TEST_DIR/`basename $NAME`"
+
     # This would be deliciously easy if GNU date's %s were always around.
     # There are three ways to do this:  1) use the builtin 'time' like we
     # do later; then getting compiler errors into LOG_FILE is a nightmare.
@@ -183,8 +196,8 @@ test_file()
     # eventually have to calculate time_t anyhow.  Or 3) just grab two
     # time_t's (no more overhead than grabbing two date(1)'s).
     COMP_TIME_START=$($TEST_DIR/printnow)
-    $CXX $CXX_FLAG $S_FLAG $INC_PATH $LIB_PATH $FILENAME \
-        -o $EXENAME 2>> $LOG_FILE
+    $CXX $CXX_FLAG $S_FLAG $INC_PATH -L$LIB_PATH -Wl,--rpath -Wl,$LIB_PATH \
+         $SRC_NAME -o $EXENAME 2>> $LOG_FILE
     COMP_TIME_END=$($TEST_DIR/printnow)
 
     if [ $COMP_TIME_START -lt $COMP_TIME_END ]; then
@@ -256,7 +269,7 @@ test_file()
            # ls on MATCH, a pattern description generated with sed.
 
            # this is the name of the resulting diff file, if any
-           DIFF_FILE="`echo $PRE_NAME | sed 's/cc$/diff/'`"
+           DIFF_FILE="`echo $TEST_NAME | sed 's/cc$/diff/'`"
            # construct wildcard names,ie for $NAME=filebuf.cc, makes
            # "filebuf*.tst"
            DATA_FILES="`echo $NAME | sed 's/\.cc/\*\.tst/g'`"
@@ -286,15 +299,14 @@ test_file()
                    RESULT="+"
                fi
            fi
-       rm "$EXENAME"
        # sometimes you want to save all failing exe files for review:
-       #if [ "$RESULT" = "+" ]; then
-       #    rm "$EXENAME"
-       #fi
+       if [ "$RESULT" = "+" ]; then
+           rm "$EXENAME"
+       fi
     else
         # the file did not compile. Write out compilation info to the log file.
      echo "$CXX $CXX_FLAG $ST_FLAG $INC_PATH $LIB_PATH $CNAME -o $EXENAME" \
-        2>> $LOG_FILE
echo "$CXX $CXX_FLAG $S_FLAG $INC_PATH -L$LIB_PATH -Wl,--rpath -Wl,$LIB_PATH \
+         $SRC_NAME -o $EXENAME" 2>> $LOG_FILE
 
        RESULT="-"
        TEXT="0"
@@ -323,10 +335,9 @@ do
     PRE_NAME="$TEST_DIR/`basename $NAME`"
     ST_NAME="`echo $PRE_NAME | sed 's/cc$/st-exe/'`"
     SH_NAME="`echo $PRE_NAME | sed 's/cc$/sh-exe/'`"
-    CNAME="$SRC_DIR/testsuite/$NAME"
 
-    test_file $CNAME $ST_NAME $ST_FLAG 
-    test_file $CNAME $SH_NAME $SH_FLAG 
+    test_file $NAME $ST_NAME $ST_FLAG 
+    test_file $NAME $SH_NAME $SH_FLAG 
     echo "$NAME" | awk '{printf("%s\n", $1)}'
 
     echo "" >> $RESULTS_FILE
@@ -351,6 +362,7 @@ mv ${RESULTS_FILE}.tmp $RESULTS_FILE
 if [ $TEST_TIME_START -lt $TEST_TIME_END ]; then
     TEST_TIME=$[ $TEST_TIME_END - $TEST_TIME_START ]
     echo "testrun == $TEST_TIME"
+    echo "testrun == $TEST_TIME" >> $RESULTS_FILE
 fi
 
 exit 0