Remove vpath usage in makefiles

Remove all usage of the vpath keyword in makefiles as it was prone
to mistakes. Specify the relative paths to source files instead.

Also reorder source files in makefiles alphabetically.

Fixes ARM-software/tf-issues#121

Change-Id: Id15f60655444bae60e0e2165259efac71a50928b
diff --git a/Makefile b/Makefile
index 23ab010..3064aa4 100644
--- a/Makefile
+++ b/Makefile
@@ -59,14 +59,14 @@
 	BUILD_TYPE	:=	release
 endif
 
-BL_COMMON_SOURCES	:=	misc_helpers.S		\
-				cache_helpers.S		\
-				tlb_helpers.S		\
-				xlat_helpers.c		\
-				std.c			\
-				bl_common.c		\
-				platform_helpers.S	\
-				io_storage.c
+BL_COMMON_SOURCES	:=	common/bl_common.c			\
+				lib/aarch64/cache_helpers.S		\
+				lib/aarch64/misc_helpers.S		\
+				lib/aarch64/tlb_helpers.S		\
+				lib/aarch64/xlat_helpers.c		\
+				lib/stdlib/std.c			\
+				lib/io_storage.c			\
+				plat/common/aarch64/platform_helpers.S
 
 ARCH 			?=	aarch64
 
@@ -161,13 +161,6 @@
 LDFLAGS			+=	--gc-sections
 
 
-vpath %.ld.S bl1:bl2:bl31
-vpath %.c bl1:bl2:bl31
-vpath %.c bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH}
-vpath %.S bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH}
-vpath %.c lib/arch/${ARCH} # One of the missing paths needed for BL_COMMON_SOURCES
-
-
 ifneq (${DEBUG}, 0)
 #CFLAGS			+= 	-g -O0
 CFLAGS			+= 	-g
diff --git a/bl1/bl1.mk b/bl1/bl1.mk
index 60609ea..032dc5e 100644
--- a/bl1/bl1.mk
+++ b/bl1/bl1.mk
@@ -28,22 +28,10 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
-vpath			%.c	plat/${PLAT}		\
-				plat/${PLAT}/${ARCH}	\
-				common			\
-				lib			\
-				lib/${ARCH}		\
-				${PLAT_BL1_C_VPATH}
-
-vpath			%.S	plat/common/${ARCH}	\
-				plat/${PLAT}/${ARCH}	\
-				lib/${ARCH}		\
-				${PLAT_BL1_S_VPATH}
-
-BL1_SOURCES		+=	bl1_arch_setup.c	\
-				bl1_entrypoint.S	\
-				bl1_exceptions.S	\
-				bl1_main.c		\
-				cpu_helpers.S
+BL1_SOURCES		+=	bl1/bl1_main.c				\
+				bl1/aarch64/bl1_arch_setup.c		\
+				bl1/aarch64/bl1_entrypoint.S		\
+				bl1/aarch64/bl1_exceptions.S		\
+				lib/aarch64/cpu_helpers.S
 
-BL1_LINKERFILE		:=	bl1.ld.S
+BL1_LINKERFILE		:=	bl1/bl1.ld.S
diff --git a/bl2/bl2.mk b/bl2/bl2.mk
index 3ecaff9..1e82078 100644
--- a/bl2/bl2.mk
+++ b/bl2/bl2.mk
@@ -28,23 +28,10 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
-vpath			%.c	common				\
-				lib				\
-				plat/${PLAT}			\
-				plat/${PLAT}/${ARCH}		\
-				${PLAT_BL2_C_VPATH}
-
-vpath			%.S	lib/${ARCH}			\
-				lib/locks/exclusive		\
-				common/${ARCH}			\
-				${PLAT_BL2_S_VPATH}
-
-BL2_SOURCES		+=	bl2_entrypoint.S		\
-				bl2_arch_setup.c		\
-				bl2_main.c			\
-				spinlock.S			\
-				early_exceptions.S
-
-BL2_LINKERFILE		:=	bl2.ld.S
+BL2_SOURCES		+=	bl2/bl2_main.c				\
+				bl2/aarch64/bl2_entrypoint.S		\
+				bl2/aarch64/bl2_arch_setup.c		\
+				common/aarch64/early_exceptions.S	\
+				lib/locks/exclusive/spinlock.S
 
