Fix order of #includes

This fix modifies the order of system includes to meet the ARM TF coding
standard. There are some exceptions in order to retain header groupings,
minimise changes to imported headers, and where there are headers within
the #if and #ifndef statements.

Change-Id: I65085a142ba6a83792b26efb47df1329153f1624
Signed-off-by: Isla Mitchell <isla.mitchell@arm.com>
diff --git a/tools/cert_create/include/ext.h b/tools/cert_create/include/ext.h
index 2aa17e2..d432e63 100644
--- a/tools/cert_create/include/ext.h
+++ b/tools/cert_create/include/ext.h
@@ -7,8 +7,8 @@
 #ifndef EXT_H_
 #define EXT_H_
 
-#include "key.h"
 #include <openssl/x509v3.h>
+#include "key.h"
 
 /* Extension types supported */
 enum ext_type_e {
diff --git a/tools/cert_create/src/cmd_opt.c b/tools/cert_create/src/cmd_opt.c
index 0d47872..64180d1 100644
--- a/tools/cert_create/src/cmd_opt.c
+++ b/tools/cert_create/src/cmd_opt.c
@@ -5,10 +5,10 @@
  */
 
 #include <assert.h>
+#include <cmd_opt.h>
 #include <getopt.h>
 #include <stddef.h>
 #include <stdlib.h>
-#include <cmd_opt.h>
 #include "debug.h"
 
 /* Command line options */
diff --git a/tools/cert_create/src/main.c b/tools/cert_create/src/main.c
index 9923637..f14601c 100644
--- a/tools/cert_create/src/main.c
+++ b/tools/cert_create/src/main.c
@@ -30,8 +30,8 @@
 #include "ext.h"
 #include "key.h"
 #include "sha.h"
-#include "tbbr/tbb_ext.h"
 #include "tbbr/tbb_cert.h"
+#include "tbbr/tbb_ext.h"
 #include "tbbr/tbb_key.h"
 
 /*
diff --git a/tools/cert_create/src/sha.c b/tools/cert_create/src/sha.c
index 5d5e9e2..2971593 100644
--- a/tools/cert_create/src/sha.c
+++ b/tools/cert_create/src/sha.c
@@ -4,8 +4,8 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include <stdio.h>
 #include <openssl/sha.h>
+#include <stdio.h>
 
 #include "debug.h"
 
diff --git a/tools/fiptool/fiptool.c b/tools/fiptool/fiptool.c
index 4d80f2f..65e4a25 100644
--- a/tools/fiptool/fiptool.c
+++ b/tools/fiptool/fiptool.c
@@ -19,7 +19,6 @@
 #include <unistd.h>
 
 #include <openssl/sha.h>
-
 #include <firmware_image_package.h>
 
 #include "fiptool.h"
diff --git a/tools/fiptool/fiptool.h b/tools/fiptool/fiptool.h
index 4b5cdd9..889b0fd 100644
--- a/tools/fiptool/fiptool.h
+++ b/tools/fiptool/fiptool.h
@@ -7,10 +7,11 @@
 #ifndef __FIPTOOL_H__
 #define __FIPTOOL_H__
 
+#include <firmware_image_package.h>
+
 #include <stddef.h>
 #include <stdint.h>
 
-#include <firmware_image_package.h>
 #include <uuid.h>
 
 #define NELEM(x) (sizeof (x) / sizeof *(x))
diff --git a/tools/fiptool/tbbr_config.c b/tools/fiptool/tbbr_config.c
index 7c6c24b..6231cd4 100644
--- a/tools/fiptool/tbbr_config.c
+++ b/tools/fiptool/tbbr_config.c
@@ -4,9 +4,8 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include <stddef.h>
-
 #include <firmware_image_package.h>
+#include <stddef.h>
 
 #include "tbbr_config.h"