#
# Makefile for Unix targets
#
# $Revision$
#


# we set a check here to see if ADK_SRC has been defined. If it has not, then
# print an error, otherwise continue.
ifeq (x$(ADK_SRC),x)
$(MAKECMDGOALS):
	@echo 
	@echo "The environment variable ADK_SRC has not been set"
	@echo 

else # ifdef ADK_SRC
# Now that we know ADK_SRC is defined, we can run the makefile


.NOTPARALLEL:

include $(ADK_SRC)/make.env

# code is run before the SUBDIRS, see below
SUBDIRS=  adk_samples utils adk_dp_app

export PKG

all: release

last_build_debug:
	$(MAKE) clean
	if [ -f $(ADK_CODE)/config/adk_haswell_rtc.cfg ]; then \
		mkdir -p $(ADK_LIBDIR); \
		cp -f $(ADK_CODE)/config/adk_haswell_rtc.cfg $(ADK_LIBDIR); \
	fi
	if [ -f $(ADK_CODE)/config/adk_release_id.h ]; then \
		mkdir -p $(ADK_INS_INCDIR); \
		cp -f $(ADK_CODE)/config/adk_release_id.h $(ADK_INS_INCDIR); \
	fi
	@touch last_build_debug

last_build_release:
	$(MAKE) clean
	if [ -f $(ADK_CODE)/config/adk_haswell_rtc.cfg ]; then \
		mkdir -p $(ADK_LIBDIR); \
		cp -f $(ADK_CODE)/config/adk_haswell_rtc.cfg $(ADK_LIBDIR); \
	fi
	if [ -f $(ADK_CODE)/config/adk_release_id.h ]; then \
		mkdir -p $(ADK_INS_INCDIR); \
		cp -f $(ADK_CODE)/config/adk_release_id.h $(ADK_INS_INCDIR); \
	fi
	@touch last_build_release


install_dependency:
	mkdir -p $(ADK_INS_INCDIR); \
	cp include/adk_modules_enabled.h $(ADK_INS_INCDIR); \
	mkdir -p $(ADK_LIBDIR); \
	cp lib.$(AXXIA_RTE_TARGET)/libGen$(LIB_EXT) $(ADK_LIBDIR);

clobber:
	+@BUILD_RULE=$@; $(MAKE) -C code $$BUILD_RULE
	+@BUILD_RULE=$@; $(SUBDIRS_BUILD)
	-$(RM) -r install last_build_debug last_build_release

clean:
	+@BUILD_RULE=$@; $(MAKE) -C code $$BUILD_RULE
	+@BUILD_RULE=$@; $(SUBDIRS_BUILD)
	-$(RM) -r install/lib.$(AXXIA_RTE_TARGET) last_build_debug last_build_release

install_hdrs mklinks rmlinks:
	+@BUILD_RULE=`echo $@ | sed -e 's/-code//'`; $(MAKE) -C code $$BUILD_RULE

debug: debug-code
	+@BUILD_RULE=$@; $(SUBDIRS_BUILD)

release: release-code
	+@BUILD_RULE=$@; $(SUBDIRS_BUILD)

debug-code: last_build_debug install_hdrs
	+@BUILD_RULE=debug; $(MAKE) -C code $$BUILD_RULE

release-code: last_build_release install_hdrs
	+@BUILD_RULE=release; $(MAKE) -C code $$BUILD_RULE

debug-test: last_build_debug
	+@BUILD_RULE=$@; $(SUBDIRS_BUILD)

release-test: last_build_release
	+@BUILD_RULE=$@; $(SUBDIRS_BUILD)

traffic:
	+@BUILD_RULE=$@; $(SUBDIRS_BUILD)

xml_update:
	+@BUILD_RULE=$@; $(SUBDIRS_BUILD)
endif # ifdef ADK_SRC
# vim: filetype=make
