MinGW package guidelines

From ArchWiki
Revision as of 08:57, 25 April 2011 by Svenstaro (Talk | contribs) (First edit)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Tango-document-new.pngThis article is a stub.Tango-document-new.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:MinGW package guidelines#)

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Package Naming

Since there are mingw32 as well as mingw-w64, it is important to properly name your packages. A package for mingw32 might be named mingw32-foo while a package for mingw-w64 should be named mingw-w64-foo. The following parts of the guide focuses on mingw32 as it is a lot more popular than mingw-w64.

Packaging

Packaging for cross platform packages can be fairly tricky as there are many different build systems and low-level quirks. Take a note of the following things though:

  • always add mingw32-runtime to depends
  • always add mingw32-gcc to makedepends
  • always add !strip to options
  • always add (mingw32) to pkgdesc
  • always add unset LDFLAGS in front of toolchain configure/Makefile generation sequences
  • always add put all stuff under the /usr/i486-mingw32 prefix
  • always use any as the architecture
  • consider using !libtool in options if you get .la files

Examples

The following examples will try to cover some of the most common conventions and build systems.

Plain Makefile

  1. Maintainer: yourname <yourmail>

pkgname=mingw32-foo pkgver=1.0 pkgrel=1 pkgdesc="Foo bar (mingw32)" arch=('any') url="http://www.foo.bar" license=('GPL') makedepends=('mingw32-gcc') depends=('mingw32-runtime') options=('!strip') source=("http://www.foo.bar/foobar.tar.gz") md5sums=('4736ac4f34fd9a41fa0197eac23bbc24')

build() {

 cd "${srcdir}/foobar"
 sed "s|LOCAL = /usr/local|LOCAL = ${pkgdir}/usr/i486-mingw32|g" -i Makefile
 sed "s|CXX = gcc|CXX = i486-mingw32-gcc|g" -i Makefile
 sed "s|CXXFLAGS = |CXXFLAGS = -fPIC |g" -i Makefile
 make

}

package() {

 cd "${srcdir}/foobar"
 mkdir -p ${pkgdir}/usr/i486-mingw32/{lib,include}
 make install
 chmod 644 ${pkgdir}/usr/i486-mingw32/lib/libfoo.a
 i486-mingw32-ranlib ${pkgdir}/usr/i486-mingw32/lib/libfoo.a

}

Autotools

# Maintainer: yourname <yourmail>
pkgname=mingw32-foo
pkgver=1.0
pkgrel=1
pkgdesc="Foo bar (mingw32)"
arch=('any')
url="http://www.foo.bar"
license=('GPL')
makedepends=('mingw32-gcc')
depends=('mingw32-runtime')
options=('!strip')
source=("http://www.foo.bar/foobar.tar.gz")
md5sums=('4736ac4f34fd9a41fa0197eac23bbc24')

build() {
  cd ${srcdir}/zziplib-${pkgver}

  unset LDFLAGS
  ./configure --prefix=/usr/i486-mingw32 --host=i486-mingw32
  make
  make DESTDIR=${pkgdir} install

  #fix permission
  chmod -s ${pkgdir}/usr/i486-mingw32/share/man/man3
  chmod 644 ${pkgdir}/usr/i486-mingw32/share/man/man3/*
  chown -R root:root ${pkgdir}/usr/i486-mingw32/share/man/man3
}

CMake

# Maintainer: yourname <yourmail>
pkgname=mingw32-sfml-git
pkgver=1816
pkgrel=1
pkgdesc="A simple, fast, cross-platform, and object-oriented multimedia API (mingw32)"
arch=('i686' 'x86_64')
url="http://sfml-dev.org"
license=('zlib')
depends=('mingw32-libsndfile' 'libxrandr' 'mingw32-libjpeg' 'mingw32-libpng' 'mingw32-openal' 'mingw32-glew' 'mingw32-freetype')
makedepends=('mesa' 'cmake' 'git')
provides=('mingw32-sfml')
source=(cmake-toolchain.cmake)
options=(!strip)
md5sums=('dd2b2db48187dff84050fe191d309d81')

_gitroot='https://github.com/LaurentGomila/SFML.git'
_gitname='SFML'

build() {
  cd "$srcdir"
  msg "Connecting to GIT server...."

  if [ -d $_gitname ] ; then
    cd $_gitname && git pull origin
    msg "The local files are updated."
  else
    git clone $_gitroot
    cd $_gitname
  fi

  msg "GIT checkout done or server timeout"
  msg "Starting make..."

  rm -rf "$srcdir/$_gitname-build"
  cp -r "$srcdir/$_gitname" "$srcdir/$_gitname-build"
  cd "$srcdir/$_gitname-build"

  unset LDFLAGS

  mkdir build && cd build
  cmake .. \
    -DCMAKE_INSTALL_PREFIX=/usr/i486-mingw32/ \
    -DCMAKE_TOOLCHAIN_FILE=${srcdir}/cmake-toolchain.cmake
  make
}

package() {
  cd "$srcdir/$_gitname-build/build"

  make DESTDIR=${pkgdir} install

  install -Dm 644 license.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  rm -r $pkgdir/usr/share/cmake-2.8
  rm $pkgdir/usr/i486-mingw32/bin/libsndfile-1.dll
  rm $pkgdir/usr/i486-mingw32/bin/openal32.dll
  rm $pkgdir/usr/i486-mingw32/license.txt
}