
#
# Support for making the build process as quiet as possible.  This lets you see errors
# and warnings more easily
#
ifndef OMNIMAKE_QUIET_MAKE
    OMNIMAKE_QUIET_MAKE=YES
endif

# Compute a rational name for the project type.  The standard NeXT Makefiels put spaces
# in this sometimes -- strip them.  Also, we don't even like 'Loadable Bundles'.
#
ifeq ("Loadable Bundle", "$(PROJECT_TYPE)")
    OMNIMAKE_PROJECT_TYPE = Bundle
else
    OMNIMAKE_PROJECT_TYPE := $(shell echo $(PROJECT_TYPE) | sed 's/ //')
endif

OMNIMAKE_UPPER_PROJECT_TYPE = $(shell echo $(OMNIMAKE_PROJECT_TYPE) | tr 'a-z' 'A-Z')
OMNIMAKE_LOWER_PROJECT_TYPE = $(shell echo $(OMNIMAKE_PROJECT_TYPE) | tr 'A-Z' 'a-z')

#
# Add a define for RHAPSODY so we can tell the difference between it and NEXTSTEP
#
ifeq ($(OMNIMAKE_MACHINE), Rhapsody)
    OTHER_CFLAGS += -DRHAPSODY
endif

#
# Import any platform specific Makefile information for the current project
#
-include Makefile.preamble-$(PLATFORM_OS)

#
# Import any platform specific Makefile information common to all projects
#
-include $(LOCAL_MAKEFILEDIR)/common.make.preamble-$(PLATFORM_OS)

#
# Turn on environment verification (see verify.make)
#
BEFORE_PREBUILD += omnimake_verify_environment

#
# By default, assertions are turned on, but you can define OMNIMAKE_FORCE_ASSERTIONS_OFF
# to turn them off for a public release.
#
ifndef OMNIMAKE_FORCE_ASSERTIONS_OFF
    ASSERTION_CFLAGS = -DOMNIMAKE_FORCE_ASSERTIONS
endif


OTHER_CFLAGS += $(ASSERTION_CFLAGS)

#
# hack to get -DDEBUG when building install
#
ifdef OMNIMAKE_FORCE_DEBUG_DEFINED
    OTHER_CFLAGS += $(DEBUG_BUILD_CFLAGS)
endif

#
# NeXT defaults these to root and wheel when installing.  This will prevent you from
# reinstalling.
#
ifndef INSTALL_AS_USER
    INSTALL_AS_USER = $(USER)
endif
ifndef INSTALL_AS_GROUP
    INSTALL_AS_GROUP = omni
endif


#  Stuff for automating the install location
OMNIMAKE_INSTALL_DIR     = $(OMNIMAKE_INSTALL_ROOT)/$(OMNIMAKE_PROJECT_TYPE)s
INSTALLDIR           = $(OMNIMAKE_INSTALL_DIR)

#
# Where the special root source tree lives.  This should never be used in place
# of OMNIMAKE_INSTALL_ROOT.  If you use this directory, you must be looking for
# source files, not compiled or installed files.
#
OMNIMAKE_UTILITY_DIR		= $(OMNIMAKE_ROOT)/utilities

#
# Some common install dirs
#
OMNIMAKE_TOOL_DIR                   = $(OMNIMAKE_INSTALL_ROOT)/Tools
OMNIMAKE_PALETTE_DIR		= $(OMNIMAKE_INSTALL_ROOT)/Palettes
OMNIMAKE_BUNDLE_DIR			= $(OMNIMAKE_INSTALL_ROOT)/Bundles
OMNIMAKE_FRAMEWORK_DIR		= $(OMNIMAKE_INSTALL_ROOT)/Frameworks
OMNIMAKE_APPLICATION_DIR		= $(OMNIMAKE_INSTALL_ROOT)/Applications
OMNIMAKE_EXPORTED_DOCUMENTATION_DIR	= $(OMNIMAKE_INSTALL_ROOT)/Documentation/$(NAME)
OMNIMAKE_LOCAL_DOCUMENTATION	= Documentation

#
# Set the NeXT provide hook for placing the results of our build in an alternate
# directory that the source directory.  This allows us to build across NFS or Samba
# efficiently and had several other good properties.
#
BUILD_OUTPUT_DIR        = $(OMNIMAKE_BUILD_OUTPUT_ROOT)/$(OMNIMAKE_PROJECT_TYPE)s/$(NAME)
OMNIMAKE_DERIVED_SOURCE_DIR = $(SFILE_DIR)

# Prevent spurious warnings or errors about $(OMNIMAKE_FRAMEWORK_DIR) not
# existing when used with '-F'
# We don't name the directory explicitly here since then a
# 'make clean' would blow away all of our installed frameworks.
BEFORE_PREBUILD += $(OMNIMAKE_FRAMEWORK_DIR)

#
#  Support for referencing symbols in frameworks.  This is necessary for NT.
#
ifeq ($(PLATFORM_OS), winnt)
    ifneq ($(OMNIMAKE_PROJECT_TYPE), Component)
        OMNIMAKE_FRAMEWORK_SYMBOL_M = $(OMNIMAKE_DERIVED_SOURCE_DIR)/FrameworkSymbols.m
        OMNIMAKE_FRAMEWORK_SYMBOL_O = $(OFILE_DIR)/FrameworkSymbols.o
        BEFORE_BUILD_RECURSION  += omnimake_framework_symbols
        OTHER_GENERATED_OFILES += $(OMNIMAKE_FRAMEWORK_SYMBOL_O)
    endif
endif


FRAMEWORK_ADDRESSES_PLIST = FrameworkAddresses.plist
PROJECT_INFO = $(OMNIMAKE_TOOL_DIR)/projectInfo

#
# Support for finding subproject plist files, and merging them using
# out improved dictionary merging tool.  The output is then given to
# the standard merging tool.
#
OMNIMAKE_MERGE_DICTIONARIES_NAME=mergeDictionaries
ifneq ($(OMNIMAKE_PROJECT_TYPE), Component)
    ifneq ($(NAME), $(OMNIMAKE_MERGE_DICTIONARIES_NAME))
	OMNIMAKE_MERGED_INFO=$(OMNIMAKE_DERIVED_SOURCE_DIR)/Omni-Info.plist

	OTHER_INFO_FILES += $(OMNIMAKE_MERGED_INFO)
	#BEFORE_BUILD_RECURSION += omnimake_merge_info
    endif
endif

#
# Make the results of the build process get copied to our personal install root
# (if we are a root level project)
#
ifndef RECURSING
    AFTER_BUILD += omnimake_copy_to_personal_install_root
endif

#
# We don't like the stupid headers created by clonehdrs.
# They mess all sorts of stuff up.  We have to set this here rather than
# in framework.make.preamble since otherwise, subproject headers will get
# cloned rather than copied.
#
CLONEHDRS = $(FASTCP)

# Due to the dumbass way NeXT's makefiles are structured, *.make.preamble
# is imported AFTER a bunch of crucial variables have been expanded in common.make
# and things it imports.  We need an earlier hook.  For example, OTHER_PROJECT_HEADERS
# is expanded in common.make->prebuild.make before framework.make.preamble has
# a chance to add anything to it.
-include $(LOCAL_MAKEFILEDIR)/$(OMNIMAKE_LOWER_PROJECT_TYPE).make.preamble.early
