
LOCAL_PREFIX    = $(OUTPUT_DIR)/install/usr/local

AVCODEC_LIB     = $(LOCAL_PREFIX)/lib/libavcodec.a
AVDEVICE_LIB    = $(LOCAL_PREFIX)/lib/libavdevice.a
AVFILTER_LIB    = $(LOCAL_PREFIX)/lib/libavfilter.a
AVFORMAT_LIB    = $(LOCAL_PREFIX)/lib/libavformat.a
AVUTIL_LIB      = $(LOCAL_PREFIX)/lib/libavutil.a
SWRESAMPLE_LIB  = $(LOCAL_PREFIX)/lib/libswresample.a
SWSCALE_LIB     = $(LOCAL_PREFIX)/lib/libswscale.a

FFMPEG_SRC_DIR  = .modules/FFmpeg
FFMPEG_INC_DIR  = $(LOCAL_PREFIX)/include
FFMPEG_LIBS     = $(AVCODEC_LIB) $(AVDEVICE_LIB) $(AVFILTER_LIB) $(AVFORMAT_LIB) $(AVUTIL_LIB) $(SWRESAMPLE_LIB) $(SWSCALE_LIB)

$(AVCODEC_LIB):
	if [ ! -d $(OUTPUT_DIR)/ffmpeg ] ; then mkdir -p $(OUTPUT_DIR)/ffmpeg && cd $(OUTPUT_DIR)/ffmpeg && ../../../$(FFMPEG_SRC_DIR)/configure --prefix=../install/usr/local; fi
	cd $(OUTPUT_DIR)/ffmpeg && make && make install

# These deps aren't real, but hack for the build
$(AVDEVICE_LIB):   $(AVCODEC_LIB)
$(AVFILTER_LIB):   $(AVCODEC_LIB)
$(AVFORMAT_LIB):   $(AVCODEC_LIB)
$(AVUTIL_LIB):     $(AVCODEC_LIB)
$(SWRESAMPLE_LIB): $(AVCODEC_LIB)
$(SWSCALE_LIB):    $(AVCODEC_LIB)

build: $(FFMPEG_LIBS)
