###############################################################################

# CLAM System default rules and targets for C++ compilation.

# This file composite macros and rules for creating compilation objects
# (such as library archives, object files, executable programs, and others).

# This file should be included in the user Makefile after the variables
# have been initialized appropriately for the particular project being
# compiled.  The user targets should be placed after the include
# directive that specifies this file.

###############################################################################

# This section manipulates variable values to prepare them for their use
# in the standard CLAM support.

# see if they have got the clean flag set.  if so, we will not build anything.
ifneq "$(CLEAN)" ""
  NO_COMPILE = t
endif
# also omit version compilation and some logging when not compiling.
ifneq "$(NO_COMPILE)" ""
  QUIET = t
endif

# add-ins for packages we use.

# secure socket and crypto libraries.
ifneq "$(USE_SSL)" ""
  LIBS_USED += ssl crypto
endif

# pull in the curl configuration using their tool.
ifneq "$(USE_CURL)" ""
  COMPILER_FLAGS += `curl-config --cflags`
  LOAD_FLAG_SUFFIX += `curl-config --libs`
endif

# x window system.
ifneq "$(USE_XWIN)" ""
  DEFINITIONS += __XWINDOWS__ __X__
  LIBS_USED += 
#Xm Xt X11 Xft Xp 
#need to separate out with a USE_MOTIF kind of thing.
#LIBS_USED += Xmu
  HEADER_SEARCH_PATH += /usr/include/X11 /usr/X11R6/include 
#/usr/include/g++
  LIBRARY_SEARCH_PATH += /usr/X11R6/lib
endif

# generalized wxwidgets toolkit configuration.
ifneq "$(USE_WXWIDGETS)" ""
  DEFINITIONS += __WXWIDGETS__ 
  use_unicode =
  ifneq "$(findstring UNICODE, $(DEFINITIONS))" ""
    use_unicode = true
  endif

  # decide whether to turn on the unicode flag or not.
###    ifneq "$(findstring UNICODE, $(DEFINITIONS))" ""
  ifneq "$(use_unicode)" ""
    UNICODE_FLAG_ADD = --unicode=yes
    DEFINITIONS += wxUSE_UNICODE
  else
    UNICODE_FLAG_ADD = --unicode=no
  endif

  COMPILER_FLAGS += $(shell wx-config --cxxflags $(UNICODE_FLAG_ADD) )
  LOAD_FLAG_PREFIX += $(shell wx-config --libs $(UNICODE_FLAG_ADD) )
endif

# add special bits for gnu on unix.
ifeq "$(CLAM_COMPILER)" "GNU_LINUX"

endif

# some special code for gnu compiler on windows.
ifeq "$(CLAM_COMPILER)" "GNU_WINDOWS"

#hmmm: LOAD_FLAG_PREFIX += -lwsock32 -lmswsock -shared
endif

###############################################################################

ifeq "$(CLAM_COMPILER)" "GNU_DARWIN"
  # finds the crypto code on macos.
  HEADER_SEARCH_PATH += /usr/local/opt/openssl/include
  LIBRARY_SEARCH_PATH += /usr/local/opt/openssl/lib/
endif

###############################################################################

# Create the real list of local libraries needed.
TEMP_LOC1 = $(LOCAL_LIBS_USED:%=%$(TRIPART_VERSION))
ACTUAL_LOCAL_LIBS = $(TEMP_LOC1)

# Create the list of objects from the list of source files.
TEMP_OBJ1 = $(SOURCE:%.cpp=%.obj)
TEMP_OBJ2 = $(TEMP_OBJ1:%.c=%.obj)

# replace this when supporting resource files on unix.
TEMP_OBJ3 = $(TEMP_OBJ2:%.rc=)

TEMP_OBJ4 = $(TEMP_OBJ3:%.h=%.bad)
OBJECTS = $(TEMP_OBJ4)

# special case for multi-build and res files that need to be rebuilt.
#RES_OBJECTS_0 = $(SOURCE:%.cpp=)
#RES_OBJECTS_1 = $(RES_OBJECTS_0:%.c=)
#RES_OBJECTS = $(RES_OBJECTS_1:%.rc=$(OBJECT_DIR)/%.res)

