###############################################################################
#  Makefile.postamble
#  Copyright 1997, Apple Computer, Inc.
#
#  Use this makefile, which is imported after all other makefiles, to
#  override attributes for a project's Makefile environment. This allows you  
#  to take advantage of the environment set up by the other Makefiles. 
#  You can also define custom rules at the end of this file.
#
###############################################################################
# 
# These variables are exported by the standard makefiles and can be 
# used in any customizations you make.  They are *outputs* of
# the Makefiles and should be used, not set.
# 
#  PRODUCTS: products to install.  All of these products will be placed in
#	 the directory $(DSTROOT)$(INSTALLDIR)
#  GLOBAL_RESOURCE_DIR: The directory to which resources are copied.
#  LOCAL_RESOURCE_DIR: The directory to which localized resources are copied.
#  OFILE_DIR: Directory into which .o object files are generated.
#  DERIVED_SRC_DIR: Directory used for all other derived files
#
#  ALL_CFLAGS:  flags to pass when compiling .c files
#  ALL_MFLAGS:  flags to pass when compiling .m files
#  ALL_CCFLAGS:  flags to pass when compiling .cc, .cxx, and .C files
#  ALL_MMFLAGS:  flags to pass when compiling .mm, .mxx, and .M files
#  ALL_PRECOMPFLAGS:  flags to pass when precompiling .h files
#  ALL_LDFLAGS:  flags to pass when linking object files
#  ALL_LIBTOOL_FLAGS:  flags to pass when libtooling object files
#  ALL_PSWFLAGS:  flags to pass when processing .psw and .pswm (pswrap) files
#  ALL_RPCFLAGS:  flags to pass when processing .rpc (rpcgen) files
#  ALL_YFLAGS:  flags to pass when processing .y (yacc) files
#  ALL_LFLAGS:  flags to pass when processing .l (lex) files
#
#  NAME: name of application, bundle, subproject, palette, etc.
#  LANGUAGE: langage in which the project is written (default "English")
#  LOCAL_RESOURCES: localized resources (e.g. nib's, images) of project
#  GLOBAL_RESOURCES: non-localized resources of project
#
#  SRCROOT:  base directory in which to place the new source files
#  SRCPATH:  relative path from SRCROOT to present subdirectory
#
#  INSTALLDIR: Directory the product will be installed into by 'install' target
#  PUBLIC_HDR_INSTALLDIR: where to install public headers.  Don't forget
#        to prefix this with DSTROOT when you use it.
#  PRIVATE_HDR_INSTALLDIR: where to install private headers.  Don't forget
#	 to prefix this with DSTROOT when you use it.
#
#  EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows)
#
###############################################################################

# Some compiler flags can be overridden here for certain build situations.
#
#    WARNING_CFLAGS:  flag used to set warning level (defaults to -Wmost)
#    DEBUG_SYMBOLS_CFLAGS:  debug-symbol flag passed to all builds (defaults
#	to -g)
#    DEBUG_BUILD_CFLAGS:  flags passed during debug builds (defaults to -DDEBUG)
#    OPTIMIZE_BUILD_CFLAGS:  flags passed during optimized builds (defaults
#	to -O)
#    PROFILE_BUILD_CFLAGS:  flags passed during profile builds (defaults
#	to -pg -DPROFILE)
#    LOCAL_DIR_INCLUDE_DIRECTIVE:  flag used to add current directory to
#	the include path (defaults to -I.)
#    DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags
#	passed to ld/libtool (defaults to nothing)


# Library and Framework projects only:
#    INSTALL_NAME_DIRECTIVE:  This directive ensures that executables linked
#	against the framework will run against the correct version even if
#	the current version of the framework changes.  You may override this
#	to "" as an alternative to using the DYLD_LIBRARY_PATH during your
#	development cycle, but be sure to restore it before installing.


# Ownership and permissions of files installed by 'install' target

#INSTALL_AS_USER = root
        # User/group ownership 
#INSTALL_AS_GROUP = wheel
        # (probably want to set both of these) 
#INSTALL_PERMISSIONS =
        # If set, 'install' chmod's executable to this


# Options to strip.  Note: -S strips debugging symbols (executables can be stripped
# down further with -x or, if they load no bundles, with no options at all).

#STRIPFLAGS = -S


