summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorQue Quotion2018-08-30 10:42:56 +0900
committerQue Quotion2018-08-30 10:49:02 +0900
commit00b4663035f5a907c5170253ce762f6df4ee7975 (patch)
tree39dc35e8b4b179f79a45c8a871ececa20a9154a5
parent32fa78c289e0c3f0ae564a73f2045de2dadb4ae5 (diff)
downloadaur-00b4663035f5a907c5170253ce762f6df4ee7975.tar.gz
Migrate makepkg-optimize2 into makepkg-optimize; this is the best way to deal with my out-of-date troll and pacman-build_env-ext
-rw-r--r--.SRCINFO38
-rw-r--r--.gitignore5
-rw-r--r--00.optipng.patch17
-rw-r--r--01.upx.patch17
-rw-r--r--02.lto.patch20
-rw-r--r--03.pgo.patch49
-rw-r--r--04.graphite.patch14
-rw-r--r--05.svgo.patch16
-rw-r--r--PKGBUILD68
-rw-r--r--ccache.sh.in46
-rw-r--r--distcc.sh.in46
-rw-r--r--graphite.sh.in35
-rw-r--r--lto.sh.in40
-rw-r--r--opticonf.patch43
-rw-r--r--pgo.sh.in54
15 files changed, 265 insertions, 243 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 55bf18d5d0c..cabbafa40f6 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,25 +1,22 @@
-# Generated by mksrcinfo v8
-# Fri Apr 1 19:02:43 UTC 2016
pkgbase = makepkg-optimize
- pkgdesc = Additional package optimization routines for makepkg
- pkgver = 1
- pkgrel = 9
- url = https://projects.archlinux.org/pacman.git/
- arch = i686
- arch = x86_64
+ pkgdesc = Supplemental build and packaging optimizations for makepkg
+ pkgver = 2
+ pkgrel = 1
+ url = https://bbs.archlinux.org/viewtopic.php?id=210350
+ arch = any
license = GPL
- depends = pacman
+ depends = pacman-buildenv_ext-git
optdepends = upx
optdepends = optipng
optdepends = nodejs-svgo
optdepends = graphite
+ conflicts = makepkg-optimize
+ conflicts = makepkg-optimize2
+ replaces = makepkg-optimize2
backup = etc/makepkg-optimize.conf
- source = 00.optipng.patch
- source = 01.upx.patch
- source = 02.lto.patch
- source = 03.pgo.patch
- source = 04.graphite.patch
- source = 05.svgo.patch
+ source = pgo.sh.in
+ source = lto.sh.in
+ source = graphite.sh.in
source = upx.sh.in
source = optipng.sh.in
source = svgo.sh.in
@@ -27,14 +24,10 @@ pkgbase = makepkg-optimize
source = destdirs_ext.conf
source = pkgopts_ext.conf
source = pkgopts-param_ext.conf
- source = opticonf.patch
source = compress-param_max.conf
- sha512sums = 67fb9359cd5dc52413ad2ca7e91b445826d7cf6b7ad3db0d2b3845310ab0bdfc41c2e70cec564e26269521ac313f7202c44996a24266380e48e88927bd1012e2
- sha512sums = b4896082fd7fc4a69abc5fc98bf22c92a94cef9ccae5d3e5d1825cd3f04dcff1bce622a3f7fdc00bd43b5e1d091825d119b3a91d354f1ab58e6a8fe3af72b0e2
- sha512sums = bbd4bf3ddbda97008764c1a619aee4f2e3d3476c8affaac75ffee328db452f587454f16158942ec666e2357474a052019e5641ce6d432c43593b3612bdc40af2
- sha512sums = 0004f7d96366b47df5f4be1de9648038a4c9a400084d37dcd13d91ae805abb634051c88bb7bd35ff90f3e563508ce65686a321ed0c64cd63f5dc344d4022d9b8
- sha512sums = 3520817c16ea83a4bed28f153138608456267eac0caed250f8d951c54cf6a07d07e5b13768c5165a8e31a56e76919b3c9b84ad3b2905489ce65e625fa067f9b0
- sha512sums = c2f74ab15214ccac6ae570fa4a4ebfdf35690be60851be9eb8ab65c1ce4ebed0f0d3cb98947fd4a586d19cb399d312390ebbc68f4de86f607adef2a2d590798e
+ sha512sums = cc885a45311f60f3512d562ca6502ec7a38440383bae4df82c6cb34f5fe4ff8f7fe9c627bea0aadd32c34ea531ab4acc50a04271d1dc0b807a3e3f34b3f29289
+ sha512sums = 566681dfc0a84f6b3f654250bb0967bfe13563ad6dcae13d9cc6e30b359f34544c5f473e3b23973e0406e405c7047d866d6459bf999c0579ff43b36d1615bfe0
+ sha512sums = 4cda8968bf9e2a1cd7f20987183b91be8becec190c7a56a5d47fecb1da373077190af0c7be627338160c371d4b3c68cb12b76783e9118de29df30a285f9e5bd9
sha512sums = 0cbcc6590b901ac33dc78b755300da02070c5abb68153a55eb7b1bf5426dd37286f5831185c53eff189fc689796a234bad84fddc8e8f43edf6b19f13667291c7
sha512sums = c2b109f3f167f61fb0cbe3580a190189f0aac9b5886cf9aba447e2e074179cd1a506d54cbc0ae4df59ff3e3d537e8d3176786a805cfcba7f90525d135824fd6b
sha512sums = 917fd21b7dcb7ccb1d82bae4e31e65fd7610c4ca0b01db2ee1a379828240c59a6eeae176e1221b04421ace5ad89a871669def4730120741173e48b05c117aadb
@@ -42,7 +35,6 @@ pkgbase = makepkg-optimize
sha512sums = e3b61fa175c7c086b5e40413e280afa59efae64f6a29ec03f395b48d6a4ee7086603c9a8295a36cb0d091ef28bf3444d02e78b288db2225d29336aac23eda317
sha512sums = abe0b14869417dfe978beeb57b9527bc3c3651ddd5a88e9a5293438e3d1ebcde41a58f60bc0d0e68b6d8b4ede228904b520a3e10ac26c8572110a312a38e15b6
sha512sums = 16ad444485cdee165f00a2e1a24ff9f74fad43c8da959feaa196be1719e67e3153daac6661b116e2351a55091504056cb7bc785943092f9f9fdaa46bd5f0d3d9
- sha512sums = 16c2b0e666234f1a493e7456f4c387fbabd24b10514c93fa4338520e8f537e9a12de0d833a6148fe871452d87f6e1b3454b2bde332b9ba4c4e7680616b7eeede
sha512sums = bbc69d237a4be0b91d3e8197d40ddb3a587c4f4c4a1fb233d3249689543ad66d56b3aef02d886f6f7d9e5a52c64a45f2d44772156bb01a50ac8e769fdc30dbe7
pkgname = makepkg-optimize
diff --git a/.gitignore b/.gitignore
index 5db6d638144..72e8ffc0db8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1 @@
-*.pkg.tar.xz
-pkg/
-src/
-makepkg-optimize2/
+*
diff --git a/00.optipng.patch b/00.optipng.patch
deleted file mode 100644
index 0c02a0ce114..00000000000
--- a/00.optipng.patch
+++ /dev/null
@@ -1,17 +0,0 @@
---- makepkg-optimize
-+++ makepkg-optimize
-@@ -1556,6 +1556,14 @@
- fi
- fi
-
-+ # optipng - PNG image optimization
-+ if check_option "optipng" "y"; then
-+ if ! type -p optipng >/dev/null; then
-+ error "$(gettext "Cannot find the %s binary required for optimizing PNG images.")" "optipng"
-+ ret=1
-+ fi
-+ fi
-+
- # distcc - compilation with distcc
- if check_buildoption "distcc" "y"; then
- if ! type -p distcc >/dev/null; then
diff --git a/01.upx.patch b/01.upx.patch
deleted file mode 100644
index 1883b75fdbf..00000000000
--- a/01.upx.patch
+++ /dev/null
@@ -1,17 +0,0 @@
---- makepkg-optimize
-+++ makepkg-optimize
-@@ -1556,6 +1556,14 @@
- fi
- fi
-
-+ # upx - binary compression
-+ if check_option "upx" "y"; then
-+ if ! type -p upx >/dev/null; then
-+ error "$(gettext "Cannot find the %s binary required for compressing binaries.")" "upx"
-+ ret=1
-+ fi
-+ fi
-+
- # optipng - PNG image optimization
- if check_option "optipng" "y"; then
- if ! type -p optipng >/dev/null; then
diff --git a/02.lto.patch b/02.lto.patch
deleted file mode 100644
index 056cad498c1..00000000000
--- a/02.lto.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- makepkg-optimize
-+++ makepkg-optimize
-@@ -866,6 +866,17 @@ run_build() {
- export DISTCC_HOSTS
- fi
-
-+ # Use lto if it is requested (check buildenv and PKGBUILD opts)
-+ if check_buildoption "lto" "y" && [[ -f "$(gcc -print-search-dirs | grep install | awk '{print $2 "liblto_plugin.so"}')" ]]; then
-+ CFLAGS+=" -flto=$(getconf _NPROCESSORS_ONLN)"
-+ CXXFLAGS+=" -flto=$(getconf _NPROCESSORS_ONLN)"
-+ LDFLAGS+=" -fuse-linker-plugin"
-+ LTOPLUGIN="$(gcc -print-search-dirs | grep install | awk '{print $2 "liblto_plugin.so"}')"
-+ ARFLAGS+=" --plugin $LTOPLUGIN"
-+ RANLIBFLAGS+=" --plugin $LTOPLUGIN"
-+ NMFLAGS+=" --plugin $LTOPLUGIN"
-+ fi
-+
- run_function_safe "build"
- }
-
diff --git a/03.pgo.patch b/03.pgo.patch
deleted file mode 100644
index f81254b5f2d..00000000000
--- a/03.pgo.patch
+++ /dev/null
@@ -1,49 +0,0 @@
---- makepkg-optimize
-+++ makepkg-optimize
-@@ -877,6 +877,23 @@ run_build() {
- NMFLAGS+=" --plugin $LTOPLUGIN"
- fi
-
-+ # Generate or utilize pgo if it is requested (check buildenv and PKGBUILD opts)
-+ if check_buildoption "pgo" "y"; then
-+ if [ ! -d "$PROFDEST/$pkgbase.gen" ]; then
-+ mkdir "$PROFDEST/$pkgbase.gen"
-+ CFLAGS+=" -fprofile-generate -fprofile-dir=$PROFDEST/$pkgbase.gen"
-+ CXXFLAGS+=" -fprofile-generate -fprofile-dir=$PROFDEST/$pkgbase.gen"
-+ LDFLAGS+=" -lgcov"
-+ else
-+ [[ ! -d "$PROFDEST/$pkgbase.used" ]] && mv "$PROFDEST/$pkgbase.gen" "$PROFDEST/$pkgbase.used"
-+ #It is not necessary, and occasionally dangerous, to profile conftest.c
-+ [[ -f "$PROFDEST/$pkgbase.used/conftest.gcda" ]] && rm "$PROFDEST/$pkgbase.used/conftest.gcda"
-+ CFLAGS+=" -fprofile-correction -fprofile-use -fprofile-dir=$PROFDEST/$pkgbase.used"
-+ CXXFLAGS+=" -fprofile-correction -fprofile-use -fprofile-dir=$PROFDEST/$pkgbase.used"
-+ fi
-+ fi
-+
-+
- run_function_safe "build"
- }
-
-@@ -2012,6 +2027,7 @@ trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' E
- # preserve environment variables and canonicalize path
- [[ -n ${PKGDEST} ]] && _PKGDEST=$(canonicalize_path ${PKGDEST})
- [[ -n ${SRCDEST} ]] && _SRCDEST=$(canonicalize_path ${SRCDEST})
-+[[ -n ${PROFDEST} ]] && _PROFDEST=$(canonicalize_path ${PROFDEST})
- [[ -n ${SRCPKGDEST} ]] && _SRCPKGDEST=$(canonicalize_path ${SRCPKGDEST})
- [[ -n ${LOGDEST} ]] && _LOGDEST=$(canonicalize_path ${LOGDEST})
- [[ -n ${BUILDDIR} ]] && _BUILDDIR=$(canonicalize_path ${BUILDDIR})
-@@ -2109,6 +2125,14 @@ if (( SOURCEONLY )); then
- IGNOREARCH=1
- fi
-
-+PROFDEST=${_PROFDEST:-$PROFDEST}
-+PROFDEST=${PROFDEST:-$startdir} #default to $startdir if undefined
-+if [[ ! -w $PROFDEST ]] ; then
-+ error "$(gettext "You do not have write permission to store profiles in %s.")" "$PROFDEST"
-+ plain "$(gettext "Aborting...")"
-+ exit 1
-+fi
-+
- LOGDEST=${_LOGDEST:-$LOGDEST}
- LOGDEST=${LOGDEST:-$startdir} #default to $startdir if undefined
- if (( LOGGING )) && [[ ! -w $LOGDEST ]]; then
diff --git a/04.graphite.patch b/04.graphite.patch
deleted file mode 100644
index ddb5a13eba2..00000000000
--- a/04.graphite.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- makepkg-optimize
-+++ makepkg-optimize
-@@ -891,6 +891,11 @@
- fi
- fi
-
-+ # Utilize graphite if it is requested (check buildenv and PKGBUILD opts)
-+ if check_buildoption "graphite" "y"; then
-+ CFLAGS+=" -fgraphite-identity -floop-nest-optimize -ftree-loop-distribution -ftree-vectorize"
-+ CXXFLAGS+=" -fgraphite-identity -floop-nest-optimize -ftree-loop-distribution -ftree-vectorize"
-+ fi
-
- run_function_safe "build"
- }
diff --git a/05.svgo.patch b/05.svgo.patch
deleted file mode 100644
index f3330f981cf..00000000000
--- a/05.svgo.patch
+++ /dev/null
@@ -1,16 +0,0 @@
---- makepkg-optimize 2016-03-21 08:09:30.386922025 +0900
-+++ makepkg-optimize+svgo 2016-03-21 15:18:36.410371191 +0900
-@@ -1603,6 +1603,13 @@
- fi
- fi
-
-+ # svgo - svg image optimization
-+ if check_option "svgo" "y"; then
-+ if ! type -p svgo >/dev/null; then
-+ error "$(gettext "Cannot find the %s binary required for optimizing SVG images.")" "svgo"
-+ ret=1
-+ fi
-+ fi
- # distcc - compilation with distcc
- if check_buildoption "distcc" "y"; then
- if ! type -p distcc >/dev/null; then
diff --git a/PKGBUILD b/PKGBUILD
index e67e279d6a1..e0f291eaba5 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,25 +1,28 @@
-# Maintainer: Que Quotion ( quequotion at g mail dot com )
+# Maintainer: Que Quotion ( quequotion@bugmenot.com )
+# Contributor: bartus ( aur\at\bartus.33mail.com )
pkgname=makepkg-optimize
-pkgver=1
-pkgrel=9
-pkgdesc='Additional package optimization routines for makepkg'
-arch=('i686' 'x86_64')
+pkgver=2
+pkgrel=1
+pkgdesc='Supplemental build and packaging optimizations for makepkg'
+arch=('any')
license=('GPL')
-url='https://projects.archlinux.org/pacman.git/'
-depends=('pacman')
+url='https://bbs.archlinux.org/viewtopic.php?id=210350'
+conflicts=(makepkg-optimize{,2})
+replaces=('makepkg-optimize2')
+depends=('pacman-buildenv_ext-git')
optdepends=('upx' 'optipng' 'nodejs-svgo' 'graphite')
backup=(etc/makepkg-optimize.conf)
-source=({00.optipng,01.upx,02.lto,03.pgo,04.graphite,05.svgo}.patch
- {upx,optipng,svgo}.sh.in
- {buildenv,destdirs,pkgopts{,-param}}_ext.conf
- 'opticonf.patch' 'compress-param_max.conf')
-sha512sums=('67fb9359cd5dc52413ad2ca7e91b445826d7cf6b7ad3db0d2b3845310ab0bdfc41c2e70cec564e26269521ac313f7202c44996a24266380e48e88927bd1012e2'
- 'b4896082fd7fc4a69abc5fc98bf22c92a94cef9ccae5d3e5d1825cd3f04dcff1bce622a3f7fdc00bd43b5e1d091825d119b3a91d354f1ab58e6a8fe3af72b0e2'
- 'bbd4bf3ddbda97008764c1a619aee4f2e3d3476c8affaac75ffee328db452f587454f16158942ec666e2357474a052019e5641ce6d432c43593b3612bdc40af2'
- '0004f7d96366b47df5f4be1de9648038a4c9a400084d37dcd13d91ae805abb634051c88bb7bd35ff90f3e563508ce65686a321ed0c64cd63f5dc344d4022d9b8'
- '3520817c16ea83a4bed28f153138608456267eac0caed250f8d951c54cf6a07d07e5b13768c5165a8e31a56e76919b3c9b84ad3b2905489ce65e625fa067f9b0'
- 'c2f74ab15214ccac6ae570fa4a4ebfdf35690be60851be9eb8ab65c1ce4ebed0f0d3cb98947fd4a586d19cb399d312390ebbc68f4de86f607adef2a2d590798e'
+_buildenv_ext=({pgo,lto,graphite}.sh.in)
+_tidy=({upx,optipng,svgo}.sh.in)
+_conf=({buildenv,destdirs,pkgopts{,-param}}_ext.conf 'compress-param_max.conf')
+source=(${_buildenv_ext[@]}
+ ${_tidy[@]}
+ ${_conf[@]}
+ )
+sha512sums=('cc885a45311f60f3512d562ca6502ec7a38440383bae4df82c6cb34f5fe4ff8f7fe9c627bea0aadd32c34ea531ab4acc50a04271d1dc0b807a3e3f34b3f29289'
+ '566681dfc0a84f6b3f654250bb0967bfe13563ad6dcae13d9cc6e30b359f34544c5f473e3b23973e0406e405c7047d866d6459bf999c0579ff43b36d1615bfe0'
+ '4cda8968bf9e2a1cd7f20987183b91be8becec190c7a56a5d47fecb1da373077190af0c7be627338160c371d4b3c68cb12b76783e9118de29df30a285f9e5bd9'
'0cbcc6590b901ac33dc78b755300da02070c5abb68153a55eb7b1bf5426dd37286f5831185c53eff189fc689796a234bad84fddc8e8f43edf6b19f13667291c7'
'c2b109f3f167f61fb0cbe3580a190189f0aac9b5886cf9aba447e2e074179cd1a506d54cbc0ae4df59ff3e3d537e8d3176786a805cfcba7f90525d135824fd6b'
'917fd21b7dcb7ccb1d82bae4e31e65fd7610c4ca0b01db2ee1a379828240c59a6eeae176e1221b04421ace5ad89a871669def4730120741173e48b05c117aadb'
@@ -27,16 +30,15 @@ sha512sums=('67fb9359cd5dc52413ad2ca7e91b445826d7cf6b7ad3db0d2b3845310ab0bdfc41c
'e3b61fa175c7c086b5e40413e280afa59efae64f6a29ec03f395b48d6a4ee7086603c9a8295a36cb0d091ef28bf3444d02e78b288db2225d29336aac23eda317'
'abe0b14869417dfe978beeb57b9527bc3c3651ddd5a88e9a5293438e3d1ebcde41a58f60bc0d0e68b6d8b4ede228904b520a3e10ac26c8572110a312a38e15b6'
'16ad444485cdee165f00a2e1a24ff9f74fad43c8da959feaa196be1719e67e3153daac6661b116e2351a55091504056cb7bc785943092f9f9fdaa46bd5f0d3d9'
- '16c2b0e666234f1a493e7456f4c387fbabd24b10514c93fa4338520e8f537e9a12de0d833a6148fe871452d87f6e1b3454b2bde332b9ba4c4e7680616b7eeede'
'bbc69d237a4be0b91d3e8197d40ddb3a587c4f4c4a1fb233d3249689543ad66d56b3aef02d886f6f7d9e5a52c64a45f2d44772156bb01a50ac8e769fdc30dbe7')
prepare() {
- # Use the user's currently installed versions as a base
- cp /usr/bin/makepkg ./makepkg-optimize
+ # Use the current makepkg config as a base
cp /etc/makepkg.conf ./makepkg-optimize.conf
# How to check for the unlikely possiblity that the directory was changed?
- sed -i "s|@libmakepkgdir@|/usr/share/makepkg|g" *.sh.in
+ sed -i "s|@libmakepkgdir@|/usr/share/makepkg|g" *.sh.in
+ for file in *.sh.in; do mv $file ${file%.in}; done
#Comment on additional BUIDENV options
sed -i "/#-- sign/r buildenv_ext.conf" makepkg-optimize.conf
@@ -52,29 +54,15 @@ prepare() {
#Comment on maximum COMPRESS~~ parameters
sed -i "/COMPRESSZ=/r compress-param_max.conf" makepkg-optimize.conf
-
- # Add features in series
- patch -Np0 < ../opticonf.patch
- patch -Np0 < ../00.optipng.patch
- patch -Np0 < ../01.upx.patch
- patch -Np0 < ../02.lto.patch
- patch -Np0 < ../03.pgo.patch
- patch -Np0 < ../04.graphite.patch
- patch -Np0 < ../05.svgo.patch
}
package() {
- #makepkg-optimize
- mkdir -p $pkgdir/usr/{bin,share/makepkg/tidy}/
- install -m755 makepkg-optimize $pkgdir/usr/bin/
+ # BUILDENV extension scripts
+ install -m755 -D -t ${pkgdir}/usr/share/makepkg/buildenv_ext/ ${_buildenv_ext[@]%.in}
- # Tidy scripts
- #Uncomment once dropped from pacman.
- #install -m755 ../optipng.sh.in $pkgdir/usr/share/makepkg/tidy/optipng.sh
- #install -m755 ../upx.sh.in $pkgdir/usr/share/makepkg/tidy/upx.sh
- install -m755 ../svgo.sh.in $pkgdir/usr/share/makepkg/tidy/svgo.sh
+ # Supplemental Tidy scripts
+ install -m755 -D -t ${pkgdir}/usr/share/makepkg/tidy/ ${_tidy[@]%.in}
# Separate config file
- mkdir -p $pkgdir/etc/
- install -m644 makepkg-optimize.conf $pkgdir/etc/
+ install -m644 -D -t ${pkgdir}/etc/ makepkg-optimize.conf
}
diff --git a/ccache.sh.in b/ccache.sh.in
new file mode 100644
index 00000000000..8d9e0b5e0db
--- /dev/null
+++ b/ccache.sh.in
@@ -0,0 +1,46 @@
+#!/usr/bin/bash
+#
+# ccache.sh - Cache compiliations and recycle them to save time on repititions
+#
+# Copyright (c) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_CCACHE_SH" ]] && return
+LIBMAKEPKG_CCACHE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+build_options+=('ccache')
+
+local ccache=0
+
+ccache() {
+
+ # use ccache if it is requested (check buildenv and PKGBUILD opts)
+ if check_buildoption "ccache" "y"; then
+ if ! type -p ccache >/dev/null; then
+ error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache"
+ return 1
+ fi
+ if [ -d /usr/lib/ccache/bin ]; then
+ export PATH="/usr/lib/ccache/bin:$PATH"
+ ccache=1
+ fi
+ fi
+}
diff --git a/distcc.sh.in b/distcc.sh.in
new file mode 100644
index 00000000000..248445ab9e2
--- /dev/null
+++ b/distcc.sh.in
@@ -0,0 +1,46 @@
+#!/usr/bin/bash
+#
+# distcc.sh - Distribute compliation to reduce compilation time
+#
+# Copyright (c) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_CCACHE_SH" ]] && return
+LIBMAKEPKG_CCACHE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+build_options+=('distcc')
+extra_buildopts+=('distcc')
+
+distcc() {
+ if check_buildoption "distcc" "y"; then
+ if ! type -p distcc >/dev/null; then
+ error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc"
+ return 1
+ fi
+ if (( ccache )); then
+ export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc"
+ export CCACHE_BASEDIR="$srcdir"
+ elif [[ -d /usr/lib/distcc/bin ]]; then
+ export PATH="/usr/lib/distcc/bin:$PATH"
+ fi
+ export DISTCC_HOSTS
+ fi
+}
diff --git a/graphite.sh.in b/graphite.sh.in
new file mode 100644
index 00000000000..a1e39ed6d25
--- /dev/null
+++ b/graphite.sh.in
@@ -0,0 +1,35 @@
+#!/usr/bin/bash
+#
+# graphite.sh - Compile with Graphite polyhedral modeling optimization
+#
+# Copyright (c) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_GRAPHITE_SH" ]] && return
+LIBMAKEPKG_GRAPHITE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/option.sh"
+
+extra_buildopts+=('graphite')
+
+graphite() {
+ if check_buildoption "graphite" "y"; then
+ CFLAGS+=" -fgraphite-identity -floop-nest-optimize -ftree-loop-distribution -ftree-vectorize"
+ CXXFLAGS+=" -fgraphite-identity -floop-nest-optimize -ftree-loop-distribution -ftree-vectorize"
+ fi
+}
diff --git a/lto.sh.in b/lto.sh.in
new file mode 100644
index 00000000000..de7373149fd
--- /dev/null
+++ b/lto.sh.in
@@ -0,0 +1,40 @@
+#!/usr/bin/bash
+#
+# lto.sh - Compile with link-time optimization
+#
+# Copyright (c) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_LTO_SH" ]] && return
+LIBMAKEPKG_LTO_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/option.sh"
+
+extra_buildopts+=('lto')
+
+lto() {
+ if check_buildoption "lto" "y" && [[ -f "$(gcc -print-search-dirs | grep install | awk '{print $2 "liblto_plugin.so"}')" ]]; then
+ CFLAGS+=" -flto=$(getconf _NPROCESSORS_ONLN)"
+ CXXFLAGS+=" -flto=$(getconf _NPROCESSORS_ONLN)"
+ LDFLAGS+=" -fuse-linker-plugin"
+ LTOPLUGIN="$(gcc -print-search-dirs | grep install | awk '{print $2 "liblto_plugin.so"}')"
+ ARFLAGS+=" --plugin $LTOPLUGIN"
+ RANLIBFLAGS+=" --plugin $LTOPLUGIN"
+ NMFLAGS+=" --plugin $LTOPLUGIN"
+ fi
+}
diff --git a/opticonf.patch b/opticonf.patch
deleted file mode 100644
index a768fa64d81..00000000000
--- a/opticonf.patch
+++ /dev/null
@@ -1,43 +0,0 @@
---- makepkg-optimize
-+++ makepkg-optimize
-@@ -1862,7 +1862,7 @@
- printf -- "$(gettext " -V, --version Show version information and exit")\n"
- printf -- "$(gettext " --allsource Generate a source-only tarball including downloaded sources")\n"
- printf -- "$(gettext " --check Run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
-- printf -- "$(gettext " --config <file> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf"
-+ printf -- "$(gettext " --config <file> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg-optimize.conf"
- printf -- "$(gettext " --holdver Do not update VCS sources")\n"
- printf -- "$(gettext " --key <key> Specify a key to use for %s signing instead of the default")\n" "gpg"
- printf -- "$(gettext " --noarchive Do not create package archive")\n"
-@@ -2010,8 +2010,8 @@
- [[ -n ${PACKAGER} ]] && _PACKAGER=${PACKAGER}
- [[ -n ${CARCH} ]] && _CARCH=${CARCH}
-
--# default config is makepkg.conf
--MAKEPKG_CONF=${MAKEPKG_CONF:-$confdir/makepkg.conf}
-+# default config is makepkg-optimize.conf
-+MAKEPKG_CONF=${MAKEPKG_CONF:-$confdir/makepkg-optimize.conf}
-
- # Source the config file; fail if it is not found
- if [[ -r $MAKEPKG_CONF ]]; then
-@@ -2022,14 +2022,14 @@
- exit 1 # $E_CONFIG_ERROR
- fi
-
--# Source user-specific makepkg.conf overrides, but only if no override config
-+# Source user-specific makepkg-optimize.conf overrides, but only if no override config
- # file was specified
- XDG_PACMAN_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/pacman"
--if [[ "$MAKEPKG_CONF" = "$confdir/makepkg.conf" ]]; then
-- if [[ -r "$XDG_PACMAN_DIR/makepkg.conf" ]]; then
-- source_safe "$XDG_PACMAN_DIR/makepkg.conf"
-- elif [[ -r "$HOME/.makepkg.conf" ]]; then
-- source_safe "$HOME/.makepkg.conf"
-+if [[ "$MAKEPKG_CONF" = "$confdir/makepkg-optimize.conf" ]]; then
-+ if [[ -r "$XDG_PACMAN_DIR/makepkg-optimize.conf" ]]; then
-+ source_safe "$XDG_PACMAN_DIR/makepkg-optimize.conf"
-+ elif [[ -r "$HOME/.makepkg-optimize.conf" ]]; then
-+ source_safe "$HOME/.makepkg-optimize.conf"
- fi
- fi
-
diff --git a/pgo.sh.in b/pgo.sh.in
new file mode 100644
index 00000000000..496043b295a
--- /dev/null
+++ b/pgo.sh.in
@@ -0,0 +1,54 @@
+#!/usr/bin/bash
+#
+# pgo.sh - Compile with, or utilize profile guided optimization
+#
+# Copyright (c) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_PGO_SH" ]] && return
+LIBMAKEPKG_PGO_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+extra_buildopts+=('pgo')
+
+[[ -n ${PROFDEST} ]] && _PROFDEST=$(canonicalize_path ${PROFDEST})
+PROFDEST=${_PROFDEST:-$PROFDEST}
+PROFDEST=${PROFDEST:-$startdir} #default to $startdir if undefined
+if [[ ! -w $PROFDEST ]] ; then
+ error "$(gettext "You do not have write permission to store profiles in %s.")" "$PROFDEST"
+ plain "$(gettext "Aborting...")"
+ exit 1
+fi
+
+pgo() {
+ [[ "$INFAKEROOT" == 1 ]] && return
+ if check_buildoption "pgo" "y"; then
+ if [ ! -d "$PROFDEST/$pkgbase.gen" ]; then
+ mkdir "$PROFDEST/$pkgbase.gen"
+ CFLAGS+=" -fprofile-generate -fprofile-dir=$PROFDEST/$pkgbase.gen"
+ CXXFLAGS+=" -fprofile-generate -fprofile-dir=$PROFDEST/$pkgbase.gen"
+ LDFLAGS+=" -lgcov"
+ else
+ [[ ! -d "$PROFDEST/$pkgbase.used" ]] && mv "$PROFDEST/$pkgbase.gen" "$PROFDEST/$pkgbase.used"
+ CFLAGS+=" -fprofile-correction -fprofile-use -fprofile-dir=$PROFDEST/$pkgbase.used"
+ CXXFLAGS+=" -fprofile-correction -fprofile-use -fprofile-dir=$PROFDEST/$pkgbase.used"
+ fi
+ fi
+}