code:
[mirrors]
http://prdownloads.sourceforge.net/disktype/disktype-9.tar.gz

[vars]
filesize=43809
sha512sum=3642e35af55341db089d3b671ddecb026eca67a9f63ba55456a0c63c3fa611e3888104e5c14c18959435577a08d1fd93f1794fbb37e0d8118ab9be65f474bdf3
desc="Disk type identification utility"

[deps]

[build]
#note, still don't have a patch for f2fs!
#note, do not use the ext4 patch on official disktype site, broken.
patch -p1 < "$K"/disktype-9-pardus-ext4.patch
patch -p1 < "$K"/disktype-9-kamwoods-exfat.patch

sed -i -e "s%^CFLAGS .*%CFLAGS = ${optcflags}%" Makefile
sed -i -e "s%^LDFLAGS .*%LDFLAGS = ${optldflags}%" Makefile

make || exit 1

mkdir -p $butch_install_dir/sbin
install -m755 -s disktype $butch_install_dir/sbin

path: pkg/disktype


code:
[mirrors]
http://pypi.python.org/packages/source/d/distribute/distribute-0.6.36.tar.gz
[vars]
filesize=644713
sha512=4f9b8408c142d837d88225364e0a312d9e058b5b7a9d74e1783b2208b197b5d7bddd09185623b324163affe080764b2fba7f3242d4b9b9c624f08e0942d0fed6

[deps]
python

[build]
python setup.py build
python setup.py install \
  --optimize=1 --prefix="$butch_prefix" --root="$butch_install_dir"

repo_name: aarf/bkauler

path: pkg/distribute

license: unknown


code:
[vars]
filesize=15057
sha512=e54fd10c0b1274eb90173aea442f0bfc496f4dda861a36d94f939e1fd835594f9aa12f3d0f90043d64e519d919b9a5273ab65012230ac022f727ee6bb64862e3

[mirrors]
http://dl.suckless.org/tools/dmenu-4.6.tar.gz

[deps]
libx11
libxcb
libxau
libxdmcp
libxinerama

[build]
cp "$K/dmenu.config.mk" config.mk
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/dmenu


code:
[deps]
util-macros

[vars]
filesize=96467
sha512=bbce91c35413a39ff8b70e5fddccea0e47af3e8f1cfc562b8acc2785ea350a04166799b29a31fd38f4a2c8d82c8d370d7a40fc24ec2c686f2244b59dce0ba4b5

[mirrors]
ftp://ftp.x.org/pub/individual/proto/dmxproto-2.3.1.tar.bz2

[build]
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/')"
./configure -C --prefix="$butch_prefix" $xconfflags
make DESTDIR="$butch_install_dir" -j$MAKE_THREADS install

path: pkg/dmxproto


code:
[mirrors]
http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.68.tar.xz

[vars]
filesize=420968
sha512=c67605f21fc5e64fe70ac4349c45a246575ebdb07ada14602c453b9a1152a12c3a7f3a01d5749db9f7a24a9f281a7fb9fd24bfaff1ec35e9ab0d213ae14cac07
desc="provides DNS, DHCP, router advertisement and network boot services"

[deps]

[build]
make PREFIX="$butch_prefix" CFLAGS="$optcflags" LDFLAGS="$optldflags" -j$MAKE_THREADS
make BINDIR="$butch_prefix"/bin PREFIX="$butch_prefix" DESTDIR="$butch_install_dir" install
install -D -m 640 dnsmasq.conf.example "$butch_install_dir"/"$butch_prefix"/etc/dnsmasq.conf

IS="$K"/bin/butch-install-service
"$IS" --down --log --force dnsmasq "$K"/services/dnsmasq

path: pkg/dnsmasq


code:
[mirrors]
http://archive.ubuntu.com/ubuntu/pool/main/d/docbook-xml/docbook-xml_4.5.orig.tar.gz

[vars]
filesize=421525
sha512=e69e8fc89a1d306377038d2ec77348e0f177e4dc2392b182adcb8ef0223a74a38a836aeb18d1c4b934c85ce02061b4b498d77eaacfdf4ae90d410320fa924bfd
tardir=docbook-xml-4.5.c31424

[deps]
libxml2

[build]

dest="$butch_install_dir""$butch_prefix"

cd docbook-4.5

install -v -d -m755 "$dest"/share/xml/docbook/xml-dtd-4.5 &&
install -v -d -m755 "$dest"/etc/xml &&
chown -R root:root . &&
cp -v -af docbook.cat *.dtd ent/ *.mod \
    "$dest"/share/xml/docbook/xml-dtd-4.5

dest="$butch_prefix"

if [ ! -e "$dest"/etc/xml/docbook ]; then
    xmlcatalog --noout --create "$dest"/etc/xml/docbook
fi &&
xmlcatalog --noout --add "public" \
    "-//OASIS//DTD DocBook XML V4.5//EN" \
    "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" \
    "$dest"/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
    "-//OASIS//DTD DocBook XML CALS Table Model V4.5//EN" \
    "file://$dest/share/xml/docbook/xml-dtd-4.5/calstblx.dtd" \
    "$dest"/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
    "-//OASIS//DTD XML Exchange Table Model 19990315//EN" \
    "file://$dest/share/xml/docbook/xml-dtd-4.5/soextblx.dtd" \
    "$dest"/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
    "-//OASIS//ELEMENTS DocBook XML Information Pool V4.5//EN" \
    "file://$dest/share/xml/docbook/xml-dtd-4.5/dbpoolx.mod" \
    "$dest"/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
    "-//OASIS//ELEMENTS DocBook XML Document Hierarchy V4.5//EN" \
    "file://$dest/share/xml/docbook/xml-dtd-4.5/dbhierx.mod" \
    "$dest"/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
    "-//OASIS//ELEMENTS DocBook XML HTML Tables V4.5//EN" \
    "file://$dest/share/xml/docbook/xml-dtd-4.5/htmltblx.mod" \
    "$dest"/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
    "-//OASIS//ENTITIES DocBook XML Notations V4.5//EN" \
    "file://$dest/share/xml/docbook/xml-dtd-4.5/dbnotnx.mod" \
    "$dest"/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
    "-//OASIS//ENTITIES DocBook XML Character Entities V4.5//EN" \
    "file://$dest/share/xml/docbook/xml-dtd-4.5/dbcentx.mod" \
    "$dest"/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
    "-//OASIS//ENTITIES DocBook XML Additional General Entities V4.5//EN" \
    "file://$dest/share/xml/docbook/xml-dtd-4.5/dbgenent.mod" \
    "$dest"/etc/xml/docbook &&
xmlcatalog --noout --add "rewriteSystem" \
    "http://www.oasis-open.org/docbook/xml/4.5" \
    "file://$dest/share/xml/docbook/xml-dtd-4.5" \
    "$dest"/etc/xml/docbook &&
xmlcatalog --noout --add "rewriteURI" \
    "http://www.oasis-open.org/docbook/xml/4.5" \
    "file://$dest/share/xml/docbook/xml-dtd-4.5" \
    "$dest"/etc/xml/docbook

if [ ! -e "$dest"/etc/xml/catalog ]; then
    xmlcatalog --noout --create "$dest"/etc/xml/catalog
fi &&
xmlcatalog --noout --add "delegatePublic" \
    "-//OASIS//ENTITIES DocBook XML" \
    "file://$dest/etc/xml/docbook" \
    "$dest"/etc/xml/catalog &&
xmlcatalog --noout --add "delegatePublic" \
    "-//OASIS//DTD DocBook XML" \
    "file://$dest/etc/xml/docbook" \
    "$dest"/etc/xml/catalog &&
xmlcatalog --noout --add "delegateSystem" \
    "http://www.oasis-open.org/docbook/" \
    "file://$dest/etc/xml/docbook" \
    "$dest"/etc/xml/catalog &&
xmlcatalog --noout --add "delegateURI" \
    "http://www.oasis-open.org/docbook/" \
    "file://$dest/etc/xml/docbook" \
    "$dest"/etc/xml/catalog

path: pkg/docbook-xml


code:
[mirrors]
http://downloads.sourceforge.net/project/docbook/docbook-xsl/1.78.1/docbook-xsl-1.78.1.tar.bz2

[vars]
filesize=5003045
sha512=0a5ca95e6e451192c4edf15d2b72c716935ce6df0c70c1974f794f0085db8f52f3e1f470435b6a77ec7c0f67e32c189a4dd334305e609031173444d5818767f3

[deps]
libxml2

[build]
dest="$butch_install_dir""$butch_prefix"
install -v -m755 -d "$dest"/share/xml/docbook/xsl-stylesheets-1.78.1 &&

cp -v -R VERSION common eclipse epub extensions fo highlighting html \
         htmlhelp images javahelp lib manpages params profiling \
         roundtrip slides template tests tools webhelp website \
         xhtml xhtml-1_1 \
    "$dest"/share/xml/docbook/xsl-stylesheets-1.78.1 &&

ln -s VERSION "$dest"/share/xml/docbook/xsl-stylesheets-1.78.1/VERSION.xsl &&

install -v -m644 -D README \
                    "$dest"/share/doc/docbook-xsl-1.78.1/README.txt &&
install -v -m644    RELEASE-NOTES* NEWS* \
                    "$dest"/share/doc/docbook-xsl-1.78.1

dest="$butch_prefix"

if [ ! -d "$dest"/etc/xml ]; then install -v -m755 -d "$dest"/etc/xml; fi &&
if [ ! -f "$dest"/etc/xml/catalog ]; then
    xmlcatalog --noout --create "$dest"/etc/xml/catalog
fi &&
xmlcatalog --noout --add "rewriteSystem" \
           "http://docbook.sourceforge.net/release/xsl/1.78.1" \
           "$dest/share/xml/docbook/xsl-stylesheets-1.78.1" \
    "$dest"/etc/xml/catalog &&
xmlcatalog --noout --add "rewriteURI" \
           "http://docbook.sourceforge.net/release/xsl/1.78.1" \
           "$dest/share/xml/docbook/xsl-stylesheets-1.78.1" \
    "$dest"/etc/xml/catalog &&
xmlcatalog --noout --add "rewriteSystem" \
           "http://docbook.sourceforge.net/release/xsl/current" \
           "$dest/share/xml/docbook/xsl-stylesheets-1.78.1" \
    "$dest"/etc/xml/catalog &&
xmlcatalog --noout --add "rewriteURI" \
           "http://docbook.sourceforge.net/release/xsl/current" \
           "$dest/share/xml/docbook/xsl-stylesheets-1.78.1" \
    "$dest"/etc/xml/catalog

path: pkg/docbook-xsl


code:
[mirrors]
http://downloads.sourceforge.net/docbook2x/docbook2X-0.8.8.tar.gz

[vars]
filesize=723909
sha512=cc336017ad734fc62d96d289105e8ea154c418a03a37f3e21b0b3520063f8b466b4aae5a5aec2e0b83f6324c6c79b5557247a93338d0a9882a94a44112f6b65c

[deps.host]
iconv
perl5-XML-SAX

[deps.run]
perl

[build]
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

CPPFLAGS="-D_GNU_SOURCE" CFLAGS="$optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure -C --prefix="$butch_prefix" $xconfflags \
  ac_cv_file__usr_local_share_java_resolver_jar=no \
  ac_cv_file__usr_share_java_resolver_jar=no \
  ac_cv_file__usr_share_java_xml_commons_resolver_1_1_jar=no \
  ac_cv_file__usr_local_share_java_saxon_jar=no \
  ac_cv_file__usr_share_java_saxon_jar=no \
  ac_cv_file__usr_local_share_java_xalan_jar=no \
  ac_cv_file__usr_share_java_xalan_jar=no \
  ac_cv_file__usr_share_java_xalan2_jar=no

make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install


code:
[vars]
filesize=601642
sha512=3d042e720c9854ae42ef72d1acf78ff8ff1cbf3c259d2c8bdba0a0b9cbf754fbe2dee9994cb9513cf1df24f26a857a13e828f0c88dc2e50f91e1c33a122eb385

[mirrors]
http://netcologne.dl.sourceforge.net/project/dos2unix/dos2unix/7.3.2/dos2unix-7.3.2.tar.gz

[deps]

[build]
#patch -p1 < "$K"/some.patch

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

#[ -n "$CROSS_COMPILE" ] && "$K"/libtool.cross.gen --sysroot="$butch_root_dir"
find ./ -name Makefile -exec sed -i 's/\/usr/\//g' {} \;
CPPFLAGS="-D_GNU_SOURCE" CFLAGS="$optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
make V=1 -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install


code:
[mirrors]
http://heanet.dl.sourceforge.net/project/dosbox/dosbox/0.74/dosbox-0.74.tar.gz

[vars]
filesize=1265711
sha512=4a6ff4c658997a495119d200ec6ad37649da940814a4b14fca0dd29a99142026e324695b7aa9d2946efc2abf9067a819d911e43778efe905ed10ddf9b9f2dd3d
desc='x86/DOS emulator to play the good old games'

[deps.host]
dynamic-toolchain

[deps]
sdl
alsa-lib
zlib
libpng

[build]
patch -p1 < "$K"/dosbox.patch
patch -p1 < "$K"/dosbox-gcc47.patch
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"
printf '#!/bin/sh\nif test x$1 = x--version ; then echo 1.2.15 ; else echo -lSDL -I$butch_root_dir$butch_prefix/include/SDL ; fi\n' > sdl-config
chmod +x sdl-config
export PATH="$PWD:$PATH"

CPPFLAGS=-D_GNU_SOURCE CFLAGS="$optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure -C --prefix="$butch_prefix" $xconfflags \
  --disable-opengl
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/dosbox


code:
[mirrors]
http://daniel-baumann.ch/files/software/dosfstools/dosfstools-3.0.24.tar.xz

[vars]
filesize=78148
sha512=9e75e3868f42d4cb404998e8a0cd7d3bc7fe4fc0cf68559644c960fe73e7f0eb67c26ff169085c9e1858e5402efed813b883a5f3682aea29e4d0fc9c9142a006

[build]
patch -p0 < "$K"/dosfstools-loff_and_BLOCK_SIZE.patch
make CFLAGS="-D_GNU_SOURCE $optcflags" LDFLAGS="$optldflags -static" \
  PREFIX="$butch_prefix" DESTDIR="$butch_install_dir" \
  SBINDIR="$butch_prefix/bin" -j$MAKE_THREADS all install

path: pkg/dosfstools