#########################################################################
# Put rules to extend the behavior of the standard Makefiles here.  Include them in
# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble.
#
# You should avoid redefining things like "install" or "app", as they are
# owned by the top-level Makefile API and no context has been set up for where 
# derived files should go.
#

PRODUCT_NAME = eogenerator
DIST_DIR = package
EXP_DIR = ExportSource
PACKAGE_DIR = $(DIST_DIR)/$(PRODUCT_NAME)
PACKAGE_SRC = $(PACKAGE_DIR)/Source
CVS=$(firstword $(wildcard /usr/bin/ocvs) cvs)

$(DIST_DIR) $(PACKAGE_DIR) $(PACKAGE_DIR)/Templates:
	$(MKDIRS) $@

# Build fat binaries on OPENSTEP
ifneq "" "$(wildcard /bin/mkdirs)"
  INSTALL_OPTS += TARGET_ARCHS="m68k i386 sparc"
endif

# Build fat, er, universal binaries on Tiger
ifneq "" "$(wildcard /usr/bin/mdimport)"
  INSTALL_OPTS += TARGET_ARCHS="ppc i386"
endif

clean-dist:
	@$(RM) -rf $(PACKAGE_DIR) $(EXP_DIR)

distpackage: clean-dist $(PACKAGE_DIR) $(PACKAGE_DIR)/Templates
	@echo ""
	@echo "===== There should be nothing after this and before the next ====="
	@$(CVS) -nq update
	@echo "====="
	@echo ""
	$(CVS) export -D now -d $(EXP_DIR) $(PRODUCT_NAME)
	$(MV) $(EXP_DIR) $(PACKAGE_SRC)
	$(MAKE) -s install $(INSTALL_OPTS) INSTALLDIR=$(PACKAGE_DIR)
	@if [ "$(STRIP)" != "" ] ; then \
		$(STRIP) $(PACKAGE_DIR)/$(PRODUCT_NAME) ; \
	fi
	$(MV) $(PACKAGE_SRC)/LICENSE.txt $(PACKAGE_DIR)
	$(MV) $(PACKAGE_SRC)/*.rtf $(PACKAGE_DIR)
	$(MV) $(PACKAGE_SRC)/*.eotemplate $(PACKAGE_DIR)/Templates
	$(RM) -rf $(PACKAGE_SRC)

distsrc: clean-dist $(DIST_DIR)
	$(CVS) export -D now -d $(EXP_DIR) $(PRODUCT_NAME)
	$(MV) $(EXP_DIR) $(PACKAGE_DIR)

dmgball-nobuild:
	@if [ "$(PKGVERS)" = "" ] ; then \
		echo Must specify a PKGVERS variable with this command ; \
	else \
		cd $(DIST_DIR) ; \
		rm -f "$(PRODUCT_NAME)-$(PKGVERS).dmg" ; \
		echo dmgmaker -q -f "$(PRODUCT_NAME)" "$(PRODUCT_NAME)-$(PKGVERS)" ; \
		../../../BFMake/Tools/dmgmaker -q -f "$(PRODUCT_NAME)" "$(PRODUCT_NAME)-$(PKGVERS)" ; \
	fi

dmgball: distpackage dmgball-nobuild

tarball-nobuild:
	@if [ "$(PKGVERS)" = "" ] ; then \
		echo Must specify a PKGVERS variable with this command ; \
	else \
		cd package ; \
		echo $(TAR) cf "$(PRODUCT_NAME)-$(PKGVERS).tar.gz" "$(PRODUCT_NAME)" ; \
		$(TAR) cf "$(PRODUCT_NAME)-$(PKGVERS).tar" "$(PRODUCT_NAME)" && \
		echo gzip -f "$(PRODUCT_NAME)-$(PKGVERS).tar" && \
		gzip -f "$(PRODUCT_NAME)-$(PKGVERS).tar" ; \
	fi

tarball: distpackage tarball-nobuild

zipball-nobuild:
	@cd package ; \
	if [ "$(PKGVERS)" = "" ] ; then \
		echo Must specify a PKGVERS variable with this command ; \
	else \
		echo $(MKZIP) -r "$(PRODUCT_NAME)-$(PKGVERS).zip" $(PRODUCT_NAME) ; \
		$(MKZIP) -r "$(PRODUCT_NAME)-$(PKGVERS).zip" $(PRODUCT_NAME) ; \
	fi

zipball: distpackage zipball-nobuild