#
# Makefile for passing make commands down to subdirectories
#
# Targets:
#
# all: build drivers
#
# install: install into proper place
#     - used when building and installing from tar file
#
# installrpm: install into tmp location.
#     -used by rpm, which can't handle conditional paths

.PHONY: dummy

# determine target architecture if not set
ifeq "$(TARGETARCH)" ""
ifeq (x86_64,$(findstring x86_64,$(shell $(CC) -dumpmachine)))
export TARGETARCH=AMD64
endif
endif


SUBDIRS = nvnet nvaudio nvgart
SUBDIR_make       =  $(patsubst %,%_make, $(SUBDIRS))
SUBDIR_install    =  $(patsubst %,%_install, $(SUBDIRS))
SUBDIR_installrpm =  $(patsubst %,%_installrpm, $(SUBDIRS))
SUBDIR_uninstall    =  $(patsubst %,%_uninstall, $(SUBDIRS))

.PHONY: subdirs $(SUBDIRS)

#Use by nvnet and nvaudio Makefiles for install
export UID = $(shell id -u)

all: $(SUBDIR_make)

install: $(SUBDIR_install)
installrpm: $(SUBDIR_installrpm)
uninstall: $(SUBDIR_uninstall)

$(SUBDIR_make): dummy
	$(MAKE) -C $(patsubst %_make, %, $@)

$(SUBDIR_install): dummy
	$(MAKE) -C $(patsubst %_install, %, $@) install

$(SUBDIR_installrpm): dummy
	$(MAKE) -C $(patsubst %_installrpm, %, $@) installrpm

$(SUBDIR_uninstall): dummy
	$(MAKE) -C $(patsubst %_uninstall, %, $@) uninstall
