__deps__ := X265_8
$(eval $(call import.MODULE.defs,X265_12,x265_12,$(__deps__),x265))
$(eval $(call import.CONTRIB.defs,X265_12))

X265_12.FETCH.url     = https://download.handbrake.fr/contrib/x265_3.2.1.tar.gz
X265_12.FETCH.url    += https://bitbucket.org/multicoreware/x265/downloads/x265_3.2.1.tar.gz
X265_12.FETCH.url    += https://download.videolan.org/pub/videolan/x265/x265_3.2.1.tar.gz
X265_12.FETCH.sha256  = fb9badcf92364fd3567f8b5aa0e5e952aeea7a39a2b864387cec31e3b58cbbcc
X265_12.EXTRACT.tarbase = x265_3.2.1

# Silence "warning: overriding recipe for target" messages
X265_12.FETCH.target =

X265_12.build_dir             = 12bit
X265_12.CONFIGURE.exe         = cmake
X265_12.CONFIGURE.args.prefix = -DCMAKE_INSTALL_PREFIX="$(X265_12.CONFIGURE.prefix)"
X265_12.CONFIGURE.deps        =
X265_12.CONFIGURE.static      =
X265_12.CONFIGURE.shared      = -DENABLE_SHARED=OFF
X265_12.CONFIGURE.extra       = -DENABLE_CLI=OFF -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DMAIN12=ON

ifneq (1,$(FEATURE.numa))
    X265_12.CONFIGURE.extra  += -DENABLE_LIBNUMA=OFF
endif

ifneq (none,$(X265_12.GCC.g))
    X265_12.CONFIGURE.extra += -DCMAKE_BUILD_TYPE=Debug
else
    X265_12.CONFIGURE.extra += -DCMAKE_BUILD_TYPE=Release
endif

ifeq (1,$(HOST.cross))
    ifeq (mingw,$(HOST.system))
        X265_12.CONFIGURE.extra += -DWIN32=ON
        X265_12.CONFIGURE.extra += -DCMAKE_SYSTEM_NAME=Windows
        X265_12.CONFIGURE.extra += -DCMAKE_C_COMPILER=$(X265_12.GCC.gcc)
        X265_12.CONFIGURE.extra += -DCMAKE_C_FLAGS="-static-libgcc -static-libstdc++ -static"
        X265_12.CONFIGURE.extra += -DCMAKE_SHARED_LIBRARY_LINK_C_FLAGS="-static-libgcc -static-libstdc++ -static"
        X265_12.CONFIGURE.extra += -DCMAKE_CXX_COMPILER=$(X265_12.GCC.gxx)
        X265_12.CONFIGURE.extra += -DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++ -static"
        X265_12.CONFIGURE.extra += -DCMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS="-static-libgcc -static-libstdc++ -static"
        X265_12.CONFIGURE.extra += -DCMAKE_RC_COMPILER=$(HOST.cross.prefix)windres
    endif
    X265_12.CONFIGURE.args.host  = -DCMAKE_SYSTEM_NAME="$(X265_12.CONFIGURE.host)"
    X265_12.CONFIGURE.args.build = -DCMAKE_HOST_SYSTEM="$(X265_12.CONFIGURE.build)"
else
    X265_12.CONFIGURE.args.host  = -DCMAKE_HOST_SYSTEM="$(X265_12.CONFIGURE.host)"
endif

## find CMakeLists.txt
X265_12.CONFIGURE.extra += "$(call fn.ABSOLUTE,$(X265_12.EXTRACT.dir/)source/)"

X265_12.INSTALL.make = $(MV.exe)
X265_12.INSTALL.args.dir = cd $(1);
X265_12.INSTALL.extra = libx265.a libx265_main12.a
X265_12.INSTALL.args = @dir !make !extra

# Override operations that are not needed
X265_12.FETCH =
X265_12.VERIFY = $(TOUCH.exe) $@
X265_12.EXTRACT = $(TOUCH.exe) $@
X265_12.PATCH = $(TOUCH.exe) $@
X265_12.XCLEAN =
