#
# FMS sample top-level makefile.
#
FMS_TOP = .
include $(FMS_TOP)/build/makedefs.mk


#
# List all subdirectories with makefiles.
#
# Put static libs first, shared libs second, and applications last.
#
FMS_SUBDIRS = loglib baselib app1 app2 app3 app4

# this causes "mkinstalldirs" to be run before we do much else
FMS_PREP_HERE = mkinstalldirs


# Override plain old "make" to run "make install".  We could also just
# annoy the user with a message about it.  Perhaps a better idea is to
# just make "make install" the default build target in makerules.mk.
default:
	$(MAKE) install
	@#echo "This build links against libraries that are installed as part"
	@#echo "of the build.  Please use 'make install'."

include $(FMS_TOP)/build/makerules.mk

# Create the installation target subdirectories.  We could also have each
# individual makefile do it, which might be handy for "local" builds.
mkinstalldirs:
	@echo "(creating installation directory for $(FMS_BUILDSPEC))"
	@-mkdir -p $(FMS_DIST_BINDIR)
	@-mkdir -p $(FMS_DIST_LIBDIR)
	@-mkdir -p $(FMS_PRIV_BINDIR)
	@-mkdir -p $(FMS_PRIV_LIBDIR)

# nothing much to do here
here:
	@true

# or here
install-here: 
	@echo "(can do some post-build stuff here)"


#
# This completely wipes out the sample installation directory, and recursively
# removes all ".obj-" directories.  A "make clean" will do this, but only
# for the currently defined target.  When this completes, you should be
# left with a pristine installation.
#
# I throw in "NONEXISTENT" to ensure we don't run "rm -r" with no
# arguments, in case somebody has an rm that does dumb things.
#
# The "rm -rf" on $(FMS_OBJECTTOP) is just printed in this sample file.
# I don't want a bad buildconfig.mk to trash the system.
#
clobber: clean
	-rm -rf install
  ifdef FMS_OBJECTTOP
	@echo Should: -rm -rf $(FMS_OBJECTTOP)
  else
	-find . -type d -name '.obj-*' -print0 | xargs -0 rm -rf NONEXISTENT_DIR
  endif

