#
# Run make in each of the subdirectories
#

# Set environment variables to correspond to the current working directory
export NF_ROOT = $(CURDIR)
export PERL5LIB := $(CURDIR)/lib/Perl5:$(PERL5LIB)
export BASE_DIR := lib/C

# List of directories in which we should build
SUBDIRS = $(BASE_DIR)/common $(BASE_DIR)/download $(BASE_DIR)/reg_access

MODULE_DIR = $(BASE_DIR)/kernel

module: 
	$(MAKE) -C $(MODULE_DIR) KVER=$(KVER)

utils:
	echo $(PERL5LIB)
	for dir in $(SUBDIRS) ; do \
		if [ -f "$$dir/Makefile" ] ; then \
			$(MAKE) -C $$dir all ; \
		fi \
	done

clean install:
	for dir in $(SUBDIRS) $(MODULE_DIR) ; do \
		if [ -f "$$dir/Makefile" ] ; then \
			$(MAKE) -C $$dir KVER=$(KVER) DESTDIR=$(DESTDIR) $@; \
		fi \
	done

kmod_install:
	$(MAKE) -C $(MODULE_DIR) KVER=$(KVER) DESTDIR=$(DESTDIR) install;


.PHONY: install subdirs $(SUBDIRS) clean
