#                            Plugins/Makefile
#
# This file is the gateway to building all of the plugins in the
# directory.  It assumes that all of the directories under the "Plugins"
# directory (this one) contain plugins that need to be built.  It then
# either builds the plugins and sticks copies of their .so files into the
# $(DestDir) directory, or it propogates the clean command to each of the
# subdirectories.
# 

# The level of this make file.  This makefile is one level lower than the
# main MagicStats directory.
#
LEVEL = ..

# Try to figure out what plugins are in this directory.
# Start out with everything in this directory, and then remove all entries
# that do not have a Makefile in them...
#
RawPluginNames     = $(wildcard *)
RawPluginDirs      = $(addsuffix /, $(RawPluginNames))
RawPluginDirFiles  = $(wildcard $(addsuffix Makefile, $(RawPluginDirs)))

# PluginDirs is all of the real directories, sorted to remove redundancies
PluginDirs  = $(sort $(dir $(RawPluginDirFiles)))

# PluginNames is the same as the PluginDirs, without the /.
PluginNames = $(PluginDirs:%/=%)

DIRS=$(PluginNames)

include $(LEVEL)/Makefile.common

# AllPlugins - Default rule, ensures all directories are available, then
# it builds the plugins and prints out a status message...
all::
	@echo ======= Plugins available: $(PluginNames) =======

# clean - Remove all intermediate files...  For plugins, just let recursive
# case take over...
clean::

# install - Install the plugins in the OutputFiles directory...
install:: $(LibInstDir)/Plugins/.dir
	cp -rf $(LEVEL)/Install/Plugins* $(LibInstDir)