-CFLAGS			+=	$(DEFINES)
+BL2_LINKERFILE		:=	bl2/bl2.ld.S
diff --git a/bl31/bl31.mk b/bl31/bl31.mk
index 420597c..ef40f67 100644
--- a/bl31/bl31.mk
+++ b/bl31/bl31.mk
@@ -28,44 +28,23 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
-vpath			%.c	common					\
-				lib					\
-				drivers/arm/gic				\
-				plat/${PLAT}				\
-				services/std_svc			\
-				services/std_svc/psci			\
-				lib/locks/bakery			\
-				plat/${PLAT}/${ARCH}			\
-				${PLAT_BL31_C_VPATH}
-
-vpath			%.S	lib/${ARCH}				\
-				services/std_svc			\
-				services/std_svc/psci			\
-				plat/${PLAT}/${ARCH}			\
-				lib/locks/exclusive			\
-				plat/common/${ARCH}			\
-				drivers/arm/gic/${ARCH}			\
-				common/${ARCH}				\
-				${PLAT_BL31_S_VPATH}
-
-BL31_SOURCES		+=	bl31_arch_setup.c			\
-				bl31_entrypoint.S			\
-				runtime_exceptions.S			\
-				bl31_main.c				\
-				std_svc_setup.c				\
-				psci_entry.S				\
-				psci_setup.c				\
-				psci_common.c				\
-				psci_afflvl_on.c			\
-				psci_main.c				\
-				psci_afflvl_off.c			\
-				psci_afflvl_suspend.c			\
-				spinlock.S				\
-				gic_v3_sysregs.S			\
-				bakery_lock.c				\
-				runtime_svc.c				\
-				early_exceptions.S			\
-				context_mgmt.c				\
-				context.S
+BL31_SOURCES		+=	bl31/bl31_main.c				\
+				bl31/context_mgmt.c				\
+				bl31/runtime_svc.c				\
+				bl31/aarch64/bl31_arch_setup.c			\
+				bl31/aarch64/bl31_entrypoint.S			\
+				bl31/aarch64/context.S				\
+				bl31/aarch64/runtime_exceptions.S		\
+				common/aarch64/early_exceptions.S		\
+				lib/locks/bakery/bakery_lock.c			\
+				lib/locks/exclusive/spinlock.S			\
+				services/std_svc/std_svc_setup.c		\
+				services/std_svc/psci/psci_afflvl_off.c		\
+				services/std_svc/psci/psci_afflvl_on.c		\
+				services/std_svc/psci/psci_afflvl_suspend.c	\
+				services/std_svc/psci/psci_common.c		\
+				services/std_svc/psci/psci_entry.S		\
+				services/std_svc/psci/psci_main.c		\
+				services/std_svc/psci/psci_setup.c
 
-BL31_LINKERFILE		:=	bl31.ld.S
+BL31_LINKERFILE		:=	bl31/bl31.ld.S
diff --git a/bl32/tsp/tsp-fvp.mk b/bl32/tsp/tsp-fvp.mk
index 02fae09..3bcf439 100644
--- a/bl32/tsp/tsp-fvp.mk
+++ b/bl32/tsp/tsp-fvp.mk
@@ -28,11 +28,7 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
-
-vpath			%.c	${PLAT_BL2_C_VPATH}
-vpath			%.S	${PLAT_BL2_S_VPATH}
-
 # TSP source files specific to FVP platform
-BL32_SOURCES		+=	bl32_plat_setup.c			\
-				platform_mp_stack.S			\
-				plat_common.c
+BL32_SOURCES		+=	plat/common/aarch64/platform_mp_stack.S		\
+				plat/fvp/bl32_plat_setup.c			\
+				plat/fvp/aarch64/plat_common.c
diff --git a/bl32/tsp/tsp.mk b/bl32/tsp/tsp.mk
index d07b18b..c478b43 100644
--- a/bl32/tsp/tsp.mk
+++ b/bl32/tsp/tsp.mk
@@ -28,27 +28,13 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
-vpath			%.c	common				\
-				lib				\
-				plat/${PLAT}			\
-				plat/${PLAT}/${ARCH}		\
-
-vpath			%.S	lib/${ARCH}			\
-				lib/locks/exclusive		\
-				common/${ARCH}
-
-BL32_SOURCES		+=	tsp_entrypoint.S		\
-				tsp_main.c			\
-				tsp_request.S			\
-				spinlock.S			\
-				early_exceptions.S
-
-BL32_LINKERFILE		:=	tsp.ld.S
+BL32_SOURCES		+=	bl32/tsp/tsp_main.c			\
+				bl32/tsp/aarch64/tsp_entrypoint.S	\
+				bl32/tsp/aarch64/tsp_request.S		\
+				common/aarch64/early_exceptions.S	\
+				lib/locks/exclusive/spinlock.S
 
-vpath %.ld.S ${BL32_ROOT}
-vpath %.c ${BL32_ROOT}
-vpath %.c ${BL32_ROOT}/${ARCH}
-vpath %.S ${BL32_ROOT}/${ARCH}
+BL32_LINKERFILE		:=	bl32/tsp/tsp.ld.S
 
 # Include the platform-specific TSP Makefile
 # If no platform-specific TSP Makefile exists, it means TSP is not supported
diff --git a/plat/fvp/platform.mk b/plat/fvp/platform.mk
index f55000d..ea72a31 100644
--- a/plat/fvp/platform.mk
+++ b/plat/fvp/platform.mk
@@ -33,68 +33,40 @@
 #
 # PLAT_INCLUDES		:=
 
