if ! $(BUILDTOP)
{
BUILDTOP = . ;
}

# Include configuration.  The value of JAMCONFIG may be overridden by targets
# which recursively invoke 'jam' with a custom configuration file.  For
# instance, this is done with the 'msvcgen' target (see CS/mk/msvcgen/Jamfile).
JAMCONFIG ?= $(BUILDTOP)/Jamconfig ;
include $(JAMCONFIG) ;

# CFLAGS.  Don't use FDefines here since Boost Jam doesn't have it, and we have
# not yet included mk/jam/build.jam which provides an emulation layer for
# Boost.  We can not include build.jam earlier because these flags need to be
# defined before build.jam is included.  :-(
COMPILER.CFLAGS.debug += -DCS_DEBUG ;
COMPILER.CFLAGS.profile += -g3 -pg ;
COMPILER.LFLAGS.profile += -g3 -pg ;

# Include CS build rules.
include $(TOP)/mk/jam/build.jam ;

# Set up default application icon.
ApplicationIconDefault win32 : gui : cs1.ico : $(TOP) libs csutil win32 ;
ApplicationIconDefault macosx : gui : appicon.icns :
  $(TOP) libs csutil macosx ;

# Unit-testing boilerplate: The code we want inserted into each test case and
# the main driver program.
UNITTEST_BOILERPLATE_TEST_PRE = "
#include \"cssysdef.h\"
#include \"csutil/scf.h\"
" ;
UNITTEST_BOILERPLATE_MAIN_PRE = $(UNITTEST_BOILERPLATE_TEST_PRE) "
CS_IMPLEMENT_APPLICATION
" ;

# Set up a property which clients can query to determine if the build directory
# differs from source directory.  This allows clients to perform conditional
# actions based upon this knowledge.  We safely detect if the two directories
# differ by checking if 'cssysdef.h' is present in $(BUILDTOP)/include.  If it
# is not, then the directories differ.
buildheaders = [ GLOB [ ConcatDirs $(BUILDTOP) include ] : *.h ] ;
if ! [ IsElem cssysdef.h : $(buildheaders:BS) ]
{
  SetProperty build : standalone ;
}
