##
# libmodplug Makefile fragment
##

.PHONY: ${libmodplug}_clean

.SUFFIXES: .cpp

libmodplug_src = contrib/libmodplug/src
libmodplug_obj = contrib/libmodplug/src/.build

libmodplug_cflags = -DHAVE_INTTYPES_H -I${libmodplug_src} \
                    -I${libmodplug_src}/libmodplug \
                    -include src/platform_endian.h

libmodplug_objs = \
    ${libmodplug_obj}/fastmix.o ${libmodplug_obj}/load_669.o \
    ${libmodplug_obj}/load_amf.o ${libmodplug_obj}/load_dsm.o \
    ${libmodplug_obj}/load_far.o ${libmodplug_obj}/load_it.o \
    ${libmodplug_obj}/load_med.o ${libmodplug_obj}/load_mod.o \
    ${libmodplug_obj}/load_mtm.o ${libmodplug_obj}/load_okt.o \
    ${libmodplug_obj}/load_s3m.o ${libmodplug_obj}/load_stm.o \
    ${libmodplug_obj}/load_ult.o ${libmodplug_obj}/load_wav.o \
    ${libmodplug_obj}/load_xm.o ${libmodplug_obj}/mmcmp.o \
    ${libmodplug_obj}/modplug.o ${libmodplug_obj}/snd_dsp.o \
    ${libmodplug_obj}/sndfile.o ${libmodplug_obj}/snd_flt.o \
    ${libmodplug_obj}/snd_fx.o ${libmodplug_obj}/sndmix.o

${libmodplug_obj}/%.o: ${libmodplug_src}/%.cpp
	$(if ${V},,@echo "  CXX     " $<)
	${CXX} -MD ${CXXFLAGS} ${libmodplug_cflags} -c $< -o $@

-include $(libmodplug_objs:.o=.d)

${libmodplug_objs}: $(filter-out $(wildcard ${libmodplug_obj}), ${libmodplug_obj})

libmodplug_clean:
	$(if ${V},,@echo "  RM      " ${libmodplug_obj})
	${RM} -r ${libmodplug_obj}
