0 Add a New Package: Full Version
Ilya Averyanov edited this page 2016-07-26 14:42:09 +04:00

A package recipe usually contain the following:

Variable Description
PKG Name of the package.
$(PKG)_IGNORE Versions of the package to be ignored by $(PKG)_UPDATE.
$(PKG)_VERSION Version of the package.
$(PKG)_CHECKSUM SHA256 checksum of $(PKG)_URL.
$(PKG)_SUBDIR The real root source tree inside $(PKG)_URL.
$(PKG)_FILE Name of the tarball or zip archive.
$(PKG)_URL URL of the tarball or zip archive.
$(PKG)_DEPS Dependencies of this package. Non-toolchain packages should always contain gcc.
$(PKG)_BUILD_<TARGET> Build recipe for TARGET.
$(PKG)_BUILD The actual build recipe.

$(PKG)_BUILD macro

The $(PKG)_BUILD macro shall take 2 parameters that will be called with make(1)'s $(call) built-in function.

The first parameter, accessible with $(1), shall be the working directory, or the root of the source tree. It shall also be mxe/tmp-$(PKG)/$($(PKG)_SUBDIR).

The second parameter, accessible with $(2), shall always be src/$(PKG)-test.

In the macro, the package will be built and installed. There shall be 3 types of packages:

  1. The package is library-only, or with an "example program". In this case, the "example program" shall not be essential to the use of the library, and the building and installation of the example program should be disabled, if possible.

Examples: packages a52dec and ffmpeg

The installation of the library that will be used for the target shall be under $(PREFIX)/$(TARGET). The installation of programs that will be used on the host machine, if any, shall be installed under $(PREFIX)/bin; and if the program is target-dependent, the installed program shall be named as $(TARGET)-origname.

For an example of prefixed program, see package yasm. For an example of unprefixed program, see package cloog.

Sample Package Recipe

# mxe/src/samplepackage.mk
# This file is part of MXE.
# See index.html for further information.

PKG             := samplepackage
# version 0.2 breaks compatibility of samplepackage2
$(PKG)_IGNORE   := 0.2%
$(PKG)_VERSION  := 0.1.0
$(PKG)_CHECKSUM := da39a3ee5e6b4b0d3255bfef95601890afd80709
$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
$(PKG)_URL      := http://$(PKG).github.io/$(PKG)-$($(PKG)_VERSION).tar.gz
$(PKG)_DEPS     := gcc

define $(PKG)_UPDATE
    $(WGET) -q -O- 'http://samplepackage.github.io/' | \
    $(SED) -n 's,.*/\([0-9][^"]*\)/"\.tar.*,\1,p' | \
    sort | uniq | \
    head -1
endef

define $(PKG)_BUILD
    cd '$(1)' && ./configure \
        --host='$(TARGET)' \
        --disable-shared \
        --prefix='$(PREFIX)/$(TARGET)' \
        --special-target-string='@special-target@'
    $(MAKE) -C '$(1)' -j '$(JOBS)'
    $(MAKE) -C '$(1)' -j 1 install
endef

$(PKG)_BUILD_i686-pc-mingw32    = $(subst @special-target@, x86-win32-gcc,    $($(PKG)_BUILD))
$(PKG)_BUILD_i686-w64-mingw32   = $(subst @special-target@, x86-win32-gcc,    $($(PKG)_BUILD))
$(PKG)_BUILD_x86_64-w64-mingw32 = $(subst @special-target@, x86_64-win64-gcc, $($(PKG)_BUILD))