common/bin/difflib.sh
author mullan
Mon, 10 Sep 2012 08:57:51 -0400
changeset 13791 059978b7e438
parent 13132 bd88bb8dd3af
permissions -rw-r--r--
7195301: XML Signature DOM implementation should not use instanceof to determine type of Node Reviewed-by: xuelei
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     1
#!/bin/bash
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     2
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     3
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     4
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     5
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     6
# This code is free software; you can redistribute it and/or modify it
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     7
# under the terms of the GNU General Public License version 2 only, as
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     8
# published by the Free Software Foundation.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     9
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    10
# This code is distributed in the hope that it will be useful, but WITHOUT
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    12
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    13
# version 2 for more details (a copy is included in the LICENSE file that
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    14
# accompanied this code).
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    15
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    16
# You should have received a copy of the GNU General Public License version
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    17
# 2 along with this work; if not, write to the Free Software Foundation,
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    18
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    19
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    20
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    21
# or visit www.oracle.com if you need additional information or have any
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    22
# questions.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    23
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    24
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    25
# Simple tool to diff two shared libraries. 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    26
# Criterias: two shared libraries are considered equal if:
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    27
# the file sizes are the same AND the symbols outputs from the nm command are equal
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    28
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    29
if [ $# -lt 2 ] 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    30
then
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    31
  echo "Diff two shared libs. Return codes:"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    32
  echo "0 - no diff"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    33
  echo "1 - Identical symbols AND size, BUT not bytewise identical"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    34
  echo "2 - Identical symbols BUT NEW size"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    35
  echo "3 - Differences, content BUT SAME size"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    36
  echo "4 - Differences, content AND size"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    37
  echo "10 - Could not perform diff"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    38
  echo "Use 'quiet' to disable any output."
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    39
  echo "Syntax: $0 file1 file2 [quiet]"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    40
  exit 10
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    41
fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    42
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    43
if [ ! -f $1 ]
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    44
then
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    45
  echo $1 does not exist
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    46
  exit 10
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    47
fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    48
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    49
if [ ! -f $2 ]
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    50
then
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    51
  echo $2 does not exist
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    52
  exit 10
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    53
fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    54
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    55
if [ "`uname`" == "SunOS" ]; then
13132
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    56
    if [ -f "`which gnm`" ]; then
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    57
        NM=gnm
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    58
# Jonas 2012-05-29: solaris native nm produces radically different output than gnm
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    59
#                   so if using that...we need different filter than "cut -f 2-"
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    60
#
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    61
    elif [ -f "`which nm`" ]; then
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    62
        NM=nm
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    63
    else
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    64
        echo "No nm command found"
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    65
        exit 10
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    66
    fi
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
    67
    LDD=ldd
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    68
elif [ $OSTYPE == "cygwin" ]; then
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    69
    NM="$VS100COMNTOOLS/../../VC/bin/amd64/dumpbin.exe"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    70
    NM_ARGS=/exports
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
    71
    LDD=
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
    72
elif [ "`uname`" == "Darwin" ]; then
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
    73
    NM=nm
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
    74
    LDD="otool -L"
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    75
else
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    76
    NM=nm
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
    77
    LDD=ldd
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    78
fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    79
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    80
# Should the differences be viewed?
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    81
VIEW=
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    82
# You can do export DIFF=meld to view
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    83
# any differences using meld instead.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    84
if [ -n "$DIFF" ]; then
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    85
    DIFF="$DIFF"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    86
else
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    87
    DIFF=diff
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    88
fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    89
OLD=$(cd $(dirname $1) && pwd)/$(basename $1)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    90
NEW=$(cd $(dirname $2) && pwd)/$(basename $2)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    91
13132
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    92
OLD_SIZE=$(ls -l "$OLD" | awk '{ print $5 }')
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
    93
NEW_SIZE=$(ls -l "$NEW" | awk '{ print $5 }')
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    94
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    95
if [ $# -gt 3 ]
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    96
then
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    97
    ROOT1=$(cd $3 && pwd)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    98
    ROOT2=$(cd $4 && pwd)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    99
    OLD_NAME=$(echo $OLD | sed "s|$ROOT1/||")
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   100
    NEW_NAME=$(echo $NEW | sed "s|$ROOT2/||")
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   101
    if [ "x$5" == "xview" ]; then VIEW=view; fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   102
else
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   103
    ROOT1=$(dirname $OLD)/
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   104
    ROOT2=$(dirname $NEW)/
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   105
    OLD_NAME=$OLD
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   106
    NEW_NAME=$NEW
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   107
    if [ "x$3" == "xview" ]; then VIEW=view; fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   108
fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   109
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   110
OLD_SUFFIX="${OLD##*.}"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   111
NEW_SUFFIX="${NEW##*.}"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   112
if [ "$OLD_SUFFIX" != "$NEW_SUFFIX" ]; then
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   113
    echo The files do not have the same suffix type!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   114
    exit 10
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   115
fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   116
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   117
if [ "$OLD_SUFFIX" != "so" ] && [ "$OLD_SUFFIX" != "dylib" ] && [ "$OLD_SUFFIX" != "dll" ]; then
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   118
    echo The files have to be .so, .dylib or .dll! They are $OLD_SUFFIX
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   119
    exit 10
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   120
fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   121
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   122
TYPE="$OLD_SUFFIX"
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   123
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   124
if cmp $OLD $NEW > /dev/null
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   125
then
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   126
    # The files were bytewise identical.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   127
    echo Identical: $OLD_NAME
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   128
    exit 0
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   129
fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   130
13132
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
   131
OLD_SYMBOLS=$COMPARE_ROOT/nm.$OLD_NAME.old
bd88bb8dd3af 7181504: Update of latest build-infra Makefiles
erikj
parents: 12801
diff changeset
   132
NEW_SYMBOLS=$COMPARE_ROOT/nm.$NEW_NAME.new
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   133
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   134
mkdir -p $(dirname $OLD_SYMBOLS)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   135
mkdir -p $(dirname $NEW_SYMBOLS)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   136
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   137
if [ $OSTYPE == "cygwin" ]; then
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   138
    "$NM" $NM_ARGS $OLD | grep " = " > $OLD_SYMBOLS
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   139
    "$NM" $NM_ARGS $NEW | grep " = " > $NEW_SYMBOLS
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   140
    "$NM" $NM_ARGS $OLD > $OLD_SYMBOLS.full
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   141
    "$NM" $NM_ARGS $NEW > $NEW_SYMBOLS.full
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   142
else
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   143
    # Strip the addresses, just compare the ordering of the symbols.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   144
    $NM $OLD | cut -f 2- -d ' ' > $OLD_SYMBOLS
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   145
    $NM $NEW | cut -f 2- -d ' ' > $NEW_SYMBOLS
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   146
    # But store the full information for easy diff access.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   147
    $NM $OLD  > $OLD_SYMBOLS.full
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   148
    $NM $NEW  > $NEW_SYMBOLS.full
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   149
fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   150
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   151
DIFFS=$(LANG=C diff $OLD_SYMBOLS $NEW_SYMBOLS)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   152
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   153
RESULT=0
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   154
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   155
if [ "${LDD}" ]
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   156
then
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   157
    NAME=`basename $OLD`
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   158
    TMP=$COMPARE_ROOT/ldd/ldd.${NAME}
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   159
    rm -rf "${TMP}"
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   160
    mkdir -p "${TMP}"
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   161
    
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   162
    (cd "${TMP}" && cp $OLD . && ${LDD} ${NAME} | awk '{ print $1;}' | sort | tee dep.old | uniq > dep.uniq.old)
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   163
    (cd "${TMP}" && cp $NEW . && ${LDD} ${NAME} | awk '{ print $1;}' | sort | tee dep.new | uniq > dep.uniq.new)
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   164
    (cd "${TMP}" && rm -f ${NAME})
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   165
    
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   166
    DIFFS_DEP=$(LANG=C diff "${TMP}/dep.old" "${TMP}/dep.new")
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   167
    DIFFS_UNIQ_DEP=$(LANG=C diff "${TMP}/dep.uniq.old" "${TMP}/dep.uniq.new")
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   168
    
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   169
    DEP_MSG=
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   170
    if [ -z "${DIFFS_UNIQ_DEP}" -a -z "${DIFFS_DEP}" ]; then
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   171
       DEP_MSG="Identical dependencies"
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   172
    elif [ -z "${DIFFS_UNIQ_DEP}" ]; then
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   173
       DEP_MSG="Redundant duplicate dependencies added"
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   174
       RES=1
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   175
    else
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   176
       DEP_MSG="DIFFERENT dependencies"
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   177
       RES=1
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   178
    fi
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   179
fi
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   180
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   181
if [ -n "$DIFFS" ]; then
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   182
   if [ $OLD_SIZE -ne $NEW_SIZE ]
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   183
   then
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   184
       echo Differences, content AND size     : $DEP_MSG : $OLD_NAME 
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   185
       RESULT=4
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   186
   else
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   187
       echo Differences, content BUT SAME size: $DEP_MSG : $OLD_NAME 
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   188
       RESULT=3
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   189
   fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   190
   if [ "x$VIEW" == "xview" ]; then
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   191
       LANG=C $DIFF $OLD_SYMBOLS $NEW_SYMBOLS
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   192
   fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   193
else
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   194
   if [ $OLD_SIZE -ne $NEW_SIZE ]
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   195
   then
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   196
       echo Identical symbols BUT NEW size    : $DEP_MSG : $OLD_NAME 
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   197
       RESULT=2
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   198
   else
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   199
       echo Identical symbols AND size, BUT not bytewise identical: $DEP_MSG : $OLD_NAME 
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   200
       RESULT=1
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   201
   fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   202
fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   203
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   204
exit $RESULT
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   205
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   206
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   207