# not much conversion anymore...
ACTUAL_OBJECTS = $(OBJECTS) $(EXTRA_OBJECTS)

# Updates the search path for the compiler and local libraries.
BASE_HEADER_PATH = $(CODEBASE_HEADERS) $(LOCAL_HEADERS) $(strip $(FEISTY_MEOW_CPP_HEADERS)) $(SEARCH_DIRS) 
HEADER_SEARCH_PATH += $(BASE_HEADER_PATH) $(COMPILER_HEADER_DIR)

LIBRARY_SEARCH_PATH += $(LOCAL_LIBRARIES) $(HOOPLE_LIBRARIES) \
  $(STATIC_LIBRARY_DIR) $(COMPILER_LIBRARY_DIR) $(SEARCH_DIRS)

# Adds some directories that must be searched onto the search path for
# header files, such as the header file directory for the compiler.
COMPILER_FLAGS += $(HEADER_SEARCH_PATH:%=-I%) $(DEFINITIONS:%=-D%) $(UNDEFINITIONS:%=-U%) -DGLOBAL_PRODUCT_NAME="$(GLOBAL_PRODUCT_NAME)"

# The load flags are updated by looking for code libraries in the directories
# to search and by adding all of the code libraries that are used.
LOAD_FLAG_PREFIX += $(LIBRARY_SEARCH_PATH:%=$(LIBRARY_PATH_FLAG)%)
ifeq "$(OPERATING_SYSTEM)" "UNIX"
  ifneq "$(CLAM_COMPILER)" "GNU_DARWIN"
    LOAD_FLAG_PREFIX += -Xlinker --start-group
    LOAD_FLAG_SUFFIX += -Xlinker --end-group
  endif
endif
# had to switch from prefix to suffix recently.  oddity.
#LOAD_FLAG_PREFIX += $(LIBS_USED:%=$(LIBRARY_NAME_FLAG)%)
LOAD_FLAG_SUFFIX += $(LIBS_USED:%=$(LIBRARY_NAME_FLAG)%)

# we steal the exe targets and represent their dependency from the hidden
# cpp for the exe.
EXE_TEMP_0 = $(TARGETS:%.dll=)
EXE_TEMP_1 = $(EXE_TEMP_0:%.so=)
EXE_TEMP_2 = $(EXE_TEMP_1:%.lib=)
EXE_TEMP_3 = $(EXE_TEMP_2:%.elf=%.cpp)
EXE_CPPS   = $(EXE_TEMP_3:%.exe=%.cpp)

# used for compiling multiple source files at the same time with visual cpp.
MULTI_BUILD_CMD = $(CC) $(COMPILER_FLAGS) -c `cat $(BUILD_LIST_FILE)` $(OBJECT_NAME_FLAG)$(OBJECT_DIR)/

ifeq "$(OMIT_VERSIONS)" ""
  ifneq "$(CLAM_VERSION_RC_ROOT)" ""
    VERSION_TARGET = $(CLAM_VERSION_RC_ROOT)_version.rc
  endif
endif

# if we are cleaning up, then do not generate dependency file.
ifeq "$(CLEAN)" ""
  ifneq "$(GENDEPS)" ""
    EXTRA_FIRST_TARGETS += gendeps
  endif

# only do the deps generation for makefiles that are properly marked.
ifneq "$(findstring __BUILD_STATIC_APPLICATION__, $(DEFINITIONS))" ""
  # generate static build dependencies for all targets in the makefile.
  GENERATED_DEPS_LIST = $(TARGETS:%.exe=%.gendeps)
else
  GENERATED_DEPS_LIST =
endif

endif

# Make sure that the directory for objects exists.
ACTUAL_FIRST_TARGETS = check_requirements $(EXTRA_FIRST_TARGETS) $(VERSION_TARGET) $(FIRST_TARGETS) pre_compilation

