1#!/bin/bash
2#
3# NAME:
4#         divergence.sh - find divergences between Linux and ACPICA
5#
6# SYNOPSIS:
7#         divergence.sh [-s] <path>
8#
9# DESCRIPTION:
10#         Find the divergences between these sets of source code:
11#          1) The current ACPICA source from the ACPICA git tree
12#          2) The version of ACPICA that is integrated into Linux
13#         The goal is to eliminate as many differences as possible between
14#         these two sets of code.
15#         Parameters:
16#          path     Path of directory to the Linux source tree.
17#         Options:
18#          -s       Single direction
19#                   (indent on Linux rather than both of Linux and ACPICA)
20#
21
22usage()
23{
24	echo "Usage: `basename $0` [-s] <path>"
25	echo "Where:"
26	echo "  -s: indent on (Linux) rather than on (Linux and ACPICA)"
27	echo "  path is path to root of Linux source code."
28	exit 1
29}
30
31while getopts "s" opt
32do
33	case $opt in
34	s) LINDENT_DIR=single;;
35	?) echo "Invalid argument $opt"
36	   usage;;
37	esac
38done
39shift $(($OPTIND - 1))
40
41SCRIPT=`(cd \`dirname $0\`; pwd)`
42. $SCRIPT/libacpica.sh
43
44LINUX_ACPICA=$CURDIR/linux-acpica
45ACPICA_LINUXIZED=$CURDIR/acpica-linuxized
46LINUX=`fulldir $1`
47
48# Parameter validation
49
50if [ -z $1 ] ; then
51	echo "Usage: $0 <Linux>"
52	echo "  Linux: Path of Linux source"
53	exit 1
54fi
55if [ ! -e $1 ] ; then
56	echo "$1, Linux source directory does not exist"
57	exit 1
58fi
59if [ ! -d $1 ] ; then
60	echo "$1, Not a directory"
61	exit 1
62fi
63
64if [ -z $LINDENT_DIR ] ; then
65	LINDENT_DIR=multiple
66fi
67
68echo "[divergence.sh] Generating tool (acpisrc)..."
69make_acpisrc $SRCDIR force > /dev/null
70
71#
72# Copy the actual Linux ACPICA files locally (from the Linux tree)
73#
74echo "[divergence.sh] Converting hierarchy..."
75copy_linux_hierarchy $LINUX $LINUX_ACPICA
76linuxize_hierarchy_ref $LINUX_ACPICA $SRCDIR $ACPICA_LINUXIZED
77
78#
79# Lindent both sets of files
80#
81echo "[divergence.sh] Converting format (lindent-acpica)..."
82linuxize_format $ACPICA_LINUXIZED
83
84if [ "x$LINDENT_DIR" = "xmultiple" ] ; then
85	echo "[divergence.sh] Converting format (lindent-linux)..."
86	lindent $LINUX_ACPICA
87fi
88
89#
90# Now we can finally do the big diff
91#
92echo "[divergence.sh] Generating divergences ($LINDENT_DIR)..."
93diff -E -b -w -B -rpuN linux-acpica acpica-linuxized > divergence-$LINDENT_DIR.diff
94diffstat divergence-$LINDENT_DIR.diff > diffstat-$LINDENT_DIR.txt
95echo "=========="
96ls -s1 divergence-$LINDENT_DIR.diff diffstat-$LINDENT_DIR.txt
97echo "=========="
98
99#
100# Cleanup
101#
102rm -rf $LINUX_ACPICA
103rm -rf $ACPICA_LINUXIZED
104