code:
[mirrors]
https://github.com/mfontanini/dot11decrypt/archive/master.tar.gz

[vars]
filesize=40176
sha512=96c4a9c820d75381183e62e8783f0038982b2c76c1ad53c826835bd20d171e51a53f3f0997164a9add82cb1cec6bd8ae3b8d7f421f870befcd1aa7fba2554b91
tarball=dot11decrypt-00dd93e9.tar.gz
tardir=dot11decrypt-master
desc="WEP/WPA2 on-the-fly decrypter. requires monitor dev, creates tap dev"

[deps]
libtins
libstdc++

[build]
#patch -p1 < "$K"/some.patch

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

CPPFLAGS="-D_GNU_SOURCE" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure -C --prefix="$butch_prefix" --disable-nls $xconfflags

#[ -n "$CROSS_COMPILE" ] && "$K"/libtool.cross.gen --sysroot="$butch_root_dir"

make V=1 -j$MAKE_THREADS
install -Dm 755 dot11decrypt "$butch_install_dir""$butch_prefix"/bin/dot11decrypt


code:
[mirrors]
http://dovecot.org/releases/2.2/dovecot-2.2.24.tar.gz

[vars]
filesize=5345872
sha512=90d98996e75353ae631c1e2da2520cc340928f427276c757316714892d7b281745284bf4cb30459eecdb9c96b7d9450eb6801e002e6acafc8669deb2b5e65a81

[deps]
libressl

[build]
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine) \
  --with-sysroot=$butch_root_dir"

CPPFLAGS="-D_GNU_SOURCE" CFLAGS="$optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
./configure -C --prefix="$butch_prefix" $xconfflags \
  --sbindir="$butch_prefix"/bin \
  --with-ioloop=poll \
  --with-notify=none i_cv_inotify_works=yes \
  lib_cv_va_copy=yes \
  lib_cv___va_copy=no \
  lib_cv_va_val_copy=no \
  i_cv_posix_fallocate_works=no \
  i_cv_signed_size_t=no \
  i_cv_gmtime_max_time_t=31 \
  i_cv_signed_time_t=yes \
  i_cv_mmap_plays_with_write=yes \
  i_cv_signed_size_t=yes \
  i_cv_c99_vsnprintf=yes \
  i_cv_fd_passing=yes \
  --without-lzma --without-gc --without-bzlib
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install
install -D -m 644 "$K"/dovecot.conf \
  "$butch_install_dir""$butch_prefix"/etc/dovecot/dovecot.conf

IS="$K"/bin/butch-install-service
"$IS" --down --log --force dovecot "$K"/services/dovecot

path: pkg/dovecot


code:
[vars]
filesize=3800328
sha512=a9e450cd700b32ccf0dec82fa2faad15016860db1e1448fafa01541ec280a59a951670338afc634472856021e8227426552f6c41b9eaddcddd3712ad709a673a
tardir=dpkg-1.16.15

[mirrors]
http://http.debian.net/debian/pool/main/d/dpkg/dpkg_1.16.15.tar.xz

[deps]
zlib
bzip2
xz
curses

[deps.host]
perl

[build]
patch -p1 < "$K"/dpkg.patch

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

CFLAGS="-D_GNU_SOURCE $optcflags" LDFLAGS="$optldflags" \
  ./configure -C --prefix="$butch_prefix" \
  --sbindir="$butch_prefix"/bin --disable-install-info \
  --disable-update-alternatives --disable-start-stop-daemon \
  --disable-dselect $xconfflags

make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/dpkg


code:
[vars]
filesize=108746
sha512=1602f58cd8a3371dacf894cde4889b9147fc08e83f98d8e0d1c748abe43ecb74cf4e0e3d5eb2f33568ba5e6d9f310303b98ba43ae3bc956ae693824b1ae0745a

[mirrors]
http://xorg.freedesktop.org/releases/individual/proto/dri2proto-2.8.tar.bz2

[deps]

[build]
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/')"
CFLAGS="-D_GNU_SOURCE $optcflags" \
LDFLAGS="$optldflags" \
  ./configure -C --prefix="$butch_prefix" $xconfflags
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install


code:
[mirrors]
http://xorg.freedesktop.org/releases/individual/proto/dri3proto-1.0.tar.bz2

[vars]
filesize=105366
sha512=d2925bc2e2bfb3f30c4dc3082d84dc6a2e7d8ea02021ea02d681cbf92e6b256e9e4e0f5abfc394aa0c7762d841b1c8f82d2098c616ca1d7f4a3b5fd8a54f01f8

[deps]

[build]

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

CPPFLAGS="-D_GNU_SOURCE" CFLAGS="$optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure -C --prefix="$butch_prefix" --disable-nls $xconfflags

#[ -n "$CROSS_COMPILE" ] && "$K"/libtool.cross.gen --sysroot="$butch_root_dir"

make V=1 -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install


code:
[mirrors]
http://matt.ucc.asn.au/dropbear/releases/dropbear-2015.68.tar.bz2

[vars]
filesize=1611161
sha512=7725cd4077a3968684db3646f6013c6202977e79d281619e029366e45fca9c4e33e271812626237b6e33938eeb4c8b260902fe2b57cff085086bf930713a934a
desc="lightweight ssh server/client"

[deps]
zlib
sshd-service

[build]
[ -n "$CROSS_COMPILE" ] && xconfflags="--host=$($CC -dumpmachine)"
CPPFLAGS="-D_GNU_SOURCE -D_BSD_SOURCE" \
CFLAGS="$optcflags" \
LDFLAGS="$optldflags" \
  ./configure -C --prefix="$butch_prefix" $xconfflags

# TODO : edit generated options.h

for i in UTMP WTMP PUTUTLINE PUTUTXLINE SYSLOG LASTLOG ; do
	echo "#define DISABLE_$i" >> config.h
done

make SCPPROGRESS=1 PROGRAMS="dropbear scp dbclient dropbearkey dropbearconvert" \
  prefix="$butch_prefix" sbindir="$butch_prefix"/bin DESTDIR="$butch_install_dir" \
  -j$MAKE_THREADS STATIC=1

make SCPPROGRESS=1 PROGRAMS="dropbear scp dbclient dropbearkey dropbearconvert" \
  prefix="$butch_prefix" sbindir="$butch_prefix"/bin DESTDIR="$butch_install_dir" \
  -j$MAKE_THREADS install STATIC=1

[ -e "$butch_prefix"/ssh ] || ln -s dbclient "$butch_install_dir""$butch_prefix"/bin/ssh

IS="$K"/bin/butch-install-service
"$IS" --down --log --force dropbear "$K"/services/dropbear

path: pkg/dropbear


code:
[mirrors]
http://monkey.org/~dugsong/dsniff/beta/dsniff-2.4b1.tar.gz

[vars]
filesize=131666
sha512=62dafab293de6dc3e9b01561b3627d63ca334467c01c3550a6318d8bcbe99d5a301ec16967af34065a14e8bca1c4b6a41da766cbd51ebd8338615b950c4f642f
tardir=dsniff-2.4
desc="collection of tools for network auditing/sniffing and penetration testing"

[deps]
dsniff-patches
libnet
libnids
portablexdr
db
libressl
libx11
libxmu

[build]
patch -p1 < "$K"/dsniff-xcompile.patch
patch -p1 < "$K"/dsniff-rpc.patch

tar xf "$C"/dsniff_2.4b1+debian-22.1.debian.tar.gz
while read i ; do
	patch -p1 < debian/patches/"$i"
done < debian/patches/series

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

CPPFLAGS="-D_GNU_SOURCE -DOPENSSL_ENABLE_OLD_DES_SUPPORT"
CFLAGS="$CPPFLAGS $optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib \
-lgthread-2.0 -lglib-2.0 -lportablexdr" \
  ./configure --prefix="$butch_prefix" --disable-nls $xconfflags \
  --mandir="$butch_prefix"/share/man \
  --sbindir="$butch_prefix"/bin \
  --with-libnet=$butch_root_dir$butch_prefix

make V=1 -j$MAKE_THREADS
make install_prefix="$butch_install_dir" install

path: pkg/dsniff


code:
[mirrors]
http://downloads.sourceforge.net/project/dtach/dtach/0.8/dtach-0.8.tar.gz
http://pkgs.fedoraproject.org/repo/pkgs/dtach/dtach-0.8.tar.gz/ec5999f3b6bb67da19754fcb2e5221f3/dtach-0.8.tar.gz

[vars]
filesize=55472
sha512=ad0a788d10a5e1e1be4c353b64e1e4a0dc8c888492a638b2442d7c59ef31d67975357116435a1059141bfc2c82a3a6e9e490faa87cf81e5fc3bc7457a99c1193

[deps]

[build]
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"
CFLAGS="$optcflags" LDFLAGS="$optldflags" \
  ./configure -C --prefix="$butch_prefix" $xconfflags

make -j$MAKE_THREADS

dest="$butch_install_dir""$butch_prefix"
install -D dtach "$dest"/bin/dtach
install -D dtach.1 "$dest"/share/man/man1/dtach.1

path: pkg/dtach


code:
[deps]
libdumb

path: pkg/dumb


code:
[deps]
libcap2
libpcap

[build]
exe=$(readlink -f "$butch_prefix"/bin/dumpcap)
setcap cap_net_raw+ep "$exe"
#setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/dumpcap"

path: pkg/dumpcap-perms


code:
[mirrors]
http://fy.chalmers.se/~appro/linux/DVD+RW/tools/dvd+rw-tools-7.1.tar.gz

[vars]
filesize=140846
sha512=938f9ec5597158af275c7bf63002696ba362f6f22a219108c6a1df28792f0485046a7af5ce57e41695aaaa0d69543bd66cbbeb4415df5c0e0a902a3f1d278a31
desc="Utilities for formating, blanking and creating DVD media"

[deps]
cdrtools

[build]
#note, could use xorriso instead of cdrtools.

#from lfs...
sed -i '/stdlib/a #include <limits.h>' transport.hxx

make || exit 1
make install prefix=$butch_install_dir

path: pkg/dvd+rw-tools


code:
[mirrors]
http://distro.ibiblio.org/quirky/quirky6/sources/t2/april/dvd_close-7.1-2014.tar.bz2

[vars]
filesize=115607
sha512=f361a3aceb0cd95ae2efa76f752f49c6b672f2fdf955b13c3825e2ba70049218d474321ef72e5a1a81306339db7699897414d39c280f8c6715a7f15f8de5a28e
desc="The 'close' utility got taken out of dvd+rw-tools. This is it."

[deps]

[build]
make || exit 1
g++ -O2 -fno-exceptions -D_REENTRANT -o close close.cpp

dest="$butch_install_dir""$butch_prefix"
mkdir -p $dest/bin
cp -a -f close $dest/bin/

path: pkg/dvd-close


code:
[vars]
filesize=34557
sha512=33c6f32510b17c0dcb3c8a216fd8c4cde14d6874495a9e0992c2104fda2ee7edb9a40de25c2efc84337b6f61858c1bf3e0e4ed5d77ab4d2db01ddfa02c1d4eaa

[mirrors]
http://www.brain-dump.org/projects/dvtm/dvtm-0.9.tar.gz

[deps]
curses

[build]
make all install \
 PREFIX="$butch_prefix" DESTDIR="$butch_install_dir" \
 CFLAGS="-std=gnu99 $optcflags -I. -I/include -DVERSION=\\\"0.9\\\"" \
 LDFLAGS="-lncurses $optldflags" \
 -j$MAKE_THREADS

path: pkg/dvtm


code:
[vars]
filesize=20810
sha512=895d1d363b3756c9ba19dbf06af34be753c1ae5971d540113d7f8901ad174c2e5944ef769b43e65f7b700f34832bb24082bc91d999b287610c9925182ce70c00

[mirrors]
http://dl.suckless.org/dwm/dwm-6.0.tar.gz

[deps]
libx11
libxcb
libxau
libxdmcp
libxinerama

[build]
make \
  PREFIX="$butch_prefix" \
  CFLAGS="$optcflags -D_GNU_SOURCE -DVERSION=\\\"6.0\\\" -DXINERAMA" \
  LDFLAGS="$optldflags -lX11 -lXinerama -lXau -lXdmcp -lxcb -lX11-xcb" \
  -j$MAKE_THREADS

make PREFIX="$butch_prefix" MANPREFIX="$butch_prefix/share/man" \
     DESTDIR="$butch_install_dir" install

path: pkg/dwm


code:
[deps]
gcc4
musl

path: pkg/dynamic-toolchain


code:
[mirrors]
http://prdownloads.sourceforge.net/e2fsprogs/e2fsprogs-1.42.9.tar.gz
[vars]
filesize=6069173
sha512=31041c45bc4e4a37fc4a1026424e15d4fc8fbf990c968fc9fba92861d9bec15f192dee8d5341cc2215af30a86b0bdb12d8a01f3c113b79a66c65f4a737136bb7

[deps.host]
pkgconf

[deps]
kernel-headers
libblkid

[build]
[ -n "$CROSS_COMPILE" ] && xconfflags="--host=$($CC -dumpmachine)"
for i in misc/fsck.c misc/mke2fs.c e2fsck/unix.c ; do
sed -i 's@sbin@bin@g' $i
done
CFLAGS="-D_GNU_SOURCE $optcflags -D__uint64_t=u_int64_t -fPIC" \
LDFLAGS="$optldflags -static" \
  ./configure -C --prefix="$butch_prefix" --with-root-prefix="$butch_prefix" \
  --sbindir="$butch_prefix"/bin $xconfflags \
  --disable-nls --disable-libblkid
make V=1 -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install
make DESTDIR="$butch_install_dir" install-libs

# install libuuid, needed for cryptsetup
(
cd lib/uuid
make DESTDIR="$butch_install_dir" install
)


code:
[vars]
filesize=680487
sha512=ada26d744974158d487774a1bfaa59192de46797eb4f35062b452cb9e6168b45626595df8c527533d75b0a95bd55008151a14b7b195b9db2eb88c76e557d8d2f

[mirrors]
http://download.enlightenment.org/releases/eet-1.7.8.tar.gz

[deps]
musl
libjpeg
zlib
eina
libressl

[build]
CFLAGS=-D_GNU_SOURCE ./configure -C --prefix="$butch_prefix"
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/eet


code:
[deps]
bash
git
pciutils
zlib
efivar-git
perl

