# $Id: $
# This Makefile will call all subdir makefiles.
# This is the only checked in Makefile, all others get generated via rules.mk.

# SOC_PATH must be defined in your shell environment.
# Include ordering scheme must be as follows:
# all_paths.mk, paths.mk, defs.mk, subdirs.mk, filelist.mk, rules.mk 
# (above optional and only need to be created if needed for the Makefile)

############################
#Error Checking
############################
# The following makes certain the user invokes the correct make. 
# It got quite tiresome to debug this time and again, thus the check here. New
# version of make will require updating this.
ifneq ($(MAKE_VERSION),3.81)
  $(error You probably are aliasing make to an older version, your make is: $(MAKE_VERSION), unalias make.)
endif

# The following makes certain the user set SOC_PATH to "something".
MY_SOC_PATH := $(shell pwd)
ifdef SOC_PATH
  $(info "YOUR SOC_PATH is   <$(SOC_PATH)>")
  $(info "YOU are working in <$(MY_SOC_PATH)>")
else
  $(error SOC_PATH environment variable must be set to the root of your working directory.)
endif

# Now begin including various .mk files. These files get generated if they
# don't already exist.
# Global defs for use by all makefiles unless overridden.

-include $(SOC_PATH)/all_paths.mk
include $(SOC_PATH)/paths.mk

-include $(SOC_PATH)/all_paths_2.mk
-include $(SOC_PATH)/paths_2.mk

# Checked in.
-include $(SOC_PATH)/defs_2.mk

# List of subdirs that have make files that need to be called.
-include ./subdirs_2.mk

# List of files that need to be compiled.
ifeq (exists, $(shell [ -e $(SOC_PATH)/filelist_2.mk ] && echo exists ))
  -include ./filelist_2.mk
endif

# Global rules for use by all makefiles unless overridden.
-include $(SOC_PATH)/rules_2.mk

# If building in ${SOC_PATH}, try to include installation routines.
ifeq (${CURDIR},${SOC_PATH})
  -include ./install_2.mk
endif
