Adds checks to 1.3->2.0 API migration script
diff --git a/scripts/rename.pl b/scripts/rename.pl
index c169078..c29519e 100755
--- a/scripts/rename.pl
+++ b/scripts/rename.pl
@@ -1,12 +1,25 @@
 #!/usr/bin/perl
-
-# rename identifiers (functions, types, enum constant, etc)
-# on upgrades of major version according to a list
+#
+# This file is part of mbed TLS (https://tls.mbed.org)
+#
+# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
+#
+# Purpose
+#
+# This script migrates application source code from the mbed TLS 1.3 API to the
+# mbed TLS 2.0 API.
+#
+# The script processes the given source code and renames identifiers - functions
+# types, enums etc, as
+#
+# Usage:  rename.pl [-f datafile] [-s] [--] [filenames...]
+#
 
 use warnings;
 use strict;
 
 use utf8;
+use Path::Class;
 use open qw(:std utf8);
 
 my $usage = "Usage: $0 [-f datafile] [-s] [--] [filenames...]\n";
@@ -45,15 +58,28 @@
 my $idnum = qr/[a-zA-Z0-9_]+/;
 my $symbols = qr/[-!#\$%&'()*+,.\/:;<=>?@[\\\]^_`{|}~]+|"/;
 
+my $lib_include_dir = dir($0)->parent->parent->subdir('include', 'mbedtls');
+my $lib_source_dir = dir($0)->parent->parent->subdir('library');
+
 # if we replace inside strings, we don't consider them a token
 my $token = $do_strings ?         qr/$space|$idnum|$symbols/
                         : qr/$string|$space|$idnum|$symbols/;
 
 my %warnings;
 
+# If no files were passed, exit...
+if ( not defined($ARGV[0]) ){ die $usage; }
+
 while( my $filename = shift )
 {
     print STDERR "$filename... ";
+
+    if( dir($filename)->parent eq $lib_include_dir ||
+         dir($filename)->parent eq $lib_source_dir )
+    {
+        die "Script cannot be executed on the mbed TLS library itself.";
+    }
+
     if( -d $filename ) { print STDERR "skip (directory)\n"; next }
 
     open my $rfh, '<', $filename or die;