[build]
dest="$S/build/efibootmgr-git"
mkdir -p "$dest"
if [ -d "$dest/efibootmgr" ]; then
	cd "$dest/efibootmgr"
	git pull
else
	cd "$dest"
	git clone -b efibootmgr-0.11.0 --depth=1 https://github.com/rhinstaller/efibootmgr.git efibootmgr
	cd efibootmgr
fi
sed -i -r 's,sys/pci\.h,pci/pci.h,g' src/lib/scsi_ioctls.c
make DESTDIR="$butch_install_dir" BINDIR="/bin" install

path: pkg/efibootmgr-git


code:
[deps]
bash
git
popt
perl

[build]
dest="$S/build/efivar-git"
mkdir -p "$dest"
if [ -d "$dest/efivar" ]; then
	cd "$dest/efivar"
	git pull
else
	cd "$dest"
	git clone -b efivar-0.14 --depth=1 https://github.com/rhinstaller/efivar.git efivar
	cd efivar
fi
patch -p1 < "$K"/efivar-git.patch
make DESTDIR="$butch_install_dir" includedir="/include" bindir="/bin" libdir="/lib"  install
ln -s ./libefivar.so.0 "$butch_install_dir"/lib/libefivar.so

path: pkg/efivar-git


code:
[mirrors]
http://download.enlightenment.org/releases/eina-1.7.10.tar.gz

[vars]
filesize=9938509
sha512=3b06db535ba0199a72fbf0676cd829337a88e871209e01e7a28dae01279c500f49fc5b35d886eca2ae3806bc98a43f66a7c49b7809709577daaa72b9fbc4d8f0

[deps]
musl

[build]
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

CFLAGS="-D_GNU_SOURCE $optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure --prefix="$butch_prefix" $xconfflags

make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/eina


code:
[mirrors]
http://download.electrum.org/Electrum-1.9.2.tar.gz

[vars]
filesize=666900
sha512=c7c4051e8c407e4980ba5a134b61953114fea73da12ef853d571a84d962ec535061b8fa369b6dbb0aa6e166990ca5b239369a51ba78fc5f15c1e009214da830a
desc="lighweight bitcoin client written in python. blockchain is used remotely."

[deps]
python
python-ecdsa
python-slowaes

[build]
# use electrum -g stdio for the bare minimum gui
# use electrum -g text if you have ncurses installed and want a shinier gui
# use electrum -g gtk if you have python-pygtk installed and want an even shinier gui
python setup.py build
python setup.py install --prefix="$butch_prefix" --root="$butch_install_dir"

path: pkg/electrum


code:
[mirrors]
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/endgame-singularity/singularity-0.30c-src.tar.gz

[vars]
filesize=2265133
sha512=ffca50c179b745561a25e3fb3525abb862d72f63f533f8a41472067d0ce94c8a236486c9c40a5040335d84e903c498805d591dc546a92d0a7651105103fe114f
tardir=singularity-0.30c
desc='strategy game'

[deps]
endgame-singularity-music

[deps.run]
python
python-pygame
python-numpy

[deps.host]
python

