###############################################################################
#
# $Id$ $Name$
#
# The contents of this file are subject to the AAF SDK Public Source
# License Agreement Version 2.0 (the "License"); You may not use this
# file except in compliance with the License.  The License is available
# in AAFSDKPSL.TXT, or you may obtain a copy of the License from the
# Advanced Media Workflow Association, Inc., or its successor.
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
# the License for the specific language governing rights and limitations
# under the License.  Refer to Section 3.3 of the License for proper use
# of this Exhibit.
#
# WARNING:  Please contact the Advanced Media Workflow Association,
# Inc., for more information about any additional licenses to
# intellectual property covering the AAF Standard that may be required
# to create and distribute AAF compliant products.
# (http://www.amwa.tv/policies).
#
# Copyright Notices:
# The Original Code of this file is Copyright 1998-2009, licensor of the
# Advanced Media Workflow Association.  All rights reserved.
#
# The Initial Developer of the Original Code of this file and the
# licensor of the Advanced Media Workflow Association is
# Avid Technology.
# All rights reserved.
#
###############################################################################

#------------------------------------------------------------------------------
#
#
#------------------------------------------------------------------------------
PACKAGE = Utilities

AAFBASE ?= ../..


# Common definitions
include $(AAFBASE)/build/common.mk


# Include directories
INCLUDES = -I$(AAFSDKINCLUDEDIR) \
		-I../Include \
	   -I../../OMF/Include \
	   -I../../OMF/portinc


# CXXOBJS2 is the list of files used to create the executable.
CXXFILES2 = AafOmfMain.$(CPP_EXTENSION)


# LIBCXXOBJS is the list of object file used to create the library.
# It's generated by taking all the object files from current OBJDIR 
# and removing AafOmfMain.o from the list. 
LIBCXXOBJS = $(filter-out $(OBJDIR)/AafOmfMain$(OBJ), $(CXXOBJS))


LIBTARGET = $(AAFSDKLIBDIR)/libAAFConverterLib$(LIBEXT)
BINTARGET = $(AAFSDKBINDIR)/AafOmf$(EXE)



.PHONY : all
all : $(OBJDIR) $(LIBTARGET) $(BINTARGET)


# Build the library. Note that we use LIBCXXOBJS to not link
# files containing main() function.
$(LIBTARGET) : $(LIBCXXOBJS)
	$(LD_STAT_LIB) $(LD_STAT_OUTPUT) $(LIBCXXOBJS)

ifeq ($(AAFPLATFORM), MipsIrix)

OMFLIBDIR=$(AAFBASE)/OMF/IrixLibs


# Build executable. Note that CXXOBJS2 is used instead of CXXOBJS.
$(BINTARGET) : $(CXXOBJS2) $(LIBTARGET)
	$(LD) $(CXXOBJS2) $(RPATH_OPT) -lAAFConverterLib \
	-L$(OMFLIBDIR) -lAJPG -lOMFI -lbento -ljpeg \
	-L$(AAFSDKLIBDIR) -laaflib -laafiid $(LIBCIO) -o $@ -lm

else

ifeq ($(AAFPLATFORM), Win)
$(BINTARGET) : $(CXXOBJS2) $(LIBTARGET)
	$(LD) $(CXXOBJS2) $(LIBTARGET) \
	../../OMF/WinLibs/omfToolkit.lib \
	../../OMF/WinLibs/libbento.lib \
	../../OMF/WinLibs/libjpeg.lib \
	$(LINK_AAF_APP)
else

$(BINTARGET) : $(CXXOBJS2) $(LIBTARGET)
	@echo "OMF library not available for $(AAFPLATFORM)."

endif

endif

.PHONY : clean
clean :
	@$(RM) $(LIBCXXOBJS)
	@$(RM) $(CXXOBJS2)
	@$(RM) $(DEPS)
	@$(RM) $(LIBTARGET)
	@$(RM) $(BINTARGET)
	@$(RMDIR) $(OBJDIR)/ii_files


.PHONY : realclean
realclean : clean


CFLAGS += -DNO_CONTAINER_EXPORTS


include $(AAFBASE)/build/rules.mk

