#######################################################################
#
# Makefile: 3D-Audio Decoder example
#
#######################################################################

# include the general makefiles using this directive
GENERALROOT=../../../../
MAKEROOT=../
-include $(GENERALROOT)/general/makefile.all

# the following directive is mandatory in order to get all local stuff into this level
ifeq "$(MAKELEVEL)" "0"


# DEFFLAGS #############################################################

ifeq "$(TARGET_SYSTEM)" "Linux"
ISOMEDIALIBDIR = linux
ISOMEDIALIBFLAGS = ""
INCL+= -I$(GENERALROOT)/tools/IsoLib/libisomediafile/linux
else
ifeq "$(TARGET_SYSTEM)" "Darwin"
ISOMEDIALIBDIR = macosx
ISOMEDIALIBFLAGS = "-arch $(TARGET_PLATFORM)"
INCL+= -I$(GENERALROOT)/tools/IsoLib/libisomediafile/macosx
endif
endif

# AFSP FILE PATH
ifeq "$(TARGET_SYSTEM)" "Linux"
ifeq "$(TARGET_PLATFORM)" "x86_64"
 AFSP_LIB = ../../../../tools/AFsp/lib/libtsplite_x86_64.a
else
 AFSP_LIB = ../../../../tools/AFsp/lib/libtsplite.a
endif
endif

ifeq "$(TARGET_SYSTEM)" "Darwin"
 AFSP_LIB = ../../../../tools/AFsp/lib/libtsplite_Mac.a
endif


# DIRECTORIES ##########################################################

SRCDIRS +=  ../src

INCL  = -I../include
INCL += -I../../../../tools/writeonlybitbuf/include
INCL += -I../../../../tools/readonlybitbuf/include
INCL += -I../../../../tools/cicp2geometry/cicp2geometryLib/include
INCL += -I../../../ascParser/ascParserLib/src
INCL += -I../../../binaural/interface/binauralInterfaceLib/include
INCL += -I../../../decoderInterfaces/sceneDisplacementInterface/sceneDisplacementInterfaceLib/include
INCL += -I../../../decoderInterfaces/localSetupInformationInterface/localSetupInformationInterfaceLib/include
INCL += -I../../../decoderInterfaces/elementInteractionInterface/elementInteractionInterfaceLib/include
INCL += -I../../../metadataPreprocessorLib/include
INCL += -I../../../saocCoder/saocDecoderLib/include
INCL += -I../../../../tools/wavIO/include
INCL += -I../../../oamCoder/oamEncoder/oamEncoderLib/include
INCL += -I../../../oamCoder/oamCommon
INCL += -I../../../oamCoder/oamDecoder/src
INCL += -I../../../formatConverter/formatConverterLib/include
INCL += -I../../../../tools/qmflib/include
INCL += -I../../../../tools/IsoLib/mpegh_in_isom/src


# SOURCES ##############################################################

SRCS = decode.c channelPath.c hoaPath.c objectPath.c saocPath.c fdBinauralPath.c tdBinauralPath.c initRenderPaths.c profileLevelHandling.c elementMetadataPreprocessorPath.c

# COMLIBS ##############################################################

COMLIBS += -lmetadataPreprocessor -llocalSetupInformationInterface -lelementInteractionInterface -lsceneDisplacementInterface -lbinauralInterface -lformatConverter -lsaocDecoder -lqmf -loamEncoder -lascParser -lcicp2geometry -lwriteonlybitbuf -lreadonlybitbuf -lwavIO -lmpeghisom

# LIBISOMEDIA FILE PATH ################################################

ISOMEDIA_LIB = $(GENERALROOT)/tools/IsoLib/libisomediafile/$(ISOMEDIALIBDIR)/libisomediafile/libisomediafile.a


# SUMMARIZE VARIABLES ##################################################

OPTIONS  += SRCDIRS="$(SRCDIRS)" INCL="$(INCL)" LIBPATH="$(LIBPATH)" SYSLIBS+="$(AFSP_LIB)" INCLDEP=1 DEFFLAGS="$(DEFFLAGS)" PLOT="$(PLOT)" GPROF="$(GPROF)"


# MAKEFILE RULES AND DEPENDENCIES ######################################
# the first rule `all' has to depend from makefile.all
all: $(GENERALROOT)/general/makefile.all $(ISOMEDIA_LIB) 3DAudioDecoder 


3DAudioDecoder:  $(ISOMEDIA_LIB) 
	@$(MAKE) TARGET=$@ $(OPTIONS) COMLIBS="$(COMLIBS)" SYSLIBS+="$(ISOMEDIA_LIB)" CFLAGS="$(CFLAGS)" SRCS="$(SRCS)" binary

$(ISOMEDIA_LIB):
	@$(MAKE) -C $(GENERALROOT)/tools/IsoLib/libisomediafile/$(ISOMEDIALIBDIR)/libisomediafile CFLAGS+=$(ISOMEDIALIBFLAGS)

clean:
	@$(MAKE) TARGET="3DAudioDecoder" SRCS="$(SRCS)" clean

clean_all:
	@$(MAKE) TARGET="3DAudioDecoder" OBJS="$(OBJS)" COMLIBS="$(COMLIBS)" clean


endif

