include $(SRC/)make/include/base.defs
include $(SRC/)make/include/contrib.defs
include $(SRC/)make/include/function.defs
include $(SRC/)make/include/gcc.defs
include $(SRC/)make/include/target.defs
include $(SRC/)make/include/tool.defs

###############################################################################

ifneq (,$(filter $(HOST.system),cygwin mingw))
ifneq ($(HAS.bz2),1)
    MODULES += contrib/bzip2
endif
endif

ifneq (,$(filter $(HOST.system),darwin cygwin mingw))
    MODULES += contrib/freetype
    MODULES += contrib/fribidi
    MODULES += contrib/harfbuzz
    MODULES += contrib/libxml2
    MODULES += contrib/libass
    MODULES += contrib/libogg
    MODULES += contrib/libvorbis
    MODULES += contrib/libopus
    MODULES += contrib/libspeex
    MODULES += contrib/libtheora
    MODULES += contrib/lame
    MODULES += contrib/x264
    MODULES += contrib/jansson
    MODULES += contrib/libvpx
endif

ifeq (1,$(FEATURE.flatpak))
    MODULES += contrib/jansson
    MODULES += contrib/x264
endif

ifeq (1,$(FEATURE.fdk_aac))
    MODULES += contrib/fdk-aac
endif

ifeq (1,$(FEATURE.x265))
    MODULES += contrib/x265
    MODULES += contrib/x265_8bit
    MODULES += contrib/x265_10bit
    MODULES += contrib/x265_12bit
endif

MODULES += contrib/libdav1d
MODULES += contrib/ffmpeg
MODULES += contrib/libdvdread
MODULES += contrib/libdvdnav
MODULES += contrib/libbluray

ifeq (1,$(FEATURE.qsv))
    MODULES += contrib/libmfx
endif

ifeq (1,$(FEATURE.vce))
    MODULES += contrib/amf
endif

ifeq (1,$(FEATURE.nvenc))
    MODULES += contrib/nvenc
endif

ifneq (,$(filter $(HOST.system),darwin))
    MODULES += contrib/xz
endif

ifneq (,$(filter $(HOST.system),cygwin mingw))
ifneq ($(HAS.iconv),1)
    MODULES += contrib/libiconv
endif
ifneq ($(HAS.xz),1)
    MODULES += contrib/xz
endif
ifneq ($(HAS.libz),1)
    MODULES += contrib/zlib
endif
ifneq ($(HAS.regex),1)
    MODULES += contrib/libgnurx
endif
endif

ifneq (,$(filter $(HOST.system),solaris))
    MODULES += contrib/libiconv
endif


## these must come after contrib since some contrib modules are optional
MODULES += libhb

###############################################################################

ifeq (1-darwin,$(FEATURE.xcode)-$(HOST.system))
    ## use macosx module when xcode+darwin
    MODULES += macosx
else
    ## default is to build CLI
    MODULES += test
endif

ifeq (1-mingw,$(FEATURE.gtk.mingw)-$(HOST.system))
    MODULES += gtk
endif

ifeq (1-linux,$(FEATURE.gtk)-$(HOST.system))
    ## build gtk when gtk+linux
    MODULES += gtk
endif

ifeq (1-freebsd,$(FEATURE.gtk)-$(HOST.system))
    ## build gtk when gtk+freebsd
    MODULES += gtk
endif

ifeq (1-kfreebsd,$(FEATURE.gtk)-$(HOST.system))
    ## build gtk when gtk+kfreebsd
    MODULES += gtk
endif

ifeq (1-gnu,$(FEATURE.gtk)-$(HOST.system))
    ## build gtk when gtk+gnu
    MODULES += gtk
endif

ifeq (1-netbsd,$(FEATURE.gtk)-$(BUILD.system))
    ## build gtk when gtk+netbsd
    MODULES += gtk
endif

###############################################################################

MODULES += pkg

###############################################################################

include $(MODULES:%=$(SRC/)%/module.defs)
include $(SRC/)make/variant/$(HOST.system).defs
-include $(SRC/)make/variant/$(HOST.system).$(HOST.machine).defs
