# 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"

SRCS_ENC = earconEncoder.c mhasWriter.c earconInfoWriter.c pcmDataPayloadWriter.c pcmDataConfigWriter.c
SRCS_ENC += earconInfo.c pcmDataConfig.c twosComplement.c printHelper.c pcmDataPayload.c

SRCS_DEC = bitstreamReader.c earconInfoReader.c pcmDataConfigReader.c wavWriter.c bsWriter.c earconDecoder.c mhasReader.c pcmDataPayloadReader.c
SRCS_DEC += earconInfo.c pcmDataConfig.c twosComplement.c printHelper.c pcmDataPayload.c

SRCDIRS_ENC += ../src/earconEncoder
SRCDIRS_ENC += ../src/common

SRCDIRS_DEC += ../src/earconDecoder
SRCDIRS_DEC += ../src/common

INCL_ENC = -I../src/earconEncoder -I../src/common -I../../../tools/wavIO/include -I../../../tools/writeonlybitbuf/include
INCL_DEC = -I../src/earconDecoder -I../src/common -I../../../tools/wavIO/include -I../../../tools/readonlybitbuf/include

COMLIBS_ENC += -lwavIO -lwriteonlybitbuf
COMLIBS_DEC += -lwavIO -lreadonlybitbuf

OPTIONS_ENC += SRCDIRS="$(SRCDIRS_ENC)" INCL="$(INCL_ENC)" LIBPATH="$(LIBPATH)" SYSLIBS="" INCLDEP=1 DEFFLAGS="$(DEFFLAGS)" PLOT="$(PLOT)" GPROF="$(GPROF)" GLOBOPTS="$(GLOBOPTS)"
OPTIONS_DEC += SRCDIRS="$(SRCDIRS_DEC)" INCL="$(INCL_DEC)" LIBPATH="$(LIBPATH)" SYSLIBS="" INCLDEP=1 DEFFLAGS="$(DEFFLAGS)" PLOT="$(PLOT)" GPROF="$(GPROF)" GLOBOPTS="$(GLOBOPTS)"

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

earconEncoder:
	@echo DEFFLAGS="$(DEFFLAGS)"
	@$(MAKE) TARGET=$@ $(OPTIONS_ENC) COMLIBS="$(COMLIBS_ENC)" SYSLIBS="" CFLAGS="$(CFLAGS)" SRCS="$(SRCS_ENC)" binary

earconDecoder:
	@echo DEFFLAGS="$(DEFFLAGS)"
	@$(MAKE) TARGET=$@ $(OPTIONS_DEC) COMLIBS="$(COMLIBS_DEC)" SYSLIBS="" CFLAGS="$(CFLAGS)" SRCS="$(SRCS_DEC)" binary

clean:
	@$(MAKE) TARGET="earconEncoder earconDecoder" SRCS="$(SRCS)" clean

clean_all:
	@$(MAKE) TARGET="earconEncoder earconDecoder" OBJS="$(OBJS)" COMLIBS="$(COMLIBS)" clean

endif