# Adds the primary targets to the list of products to create.
ACTUAL_TARGETS1 = $(TARGETS:%.exe=$(EXECUTABLE_DIR)/%)
ACTUAL_TARGETS2 = $(ACTUAL_TARGETS1:%.dll=%.so)
ACTUAL_TARGETS3 = $(ACTUAL_TARGETS2:%.so=$(DYNAMIC_LIBRARY_DIR)/%$(TRIPART_VERSION).so)
ACTUAL_TARGETS4 = $(ACTUAL_TARGETS3:%.lib=$(STATIC_LIBRARY_DIR)/%$(TRIPART_VERSION).library)
ACTUAL_TARGETS = $(ACTUAL_TARGETS4:%.elf=$(EXECUTABLE_DIR)/%.elf)

# Adds the last few targets that CLAM works on.
ACTUAL_LAST_TARGETS = post_compilation $(LAST_TARGETS)

############################################################################

# This section defines the rules used to generate various objects from their
# source files.

############################################################################

# The first section provides simplistic pseudo-targets for testing compilation
# rather than generating built products.

# the blank target is used to (somewhat) safely remove items from the SOURCE
# list.  it is an empty file that should be able to go in a library archive
# without hosing it up.
%.nil:
ifeq "$(NO_COMPILE)" ""
	$(CATCHER)$(CC) -c $(CLAM_SCRIPTS)/cpp/blank_target.c -o $@
endif

%.bad:
	@echo There is a problem with the makefile in the SOURCE variable.
	@echo The offending item is: $@
	$(HIDESH)$(CLAM_SCRIPTS)/exit_make.sh

## faked debug object.
#%.obj: %.cpp
#ifeq "$(NO_COMPILE)" ""
#	@echo Bogus [$@].
#	$(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$(TEMP)/$@
#endif

ifeq "$(CLEAN)" ""
# recreate dependencies for static applications.
%.gendeps: %.cpp
	@echo "Generating Static Deps: $*.cpp"
	$(CATCHER)$(CLAM_SCRIPTS)/cpp/buildor_gen_deps.sh "$*.cpp"
endif

############################################################################

# trying to delay loading this as long as possible so the built in rule system for CLEANUPS can run with the right values.
# so far not working right!
#hmmm: fix this.

# Adds the main CLAM system in to get some work done.  This should be placed
# after the module rules are defined and before the module targets are
# defined.
include rules.def

############################################################################

# this adds in a customization for the cleanup variables, since the base
# clam code has no idea about a dynamic library directory.

cpp_add_to_cleanups_variable:
#	echo here is actual targets before hand $(ACTUAL_TARGETS)
	$(eval CLEANUPS = $(ACTUAL_TARGETS:%.exe=%) $(ACTUAL_TARGETS:$(STATIC_LIBRARY_DIR)/%.library=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%.a) $(CLEANUPS) )
#	echo "IN CPP, new CLEANUPS variable: $(CLEANUPS)"
#fodder for anything missing a cleanup.
#	$(eval CLEANUPS = $(ACTUAL_TARGETS) $(ACTUAL_TARGETS:%.dll=%.so) $(ACTUAL_TARGETS:%.so=%.dll) $(CLEANUPS) )

#dynamic is taken care of in clam base still?
#DYNAMIC_LIBRARY_DIR
#hmmm: still should change there in the base and do it
# here instead.

############################################################################

# C++ source to object file translation.
# if there is a special set of flags for this source file, we use them
# instead of the default compiler flags.

