#                             Themes/Makefile.themes
#
# This file is the backend that does all of the building for the themes.
#
# There are only two ways for a Theme to organize it's build structure:
#   1. If only the defaults are needed, just create a makefile that
#      includes "../Makefile.themes".
#
#   2. Define a completely custom makefile and not use this one.  This
#      is not at all recommended.
#
# The following functionality may be overridden by defining variables:
#   1. $(ResourceFiles) may contain a list of files to be copied to the
#      destination directory.  If these files do not exist, "make" will
#      stop.  This variable should be defined to include all of the skel
#      files and other resources used by the theme. Usually, something 
#      like "ResourceFiles = $(wildcard *.html *.gif *.jpg)" works... 
#      which happens to be the default...
#

LEVEL = ../..

# Include the "Common" files...
include $(LEVEL)/Makefile.common

ThemeName = $(notdir $(shell pwd))

# DestDir is the directory to copy the resulting resources into...
#
DestDir = $(LEVEL)/Install/Themes/$(ThemeName)/

# If no resources have been specified, use default...
ifeq ($(DestResources),)
ResourceFiles = $(wildcard *.html *.gif *.jpg)
endif

DestResources = $(addprefix $(DestDir),$(ResourceFiles))

# Define the rule to copy files over to the destination directory...
#
$(DestDir)%: % $(DestDir).dir
	cp $< $@

all:: $(DestDir)$(ThemeName).cfg $(DestResources) $(DestDir).dir

# Find out if we have documentation for the theme...
#
DocSource = $(wildcard index.html)

# if we have documentation for the theme...
#
ifneq ($(DocSource),)

ResourceFiles += $(DocSource)

else
# Create an obnoxious warning so that people will document their stuff...
all::
	@echo \*\*\* Warning, no documentation found for $(ThemeName) theme! \*\*\*

endif

clean::

