# This is the top level Makefile for all source packages. 
# It makes all the code in the "src" directory, then installs it
# to the "install" directory", then makes the images in
# the images directory (if present)

ROOT_DIR := $(notdir $(CURDIR))
ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)
unexport ROOT_DIR

.PHONY: all install clean links make_links dummy images prebuilt

# Expands to a single newline character
define NEWLINE


endef

SUFFIXES := .mk

all: install $(if $(wildcard images/*),images)
	@echo done

subdirs:=$(subst /Makefile,,$(wildcard */[Mm]akefile))

clean:
	$(foreach dir,$(subdirs), $(MAKE) -C$(dir) clean $(NEWLINE))
	-$(RM_HOST) -r install/*

install: $(if $(wildcard prebuilt/*),prebuilt)
	$(MAKE) -Csrc hinstall
	$(MAKE) -Csrc install

images:
	$(MAKE) -Cimages

prebuilt:
	cp -r prebuilt/* install