$(OBJECT_DIR)/%.obj: $(CURRENT_DIR)/%.cpp
ifeq "$(NO_COMPILE)" ""
	@echo Compiling Object [$(notdir $@)]
	$(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi'
	$(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$@
endif

############################################################################

# C source to object file translation.

$(OBJECT_DIR)/%.obj: $(CURRENT_DIR)/%.c
ifeq "$(NO_COMPILE)" ""
	@echo Compiling Object [$(notdir $@)]
	$(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi'
	$(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$@
endif

############################################################################

# resource compiler for windoze.

# we currently do not use rc files.
$(OBJECT_DIR)/%.res: %.rc
  ifeq "$(NO_COMPILE)" ""
	@echo Bogus resource [$@]
	@echo >$@
  endif

############################################################################

# creates static libraries.
ifneq "$(NO_COMPILE)" ""
$(STATIC_LIBRARY_DIR)/%.library:
endif

ifeq "$(NO_COMPILE)" ""
$(STATIC_LIBRARY_DIR)/%.library: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
	$(HIDER)echo Building Static Library [$(notdir $@)]
	@echo $@ >$(DIRTY_FILE)
	$(CATCHER)$(LIBRARY_TOOL) $(LIBRARIAN_FLAGS) $(CREATE_LIBRARY_FLAG)$@ $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%)
  ifneq "$(OPERATING_SYSTEM)" "UNIX"
	$(HIDER)ranlib $@ 
	$(HIDER)rm -f $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
	$(HIDER)ln -s $@ $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
  else
#copied from unix above, not right yet, was not right before either though.
	$(HIDER)ranlib $@ 
	$(HIDER)rm -f $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
	$(HIDER)ln -s $@ $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
  endif
endif #no_compile

############################################################################

# creates dynamic libraries.

# we whack any existing LIB file, since we want to use changes in that file
# as a clue for when we should rescan the dependencies.  we'd be fine if
# visual c++ didn't keep an existing LIB if it does not change (even when the
# DLL does).

ifneq "$(NO_COMPILE)" ""
$(DYNAMIC_LIBRARY_DIR)/%.dll:
endif

ifeq "$(NO_COMPILE)" ""
$(DYNAMIC_LIBRARY_DIR)/%.dll: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(ACTUAL_RESX) $(PARAMETER_FILE) 
	$(HIDER)echo Building Dynamic Library [$(notdir $@)]
	@echo $@ >$(DIRTY_FILE)
	$(HIDER)rm -f $(@:%.dll=%.lib)
	echo about to run link tool.
	$(CATCHER)$(LINK_TOOL) $(LINKER_OUTPUT_FLAG)$@ -dll $(LOAD_FLAG_PREFIX) $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_RESX_FLAGS) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)$(LIB_PREFIX)%$(LIB_ENDING)) $(LOAD_FLAG_SUFFIX)
	echo ran link tool.
  ifeq "$(CLAM_COMPILER_VERSION)" "8"
	$(HIDESH)$(CLAM_SCRIPTS)/cpp/ms_manifest.sh "$@" "2"
  endif
  ifeq "$(CLAM_COMPILER_VERSION)" "10"
	$(HIDESH)$(CLAM_SCRIPTS)/cpp/ms_manifest.sh "$@" "2"
  endif
  ifneq "$(VCPP_VISTA_ICON)" ""
	$(HIDER)ReplaceVistaIcon "$@" "$(VCPP_VISTA_ICON)"
  endif
endif #no_compile

ifneq "$(NO_COMPILE)" ""
$(DYNAMIC_LIBRARY_DIR)/%.so:
endif

ifeq "$(NO_COMPILE)" ""
$(DYNAMIC_LIBRARY_DIR)/%.so: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
  ifeq "$(CLAM_COMPILER:%_LINUX=LINUX)" "LINUX"
	$(HIDER)echo Shared [$@]
	@echo $@ >$(DIRTY_FILE)
	$(CATCHER)$(LINK_TOOL) $(LINKER_OUTPUT_FLAG)$@ $(LOAD_FLAG_PREFIX) -shared -Wl,-soname,$*.so $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)%) $(LOAD_FLAG_SUFFIX) 
	$(HIDER)rm -f $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
	$(HIDER)ln -s $@ $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
  endif
endif #no_compile

############################################################################

# creates "exe" executables using all of the appropriate objects.

ifneq "$(NO_COMPILE)" ""
$(EXECUTABLE_DIR)/%:
endif

ifeq "$(NO_COMPILE)" ""
$(EXECUTABLE_DIR)/%: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
	$(HIDER)echo Building Application [$(notdir $@)]
	@echo $@ >$(DIRTY_FILE)
	$(CATCHER)$(LINK_TOOL) $(EXE_FLAGS) $(LOAD_FLAG_PREFIX) $< $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)%) $(LOAD_FLAG_SUFFIX) $(LINKER_OUTPUT_FLAG)$@
