-# -*- makefile -*-
+# -*- makefile-gmake -*-
# Config file for compilation by OMK for AQuoSA/Linux OS target
-ifeq ($(RELATIVE_DIR:ffmpeg%=ffmpeg),ffmpeg)
-# Allow building ffmpeg by OMK
+OMIT_KERNEL_PASSES=y
+
+# For the FFMPEG2OMK hack, we need RELATIVE_DIR earlier:
+ifndef RELATIVE_DIR
+RELATIVE_DIR := $(SOURCES_DIR:$(OUTPUT_DIR)%=%)
+endif
-define FFMPEG_OMKIZE
-lib_LIBRARIES:=$(NAME)
-$(NAME)_SOURCES:=$(OBJS:%.o=%.c) $(OBJS-y:%.o=%.c) $(OBJS-yes:%.o=%.c)
-renamed_include_HEADERS:=$(foreach h,$(HEADERS),$(h)->lib$(NAME)/$(h) )
-INCLUDES += -I $(srcdir)/..
-endef
+FFMPEG_BUILD_DIR=$(OUTPUT_DIR)/_build/user/ffmpeg
-$(SOURCES_DIR)/Makefile.omk: $(SOURCES_DIR)/Makefile $(MAKERULES_DIR)/ffmpeg/libswscale
+# Allow building ffmpeg by OMK
+ifeq ($(RELATIVE_DIR:ffmpeg%=ffmpeg),ffmpeg)
+$(SOURCES_DIR)/Makefile.omk: $(MAKERULES_DIR)/ffmpeg/libswscale \
+ $(MAKERULES_DIR)/Makefile.omk.ffmpeg \
+ $(FFMPEG_BUILD_DIR)/config.mak \
+ $(FFMPEG_BUILD_DIR)/version.h \
+ $(OUTPUT_DIR)/_build/user/$(RELATIVE_DIR)/Makefile \
+ $(MAKERULES_DIR)/../build/config.target # this file
@echo " FFOMK $@"
- $(Q)make DEPS="" -C $(SOURCES_DIR) -qp -f $< |sed -ne '/# Pattern-specific Variable Values/,$$ d' -e '/# makefile/,+1 p'|\
- sed -e /^define/d -e "/^#/d" -e "/^MAKE/d" > $@
-# echo '$(value FFMPEG_OMKIZE)' >> $@ # There is a bug in make
-ifeq ($(SOURCES_DIR:%/libavcodec=YES),YES)
- $(Q)echo 'SUBDIRS=x86' >> $@
-endif
+ $(Q)echo "FFMPEG_SUBDIR=$(RELATIVE_DIR:ffmpeg/%=%)" > $@
$(Q)cat $(MAKERULES_DIR)/Makefile.omk.ffmpeg >> $@
-$(MAKERULES_DIR)/ffmpeg/libavcodec/x86/Makefile:
+$(OUTPUT_DIR)/_build/user/$(RELATIVE_DIR)/Makefile.inc.ffmpeg: $(OUTPUT_DIR)/_build/user/$(RELATIVE_DIR)/Makefile
+ @echo " SCRIPT $@"
+ $(Q)make DEPS="" -C $(OUTPUT_DIR)/_build/user/$(RELATIVE_DIR) -rqp \
+ | sed -ne '/# Pattern-specific Variable Values/,$$ d' -e '/# makefile/,+1 p' \
+ | sed -e /^define/d -e "/^#/d" -e "/^MAKE/d" > $@
+
+$(FFMPEG_BUILD_DIR)/tools/Makefile:
+ touch $@
+
+$(FFMPEG_BUILD_DIR)/libavcodec/x86/Makefile:
touch $@
$(MAKERULES_DIR)/ffmpeg/libswscale:
ln -sf ../../src/libswscale $@
+
+ifeq ($(wildcard $(FFMPEG_BUILD_DIR)/Makefile),)
+$(FFMPEG_BUILD_DIR)/Makefile: $(FFMPEG_BUILD_DIR)/config.mak
+endif
+
+$(FFMPEG_BUILD_DIR)/config.mak: \
+ $(MAKERULES_DIR)/ffmpeg/configure \
+ $(MAKERULES_DIR)/../build/config.target # this file
+ cd $(dir $@) && $(MAKERULES_DIR)/ffmpeg/configure $(if $(CONFIG_FFMPEG_WITH_FRSH:y=),--disable-protocol=frsh)
+
+$(FFMPEG_BUILD_DIR)/version.h:
+ cd $(dir $@) && $(MAKERULES_DIR)/ffmpeg/version.sh $(PWD) $@
endif
CONFIG_FORB_PROTO_UNIX=n
CONFIG_FORB_PROTO_INET_DEFAULT=y
CONFIG_AQUOSA=y
+CONFIG_FFMPEG_WITH_FRSH=y
+CONFIG_DISKBFQ=y
########################################
# Setting of compiler
# Instead, we call normal gcc with parameters which mgcc adds
-CFLAGS=$(ARCH_GCC_OPTS) -Wall -Wuninitialized -g -O1 -D_REENTRANT -D$(PLATFORM) -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
+CFLAGS=$(ARCH_GCC_OPTS) -Wall -Wuninitialized -g -O2 $(CFLAGS-y) -D_REENTRANT -D$(PLATFORM) -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -fPIC
+
LDFLAGS=$(ARCH_LD_OPTS) $(LIBS_PATH) $(LIBS)
LDFLAGS += '-Wl,-rpath,$$ORIGIN/../lib' -z origin --enable-new-dtags