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

include $(ADK_SRC)/make.env

# SUBDIRS is set using either ALLSUBDIRS or INI_SUBDIRS from the include file
# makefile.subdirs
#SUBDIRS= 

include ./makefile.subdirs

ALL_SUBDIRS=$(shell \ls -1 | grep -v makefile | \
			                 grep -v deprecated | \
			                 grep -v IPSecDemo_IPv6 | \
							 grep -v traffic_files )

ifeq ($(MAKECMDGLOAS), clobber)
SUBDIRS=$(ALL_SUBDIRS)
else
SUBDIRS=$(if $(INI_SUBDIRS), $(INI_SUBDIRS), $(ALL_SUBDIRS))
endif

all: debug traffic

# We don't need to run this compilation in parallel as it will cause
# the adk_sample_os.c to compile multiple times simultaneously.
# Disable it for this directory.
.NOTPARALLEL:

clean clean-c: $(SUBDIRS)
#	-@echo "SUBDIRS: '$(SUBDIRS)'"
#	-@echo "ALL_SUBDIRS: '$(ALL_SUBDIRS)'"
	-$(ADK_Q)$(RM) -rf $(TEST_EXE) $(OBJS) $(TEST_DEPS) $(LINT_DEPS) $(DATS) *_db
	-$(ADK_Q)$(RM) -rf common/src/C/*$(AXXIA_RTE_TARGET).o common/src/C/*$(AXXIA_RTE_TARGET).d

clobber: $(SUBDIRS)
#	-@echo "SUBDIRS: '$(SUBDIRS)'"
#	-@echo "ALL_SUBDIRS: '$(ALL_SUBDIRS)'"
	-$(ADK_Q)$(RM) -rf *_exe *.o *.d $(LINT_DEPS) $(DATS) *_db
	-$(ADK_Q)$(RM) -rf common/src/C/*.o common/src/C/*.d

debug release code: $(SUBDIRS)

.PHONY: $(SUBDIRS)

$(SUBDIRS):
	$(ADK_Q)if [ -d $@ ]; then $(MAKE) -C $@ $(MAKECMDGOALS); fi

install install_hdrs: $(SUBDIRS)

traffic: $(DATS) $(SUBDIRS)

%.dat: %.xml
	$(ACPTRAFGEN) $<
	touch $@

xml_update: $(XMLS_UPDATE) topology.xmlup topology_ipsec.xmlup $(SUBDIRS)

%.xmlup: %.xml
	$(CONFIG) -U $^