#hmmm: experimental item below.
#$(^:force_rebuild=) 
endif #no_compile

############################################################################

# creates firmware "elf" executables with the proper objects.

ifneq "$(NO_COMPILE)" ""
$(EXECUTABLE_DIR)/%.elf:
endif

ifeq "$(NO_COMPILE)" ""
$(EXECUTABLE_DIR)/%.elf: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
	$(HIDER)echo Building Application [$(notdir $@)]
	@echo $@ >$(DIRTY_FILE)
	$(CATCHER)$(LINK_TOOL) $(MAP) $(LOAD_FLAG_PREFIX) $< $(LINKER_COMMAND_FILE) $(STARTUP_OBJECT_FILE) $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)%) $(LOAD_FLAG_SUFFIX) $(LINKER_OUTPUT_FLAG)$@
#$(^:force_rebuild=) 
	@echo Hex [$(EXECUTABLE_DIR)/$*.out]
	$(CATCHER)$(DDUMP_TOOL) $(DDUMP_OPTIONS) $@ -o$(EXECUTABLE_DIR)/$*.out
	@echo Binary [$(EXECUTABLE_DIR)/$*.bin]
	$(CATCHER)$(DDUMP_TOOL) $(DDUMP_BIN_OPTIONS) $@ -o$(EXECUTABLE_DIR)/$*.bin
endif #no_compile

############################################################################

# handles creating version resource files if this project has a version.ini.

ifeq "$(OMIT_VERSIONS)" ""
  ifneq "$(CLAM_VERSION_RC_ROOT)" ""
# only redo the version resource if it or version.ini is out of date.
%_version.rc: version.ini $(PARAMETER_FILE)
	$(CATCHER)$(CLAM_BINARIES)/version_stamper$(EXE_ENDING) . $(FEISTY_MEOW_GENERATED_STORE)/versions $(PARAMETER_FILE)
  endif
endif

############################################################################

# Now the active part of the make process...

# make sure we really want to include the dependencies file.
ifeq "$(TYPE)" "hierarchy"
  # no dependencies for a simple hierarchy builder.
  NO_DEPS = t
endif
ifneq "$(CLEAN)" ""
  NO_DEPS = t
endif
ifneq "$(NO_COMPILE)" ""
  # non compiling projects do not need dependencies.
  NO_DEPS = t
endif
ifneq "$(REBUILD)" ""
  NO_DEPS = t
  # if we are rebuilding everything, we zap the deps file.
  $(shell rm -f $(DEPS_FILE))
endif

# preserves intermediate files from being deleted.
ifeq "$(CLEAN)" ""
.PRECIOUS: $(OBJECT_DIR)/%.obj $(OBJECT_DIR)/%.res $(OBJECT_DIR)/%.resources $(OBJECT_DIR)/%.deps
#hmmm: added above deps.  maybe not right.
endif

# zaps things when they could not be created correctly.
####.DELETE_ON_ERROR:

############################################################################

# autodependency file creator.  See the make_dep man page for more info.

# we do the auto-dependencies unless the disabling flag is set.
ifneq "$(NO_DEPS)" ""
    # makes the dependencies a no-op.
    deps: $(PARAMETER_FILE)

    $(DEPS_FILE): $(PARAMETER_FILE)

else
  ifeq "$(CLEAN)" ""
  deps: $(DEPS_FILE)

  # this causes the dependency file to be regenerated if the sources or libs
  # have changed.  we have to touch the deps file in case it is missing;
  # makedep does not deal well with that.  also, we touch the dirty flag file
  # to ensure that the fact we redid dependencies for some reason causes us
  # to re-promote.  we only bother with any of this if we know we are going
  # to really do some compilation; if in non-compile mode, we'll skip it.
  ifneq "$(NO_COMPILE)" ""
    # no dependencies in non-compile mode.
    $(DEPS_FILE):

  else
    ifeq "$(LAX_DEPENDENCIES)" ""
      $(DEPS_FILE): $(SOURCE) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(wildcard *.h) $(EXE_CPPS)
    else  # lax dependencies means create if missing or if parm file changed.
      $(DEPS_FILE): $(PARAMETER_FILE)
    endif # !lax dependencies.
    ifneq "$(CLAM_VERSION_RC_ROOT)" ""
      ifeq "$(OMIT_VERSIONS)" ""
        $(DEPS_FILE): $(CLAM_VERSION_RC_ROOT)_version.rc
      endif
    endif
	@echo Dependencies [$(notdir $@)]
	-$(HIDESH)$(CLAM_SCRIPTS)/cpp/preconditions.sh
	@touch $@
