13 Customisable Packages
Tony Theodore edited this page 2016-08-08 21:27:49 +10:00

This is a "blueprint" of customisable packages feature in MXE. Suggestions and implementations welcome.

Goals

  • User-defined CFLAGS etc.
  • Threading, exception, and debug variants
  • Other toolchain features (i.e. libgomp)
  • Optional non-free section (i.e. AAC codecs)
  • Minimal builds (i.e. removing Qt features, optimising for small size)
  • Customisations to be persistent and kept under user's own version control
  • Selection of alternate implementations (i.e. jpeg/libjpeg-turbo or lua/luajit)

Outline

Customisation files read in following order:

  1. settings.mk - deprecated (doesn't persist across checkouts and not useful for automated builds)
  2. MXE_SETTINGS_FILE
    • installation prefix, log, pkg, and tmp dirs
    • plugin dirs
    • targets
    • jobs and max-load
    • read before any pkg rules
    • defaults to ~/.mxe/settings.mk?
  3. src/*.mk
  4. MXE_PLUGIN_DIRS*
    • read after all standard rules
    • lexically sorted list of directory sets to include:
MXE_PLUGIN_DIRS_01='path/to/foo path/to/bar /path/to/baz' MXE_PLUGIN_DIRS_02=path/to/final/overrides

Makefile

  • use env -i for pristine environment
  • MXE_ENV: standard global pre-load and whitelist (allows native builds to bypass whitelist)
  • USR_ENV: user global overrides
  • PKG_ENV: package-specific overrides
env -i $(MXE_ENV) $(USR_ENV) $(PKG_ENV) \
       $(MAKE) -f '$(MAKEFILE)' \
           'build-only-$(1)_$(3)' \
           WGET=false

Package makefiles

  • BUILD_DIR: automatically created out-of-source dir
  • SOURCE_DIR: can be set to local repository
  • MXE_CONFIGURE_OPTS: standard static, shared, disable docs etc.
  • PKG_CONFIGURE_OPTS: package-specific overrides (can be used for single - options also e.g. qt)
  • PKG_CMAKE_OPTS: package-specific overrides
  • MXE_MFLAGS: standard disable docs, bins etc (possibly also -l or --max-load option)
  • PKG_MFLAGS: package-specific overrides (unlikely to be used)
Rule examples
define $(PKG)_CONFIGURE # autotools
    cd '$(BUILD_DIR)' && '$(SOURCE_DIR)/configure' \
        $(MXE_CONFIGURE_OPTS) \
        --enable-foo \
        --disable-bar \
        $(PKG_CONFIGURE_OPTS)
endef

define $(PKG)_CONFIGURE # cmake
    cd '$(BUILD_DIR)' && '$(TARGET)-cmake' '$(SOURCE_DIR)' \
        -DFOO_FEATURE=ON \
        -DBAR_FEATURE=OFF \
        $(PKG_CMAKE_OPTS)        
endef

define $(PKG)_MAKE # enables retry of failed parallel builds
    $(MAKE) -C $(BUILD_DIR) -j '$(JOBS)' $(MXE_MFLAGS) $(PKG_MFLAGS)
    $(MAKE) -C $(BUILD_DIR) -j 1 install $(MXE_MFLAGS) $(PKG_MFLAGS)
endef

define $(PKG)_BUILD # simple
    $($(PKG)_CONFIGURE)
    $($(PKG)_MAKE)
endef

define $(PKG)_BUILD # many hooks
    $($(PKG)_PRE_CONFIGURE)
    $($(PKG)_CONFIGURE)
    $($(PKG)_POST_CONFIGURE)
    $($(PKG)_PRE_MAKE)
    $($(PKG)_MAKE)
    $($(PKG)_POST_MAKE)
endef

Plugins

Inheritance style with new package
#bar-minimal.mk
$(PKG) := bar-minimal
...
define $(PKG)_BUILD
    $(subst --enable-foo,--disable-foo,$(bar_CONFIGURE))
    $(bar_MAKE)
endef
Override style
#overrides.mk
bar_CONFIGURE_OPTS := --disable-foo
baz_CMAKE_OPTS     := -DFOO_FEATURE=OFF

See a list here