-PLAT_BL1_C_VPATH	:=	drivers/arm/cci400			\
-				drivers/arm/pl011			\
-				lib/${ARCH}				\
-				lib/semihosting				\
-				lib/stdlib				\
-				drivers/io
+PLAT_BL_COMMON_SOURCES	:=	drivers/arm/pl011/pl011.c			\
+				drivers/arm/pl011/pl011_console.c		\
+				drivers/io/io_fip.c				\
+				drivers/io/io_memmap.c				\
+				drivers/io/io_semihosting.c			\
+				lib/mmio.c					\
+				lib/aarch64/sysreg_helpers.S		\
+				lib/aarch64/xlat_tables.c			\
+				lib/semihosting/semihosting.c			\
+				lib/semihosting/aarch64/semihosting_call.S	\
+				plat/fvp/plat_io_storage.c
 
-PLAT_BL1_S_VPATH	:=	lib/semihosting/${ARCH}
+BL1_SOURCES		+=	drivers/arm/cci400/cci400.c			\
+				plat/common/aarch64/platform_up_stack.S		\
+				plat/fvp/bl1_plat_setup.c			\
+				plat/fvp/aarch64/bl1_plat_helpers.S		\
+				plat/fvp/aarch64/plat_common.c			\
+				plat/fvp/aarch64/plat_helpers.S
 
-PLAT_BL2_C_VPATH	:=	drivers/arm/cci400			\
-				drivers/arm/pl011			\
-				drivers/arm/tzc400			\
-				lib/${ARCH}				\
-				lib/stdlib				\
-				lib/semihosting				\
-				drivers/io
-
-PLAT_BL2_S_VPATH	:=	lib/semihosting/${ARCH}
-
-PLAT_BL31_C_VPATH	:=	drivers/arm/cci-400			\
-				drivers/arm/pl011			\
-				lib/${ARCH}				\
-				lib/semihosting				\
-				lib/stdlib				\
-				drivers/io				\
-				plat/fvp/drivers/pwrc
-
-PLAT_BL31_S_VPATH	:=	lib/semihosting/${ARCH}
-
-PLAT_BL_COMMON_SOURCES	:=	semihosting_call.S			\
-				mmio.c					\
-				pl011_console.c				\
-				pl011.c					\
-				semihosting.c				\
-				sysreg_helpers.S			\
-				plat_io_storage.c			\
-				io_semihosting.c			\
-				io_fip.c				\
-				io_memmap.c				\
-				xlat_tables.c
-
-BL1_SOURCES		+=	bl1_plat_setup.c			\
-				bl1_plat_helpers.S			\
-				plat_helpers.S				\
-				platform_up_stack.S			\
-				plat_common.c				\
-				cci400.c
-
-BL2_SOURCES		+=	bl2_plat_setup.c			\
-				platform_up_stack.S			\
-				plat_common.c				\
-				plat_security.c				\
-				tzc400.c
+BL2_SOURCES		+=	drivers/arm/tzc400/tzc400.c			\
+				plat/common/aarch64/platform_up_stack.S		\
+				plat/fvp/bl2_plat_setup.c			\
+				plat/fvp/plat_security.c			\
+				plat/fvp/aarch64/plat_common.c
 
-BL31_SOURCES		+=	bl31_plat_setup.c			\
-				plat_helpers.S				\
-				platform_mp_stack.S			\
-				plat_common.c				\
-				plat_pm.c				\
-				plat_topology.c				\
-				plat_gic.c				\
-				fvp_pwrc.c				\
-				cci400.c				\
-				gic_v2.c				\
-				gic_v3.c
+BL31_SOURCES		+=	drivers/arm/gic/gic_v2.c			\
+				drivers/arm/gic/gic_v3.c			\
+				drivers/arm/gic/aarch64/gic_v3_sysregs.S	\
+				drivers/arm/cci400/cci400.c			\
+				plat/common/aarch64/platform_mp_stack.S		\
+				plat/fvp/bl31_plat_setup.c			\
+				plat/fvp/plat_gic.c				\
+				plat/fvp/plat_pm.c				\
+				plat/fvp/plat_topology.c			\
+				plat/fvp/aarch64/plat_helpers.S			\
+				plat/fvp/aarch64/plat_common.c			\
+				plat/fvp/drivers/pwrc/fvp_pwrc.c
diff --git a/services/spd/tspd/tspd.mk b/services/spd/tspd/tspd.mk
index 02446a3..a32f4c4 100644
--- a/services/spd/tspd/tspd.mk
+++ b/services/spd/tspd/tspd.mk
@@ -31,13 +31,10 @@
 TSPD_DIR		:=	services/spd/tspd
 SPD_INCLUDES		:=	-Iinclude/bl32/payloads
 
-SPD_SOURCES		:=	tspd_common.c		\
-				tspd_main.c		\
-				tspd_pm.c		\
-				tspd_helpers.S
-
-vpath %.c ${TSPD_DIR}
-vpath %.S ${TSPD_DIR}
+SPD_SOURCES		:=	services/spd/tspd/tspd_common.c		\
+				services/spd/tspd/tspd_helpers.S	\
+				services/spd/tspd/tspd_main.c		\
+				services/spd/tspd/tspd_pm.c
 
 # This dispatcher is paired with a Test Secure Payload source and we intend to
 # build the Test Secure Payload along with this dispatcher.