#	@echo dep adds: $(DEPENDENCY_ADDITIONS)
	@$(CLAM_BINARIES)/makedep$(EXE_ENDING) $(DEPENDENCY_DEFINITIONS:%=-D%) $(DEPENDENCY_ADDITIONS) -f$@ -o.obj -p$(OBJECT_DIR)/ -w 420 $(COMPILER_HEADER_DIR:%=-X%) $(THIRD_PARTY_DIR:%=-X%) -- $(COMPILER_FLAGS) $(SOURCE) $(EXE_CPPS)
#	$(CATCHER)$(CLAM_BINARIES)/makedep$(EXE_ENDING) $(DEPENDENCY_DEFINITIONS:%=-D%) $(DEPENDENCY_ADDITIONS) -f$@ -o.obj -p$(OBJECT_DIR)/ -w 420 $(COMPILER_HEADER_DIR:%=-X%) $(THIRD_PARTY_DIR:%=-X%) -- $(COMPILER_FLAGS) $(SOURCE) $(EXE_CPPS)
	@echo $@ >$(SUBMAKE_FLAG)
  endif # non-compile.
 else # cleaning.
    # makes the dependencies a no-op for cleaning.
    deps: $(PARAMETER_FILE)

    $(DEPS_FILE): $(PARAMETER_FILE)
 endif
endif # no-deps.

############################################################################

# examines the required variables and complains if they are missing.
check_requirements:
	$(HIDESH) -c 'if [ -z "$(PROJECT)" ]; then echo the PROJECT variable is not defined!; . $(CLAM_SCRIPTS)/exit_make.sh; fi'
	$(HIDESH) -c 'if [ -z "$(TYPE)" ]; then echo the TYPE variable is not defined!; . $(CLAM_SCRIPTS)/exit_make.sh; fi'
	$(HIDESH) -c 'if [ ! -d $(FEISTY_MEOW_GENERATED_STORE)/versions ]; then mkdir $(FEISTY_MEOW_GENERATED_STORE)/versions; fi'
 
############################################################################

# includes the auto-dependency information.  the dependency file is checked
# for being up-to-date.  if not, it gets rebuilt and the make is restarted.
ifeq "$(CLEAN)" ""
  ifeq "$(NO_DEPS)" ""

    # thank the buddha for this bit of code, or at least thank this page:
    # http://stackoverflow.com/questions/5553352/how-do-i-check-if-file-exists-in-makefile
    ifneq ("$(wildcard $(DEPS_FILE))","")
      include $(DEPS_FILE)
    endif

  endif
endif

############################################################################

# calls the script for preparing output directories and such.
pre_compilation:
	$(HIDESH)$(CLAM_SCRIPTS)/cpp/preconditions.sh

############################################################################

# calls the script for copying the final products to the library directory.
# we do not bother reporting errors from touch since there will sometimes
# not be any objects in the final directory.
post_compilation:
	$(HIDESH)$(CLAM_SCRIPTS)/cpp/postconditions.sh

############################################################################

# if REBUILD is defined, then we cause all objects to be recompiled.
.PHONY: force_rebuild
force_rebuild:

ifneq "$(REBUILD)" ""
  # the target below needs the blank rule that it has for this to work.
  $(FIRST_TARGETS) $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_TARGETS) $(EXE_CPPS:%.cpp=$(OBJECT_DIR)/%.obj) $(LAST_TARGETS): force_rebuild
endif

############################################################################

# generate dependencies for any static targets if requested.
gendeps: $(GENERATED_DEPS_LIST)

############################################################################

