#
# This file is licensed under the terms of the GNU General Public License,
# version 2. See the file COPYING in the main directory for details.
#
# Copyright (C) 2003  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
#

#
# We build the loader binaries only if we are compiling for a mipsel-linux
# machine. Otherwise we build only the installer. This is useful to make
# CDs, disks and other media bootable on non-mipsel machines.
#
add_native = $(shell if [ $$($(CC) -dumpmachine) = "mipsel-linux" ]; then echo "$(1)"; fi)

SUBDIRS = delo t-rex $(call add_native, loader t-rex-loader)

.PHONY = all $(patsubst %, _dir_%, $(SUBDIRS))
all: $(patsubst %, _dir_%, $(SUBDIRS))
$(patsubst %, _dir_%, $(SUBDIRS)):
	$(MAKE) -C $(patsubst _dir_%, %, $@) all

.PHONY = install $(patsubst %, _instdir_%, $(SUBDIRS))
install: $(patsubst %, _instdir_%, $(SUBDIRS))
$(patsubst %, _instdir_%, $(SUBDIRS)):
	$(MAKE) -C $(patsubst _instdir_%, %, $@) install

.PHONY = clean $(patsubst %, _cleandir_%, $(SUBDIRS))
clean: $(patsubst %, _cleandir_%, $(SUBDIRS))
	-rm -f core *~
$(patsubst %, _cleandir_%, $(SUBDIRS)):
	$(MAKE) -C $(patsubst _cleandir_%, %, $@) clean

.PHONY = reallyclean $(patsubst %, _reallycleandir_%, $(SUBDIRS))
reallyclean: clean $(patsubst %, _reallycleandir_%, $(SUBDIRS))
$(patsubst %, _reallycleandir_%, $(SUBDIRS)):
	$(MAKE) -C $(patsubst _reallycleandir_%, %, $@) reallyclean