[build]
mkdir music
unzip "$C"/endgame-singularity-music-007.zip
mv endgame-singularity-music-007/* music/
dest="$butch_install_dir""$butch_prefix"
mkdir -p "$dest"/bin
mkdir -p "$dest"/share/singularity
for i in code data music utils singularity.py ; do
mv $i "$dest"/share/singularity/
done
cat << EOF > "$dest"/bin/endgame-singularity
#!/bin/sh
cd $butch_prefix/share/singularity/
exec python singularity.py "\$@"
EOF
chmod +x "$dest"/bin/endgame-singularity

path: pkg/endgame-singularity


path: pkg/endgame-singularity-music


code:
[mirrors]
http://pkgs.fedoraproject.org/repo/pkgs/epdfview/epdfview-0.1.8.tar.bz2/e50285b01612169b2594fea375f53ae4/epdfview-0.1.8.tar.bz2
http://anduin.linuxfromscratch.org/sources/BLFS/conglomeration/epdfview/epdfview-0.1.8.tar.bz2

[vars]
filesize=466270
sha512=e81ca39158ed77040a00b69cdbbea4726a1bbf4885a096aaa3dfc4c64d0cbcadabdc69c559bb14d23c2bf7fc8244799176d2c2d5689ab670c13237edc10e8e40

[deps]
gtk+2
poppler

[build]
patch -p1 < "$K"/epdfview-0.1.8-fixes-1.patch
patch -p1 < "$K"/epdfview-0.1.8-NULL.patch
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

CPPFLAGS="-D_GNU_SOURCE" CFLAGS="$optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure -C --prefix="$butch_prefix" --disable-nls $xconfflags
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/epdfview


code:
[mirrors]
http://www.erlang.org/download/otp_src_18.0.tar.gz

[vars]
filesize=68124710
sha512=84ec2a3834270c1babe153572d6187faa36c12128e604037d55be01719788c0dd79d46769ea7090d530b746206a25fe02346b02849abee10ee41ed4ac7567c02
tardir=otp_src_18.0

[deps.host]
curses

[build]
patch -p1 < "$K"/erlang.patch

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

CPPFLAGS="-D_GNU_SOURCE" CFLAGS="$optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure -C --prefix="$butch_prefix" --disable-nls $xconfflags

#[ -n "$CROSS_COMPILE" ] && "$K"/libtool.cross.gen --sysroot="$butch_root_dir"

make V=1 -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/erlang


code:
[mirrors]
http://cdn.kernel.org/pub/software/network/ethtool/ethtool-4.5.tar.xz

[vars]
filesize=204244
sha512=fa5b4547de0315c54113d9c7baea53dd4bb6e46c9340255cecf9a39f549190cb5de9db98ad4330a6eeced3a1f9ed6f2ae42cf5a602c0ef1c5a9fd17c825558a4

[deps]

[build]
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"
CFLAGS="-D_GNU_SOURCE $optcflags" LDFLAGS="$optldflags" \
  ./configure -C --prefix="$butch_prefix" $xconfflags

make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/ethtool


code:
[mirrors]
http://dev.gentoo.org/~blueness/eudev/eudev-1.3.tar.gz

[vars]
filesize=1679385
sha512=5e0016fbe15eebfa68bb04fa7b5aedd7edc7a508afdc030adb7cbec4e9eca84fe16119ca73f5724ec290ad4bba179b42d2d0bc56f3aaf2a07e3c48b18374b3b3

[deps]
kernel-headers
libblkid
glib

[build]
patch -p1 < "$K"/eudev-Handle-1-return-from-sysconf.patch

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine) --with-sysroot=$butch_root_dir"

# https://github.com/gentoo/eudev/issues/75
# https://github.com/gentoo/eudev/issues/70
CFLAGS="-D_GNU_SOURCE $optcflags" \
LDFLAGS="$optldflags -lblkid" \
  ./configure -C --prefix="$butch_prefix" $xconfflags \
  --disable-manpages \
  --disable-keymap \
  --disable-blkid \
  --disable-introspection \

patch -p1 < "$K"/libtool-sysroot.patch

make -j$MAKE_THREADS V=1
make DESTDIR="$butch_install_dir" install

dest="$butch_install_dir""$butch_prefix"
# prevent renaming of ethernet interfaces
ln -s /dev/null "$dest"/etc/udev/rules.d/80-net-name-slot.rules
printf "%s\n" 'KERNEL=="kvm", NAME="%k", GROUP="kvm", MODE="0660"' \
 > "$dest"/etc/udev/rules.d/65-kvm.rules
mkdir -p "$dest"/lib/pkgconfig
mv "$dest"/share/pkgconfig/* "$dest"/lib/pkgconfig/
rm -rf "$dest"/share/pkgconfig

path: pkg/eudev


code:
[mirrors]
http://download.enlightenment.org/releases/evas-1.7.10.tar.gz

[vars]
filesize=10261143
sha512=7ee95adc71c9e83ae88a0ef45a40a8f1837edc190d435ebb173a8d6af07b311f6453b3036fd8ba77a2689f77bc76581f834b62eb85fb56da96ae92e9f9b4d017

[deps]
musl
eina
evas-generic-loaders
freetype
libx11
libxcb
fontconfig
libpng
libjpeg
libtiff
sdl
cairo

[build]
# for future EFL releases, wayland support can be enabled with:
# --enable-wayland-shm --enable-wayland-egl --enable-gl-flavor-gles --enable-gles-variety-sgx
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

CFLAGS="-D_GNU_SOURCE $optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
./configure -C --prefix="$butch_prefix" --enable-fontconfig --enable-fb=static \
--disable-harfbuzz --enable-buffer=static --disable-directfb --enable-static-software-generic --enable-software-xlib=static \
--enable-software-xcb --enable-sdl-primitive --enable-image-loader-jpeg --enable-image-loader-png --enable-image-loader-tiff \
--disable-install-examples --disable-tests --disable-doc $xconfflags

make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/evas


code:
[mirrors]
http://download.enlightenment.org/releases/evas_generic_loaders-1.7.10.tar.gz

[vars]
filesize=258286
sha512=f5df5bfd3b25f99bf6bc564c75b2292e8c587637af6e50a650c45e5d127045a326463f038418e6662391bec10b2248a3cf9b242dc80e45cf972863892a5df675

[deps]
musl
eina
gstreamer01
libraw

[build]
# there are more optional plugins: poppler, librsvg, libspectre but they depend on lots of stuff
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

CFLAGS="-D_GNU_SOURCE $optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure -C --prefix="$butch_prefix" --enable-libraw --enable-gstreamer $xconfflags

make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/evas-generic-loaders


code:
[mirrors]
http://ftp.gnome.org/pub/GNOME/sources/evince/2.32/evince-2.32.0.tar.gz

[vars]
filesize=3523623
sha512=ec43243e5b487d3101f6906bb156ed64c0b9778c13a50257602286df1b581340470558c2d8ab9078977c79cb2ebbb6f744fb411eb0faab74950da4f3d738d730

[deps]
gtk+2
glib
poppler-data
poppler
gnome-icon-theme-fake
shared-mime-info
libsm

[deps.host]
glib

[build]
# https://bugzilla.gnome.org/show_bug.cgi?id=637055
patch -p1 < "$K"/evince-scroll.patch
# https://bugzilla.gnome.org/show_bug.cgi?id=638312
patch -p1 < "$K"/evince-quit-crash.patch
patch -p1 < "$K"/evince-segfault.patch
patch -p1 < "$K"/evince-segfault2.patch

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

CPPFLAGS="-D_GNU_SOURCE" CFLAGS="$optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
./configure -C --prefix="$butch_prefix" $xconfflags \
--without-keyring \
--without-gconf \
--without-gtk-unix-print \
--with-gnu-ld \
--with-pic=yes \
--disable-help \
--disable-dbus \
--disable-nls \
--disable-gtk-doc \
--disable-gtk-doc-html \
--disable-gtk-doc-pdf \
--disable-nautilus \
--disable-thumbnailer \
--disable-previewer \
--disable-silent-rules \

[ -n "$CROSS_COMPILE" ] && "$K"/libtool.cross.gen --sysroot="$butch_root_dir"

printf '#define HAVE_POPPLER_DOCUMENT_IS_LINEARIZED\n' >> config.h

for i in po ; do
	printf 'all:\n\ttrue\ninstall:\n\ttrue\clean:\n\ttrue\n' > "$i"/Makefile
done

make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

# evince uses some braindamaged "GSettings schemas"
# without compiling this stuff, it won't even start up
# GSETTINGS_BACKEND=keyfile env var may be needed to save settings

glib-compile-schemas "$butch_install_dir""$butch_prefix"/share/glib-2.0/schemas

path: pkg/evince


code:
[mirrors]
http://sourceforge.net/projects/expat/files/expat/2.1.1/expat-2.1.1.tar.bz2

[vars]
filesize=405103
sha512=088e2ef3434f2affd4fc79fe46f0e9826b9b4c3931ddc780cd18892f1cd1e11365169c6807f45916a56bb6abcc627dcd17a23f970be0bf464f048f5be2713628
desc='library to interface with XML files'
uchkurl=https://sourceforge.net/projects/expat/files/expat/

[deps]
musl

[build]
[ -n "$CROSS_COMPILE" ] && xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/')"
CFLAGS="-D_GNU_SOURCE $optcflags" LDFLAGS="$optldflags" \
  ./configure -C --prefix="$butch_prefix" \
  --mandir="$butch_prefix"/share/man $xconfflags
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/expat


code:
[vars]
filesize=6119479
sha512=3f4b76ff7754de4885f26f802d9b5310a7e22ae12b1b6dcabc4ae3b090746b48ad27f9a01c9d8dc1b0353f1e96dc6ec420a5ca8afe7fe5a9f30b863b02dddb67

[mirrors]
http://download.enlightenment.org/releases/expedite-1.7.8.tar.gz

[deps]
eet
musl
evas

[build]
CFLAGS=-D_GNU_SOURCE ./configure -C --prefix="$butch_prefix"
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/expedite


code:
[deps]
kernel-headers

[vars]
filesize=5340791
sha512=378c69f50bf4cc3e71b84a85bfdb6c9bdb2f6204e7b4e989e265513e9691a36903a393e9bba5201ac8642824de85895feafca4f562bf9c464779a0d457ef71df

[mirrors]
ftp://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-4.04.tar.bz2
http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-4.04.tar.bz2
http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.04.tar.bz2
http://ftp.wh2.tu-dresden.de/pub/mirrors/kernel.org/linux/utils/boot/syslinux/syslinux-4.04.tar.bz2
http://ftp.hosteurope.de/mirror/ftp.kernel.org/pub/linux/utils/boot/syslinux/syslinux-4.04.tar.bz2
http://ftp.uni-ulm.de/pub/mirrors/kernel.org/utils/boot/syslinux/4.xx/syslinux-4.04.tar.bz2

[build]

sed -i '/#define statfs/d;/#undef statfs/d' libinstaller/linuxioctl.h

$HOSTCC -Wall "$K"/extlinux-bin2c-replacement.c -o libinstaller/bin2c.pl

PATH="$PATH:$PWD/libinstaller" make -j$MAKE_THREADS -C libinstaller CC="$CC" PERL=""
make -j$MAKE_THREADS -C extlinux \
  CC="$CC" OPTFLAGS="-D_GNU_SOURCE $optcflags" LDFLAGS="-static $optldflags"
make -j$MAKE_THREADS -C linux \
  CC="$CC" OPTFLAGS="-D_GNU_SOURCE $optcflags" LDFLAGS="-static $optldflags"

dest="${butch_install_dir}${butch_prefix}"
mkdir -p "$dest"/bin
cp extlinux/extlinux "$dest"/bin
cp linux/syslinux "$dest"/bin/
mkdir -p "$dest"/lib/syslinux
cp mbr/*mbr.bin "$dest"/lib/syslinux/

path: pkg/extlinux


code:
[mirrors]
http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs-tools.git/snapshot/f2fs-tools-1.6.1.tar.gz
http://distro.ibiblio.org/quirky/quirky6/sources/alphabetical/f/f2fs-tools-1.6.1.tar.gz

[vars]
filesize=73428
sha512=715d37507312d994612fb2b2f177656e3752fbd2f6145f0049e60ffca701eae923bb9939d716caceb3f680755516de954093173fdbf72fc84f8048f792b406ec
desc='utilities for the f2fs filesystem'

[deps]
libuuid
autoconf
automake
libtool
m4
pkgconf

[build]
patch -p1 < "$K"/f2fs-tools-fix-missing-queue.h.patch
#pkgconf or pkg-config

#want to compile statically:
echo 'mkfs_f2fs_LDFLAGS = -all-static' >> mkfs/Makefile.am
echo 'fsck_f2fs_LDFLAGS = -all-static' >> fsck/Makefile.am

autoreconf --install

CFLAGS="$optcflags" \
  LDFLAGS="$optldflags -static" \
    ./configure --prefix="$butch_prefix" $xconfflags \
      --disable-shared --enable-static
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install


code:
[mirrors]
http://feh.finalrewind.org/feh-2.15.1.tar.bz2

[vars]
filesize=2120474
sha512=4e959a1b4d942d16e77ca54546172e1159b8998baff65a01a108e8788b2012d0eef2437c2f7da2fd1e3ba8d568d7574b59e44e36316f579191e2b0d8eb799c90
desc='command-line oriented X11 image viewer'

[deps]
curl
giblib
libxinerama
libexif
libxt

[build]
CFLAGS="-D_GNU_SOURCE $optcflags -include string.h" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  make -j$MAKE_THREADS PREFIX="$butch_prefix" exif=1 help=1
make PREFIX="$butch_prefix" DESTDIR="$butch_install_dir" install

path: pkg/feh


code:
[mirrors]
http://ffmpeg.org/releases/ffmpeg-3.0.2.tar.xz

[vars]
filesize=7461808
sha512=a784258412431ef867372d24873f14d25cdbf333425b700f6836810c250a9d8811398de31dd042031c48e409659881bf6f6d6bfa46d74e3146536274d5186a22

[deps]
alsa-lib
libvorbis
libflac

[deps.host]
bash

[build]
[ -z "$butch_prefix" ] && butch_prefix=/
sed -i 's@/bin/sh@/bin/bash@' configure

[ -n "$CROSS_COMPILE" ] && xconfflags="--enable-cross-compile --target-os=linux --arch=$A"

testlib() {
	printf "int main() {}\n" > test_lib.c
	$CC test_lib.c -l$1 >/dev/null 2>&1
}

libvpx=
testlib vpx && libvpx=--enable-libvpx
libv4l2=
testlib v4l2 && libv4l2=--enable-libv4l2
libx11=
testlib X11 && libx11=--enable-x11grab

CFLAGS="-D_BSD_SOURCE $optcflags" LDFLAGS="$optldflags" \
  ./configure --prefix="$butch_prefix" --disable-debug --disable-yasm \
  --cc="$CC" --cxx="$CXX" --host-cc="$HOSTCC" $xconfflags \
  --enable-shared --enable-postproc --enable-gpl $libvpx $libv4l2 $libx11 \
  --enable-libvorbis \
  --disable-stripping

make V=1 -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/ffmpeg


code:
[deps]
libvpx
ffmpeg

[build]
# template service for a video-stream server
dest="$butch_install_dir""$butch_prefix"
install -Dm 644 "$K"/ffserver.conf "$dest"/etc/ffserver.conf
IS="$K"/bin/butch-install-service
"$IS" --down --log --force ffserver "$K"/services/ffserver
"$IS" --down --log --force ffclient "$K"/services/ffclient

path: pkg/ffserver


code:
[mirrors]
http://distfiles.macports.org/file/file-5.26.tar.gz
ftp://ftp.astron.com/pub/file/file-5.26.tar.gz
http://dbg.download.sourcemage.org/fallback/file-5.26.tar.gz

[vars]
filesize=773061
sha512=e3251dde54f200b6bcade5db97fda25e73efcb2629ff5c464601c82190e12290b89eb942d820d43aa67ef37be3c0f2db00e7e5c303c083e4a8d1c49499b907dd
desc='analyzes files and often outputs helpful information'

[build]
cp -f "$K"/config.sub .
printf "all:\n\ttrue\n\ninstall:\n\ttrue\n\n" > tests/Makefile.in
[ -n "$CROSS_COMPILE" ] && xconfflags="--host=$($CC -dumpmachine)"
LDFLAGS="$optldflags" \
CC="$CC -Wl,-static -static-libgcc -static -D_GNU_SOURCE -D_BSD_SOURCE" \
CFLAGS="$optcflags" \
./configure -C --prefix="$butch_prefix" \
  --disable-shared $xconfflags
sed -i 's/memory.h/string.h/' src/encoding.c src/ascmagic.c
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/file


code:
[mirrors]
http://ftp.gnu.org/pub/gnu/findutils/findutils-4.6.0.tar.gz

[vars]
filesize=3780154
sha512=41fcd4197c1efbd77f7420e5754e2cf9332dfef19f90c65a8fa1844bb4bc5d529c8393ee0ff979a054e9ac65ff71d7fe3921ea079f9960843412fc9a71f8afd4
desc="find, xargs, locate, updatedb utilities"

[deps]

[build]
CFLAGS="$optcflags" \
  LDFLAGS="$optldflags" \
    ./configure --prefix="$butch_prefix" $xconfflags \
      --enable-shared --disable-static
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/findutils


code:
[mirrors]
http://releases.mozilla.org/pub/mozilla.org/firefox/releases/38.8.0esr//source/firefox-38.8.0esr.source.tar.bz2
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/38.8.0esr/source/firefox-38.8.0esr.source.tar.bz2

[vars]
filesize=181198635
sha512=fcd2497a60176b8403a1793d1ad0a1c96a0a60217c2d4d7acd0506abf6810892bd51fd113d8f952f92b20032efc539a6b1233d8d124c2eb72d726b0935c04d65
tardir=mozilla-esr38
uchkurl=http://releases.mozilla.org/pub/mozilla.org/firefox/releases/

[deps]
libevent
gtk+2
alsa-lib
zip
zlib
libpng
bzip2
libxt
mesalib
libogg
libvorbis
icu
libvpx

[deps.host]
yasm
perl
python

[build]
FF_VERSION=38.8.0esr
export SHELL=/bin/sh

PATCH() {
	echo "***** $1 *****"
	patch -p1 < "$K"/"$1"
}

PATCH firefox-virtualenv.patch
PATCH firefox-getprotobyname_r.patch
PATCH firefox-finite.patch
PATCH firefox-gregor.patch
PATCH firefox-profiler.patch
PATCH firefox-hunspell.patch

# https://bugzilla.mozilla.org/show_bug.cgi?id=1041962
PATCH firefox-31-basename.patch

PATCH firefox38-BLOCK_SIZE.patch
PATCH firefox38-xul-order.patch
PATCH firefox38-arm-temp-failure.patch

cat << EOF > mozconfig
mk_add_options MOZ_MAKE_FLAGS="-j$MAKE_THREADS"
mk_add_options MOZ_GL_DEFAULT_PROVIDER=NONE
ac_add_options --disable-dbus
ac_add_options --disable-necko-wifi
ac_add_options --disable-libnotify
ac_add_options --disable-jemalloc
ac_add_options --disable-replace-malloc
ac_add_options --disable-wrap-malloc

ac_add_options --disable-profiling
ac_add_options --disable-shark
ac_add_options --disable-callgrind
ac_add_options --disable-vtune

ac_add_options --disable-elf-hack

# this option breaks the build
#ac_add_options --disable-webspeech
# disabling ogg as the makefile forgets to add -logg -lvorbis
#ac_add_options --disable-ogg
#ac_add_options --disable-opus
ac_add_options --disable-webgl

# GStreamer is necessary for H.264 video playback in HTML5 Video Player;
# to be enabled, also remember to set "media.gstreamer.enabled" to "true"
# in about:config. If you have installed GStreamer comment out this line:
ac_add_options --disable-gstreamer

# Uncomment these lines if you have installed optional dependencies:
#ac_add_options --enable-system-hunspell
#ac_add_options --enable-startup-notification

# Uncomment this line if you compiled Cairo with --enable-tee switch and want
# to use it instead of the bundled one:
#ac_add_options --enable-system-cairo

# If you have not installed Yasm then uncomment these 3 lines:
#ac_add_options --disable-webm
ac_add_options --disable-webrtc
ac_add_options --disable-libjpeg-turbo

ac_add_options --disable-pulseaudio

# If you have installed xulrunner uncomment the next two ac_add_options lines
# and check that the sdk will be set by running pkg-config in a subshell
# and has not become hardcoded or empty when you created this file
#ac_add_options --with-system-libxul
#ac_add_options --with-libxul-sdk=$(pkg-config --variable=sdkdir libxul)

# Comment out following options if you have not installed
# recommended dependencies:
#ac_add_options --enable-system-sqlite
ac_add_options --with-system-libevent
ac_add_options --with-system-libvpx
#ac_add_options --with-system-nspr
#ac_add_options --with-system-nss
ac_add_options --with-system-icu

# It is recommended not to touch anything below this line
ac_add_options --prefix=/$butch_prefix
ac_add_options --enable-application=browser

ac_add_options --disable-crashreporter
ac_add_options --disable-installer
ac_add_options --disable-updater
ac_add_options --disable-debug
ac_add_options --disable-tests

ac_add_options --enable-optimize
ac_add_options --enable-strip
ac_add_options --enable-install-strip
ac_add_options --enable-gio
ac_add_options --enable-official-branding
ac_add_options --enable-safe-browsing
ac_add_options --enable-url-classifier

ac_add_options --enable-system-ffi
ac_add_options --enable-system-pixman

ac_add_options --with-pthreads

ac_add_options --with-system-bz2
#ac_add_options --with-system-jpeg
#ac_add_options --with-system-png
ac_add_options --with-system-zlib

mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/firefox-build-dir
EOF
[ -n "$CROSS_COMPILE" ] && \
  printf "ac_add_options %s\n" "--target=$($CC -dumpmachine)" >> mozconfig

mkdir -p include/sys
cat << EOF > include/sys/cdefs.h
#ifndef __P
#define __P(foo) foo
#endif
EOF

find . -name '*.[ch]' | xargs sed -i s'@#include <sys/cdefs.h>@#define __P(x) x@g'

# prevent overriding our own CFLAGS with built-in -O3 -g by appending
sed -i 's@MOZ_OPTIMIZE_FLAGS=@MOZ_OPTIMIZE_FLAGS= #@g' configure
sed -i 's@MOZ_PGO_OPTIMIZE_FLAGS=@MOZ_PGO_OPTIMIZE_FLAGS= #@g' configure
sed -i 's@MOZ_DEBUG_FLAGS=@MOZ_DEBUG_FLAGS= #@g' configure
sed -i 's@HOST_OPTIMIZE_FLAGS=@HOST_OPTIMIZE_FLAGS= #@g' configure

reqldf="-Wl,--no-keep-memory -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib"
allflags="-D_GNU_SOURCE $optcflags -I$PWD/include $optldflags $reqldf"
# on arm binutils 2.24 assertion failure is triggered due to some of the cflags
# in the default butch config. see issue #186
[ "$A" = arm ] && \
allflags="-D_GNU_SOURCE -I$PWD/include -Os -g0 -fno-unwind-tables \
-fno-asynchronous-unwind-tables -Wa,--noexecstack $reqldf"
CFLAGS="$allflags" \
CXXFLAGS="$allflags" \
make -f client.mk

# TODO: check whether this step is actually necessary
CFLAGS="$allflags" \
CXXFLAGS="$allflags" \
make -C firefox-build-dir/browser/installer

dest="$butch_install_dir""$butch_prefix"
mkdir -p "$dest"/lib/firefox-"$FF_VERSION" "$dest"/bin \
  "$dest"/share/applications "$dest"/share/pixmaps
cp -r firefox-build-dir/dist/firefox/* "$dest"/lib/firefox-"$FF_VERSION"/ \

ln -sf ../lib/firefox-"$FF_VERSION"/firefox-bin "$dest"/bin/

cat << EOF > "$dest"/bin/firefox
#!/bin/sh
LD_LIBRARY_PATH="$dest"/lib/firefox-"$FF_VERSION" \
firefox-bin
EOF
chmod +x "$dest"/bin/firefox

cat << EOF > "$dest"/share/applications/firefox.desktop
[Desktop Entry]
Encoding=UTF-8
Name=Firefox Web Browser
Comment=Browse the World Wide Web
GenericName=Web Browser
Exec=firefox %u
Terminal=false
Type=Application
Icon=firefox
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=application/xhtml+xml;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
StartupNotify=true
EOF
ln -sf ../../lib/firefox-"$FF_VERSION"/browser/icons/mozicon128.png \
"$dest"/share/pixmaps/firefox.png

path: pkg/firefox


code:
[vars]
filesize=100886
sha512=93c6a8b6e4345c3049c08f2f3960f5eb5f92c487f26d227430964361bf82041b49e61f873fbbb8ee0e111556f90532b852c20e6082ee8008be641373251fa78c

[mirrors]
ftp://ftp.x.org/pub/individual/proto/fixesproto-5.0.tar.bz2

[build]
[ -n "$CROSS_COMPILE" ] && xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/')"
CFLAGS="$optcflags" LDFLAGS="$optldflags" \
./configure -C --prefix="$butch_prefix" $xconfflags
make DESTDIR="$butch_install_dir" -j$MAKE_THREADS install

path: pkg/fixesproto


code:
[vars]
filesize=1612101
sha512=8b1b86b81e7d231c746887c0c24fd1004f3f7598af4e41408667f609918a9994721b61d666a1e184822409de329323b829193a4a8dcdf12ce9313d0fe37cbbc1

[mirrors]
http://downloads.sourceforge.net/sourceforge/flex/flex-2.5.39.tar.bz2

[build]
printf "all:\n\ttrue\n\ninstall:\n\ttrue\n\n" > tests/Makefile.in
[ -n "$CROSS_COMPILE" ] && xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/')"
LDFLAGS="$optldflags -static" CPPFLAGS="-D_GNU_SOURCE -DSTDC_HEADERS" CFLAGS="$optcflags" \
  ./configure -C --prefix="$butch_prefix" $xconfflags \
  --disable-nls --infodir="$butch_prefix"/share/info --mandir="$butch_prefix"/share/man
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/flex


code:
[mirrors]
http://fltk.org/pub/fltk/1.3.2/fltk-1.3.2-source.tar.gz

[vars]
filesize=4260874
sha512=9372a34d8dfc4b4ece7632683c1c92f9ea9e538ba6eec08bec69615e2b2c885957d229a5ec495830f673b6a059f55a94b61727e8eb1fb7b3bd37005dc0b8312e
tardir=fltk-1.3.2

[deps.host]
libstdc++

[deps]
libpng
libjpeg
alsa-lib
libx11

[build]
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"
printf "#!/bin/sh\necho -lfreetype -I$butch_root_dir$butch_prefix/include/freetype2\n" > freetype-config
chmod +x freetype-config
export PATH="$PWD:$PATH"

CXXFLAGS="-D_GNU_SOURCE -D_BSD_SOURCE $optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure -C --prefix="$butch_prefix" $xconfflags
sed -i 's@.SILENT:@@' makeinclude
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install


code:
[mirrors]
http://downloads.sourceforge.net/project/androidframe/soundfonts/FluidR3_GM.sf2

[vars]
filesize=148398306
sha512=023cca1683ae18376999ae8121fbfbd134f345b6539e32b2eaa91929e23695785798e9983aaa1bb1e2c88587c8d5b172e4a041b505fff3fbd8bd17314cb8c4e3

[deps]

[build]
dest="$butch_install_dir""$butch_prefix"
install -D -m 644 "$C"/FluidR3_GM.sf2 "$dest"/share/sounds/sf2/FluidR3_GM.sf2

path: pkg/fluid-soundfont-gm


code:
[mirrors]
http://downloads.sourceforge.net/project/androidframe/soundfonts/FluidR3_GS.sf2

[vars]
filesize=3201926
sha512=7b09d1a3741528c8dab77d74ecd424325c4db9e32b9a8a3a1b018f600aee871d0c6e56b3b098ee58312b40809c78d3e85876d42e1f5c7d5f10857ebae5ad6967

[deps]

[build]
dest="$butch_install_dir""$butch_prefix"
install -D -m 644 "$C"/FluidR3_GS.sf2 "$dest"/share/sounds/sf2/FluidR3_GS.sf2

path: pkg/fluid-soundfont-gs


code:
[mirrors]
http://heanet.dl.sourceforge.net/project/fluidsynth/fluidsynth-1.1.6/fluidsynth-1.1.6.tar.bz2

[vars]
filesize=823783
sha512=0ead8bf86c0edf6d98044eb16b52b85fac8bc3bdeb9c1478d0bceb4f5b38ca28218fcf2cd18cdd5608190dc70b7c39bde681765d01787bc84bc97c6ab3bbf946

[deps]
alsa-lib
libsndfile
glib

[build]
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') --with-sysroot=$butch_root_dir"
CFLAGS="$optcflags -D_GNU_SOURCE" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure -C --prefix="$butch_prefix" $xconfflags
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/fluidsynth


code:
[mirrors]
http://ftp.x.org/archive//individual/font/font-util-1.3.1.tar.bz2

[vars]
filesize=153289
sha512=9fd6dd4c0a01ede5f0b09ec0f9d316267ca086e2ee9526a43a4e4d6ce3cd67c977293bd3cf440328ca417292fcae1579888b24b7259eaf012230890210d74889

[deps]

[build]
#patch -p1 < "$K"/some.patch

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"

CPPFLAGS="-D_GNU_SOURCE" CFLAGS="$optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure -C --prefix="$butch_prefix" --disable-nls $xconfflags

#[ -n "$CROSS_COMPILE" ] && "$K"/libtool.cross.gen --sysroot="$butch_root_dir"

make V=1 -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/font-util


code:
[mirrors]
http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.11.95.tar.bz2

[vars]
filesize=1591200
sha512=e3d7696814b585512bbe191ae4e5a4fe5a645895b4b1f5783dc575efe3f0a2b725daa48eb9c43168d2cd2fc752bf114be41c58a4ae81f2db49f431984e134b54

[deps]
freetype
expat

[deps.host]
pkgconf

[build]
printf "all:\n\ttrue\n\ninstall:\n\ttrue\n\n" > test/Makefile.in
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') --with-sysroot=$butch_root_dir"
CFLAGS="-D_GNU_SOURCE $optcflags" \
LDFLAGS="$optldflags" \
  ./configure -C --prefix="$butch_prefix" $xconfflags \
	--disable-docs \

make -j$MAKE_THREADS V=1
make DESTDIR="$butch_install_dir" install

path: pkg/fontconfig


code:
[deps]
util-macros

[mirrors]
http://xorg.freedesktop.org/releases/individual/proto/fontsproto-2.1.3.tar.bz2

[vars]
filesize=154087
sha512=f46d5b733aa48644aa3aa75d4ed47231ef78cb60f747f7200d82331a1ba566190bf37b5b9926c690dec6356043ce7c85a5b59fc1b4b11667ef432518b5d4cc87

[build]
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine)"
CFLAGS="$optcflags" LDFLAGS="$optldflags" \
  ./configure -C --prefix="$butch_prefix" $xconfflags
make DESTDIR="$butch_install_dir" -j$MAKE_THREADS install

path: pkg/fontsproto


code:
[mirrors]
http://www.openprinting.org/download/foomatic/foomatic-filters-4.0.12.tar.gz

[vars]
filesize=265634
sha512=5ce95bdac252d40c82f9afbd2e402f9b387f942d975013a51a0e23124fa76d827a4ff136a8c691e59d9060d4a6557e9b1d5f54192dee19c9d72465a175b23a0a
desc="The universal print filter 'foomatic-rip', used by spoolers to convert PostScript job data into the printer's native format"

[deps]

[build]

CFLAGS="$optcflags" LDFLAGS="$optldflags" \
  ./configure -C --prefix="$butch_prefix" $xconfflags --disable-dbus

make -j$MAKE_THREADS || exit 1

make DESTDIR="$butch_install_dir" install

path: pkg/foomatic-filters


code:
[vars]
filesize=419095
sha512=9c45d5b203b26a7ff92331b3e080a48e806c92fbbe7c65d9262dd18c39cd6efdad8a795a80f499a2d23df84b4909dbd7c1bab20d7dd3555d3d88782ce9dd15b0

[mirrors]
http://downloads.sourceforge.net/freeglut/freeglut-3.0.0.tar.gz

[deps]
mesalib
glu
libxi

[deps.host]
cmake

[build]
mkdir -p build && cd build
for i in ar ld nm objcopy objdump strip ; do
printf '#!/bin/sh\n%s%s "$@"\n' "$CROSS_COMPILE" "$i" > "$CROSS_COMPILE""$i"
chmod +x "$CROSS_COMPILE""$i"
done
[ -n "$CROSS_COMPILE" ] && xconfflags="
-DCMAKE_FIND_ROOT_PATH=$butch_root_dir$butch_prefix \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_AR="$CROSS_COMPILE"ar \
-DCMAKE_LD="$CROSS_COMPILE"ld \
-DCMAKE_NM="$CROSS_COMPILE"nm \
-DCMAKE_OBJCOPY="$CROSS_COMPILE"objcopy \
-DCMAKE_OBJDUMP="$CROSS_COMPILE"objdump \
-DCMAKE_STRIP="$CROSS_COMPILE"strip \
"

CFLAGS="-D_GNU_SOURCE $optcflags" \
LDFLAGS="$optldflags  -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
CXXFLAGS="$optcflags" \
cmake $xconfflags \
  -DCMAKE_INSTALL_PREFIX="$butch_prefix" \
  -DCMAKE_VERBOSE_MAKEFILE=ON \
  -DFREEGLUT_BUILD_DEMOS=OFF       \
  -DFREEGLUT_BUILD_STATIC_LIBS=OFF \
  ..
make -j$MAKE_THREADS VERBOSE=1
make DESTDIR="$butch_install_dir" install

path: pkg/freeglut


code:
[mirrors]
http://distro.ibiblio.org/quirky/quirky6/sources/t2/april/freememapplet_tray-2.4.tar.bz2

[vars]
filesize=7849
sha512=55476ccb332aa546b7721c4bbf3fcbec0af7746c9ed0395c737e2fc90d1f675c47671c9100cc03a1d2fa5396613980576db17b9328b9774a1a80d70d365752f5
desc="Free memory applet for desktop tray. Designed for Puppy Linux."

[deps]
gtk+2
gettext-gnu

[build]
dest="$butch_install_dir""$butch_prefix"

sed -i -e 's%/usr/%/%' freememapplet_tray.c

[ -f freememapplet_tray ] && rm -f freememapplet_tray
[ -f freememapplet_tray.pot ] && rm -f freememapplet_tray.pot
gcc freememapplet_tray.c -o freememapplet_tray `pkg-config --cflags --libs gtk+-2.0`
xgettext --keyword="_" -o freememapplet_tray.pot freememapplet_tray.c

#these destinations are Puppy-heritage: /root/Startup
#need to rethink these. set to /lib/Startup
strip --strip-unneeded freememapplet_tray
mkdir -p "$dest"/lib/Startup
cp -a -f freememapplet_tray "$dest"/lib/Startup/
mkdir -p "$dest"/share/doc/nls/freememapplet_tray
cp -a -f freememapplet_tray.pot "$dest"/share/doc/nls/freememapplet_tray/

path: pkg/freememapplet-tray


code:
[mirrors]
http://download.savannah.gnu.org/releases/freetype/freetype-2.6.3.tar.bz2

[vars]
filesize=1753083
sha512=e1f9018835fc88beeb4479537b59f866c52393ae18d24a1e0710a464cf948ab02b35c2c6043bc20c1db3a04871ee4eb0bb1d210550c0ea2780c8b1aea98fbf0d

[deps]
zlib
libpng

[build]
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine) \
  --with-sysroot=$butch_root_dir"
printf "#!/bin/sh\necho -lpng15 -I$butch_root_dir$butch_prefix/include/libpng15\n" > libpng-config
chmod +x libpng-config
cp libpng-config libpng15-config
export PATH="$PWD:$PATH"

CPPFLAGS="-D_GNU_SOURCE" CFLAGS="$optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="-L/lib $optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure -C --prefix="$butch_prefix" --disable-nls $xconfflags \
  --with-harfbuzz=no

#[ -n "$CROSS_COMPILE" ] && "$K"/libtool.cross.gen --sysroot="$butch_root_dir"

make V=1 -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/freetype


code:
[mirrors]
http://fribidi.org/download/fribidi-0.19.7.tar.bz2

[vars]
filesize=648299
sha512=4bfdda43d961030a8a2ae2c98d2ca5d43c1b59633fa0987920c5537ec69f3f624204ceacc4c474d878cbb417ee2d9e708dfe169cfce6ad584d2f2d5122678b63

[deps]

[build]
[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine) \
  --with-sysroot=$butch_root_dir"

cp -f "$K"/config.sub .

CFLAGS="-D_GNU_SOURCE $optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
  ./configure -C --prefix="$butch_prefix" $xconfflags

make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/fribidi


code:
[mirrors]
http://downloads.sourceforge.net/project/fuse/fuse-2.X/2.9.3/fuse-2.9.3.tar.gz

[vars]
filesize=572044
sha512=03f43f88694ec7e039ff3579a8e76349b5a5a05872c55901fc1d9ee53dbb6b1e69f6dd0005b620f3b5ead0b14da8eeb31d46b922d10f88f4e3f830aa47e8162c

[deps]

[build]
patch -p1 < "$K"/fuse-lock.patch
patch -p1 < "$K"/fuse-paths.patch
patch -p1 < "$K"/fuse-headers.patch

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') \
  --with-sysroot=$butch_root_dir"
CFLAGS="-D_GNU_SOURCE $optcflags" LDFLAGS="$optldflags" \
  ./configure -C --prefix="$butch_prefix" $xconfflags

make V=1 -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

path: pkg/fuse


code:
[vars]
filesize=2063647
sha512=9a337673725d3190c76da7e61f9b5e6df348eb4e08a3f7a7a1b5869d0bec6514d97782dffbb56ec5c4897e8f2ec9994b401c00fe0b47e0510e11eb963c9c2efb

[mirrors]
http://ftpmirror.gnu.org/gawk/gawk-4.0.0.tar.bz2
http://ftp.gnu.org/pub/gnu/gawk/gawk-4.0.0.tar.bz2

[build]
printf "all:\n\ttrue\n\ninstall:\n\ttrue\n\n" > test/Makefile.in
CC="$CC -static" ./configure -C --prefix="$butch_prefix" --libexecdir="$butch_prefix"/lib \
  --disable-nls ac_cv_header_dlfcn_h=no
make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install
dest="$butch_install_dir""$butch_prefix"
ln -sf gawk "$dest"/bin/awk

path: pkg/gawk


code:
[mirrors]
ftp://sourceware.org/pub/java/ecj-4.5.jar

[vars]
filesize=1470676
sha512=d4e1bf7538ace56e3d69fa91da5bbd16c272923b4de0a9d8dee23ea2b75f9f38c603de72fc4061df49285c450b63f3df211cee5270e9fffc5447445d1a9c9e4e
desc='eclipse java compiler modified to be usable by gcc as gcj backend'


code:
[mirrors]
http://ftp.gnu.org/gnu/gcc/gcc-3.4.6/gcc-core-3.4.6.tar.bz2

[vars]
filesize=13366790
sha512=06645865a851bfdeca399ed1266f99e072a9bb1d8c6f0d3d6d0f809080ce1e60f45d9e4b52c93cf89f2062a4db0a69f519f23ac5de918bc89bdd794ebd2b96b4
tardir=gcc-3.4.6

[build]
VERSION=3.4.6
patch -p1 < "$K"/gcc-346-unwind2.patch
patch -p1 < "$K"/gcc-346-unlink.patch
patch -p1 < "$K"/gcc-346-libgcc-visibility.patch

find gcc/config -name linux.h -exec sed -i 's@struct siginfo@siginfo_t@g' "{}" \;

intel32=false
case "$A" in i[3-6]86) intel32=true ;; esac
if $intel32 && [ "$(./config.guess)" = "i686-pc-linux-gnulibc1" ] ; then
	printf '#!/bin/sh\necho i386-unknown-linux-gnu\n' > config.guess
fi

# remove fix-includes
sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in

#apparently some control freak gcc used by ubuntu enforces that the mode arg is set in open calls
sed -i 's@O_CREAT@O_CREAT, 0770@' gcc/collect2.c

sed -i 's@/lib/ld-linux.so.[12]@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux.h
sed -i 's@/lib/ld-linux.so.[12]@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib64/ld-linux-x86-64.so.2@/lib/ld-musl-x86_64.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib64/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib32/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/sysv4.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/linux64.h
sed -i 's@/lib64/ld64.so.1@/lib/ld-musl-powerpc64.so.1@g' gcc/config/rs6000/linux64.h

"$K"/libibertyfix libiberty

case "$A" in
  arm) echo "error: gcc 3.4.6 does not support EABI!" ; exit 1 ;;
  x86_64) archflags=--disable-multilib ;;
  i[3-6]86) archflags=--disable-multilib ;;
  *) archflags= ;;
esac
[ -n "$GCC_ARCH_CONFIG_FLAGS" ] && archflags="$archflags $GCC_ARCH_CONFIG_FLAGS"

# workaround for debian idiocy: they put bits/ into an arch-specific
# sysdir in /usr/include, so the bootstrap compiler (xgcc), which
# uses the host headers, will use a broken set of headers.
is_ubuntu_or_debian() {
	uname -v | grep Ubuntu >/dev/null 2>&1  || \
	uname -v | grep Debian >/dev/null 2>&1
}

if [ "$STAGE" = "0" ] && is_ubuntu_or_debian ; then
	echo debian/ubuntu detected!
	if [ -d /usr/include/"$A"-linux-gnu/bits ] ; then
		for i in sys bits asm gnu ; do
			ln -sf /usr/include/"$A"-linux-gnu/"$i" include/
		done
	fi
fi

./configure --prefix="$butch_prefix" \
  --mandir="$butch_prefix"/share/man \
  --infodir="$butch_prefix"/infoXXX \
  --disable-bootstrap --disable-shared --disable-nls $archflags
make \
  CFLAGS="-DSTDC_HEADERS -Werror-implicit-function-declaration" \
  LDFLAGS="-static" \
  -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install-gcc

dest="$butch_install_dir""$butch_prefix"

rm -rf "$dest"/infoXXX

# rename gcc to rawcc so musl-gcc can call the *right* gcc
mv "$dest"/bin/gcc "$dest"/bin/rawcc
ln -sf "rawcc" "$dest"/bin/gcc

ln -sf ar "$dest"/bin/gcc-ar
ln -sf ranlib "$dest"/bin/gcc-ranlib
ln -sf nm "$dest"/bin/gcc-nm

[ "$A" = "x86_64" ] && mv "$dest"/lib64/* "$dest"lib/ || true

ln -sf rawcc "$dest"/bin/gcc-$VERSION


code:
[vars]
filesize=18927613
sha512=3b29aba3d90525d6cc4fcc2e0b99ac9f65a5cda488937346c2c742647b8b2f3b93644bfef801eda358945f9beef6a2cd108bb43071d0b13dce384f282921a7ca
tardir=gcc-4.2.4

[deps]

[mirrors]
http://ftp.gnu.org/gnu/gcc/gcc-4.2.4/gcc-core-4.2.4.tar.bz2

[build]
VERSION=4.2.4

patch -p1 < "$K"/gcc-424-libgcc-visibility.patch

sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
sed -i 's@/lib/ld-linux.so.[12]@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux.h
sed -i 's@/lib/ld-linux.so.[12]@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib64/ld-linux-x86-64.so.2@/lib/ld-musl-x86_64.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib64/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib32/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/sysv4.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/linux64.h
sed -i 's@/lib64/ld64.so.1@/lib/ld-musl-powerpc64.so.1@g' gcc/config/rs6000/linux64.h
sed -i 's@/lib/ld-linux.so.3@/lib/ld-musl-arm.so.1@' gcc/config/arm/linux-eabi.h
sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-arm.so.1@' gcc/config/arm/linux-elf.h

"$K"/libibertyfix libiberty

archflags=
[ -n "$GCC_ARCH_CONFIG_FLAGS" ] && archflags="$GCC_ARCH_CONFIG_FLAGS"
#gcc424 doesn't support hardfloat so we can assume arm-linux-gnueabi
[ "$A" = "arm" ] && archflags="$archflags --target=arm-linux-gnueabi --host=arm-linux-gnueabi --build=arm-linux-gnueabi"

echo ac_cv_func_strsignal=yes > config.site
./configure --prefix="$butch_prefix" \
--mandir="$butch_prefix"/share/man \
--infodir="$butch_prefix"/infoXXX \
--with-newlib --with-headers=no \
--disable-bootstrap \
--disable-shared \
--disable-multilib \
--disable-nls \
--disable-mudflap --disable-libmudflap --disable-libssp \
--disable-libgomp \
$archflags
make CFLAGS="-D_GNU_SOURCE -DSTDC_HEADERS -DHAVE_STRSIGNAL -DHAVE_GETRLIMIT \
 -DHAVE_GETRLIMIT -O0 -g0" LDFLAGS="-static" -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install-gcc

dest="$butch_install_dir""$butch_prefix"
rm -rf "$dest"/infoXXX

[ "$A" = x86_64 ] && mv "$dest"/lib64/* "$dest"/lib/ || true

# rename gcc to rawcc so musl-gcc can call the *right* gcc
mv "$dest"/bin/gcc "$dest"/bin/rawcc
ln -sf "rawcc" "$dest"/bin/gcc

ln -sf ar "$dest"/bin/gcc-ar
ln -sf ranlib "$dest"/bin/gcc-ranlib
ln -sf nm "$dest"/bin/gcc-nm

ln -sf rawcc "$dest"/bin/gcc-$VERSION


code:
[deps]
m4
gmp
mpfr
mpc
zlib
g++447

[vars]
filesize=25784094
sha512=318522e170a9e54d051311416dc221d8d727a85d6e24a97fdbd9125d9dea1530930efd04b846c06ddbe3c5acaeef8810e0d4e79b8e9af535f0b08f1f20e5b10b
tardir=gcc-4.4.7

[mirrors]
http://ftpmirror.gnu.org/gcc/gcc-4.4.7/gcc-core-4.4.7.tar.bz2

[build]
VERSION=4.4.7
VERSION_REMOVE='s,4\.4\.7.*,,'
# check that libc.so is available, otherwise we'll get a libstdc++.so
# that is statically linked against musls libc.a.
# this will lead to random crashes in C++ apps since two concurrent
# malloc implementations will call brk and mess up each other.
if [ ! -f "$butch_prefix"/lib/libc.so ] ; then
	echo "libc.so non-existing or symlink broken"
	exit 1
fi

# we're doing a bit of hack to place the g++ contents in this folder
# the build system isnt really laid out for extracting multiple tarballs into
# the same dir...

(
cd ..
tar xf $C/gcc-g++-$VERSION.tar.bz2
)

"$K"/libibertyfix libiberty

#more g++ hackery
#sed -i 's,# include <syscall.h>,#include <sys/syscall.h>,' ./libstdc++-v3/libsupc++/guard.cc

#todo check if this isnt to intrusive
sed -i 's,gcc_no_link=yes,gcc_no_link=no,' ./libstdc++-v3/configure

#and even more g++ hackery
mv ./libstdc\+\+-v3/config/os/gnu-linux ./libstdc\+\+-v3/config/os/gnu-linux.org
cp -r ./libstdc\+\+-v3/config/os/generic ./libstdc\+\+-v3/config/os/gnu-linux
cp ./libstdc++-v3/config/os/gnu-linux.org/arm-eabi-extra.ver ./libstdc++-v3/config/os/gnu-linux/
#g++ hackery done

sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in

sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux.h
sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib/ld-linux.so.3@/lib/ld-musl-arm.so.1@' gcc/config/arm/linux-eabi.h
sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-arm.so.1@' gcc/config/arm/linux-elf.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib64/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib32/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib64/ld-linux-x86-64.so.2@/lib/ld-musl-x86_64.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/sysv4.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/linux64.h
sed -i 's@/lib64/ld64.so.1@/lib/ld-musl-powerpc64.so.1@g' gcc/config/rs6000/linux64.h

patch -p1 < "$K"/gcc-453-patch0.patch

config_arch_flags=
config_arch_target_cflags=
config_arch_target_ldflags=
if [ "$A" = "arm" ] ; then
	patch -p1 < "$K"/gcc-453-patch1.patch
elif [ "$A" = "powerpc" ] ; then
	patch -p1 < "$K"/gcc-454-stackend.patch
	config_arch_flags="--enable-secureplt --with-long-double-64"
	config_arch_target_cflags="-Wl,--secure-plt"
	config_arch_target_ldflags="-Wl,--secure-plt"
fi

export CC="$CC -static -D_GNU_SOURCE"

CFLAGS="-O0 -s" LDFLAGS="-Wl,--no-keep-memory" \
CFLAGS_FOR_TARGET="$config_arch_target_cflags" LDFLAGS_FOR_TARGET="$config_arch_target_ldflags" \
./configure -C --with-newlib --with-headers=no --prefix="$butch_prefix" \
  --disable-multilib --disable-nls --disable-mudflap \
  --disable-libmudflap --enable-libssp --disable-libgomp \
  --disable-debug --disable-bootstrap \
  --with-system-zlib \
  --with-target-libiberty=no --with-target-zlib=no \
  --enable-languages=c,c++ --enable-clocale=generic \
  $config_arch_flags

gcc_cv_libc_provides_ssp=yes \
make -j$MAKE_THREADS BOOT_LDFLAGS="-static" LDFLAGS="-static"
make -j1 DESTDIR="$butch_install_dir" \
  install-gcc install-target-libgcc install-target-libstdc++-v3

dest=$butch_install_dir$butch_prefix

#create a host_tuple dummy entry, so binutils stuff will get into /bin, etc
lib_gcc=`$dest/bin/gcc -print-libgcc-file-name`
lib_gcc_minus_filename=`echo $lib_gcc | sed "$VERSION_REMOVE"`
host_tuple=`basename $lib_gcc_minus_filename`
echo host tuple is $host_tuple

if [ ! -e ${dest}/${host_tuple} ] ; then
	(
	cd $dest
	ln -sf . ${host_tuple}
	)
fi

#remove gcc's stddef.h which is not compatible
rm $dest/lib/gcc/$host_tuple/$VERSION/include/stddef.h

copy() {
	printf "cp %s %s\n" "$1" "$2"
	cp "$1" "$2"
}

echo link gcc intrinsic headers into /include/gcc
# this allows usage of -I/include/gcc for stuff that uses them
mkdir -p  $dest/include/gcc
for i in $dest/lib/gcc/$host_tuple/$VERSION/include/* ; do
  header=`basename "$i"`
  # do not copy headers that exist in musl
  [ -e "$dest/include/$header" ] || copy "$i" "$dest/include/gcc/"
done

# fix specs file. this prevents libgcc_s from being used.
# not only is it slower, it'll cause assertion errors in ld.
# the default location for this file is relative from the gcc
# binary used, "gccdir"/lib/gcc/$host_tuple/$gcc-version/specs
# the second default path is "gccdir"/lib/gcc/specs. we use
# the latter to use less movable parts.

"$dest"/bin/gcc -dumpspecs > "$dest"/lib/gcc/specs
sed -i 's,-lgcc_s,-lgcc_eh,' "$dest"/lib/gcc/specs

if [ "$A" = x86_64 ] ; then
	mv "$dest"/lib64/* "$dest"/lib/ || true
	sed -i 's,/lib/../lib64,/lib,' "$dest"/lib/libstdc++.la
	sed -i 's,/lib/../lib64,/lib,' "$dest"/lib/libsupc++.la
fi

ln -sf gcc "$dest"/bin/cc

# assert that libstdc++.so is not statically linked against musl
if ! readelf -a "$dest"/lib/libstdc++.so | grep NEEDED | grep libc.so > /dev/null ; then
	echo "error: libstdc++.so has no NEEDED entry for libc.so!"
	exit 1
fi

ln -sf gcc "$dest"/bin/gcc-$VERSION
ln -sf g++ "$dest"/bin/g++-$VERSION


code:
[deps]
m4
gmp
mpfr
mpc
zlib
libelf
g++454

[vars]
filesize=28265185
sha512=82f81a6860155e78cecac846038ceb5a5ec68e399f3ab058c5d569745e47460761f162e92f627d0275a37ff24cbc6582a018b5057d57fc01107f615e59192451
tardir=gcc-4.5.4

[mirrors]
http://ftpmirror.gnu.org/gcc/gcc-4.5.4/gcc-core-4.5.4.tar.bz2

[build]
VERSION=4.5.4
VERSION_REMOVE='s,4\.5\.4.*,,'

# check that libc.so is available, otherwise we'll get a libstdc++.so
# that is statically linked against musls libc.a.
# this will lead to random crashes in C++ apps since two concurrent
# malloc implementations will call brk and mess up each other.
if [ ! -f "$butch_prefix"/lib/libc.so ] ; then
	echo "libc.so non-existing or symlink broken"
	exit 1
fi

# we're doing a bit of hack to place the g++ contents in this folder
# the build system isnt really laid out for extracting multiple tarballs into
# the same dir...

(
cd ..
tar xf $C/gcc-g++-$VERSION.tar.bz2
)

"$K"/libibertyfix libiberty

#more g++ hackery
#sed -i 's,# include <syscall.h>,#include <sys/syscall.h>,' ./libstdc++-v3/libsupc++/guard.cc

#todo check if this isnt to intrusive
sed -i 's,gcc_no_link=yes,gcc_no_link=no,' ./libstdc++-v3/configure

#and even more g++ hackery
mv ./libstdc\+\+-v3/config/os/gnu-linux ./libstdc\+\+-v3/config/os/gnu-linux.org
cp -r ./libstdc\+\+-v3/config/os/generic ./libstdc\+\+-v3/config/os/gnu-linux
cp ./libstdc++-v3/config/os/gnu-linux.org/arm-eabi-extra.ver ./libstdc++-v3/config/os/gnu-linux/
#g++ hackery done

sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in

sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux.h
sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib/ld-linux.so.3@/lib/ld-musl-arm.so.1@' gcc/config/arm/linux-eabi.h
sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-arm.so.1@' gcc/config/arm/linux-elf.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib64/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib32/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib64/ld-linux-x86-64.so.2@/lib/ld-musl-x86_64.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/sysv4.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/linux64.h
sed -i 's@/lib64/ld64.so.1@/lib/ld-musl-powerpc64.so.1@g' gcc/config/rs6000/linux64.h

patch -p1 < "$K"/gcc-453-patch0.patch

config_arch_flags=
config_arch_target_cflags=
config_arch_target_ldflags=
if [ "$A" = "arm" ] ; then
	patch -p1 < "$K"/gcc-453-patch1.patch
elif [ "$A" = "powerpc" ] ; then
	patch -p1 < "$K"/gcc-454-stackend.patch
	config_arch_flags="--enable-secureplt --with-long-double-64"
	config_arch_target_cflags="-Wl,--secure-plt"
	config_arch_target_ldflags="-Wl,--secure-plt"
fi

export CC="$CC -static -D_GNU_SOURCE"

CFLAGS="$optcflags" LDFLAGS="-Wl,--no-keep-memory $optldflags" \
CFLAGS_FOR_TARGET="$config_arch_target_cflags" LDFLAGS_FOR_TARGET="$config_arch_target_ldflags" \
./configure -C --with-newlib --with-headers=no --prefix="$butch_prefix" \
  --disable-multilib --disable-nls --disable-mudflap \
  --disable-libmudflap --enable-libssp --disable-libgomp \
  --disable-debug --disable-bootstrap \
  --enable-lto --with-system-zlib \
  --with-target-libiberty=no --with-target-zlib=no \
  --enable-languages=c,c++ --enable-clocale=generic \
  $config_arch_flags

gcc_cv_libc_provides_ssp=yes \
make -j$MAKE_THREADS BOOT_LDFLAGS="-static" LDFLAGS="-static"
make -j1 DESTDIR="$butch_install_dir" \
  install-gcc install-lto-plugin install-target-libgcc install-target-libstdc++-v3

dest=$butch_install_dir$butch_prefix

#create a host_tuple dummy entry, so binutils stuff will get into /bin, etc
lib_gcc=`$dest/bin/gcc -print-libgcc-file-name`
lib_gcc_minus_filename=`echo $lib_gcc | sed "$VERSION_REMOVE"`
host_tuple=`basename $lib_gcc_minus_filename`
echo host tuple is $host_tuple

if [ ! -e ${dest}/${host_tuple} ] ; then
	(
	cd $dest
	ln -sf . ${host_tuple}
	)
fi

#remove gcc's stddef.h which is not compatible
rm $dest/lib/gcc/$host_tuple/$VERSION/include/stddef.h

copy() {
	printf "cp %s %s\n" "$1" "$2"
	cp "$1" "$2"
}

echo link gcc intrinsic headers into /include/gcc
# this allows usage of -I/include/gcc for stuff that uses them
mkdir -p  $dest/include/gcc
for i in $dest/lib/gcc/$host_tuple/$VERSION/include/* ; do
  header=`basename "$i"`
  # do not copy headers that exist in musl
  [ -e "$dest/include/$header" ] || copy "$i" "$dest/include/gcc/"
done

# fix specs file. this prevents libgcc_s from being used.
# not only is it slower, it'll cause assertion errors in ld.
# the default location for this file is relative from the gcc
# binary used, "gccdir"/lib/gcc/$host_tuple/$gcc-version/specs
# the second default path is "gccdir"/lib/gcc/specs. we use
# the latter to use less movable parts.

"$dest"/bin/gcc -dumpspecs > "$dest"/lib/gcc/specs
sed -i 's,-lgcc_s,-lgcc_eh,' "$dest"/lib/gcc/specs

if [ "$A" = x86_64 ] ; then
	mv "$dest"/lib64/* "$dest"/lib/ || true
	sed -i 's,/lib/../lib64,/lib,' "$dest"/lib/libstdc++.la
	sed -i 's,/lib/../lib64,/lib,' "$dest"/lib/libsupc++.la
fi

ln -sf gcc "$dest"/bin/cc

# assert that libstdc++.so is not statically linked against musl
if ! readelf -a "$dest"/lib/libstdc++.so | grep NEEDED | grep libc.so > /dev/null ; then
	echo "error: libstdc++.so has no NEEDED entry for libc.so!"
	exit 1
fi

ln -sf gcc "$dest"/bin/gcc-$VERSION
ln -sf g++ "$dest"/bin/g++-$VERSION


code:
[deps]
m4
gmp
mpfr
mpc
zlib
libelf
g++464

[mirrors]
http://ftpmirror.gnu.org/gcc/gcc-4.6.4/gcc-core-4.6.4.tar.bz2
[vars]
filesize=30353380
sha512=93b1dfb945256ab08d4cadd43237da09b5b37ebc9d82b6ba4072df253f139ae0795860cd58d9fde83018b0b5ce6e23bc679dfb22ca76813a9a29c8129fd2854d
tardir=gcc-4.6.4

[build]
VERSION=4.6.4
VERSION_REMOVE='s,4\.6\.4.*,,'
# check that libc.so is available, otherwise we'll get a libstdc++.so
# that is statically linked against musls libc.a.
# this will lead to random crashes in C++ apps since two concurrent
# malloc implementations will call brk and mess up each other.
if [ ! -f "$butch_prefix"/lib/libc.so ] ; then
	echo "libc.so non-existing or symlink broken"
	exit 1
fi

# we're doing a bit of hack to place the g++ contents in this folder
# the build system isnt really laid out for extracting multiple tarballs into
# the same dir...

(
cd ..
tar xf $C/gcc-g++-$VERSION.tar.bz2
)

"$K"/libibertyfix libiberty

#more g++ hackery
#sed -i 's,# include <syscall.h>,#include <sys/syscall.h>,' ./libstdc++-v3/libsupc++/guard.cc

#todo check if this isnt to intrusive
sed -i 's,gcc_no_link=yes,gcc_no_link=no,' ./libstdc++-v3/configure

#and even more g++ hackery
mv ./libstdc\+\+-v3/config/os/gnu-linux ./libstdc\+\+-v3/config/os/gnu-linux.org
cp -r ./libstdc\+\+-v3/config/os/generic ./libstdc\+\+-v3/config/os/gnu-linux
cp ./libstdc++-v3/config/os/gnu-linux.org/arm-eabi-extra.ver ./libstdc++-v3/config/os/gnu-linux/
#g++ hackery done

sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in

sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux.h
sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib/ld-linux.so.3@/lib/ld-musl-arm.so.1@' gcc/config/arm/linux-eabi.h
sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-arm.so.1@' gcc/config/arm/linux-elf.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib64/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib32/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib64/ld-linux-x86-64.so.2@/lib/ld-musl-x86_64.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/sysv4.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/linux64.h
sed -i 's@/lib64/ld64.so.1@/lib/ld-musl-powerpc64.so.1@g' gcc/config/rs6000/linux64.h

patch -p1 < "$K"/gcc-453-patch0.patch

config_arch_flags=
config_arch_target_cflags=
config_arch_target_ldflags=
if [ "$A" = "arm" ] ; then
	patch -p1 < "$K"/gcc-453-patch1.patch
elif [ "$A" = "powerpc" ] ; then
	patch -p1 < "$K"/gcc-454-stackend.patch
	config_arch_flags="--enable-secureplt --with-long-double-64"
	config_arch_target_cflags="-Wl,--secure-plt"
	config_arch_target_ldflags="-Wl,--secure-plt"
fi

export CC="$CC -static -D_GNU_SOURCE"

CFLAGS="-O0 -s" LDFLAGS="-Wl,--no-keep-memory" \
CFLAGS_FOR_TARGET="$config_arch_target_cflags" LDFLAGS_FOR_TARGET="$config_arch_target_ldflags" \
./configure -C --with-newlib --with-headers=no --prefix="$butch_prefix" \
  --disable-multilib --disable-nls --disable-mudflap \
  --disable-libmudflap --enable-libssp --disable-libgomp \
  --disable-debug --disable-bootstrap \
  --enable-lto \
  --with-system-zlib \
  --with-target-libiberty=no --with-target-zlib=no \
  --enable-languages=c,c++ --enable-clocale=generic \
  $config_arch_flags

gcc_cv_libc_provides_ssp=yes \
make -j$MAKE_THREADS BOOT_LDFLAGS="-static" LDFLAGS="-static"
make -j1 DESTDIR="$butch_install_dir" \
  install-gcc install-lto-plugin install-target-libgcc install-target-libstdc++-v3

dest=$butch_install_dir$butch_prefix

#create a host_tuple dummy entry, so binutils stuff will get into /bin, etc
lib_gcc=`$dest/bin/gcc -print-libgcc-file-name`
lib_gcc_minus_filename=`echo $lib_gcc | sed "$VERSION_REMOVE"`
host_tuple=`basename $lib_gcc_minus_filename`
echo host tuple is $host_tuple

if [ ! -e ${dest}/${host_tuple} ] ; then
	(
	cd $dest
	ln -sf . ${host_tuple}
	)
fi

#remove gcc's stddef.h which is not compatible
rm $dest/lib/gcc/$host_tuple/$VERSION/include/stddef.h

copy() {
	printf "cp %s %s\n" "$1" "$2"
	cp "$1" "$2"
}

echo link gcc intrinsic headers into /include/gcc
# this allows usage of -I/include/gcc for stuff that uses them
mkdir -p  $dest/include/gcc
for i in $dest/lib/gcc/$host_tuple/$VERSION/include/* ; do
  header=`basename "$i"`
  # do not copy headers that exist in musl
  [ -e "$dest/include/$header" ] || copy "$i" "$dest/include/gcc/"
done

# fix specs file. this prevents libgcc_s from being used.
# not only is it slower, it'll cause assertion errors in ld.
# the default location for this file is relative from the gcc
# binary used, "gccdir"/lib/gcc/$host_tuple/$gcc-version/specs
# the second default path is "gccdir"/lib/gcc/specs. we use
# the latter to use less movable parts.

"$dest"/bin/gcc -dumpspecs > "$dest"/lib/gcc/specs
sed -i 's,-lgcc_s,-lgcc_eh,' "$dest"/lib/gcc/specs

if [ "$A" = x86_64 ] ; then
	mv "$dest"/lib64/* "$dest"/lib/ || true
	sed -i 's,/lib/../lib64,/lib,' "$dest"/lib/libstdc++.la
	sed -i 's,/lib/../lib64,/lib,' "$dest"/lib/libsupc++.la
fi

ln -sf gcc "$dest"/bin/cc

# assert that libstdc++.so is not statically linked against musl
if ! readelf -a "$dest"/lib/libstdc++.so | grep NEEDED | grep libc.so > /dev/null ; then
	echo "error: libstdc++.so has no NEEDED entry for libc.so!"
	exit 1
fi

ln -sf gcc "$dest"/bin/gcc-$VERSION
ln -sf g++ "$dest"/bin/g++-$VERSION


code:
[deps]
gmp
mpfr
mpc
zlib

[deps.host]
m4
zlib
libelf

[mirrors]
http://ftpmirror.gnu.org/gcc/gcc-4.7.4/gcc-4.7.4.tar.bz2

[vars]
filesize=82935453
sha512=dfcb737073191e628231031a3571ec77ee760a59377630f4a6e4fdfa66f9ddad39fde47e3f0f227eb43cdf90e0d34cde5abdc9ac892c1e111a911062a66c9189

[build]
VERSION=4.7.4
VERSION_REMOVE='s,4\.7\.4.*,,'
# check that libc.so is available, otherwise we'll get a libstdc++.so
# that is statically linked against musls libc.a.
# this will lead to random crashes in C++ apps since two concurrent
# malloc implementations will call brk and mess up each other.
if [ ! -f "$butch_prefix"/lib/libc.so ] ; then
	echo "libc.so non-existing or symlink broken"
	exit 1
fi

patch -p1 < "$K"/gcc473-unwind-dliterate.patch
patch -p1 < "$K"/gcc473-dliterate-configure-var.patch
patch -p1 < "$K"/gcc473-arm-hwcap.patch
patch -p1 < "$K"/gcc473-config-sub.patch
patch -p1 < "$K"/gcc473-powerpc-libc-stack-end.patch
patch -p1 < "$K"/gcc-474-universal-initializer-no-warning.patch
patch -p1 < "$K"/gcc474-libssp_nonshared.patch
patch -p1 < "$K"/gcc474-libgcc_fixver.patch
patch -p1 < "$K"/gcc4-boehm-gc.patch
patch -p1 < "$K"/gcc4-gcj-musl.patch
patch -p1 < "$K"/gcc4-gcj-iconv-musl.patch

# fix specs file generation. this prevents libgcc_s from being used.
# not only is it slower, it'll cause assertion errors in ld.
sed -i 's,-lgcc_s,--start-group -lgcc_eh -lgcc -lc --end-group,' gcc/gcc.c

# we're doing a bit of hack to place the g++ contents in this folder
# the build system isnt really laid out for extracting multiple tarballs into
# the same dir...

"$K"/libibertyfix libiberty

#more g++ hackery
#sed -i 's,# include <syscall.h>,#include <sys/syscall.h>,' ./libstdc++-v3/libsupc++/guard.cc

#todo check if this isnt to intrusive
sed -i 's,gcc_no_link=yes,gcc_no_link=no,' ./libstdc++-v3/configure

#and even more g++ hackery
mv ./libstdc\+\+-v3/config/os/gnu-linux ./libstdc\+\+-v3/config/os/gnu-linux.org
cp -r ./libstdc\+\+-v3/config/os/generic ./libstdc\+\+-v3/config/os/gnu-linux
cp ./libstdc++-v3/config/os/gnu-linux.org/arm-eabi-extra.ver ./libstdc++-v3/config/os/gnu-linux/
#g++ hackery done

mv ./libitm/config/linux/x86 ./libitm/config/linux/x86_glibc
cp -r ./libitm/config/generic ./libitm/config/linux/x86

sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in

sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux.h
sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux64.h
if [ "$A" = arm ] ; then
dlarch=arm
$CC -dM -E - < /dev/null | grep __ARMEB__ > /dev/null && dlarch=${dlarch}eb
$CC -dM -E - < /dev/null | grep __ARM_PCS_VFP > /dev/null && dlarch=${dlarch}hf
sed -i 's@/lib/ld-linux.so.3@/lib/ld-musl-'$dlarch'.so.1@' gcc/config/arm/linux-eabi.h
sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-'$dlarch'.so.1@' gcc/config/arm/linux-elf.h
elif [ "$A" = mips ] ; then
dlarch=mips
$CC -dM -E - < /dev/null | grep _MIPSEL > /dev/null && dlarch=${dlarch}el
$CC -dM -E - < /dev/null | grep __mips_soft_float > /dev/null && dlarch=${dlarch}-sf
sed -i 's@/lib/ld.so.1@/lib/ld-musl-'$dlarch'.so.1@' gcc/config/mips/linux.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-'$dlarch'.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib64/ld.so.1@/lib/ld-musl-'$dlarch'.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib32/ld.so.1@/lib/ld-musl-'$dlarch'.so.1@' gcc/config/mips/linux64.h
fi
sed -i 's@/lib64/ld-linux-x86-64.so.2@/lib/ld-musl-x86_64.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/sysv4.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/linux64.h
sed -i 's@/lib64/ld64.so.1@/lib/ld-musl-powerpc64.so.1@g' gcc/config/rs6000/linux64.h

patch -p1 < "$K"/gcc-453-patch0.patch

config_arch_flags=
config_arch_target_cflags=
config_arch_target_ldflags=
if [ "$A" = "arm" ] ; then
	patch -p1 < "$K"/gcc-453-patch1.patch
elif [ "$A" = "powerpc" ] ; then
	patch -p1 < "$K"/gcc-454-stackend.patch
	config_arch_flags="--enable-secureplt --with-long-double-64"
	config_arch_target_cflags="-Wl,--secure-plt"
	config_arch_target_ldflags="-Wl,--secure-plt"
fi

machine=
if [ -n "$CROSS_COMPILE" ] ; then
	if [ -z "$GCC_ARCH_CONFIG_FLAGS" ] ; then
		#autodetect arch specifics if not passed via config
		gccv=$($CC -v 2>&1|grep "^Configured with: ")
		for flag in --with-arch --with-float --with-fpu ; do
			for arg in $gccv ; do
				printf "%s" "$arg" | grep "^$flag=" >/dev/null \
				&& { GCC_ARCH_CONFIG_FLAGS="$arg $GCC_ARCH_CONFIG_FLAGS" ; break ; }
			done
		done
	fi
	machine=$($CC -dumpmachine)
	xconfflags="--host=$machine --target=$machine $GCC_ARCH_CONFIG_FLAGS"
	export GCC_FOR_TARGET="$CC"
fi

extralangs=
extrainst=
[ "$option_java" = 1 ] && extralangs=,java && extrainst=install-target-libjava \
&& cp -f "$C"/ecj-4.5.jar ./ecj.jar

export CC="$CC -static -D_GNU_SOURCE"

CFLAGS="-O0 -s" LDFLAGS="-Wl,--no-keep-memory" \
CFLAGS_FOR_TARGET="$config_arch_target_cflags" \
LDFLAGS_FOR_TARGET="$config_arch_target_ldflags" \
./configure -C --with-headers=no --prefix="$butch_prefix" \
  --disable-multilib \
  --with-multilib-list= \
  --disable-nls \
  --disable-mudflap \
  --disable-libmudflap \
  --enable-libssp \
  --disable-libgomp \
  --disable-debug \
  --disable-bootstrap \
  --disable-gnu-indirect-function \
  --enable-lto \
  --with-system-zlib \
  --with-target-libiberty=no --with-target-zlib=no \
  --enable-languages=c,c++$extralangs --enable-clocale=generic \
  $config_arch_flags $xconfflags

gcc_cv_libc_provides_ssp=yes \
make -j$MAKE_THREADS BOOT_LDFLAGS="-static" LDFLAGS="-static"
make -j1 DESTDIR="$butch_install_dir" \
  install-gcc \
  install-lto-plugin \
  install-target-libgcc \
  install-target-libssp \
  install-target-libstdc++-v3 $extrainst

dest=$butch_install_dir$butch_prefix

#create a host_tuple dummy entry, so binutils stuff will get into /bin, etc
[ -z $machine ] && machine=$($dest/bin/gcc -dumpmachine)

[ ! -e ${dest}/${machine} ] && 	( cd $dest ; ln -sf . ${machine} )

#remove gcc's stddef.h which is not compatible
rm $dest/lib/gcc/$machine/$VERSION/include/stddef.h

#remove gcc's libssp.* (we only need libssp_nonshared.a)
rm "$dest"/lib/libssp.*

copy() {
	printf "cp %s %s\n" "$1" "$2"
	cp "$1" "$2"
}

echo link gcc intrinsic headers into /include/gcc
# this allows usage of -I/include/gcc for stuff that uses them
mkdir -p  $dest/include/gcc
for i in $dest/lib/gcc/$machine/$VERSION/include/* ; do
  header=`basename "$i"`
  # do not copy headers that exist in musl
  [ -e "$dest/include/$header" ] || copy "$i" "$dest/include/gcc/" || true
done

ln -sf gcc "$dest"/bin/cc

# assert that libstdc++.so is not statically linked against musl
if ! readelf -a "$dest"/lib/libstdc++.so | grep NEEDED | grep libc.so > /dev/null ; then
	echo "error: libstdc++.so has no NEEDED entry for libc.so!"
	exit 1
fi

ln -sf gcc "$dest"/bin/gcc-$VERSION
ln -sf g++ "$dest"/bin/g++-$VERSION

rm "$butch_install_dir""$butch_prefix"/lib/*.la

if test "$option_java" = 1 ; then
	ln -sf gcj "$dest"/bin/gcj-$VERSION
	GCJ=$dest/bin/gcj
	[ -n "$CROSS_COMPILE" ] && GCJ=gcj
	$GCJ -Wl,-Bsymbolic -findirect-dispatch -o $dest/bin/javac \
	--main=org.eclipse.jdt.internal.compiler.batch.Main "$C"/ecj-4.5.jar \
	-lgcj || echo "WARNING: optimized javac not created" >&2
fi


code:
[deps]
gmp
mpfr
mpc
zlib

[deps.host]
m4
zlib
libelf

[mirrors]
http://ftpmirror.gnu.org/gcc/gcc-4.8.5/gcc-4.8.5.tar.bz2

[vars]
filesize=86165587
sha512=47fdfeca0c0a624cdec9c4ae47137d056c918d5c386d4b96985bb3c8172aba377cb66cbcc30e80832fd244a7d98f562c20198056915c70cfef0977545073a8ea

[build]
VERSION=4.8.5
VERSION_REMOVE='s,4\.8\.5.*,,'
# check that libc.so is available, otherwise we'll get a libstdc++.so
# that is statically linked against musls libc.a.
# this will lead to random crashes in C++ apps since two concurrent
# malloc implementations will call brk and mess up each other.
if [ ! -f "$butch_prefix"/lib/libc.so ] ; then
	echo "libc.so non-existing or symlink broken"
	exit 1
fi

patch -p1 < "$K"/gcc485-unwind-dliterate.patch
patch -p1 < "$K"/gcc473-dliterate-configure-var.patch
patch -p1 < "$K"/gcc473-arm-hwcap.patch
patch -p1 < "$K"/gcc485-universal-initializer-no-warning.patch
patch -p1 < "$K"/gcc474-libssp_nonshared.patch

# fix specs file generation. this prevents libgcc_s from being used.
# not only is it slower, it'll cause assertion errors in ld.
sed -i 's,-lgcc_s,--start-group -lgcc_eh -lgcc -lc --end-group,' gcc/gcc.c

# we're doing a bit of hack to place the g++ contents in this folder
# the build system isnt really laid out for extracting multiple tarballs into
# the same dir...

"$K"/libibertyfix libiberty

#more g++ hackery
#sed -i 's,# include <syscall.h>,#include <sys/syscall.h>,' ./libstdc++-v3/libsupc++/guard.cc

#todo check if this isnt to intrusive
sed -i 's,gcc_no_link=yes,gcc_no_link=no,' ./libstdc++-v3/configure

#and even more g++ hackery
mv ./libstdc\+\+-v3/config/os/gnu-linux ./libstdc\+\+-v3/config/os/gnu-linux.org
cp -r ./libstdc\+\+-v3/config/os/generic ./libstdc\+\+-v3/config/os/gnu-linux
cp ./libstdc++-v3/config/os/gnu-linux.org/arm-eabi-extra.ver ./libstdc++-v3/config/os/gnu-linux/
#g++ hackery done

mv ./libitm/config/linux/x86 ./libitm/config/linux/x86_glibc
cp -r ./libitm/config/generic ./libitm/config/linux/x86

sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in

sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux.h
sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux64.h
if [ "$A" = arm ] ; then
dlarch=arm
$CC -dM -E - < /dev/null | grep __ARMEB__ > /dev/null && dlarch=${dlarch}eb
$CC -dM -E - < /dev/null | grep __ARM_PCS_VFP > /dev/null && dlarch=${dlarch}hf
sed -i 's@/lib/ld-linux.so.3@/lib/ld-musl-'$dlarch'.so.1@' gcc/config/arm/linux-eabi.h
sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-'$dlarch'.so.1@' gcc/config/arm/linux-elf.h
elif [ "$A" = mips ] ; then
dlarch=mips
$CC -dM -E - < /dev/null | grep _MIPSEL > /dev/null && dlarch=${dlarch}el
$CC -dM -E - < /dev/null | grep __mips_soft_float > /dev/null && dlarch=${dlarch}-sf
sed -i 's@/lib/ld.so.1@/lib/ld-musl-'$dlarch'.so.1@' gcc/config/mips/linux.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-'$dlarch'.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib64/ld.so.1@/lib/ld-musl-'$dlarch'.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib32/ld.so.1@/lib/ld-musl-'$dlarch'.so.1@' gcc/config/mips/linux64.h
fi
sed -i 's@/lib64/ld-linux-x86-64.so.2@/lib/ld-musl-x86_64.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/sysv4.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/linux64.h
sed -i 's@/lib64/ld64.so.1@/lib/ld-musl-powerpc64.so.1@g' gcc/config/rs6000/linux64.h

patch -p1 < "$K"/gcc-453-patch0.patch

config_arch_flags=
config_arch_target_cflags=
config_arch_target_ldflags=
if [ "$A" = "arm" ] ; then
	patch -p1 < "$K"/gcc-453-patch1.patch
elif [ "$A" = "powerpc" ] ; then
	patch -p1 < "$K"/gcc-454-stackend.patch
	config_arch_flags="--enable-secureplt --with-long-double-64"
	config_arch_target_cflags="-Wl,--secure-plt"
	config_arch_target_ldflags="-Wl,--secure-plt"
fi

machine=
if [ -n "$CROSS_COMPILE" ] ; then
	if [ -z "$GCC_ARCH_CONFIG_FLAGS" ] ; then
		#autodetect arch specifics if not passed via config
		gccv=$($CC -v 2>&1|grep "^Configured with: ")
		for flag in --with-arch --with-float --with-fpu ; do
			for arg in $gccv ; do
				printf "%s" "$arg" | grep "^$flag=" >/dev/null \
				&& { GCC_ARCH_CONFIG_FLAGS="$arg $GCC_ARCH_CONFIG_FLAGS" ; break ; }
			done
		done
	fi
	machine=$($CC -dumpmachine)
	xconfflags="--host=$machine --target=$machine $GCC_ARCH_CONFIG_FLAGS"
	export GCC_FOR_TARGET="$CC"
fi
export CC="$CC -static -D_GNU_SOURCE"

CFLAGS="-O0 -s" LDFLAGS="-Wl,--no-keep-memory" \
CFLAGS_FOR_TARGET="$config_arch_target_cflags" \
LDFLAGS_FOR_TARGET="$config_arch_target_ldflags" \
./configure -C --with-headers=no --prefix="$butch_prefix" \
  --disable-multilib \
  --with-multilib-list= \
  --disable-nls \
  --disable-mudflap \
  --disable-libmudflap \
  --enable-libssp \
  --disable-libgomp \
  --disable-debug \
  --disable-bootstrap \
  --disable-libsanitizer \
  --disable-gnu-indirect-function \
  --enable-lto \
  --with-system-zlib \
  --with-target-libiberty=no --with-target-zlib=no \
  --enable-languages=c,c++ --enable-clocale=generic \
  $config_arch_flags $xconfflags

gcc_cv_libc_provides_ssp=yes \
make -j$MAKE_THREADS BOOT_LDFLAGS="-static" LDFLAGS="-static"
make -j1 DESTDIR="$butch_install_dir" \
  install-gcc \
  install-lto-plugin \
  install-target-libgcc \
  install-target-libssp \
  install-target-libstdc++-v3

dest=$butch_install_dir$butch_prefix

#create a host_tuple dummy entry, so binutils stuff will get into /bin, etc
[ -z $machine ] && machine=$($dest/bin/gcc -dumpmachine)

[ ! -e ${dest}/${machine} ] && 	( cd $dest ; ln -sf . ${machine} )

#remove gcc's stddef.h which is not compatible
rm $dest/lib/gcc/$machine/$VERSION/include/stddef.h

#remove gcc's libssp.* (we only need libssp_nonshared.a)
rm "$dest"/lib/libssp.*

copy() {
	printf "cp %s %s\n" "$1" "$2"
	cp "$1" "$2"
}

echo link gcc intrinsic headers into /include/gcc
# this allows usage of -I/include/gcc for stuff that uses them
mkdir -p  $dest/include/gcc
for i in $dest/lib/gcc/$machine/$VERSION/include/* ; do
  header=`basename "$i"`
  # do not copy headers that exist in musl
  [ -e "$dest/include/$header" ] || copy "$i" "$dest/include/gcc/" || true
done

ln -sf gcc "$dest"/bin/cc

# assert that libstdc++.so is not statically linked against musl
if ! readelf -a "$dest"/lib/libstdc++.so | grep NEEDED | grep libc.so > /dev/null ; then
	echo "error: libstdc++.so has no NEEDED entry for libc.so!"
	exit 1
fi

ln -sf gcc "$dest"/bin/gcc-$VERSION
ln -sf g++ "$dest"/bin/g++-$VERSION

rm "$butch_install_dir""$butch_prefix"/lib/*.la