aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. Jung2021-12-31 21:47:26 +0000
committerP. Jung2021-12-31 21:47:26 +0000
commit6bff40dc642d9408d6f1ec36eef269f02384b521 (patch)
treee4824d30bfdc005252c20962057264c4a3fd37bf
downloadaur-6bff40dc642d9408d6f1ec36eef269f02384b521.tar.gz
added mold, fixed some flags
-rw-r--r--.SRCINFO60
-rw-r--r--PKGBUILD105
-rw-r--r--ZZ-lto.sh.in34
-rw-r--r--buildenv_ext.conf6
-rw-r--r--cflags.conf2
-rw-r--r--cmake-flags.conf4
-rw-r--r--compress-param_max.conf9
-rw-r--r--cxxflags.conf1
-rw-r--r--debug-makeflags.conf3
-rw-r--r--destdirs_ext.conf2
-rw-r--r--graphite.sh.in25
-rw-r--r--ldflags.conf2
-rw-r--r--makeflags.conf1
-rw-r--r--mold.sh.in23
-rw-r--r--optipng-exec.sh.in22
-rw-r--r--optipng.sh.in30
-rw-r--r--pgo.sh.in48
-rw-r--r--pkgopts-param_ext.conf6
-rw-r--r--pkgopts_ext.conf3
-rw-r--r--rice.sh.in27
-rw-r--r--svgo-exec.sh.in22
-rw-r--r--svgo.sh.in30
-rw-r--r--upx-exec.sh.in22
-rw-r--r--upx.sh.in38
24 files changed, 525 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..3ca836165a32
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,60 @@
+pkgbase = makepkg-optimize
+ pkgdesc = Supplemental build and packaging optimizations for makepkg
+ pkgver = 19
+ pkgrel = 1
+ url = https://wiki.archlinux.org/index.php/Makepkg-optimize
+ arch = any
+ license = GPL
+ depends = pacman
+ optdepends = upx: Compress executables
+ optdepends = optipng: Optimize PNG files
+ optdepends = svgo: Optimize SVG files
+ optdepends = openmp: Parallelize loops
+ optdepends = mold: a modern fast linker
+ backup = etc/makepkg-optimize.conf
+ source = pgo.sh.in
+ source = ZZ-lto.sh.in
+ source = graphite.sh.in
+ source = rice.sh.in
+ source = mold.sh.in
+ source = upx-exec.sh.in
+ source = optipng-exec.sh.in
+ source = svgo-exec.sh.in
+ source = upx.sh.in
+ source = optipng.sh.in
+ source = svgo.sh.in
+ source = cflags.conf
+ source = cxxflags.conf
+ source = makeflags.conf
+ source = ldflags.conf
+ source = debug-makeflags.conf
+ source = cmake-flags.conf
+ source = buildenv_ext.conf
+ source = destdirs_ext.conf
+ source = pkgopts_ext.conf
+ source = pkgopts-param_ext.conf
+ source = compress-param_max.conf
+ sha1sums = 4c5f0be71638a6ec2f18c01675d99f19eb6dd45d
+ sha1sums = 8a29f5b36fd191f5ca061625f006dfe822148281
+ sha1sums = d7a3801037333c582dba976db27cf8896bc1b401
+ sha1sums = 3a356f52131e39f59d360c54a572d678c7208b42
+ sha1sums = 9ea51e4cade43db60a43ebc7f41bdb19f881c94b
+ sha1sums = a893c32f2a3fff8b279025ec60f0c3d88143dc1e
+ sha1sums = 9270b5e33d4508a959688a10c20dec3732763937
+ sha1sums = 34a33b47a8b667f9dc810737c0f598660b962d4c
+ sha1sums = 4def44ef53ba3b579bed40af897d6f0c038ec78d
+ sha1sums = 2efb74a7743764205d20e0dd74fb5f948673f825
+ sha1sums = 0dbba257ec59dc55583a74da0319d6c210cf717a
+ sha1sums = 1a4f26170da04998f9cba088a63a95fd75c1113e
+ sha1sums = 386cb4a2c52247bdd1b4a2cd2f804fa8bc8b0b4e
+ sha1sums = 9cb1a46ca7c3c6fab8a44ca5355528e9eb9e0650
+ sha1sums = f17b1a8ccbd807fd59fbc716cc695be32e261e38
+ sha1sums = 3c61762a183a2f76cc2ff2e55cfffb68b6a8320c
+ sha1sums = 981eab856abb43c5e093620cdf4d8bfa2d690805
+ sha1sums = 02b26a3abf1102fb9d1c746575b570265b10f11d
+ sha1sums = efb3ed7d7d5516259709149d7bcd6ec208c07593
+ sha1sums = 1fc8035e64b739e20c70fbb4eaa5cb7aa1c63c90
+ sha1sums = 5d0cde13b50641371e4ec4d813d6b2dfae493889
+ sha1sums = 67801619b39ea4542829a4b715034a9f7ac7cf2c
+
+pkgname = makepkg-optimize
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..930fdd1644ca
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,105 @@
+# Maintainer: ptr1337 (ptr1337@cachyos.org)
+# Contributor: Que Quotion ( quequotion@bugmenot.com )
+# Contributor: bartus ( aur\at\bartus.33mail.com )
+
+pkgname=makepkg-optimize
+pkgver=19
+pkgrel=1
+pkgdesc='Supplemental build and packaging optimizations for makepkg'
+arch=('any')
+license=('GPL')
+url='https://wiki.archlinux.org/index.php/Makepkg-optimize'
+depends=('pacman')
+optdepends=("upx: Compress executables"
+ "optipng: Optimize PNG files"
+ "svgo: Optimize SVG files"
+ "openmp: Parallelize loops"
+ "mold: a modern fast linker")
+backup=(etc/makepkg-optimize.conf)
+_buildenv=({pgo,ZZ-lto,graphite,rice,mold}.sh.in)
+_executable=({upx,optipng,svgo}-exec.sh.in)
+_tidy=({upx,optipng,svgo}.sh.in)
+_conf=({{c,cxx,make,ld,debug-make,cmake-}flags,{buildenv,destdirs,pkgopts{,-param}}_ext,compress-param_max}.conf)
+source=(${_buildenv[@]}
+ ${_executable[@]}
+ ${_tidy[@]}
+ ${_conf[@]})
+sha1sums=('4c5f0be71638a6ec2f18c01675d99f19eb6dd45d'
+ '8a29f5b36fd191f5ca061625f006dfe822148281'
+ 'd7a3801037333c582dba976db27cf8896bc1b401'
+ '3a356f52131e39f59d360c54a572d678c7208b42'
+ '9ea51e4cade43db60a43ebc7f41bdb19f881c94b'
+ 'a893c32f2a3fff8b279025ec60f0c3d88143dc1e'
+ '9270b5e33d4508a959688a10c20dec3732763937'
+ '34a33b47a8b667f9dc810737c0f598660b962d4c'
+ '4def44ef53ba3b579bed40af897d6f0c038ec78d'
+ '2efb74a7743764205d20e0dd74fb5f948673f825'
+ '0dbba257ec59dc55583a74da0319d6c210cf717a'
+ '1a4f26170da04998f9cba088a63a95fd75c1113e'
+ '386cb4a2c52247bdd1b4a2cd2f804fa8bc8b0b4e'
+ '9cb1a46ca7c3c6fab8a44ca5355528e9eb9e0650'
+ 'f17b1a8ccbd807fd59fbc716cc695be32e261e38'
+ '3c61762a183a2f76cc2ff2e55cfffb68b6a8320c'
+ '981eab856abb43c5e093620cdf4d8bfa2d690805'
+ '02b26a3abf1102fb9d1c746575b570265b10f11d'
+ 'efb3ed7d7d5516259709149d7bcd6ec208c07593'
+ '1fc8035e64b739e20c70fbb4eaa5cb7aa1c63c90'
+ '5d0cde13b50641371e4ec4d813d6b2dfae493889'
+ '67801619b39ea4542829a4b715034a9f7ac7cf2c')
+
+prepare() {
+ # 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
+ for file in *.sh.in; do mv $file ${file%.in}; done
+
+ #Extra ricer and debugging CFLAGS
+ sed -i "/^CFLAGS/r cflags.conf" makepkg-optimize.conf
+
+ #Mirror CFLAGS into CXXFLAGS
+ sed -i "/^CXXFLAGS/r cxxflags.conf" makepkg-optimize.conf
+
+ #Extra ricer Makeflags
+ sed -i "/^MAKEFLAGS/r makeflags.conf" makepkg-optimize.conf
+
+ #Extra ricer LDFLAGS
+ sed -i "/^LDFLAGS/r ldflags.conf" makepkg-optimize.conf
+
+ #Debugging flags for make (note, DEBUG_MAKEFLAGS isn't a real thing)
+ sed -i "/^DEBUG_CXXFLAGS/r debug-makeflags.conf" makepkg-optimize.conf
+
+ #Cmake is a build obfuscation system
+ sed -i "/^#DEBUG_MAKEFLAGS/r cmake-flags.conf" makepkg-optimize.conf
+
+ #Additional BUIDENV macros
+ sed -i "/^#-- sign/r buildenv_ext.conf" makepkg-optimize.conf
+
+ #Additional DEST directories
+ sed -i "/^#*SRCPKGDEST=/r destdirs_ext.conf" makepkg-optimize.conf
+
+ #Additional OPTIONS macros
+ sed -i "/^#-- debug/r pkgopts_ext.conf" makepkg-optimize.conf
+
+ #Additional OPTIONS parameters
+ sed -i "/^#*PURGE_TARGETS=/r pkgopts-param_ext.conf" makepkg-optimize.conf
+
+ #Maximum COMPRESS parameters
+ sed -i "/^COMPRESSLZ=/r compress-param_max.conf" makepkg-optimize.conf
+}
+
+package() {
+ # BUILDENV extension scripts
+ install -m644 -D -t ${pkgdir}/usr/share/makepkg/buildenv/ ${_buildenv[@]%.in}
+
+ # Executable finding scripts
+ for i in ${_executable[@]%.in}; do
+ install -m644 -D -T ${i} ${pkgdir}/usr/share/makepkg/executable/${i//-exec.sh/.sh}; done
+
+ # Supplemental Tidy scripts
+ install -m644 -D -t ${pkgdir}/usr/share/makepkg/tidy/ ${_tidy[@]%.in}
+
+ # Separate config file
+ install -m644 -D -t ${pkgdir}/etc/ makepkg-optimize.conf
+}
diff --git a/ZZ-lto.sh.in b/ZZ-lto.sh.in
new file mode 100644
index 000000000000..6d0972cd9d39
--- /dev/null
+++ b/ZZ-lto.sh.in
@@ -0,0 +1,34 @@
+#!/usr/bin/bash
+#
+# ZZ-lto.sh - Compile with link-time optimization
+#
+
+[[ -n "$LIBMAKEPKG_BUILDENV_LTO_SH" ]] && return
+LIBMAKEPKG_BUILDENV_LTO_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/option.sh"
+
+build_options+=('lto' 'lto-thin' 'lto-clang' 'lto-thin-clang')
+buildenv_functions+=('buildenv_lto')
+
+buildenv_lto() {
+ if check_buildoption "lto" "y" || check_buildoption "lto-thin" "y" || \
+ check_buildoption "lto-clang" "y" || check_buildoption "lto-thin-clang" "y"; then
+ ltoflags=" -flto"
+ check_buildoption "lto-thin-clang" "y" && ltoflags+="=thin"
+ check_buildoption "lto-thin" "y" || check_buildoption "lto" "y" && \
+ [[ -f "$(gcc -print-search-dirs | grep install | awk '{print $2 "liblto_plugin.so"}')" ]] && \
+ ltoflags+="=auto -fno-fat-lto-objects"
+ check_buildoption "lto" "y" && ltoflags+=" -flto-partition=none"
+
+ CFLAGS+="$ltoflags"
+ CXXFLAGS+="$ltoflags"
+ LDFLAGS+=" -fuse-linker-plugin $CFLAGS $CXXFLAGS"
+ 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/buildenv_ext.conf b/buildenv_ext.conf
new file mode 100644
index 000000000000..e034fa916c3b
--- /dev/null
+++ b/buildenv_ext.conf
@@ -0,0 +1,6 @@
+#-- lto{,-clang}: Use monolithic link-time optimization (use "lto-clang" for clang/llvm)
+#-- lto-thin{,-clang}: Use partitioned link-time optimization (use "lto-thin-clang" for clang/llvm)
+#-- pgo: Generate or utilize profile guided optimization (requires two build and install cycles)
+#-- {graphite,polly}: Use polyhedral model optimization (use "polly" for clang/llvm)
+#-- rice{,-clang}: Use extreme and unsafe optimization (use "rice-clang" for clang/llvm)
+#-- mold: Use the fast mold linker (does not work with lto, and for gcc versions under 12)
diff --git a/cflags.conf b/cflags.conf
new file mode 100644
index 000000000000..433801db6b5f
--- /dev/null
+++ b/cflags.conf
@@ -0,0 +1,2 @@
+#CFLAGS="-march=native -Ofast -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fno-plt -pthread -Wno-error -w" #
+#CFLAGS="-march=native -Og -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fno-plt" #
diff --git a/cmake-flags.conf b/cmake-flags.conf
new file mode 100644
index 000000000000..db0077b91d8c
--- /dev/null
+++ b/cmake-flags.conf
@@ -0,0 +1,4 @@
+#-- CMAKE flags
+#CMAKE_C_COMPILER="command gcc $CFLAGS"
+#CMAKE_CXX_COMPILER="command g++ $CXXFLAGS"
+#CMAKE_LINKER="command ld $LDFLAGS"
diff --git a/compress-param_max.conf b/compress-param_max.conf
new file mode 100644
index 000000000000..ea5cbe121586
--- /dev/null
+++ b/compress-param_max.conf
@@ -0,0 +1,9 @@
+#COMPRESSGZ=(gzip -c -f -n --best)
+#COMPRESSBZ2=(bzip2 -c -f --best)
+#COMPRESSXZ=(xz -T "$(getconf _NPROCESSORS_ONLN)" -c -z --best -)
+#COMPRESSZST=(zstd -c -z -q --ultra -T0 -22 -)
+#COMPRESSLRZ=(lrzip -9 -q)
+#COMPRESSLZO=(lzop -q --best)
+#COMPRESSZ=(compress -c -f)
+#COMPRESSLZ4=(lz4 -q --best)
+#COMPRESSLZ=(lzip -c -f)
diff --git a/cxxflags.conf b/cxxflags.conf
new file mode 100644
index 000000000000..d19a65a4a023
--- /dev/null
+++ b/cxxflags.conf
@@ -0,0 +1 @@
+#CXXFLAGS="${CFLAGS}"
diff --git a/debug-makeflags.conf b/debug-makeflags.conf
new file mode 100644
index 000000000000..fbdc7a5ead18
--- /dev/null
+++ b/debug-makeflags.conf
@@ -0,0 +1,3 @@
+#DEBUG_CFLAGS="-g"
+#DEBUG_CXXFLAGS="-g"
+#DEBUG_RUSTFLAGS="-C debuginfo=2"
diff --git a/destdirs_ext.conf b/destdirs_ext.conf
new file mode 100644
index 000000000000..3f7a87ac2e85
--- /dev/null
+++ b/destdirs_ext.conf
@@ -0,0 +1,2 @@
+#-- Profile cache: specify a fixed directory where profiles will be stored
+#PROFDEST=/mnt/pgo
diff --git a/graphite.sh.in b/graphite.sh.in
new file mode 100644
index 000000000000..37b729f625df
--- /dev/null
+++ b/graphite.sh.in
@@ -0,0 +1,25 @@
+#!/usr/bin/bash
+#
+# graphite.sh - Compile with polyhedral model optimization
+#
+
+[[ -n "$LIBMAKEPKG_BUILDENV_GRAPHITE_SH" ]] && return
+LIBMAKEPKG_BUILDENV_GRAPHITE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/option.sh"
+
+build_options+=('graphite' 'polly')
+buildenv_functions+=('buildenv_graphite')
+
+buildenv_graphite() {
+ if check_buildoption "graphite" "y" || check_buildoption "polly" "y"; then
+ graphiteflags=" -lgomp -mllvm -polly -mllvm -polly-num-threads=$(getconf _NPROCESSORS_ONLN) -mllvm -polly-parallel"
+ check_buildoption "graphite" "y" && \
+ graphiteflags=" -fgraphite-identity -floop-interchange -floop-nest-optimize -floop-parallelize-all -ftree-loop-distribution -ftree-parallelize-loops=$(getconf _NPROCESSORS_ONLN) -ftree-vectorize"
+
+ CFLAGS+="$graphiteflags"
+ CXXFLAGS+="$graphiteflags"
+ fi
+}
diff --git a/ldflags.conf b/ldflags.conf
new file mode 100644
index 000000000000..7736456cddd9
--- /dev/null
+++ b/ldflags.conf
@@ -0,0 +1,2 @@
+#LDFLAGS="-Wl,-O4,--sort-common,--as-needed,-z,relro,-z,now,-lgomp,-lpthread" #
+#LDFLAGS="-Wl,-O1 -Wl,-z,now -Wl,-z,relro -Wl,--as-needed -Wl,--no-copy-dt-needed-entries -Wl,--sort-common -Wl,--hash-style=gnu"
diff --git a/makeflags.conf b/makeflags.conf
new file mode 100644
index 000000000000..2590c95095ca
--- /dev/null
+++ b/makeflags.conf
@@ -0,0 +1 @@
+# MAKEFLAGS="-j$(nproc)"
diff --git a/mold.sh.in b/mold.sh.in
new file mode 100644
index 000000000000..869534501cb5
--- /dev/null
+++ b/mold.sh.in
@@ -0,0 +1,23 @@
+#!/usr/bin/bash
+#
+# mold.sh - Compile with the fast mold linker
+#
+
+[[ -n "$LIBMAKEPKG_BUILDENV_MOLD_SH" ]] && return
+LIBMAKEPKG_BUILDENV_MOLD_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/option.sh"
+
+build_options+=('mold')
+buildenv_functions+=('buildenv_mold')
+
+buildenv_mold() {
+ if check_buildoption "mold" "y"; then
+ moldflags=" -fuse-ld=mold"
+ CFLAGS+="$moldflags"
+ CFLAGS+="$moldflags"
+ CLAGS+="$moldflags"
+ fi
+}
diff --git a/optipng-exec.sh.in b/optipng-exec.sh.in
new file mode 100644
index 000000000000..3c56d3eed5a4
--- /dev/null
+++ b/optipng-exec.sh.in
@@ -0,0 +1,22 @@
+#!/usr/bin/bash
+#
+# optipng.sh - Confirm presence of optipng executable
+#
+
+[[ -n "$LIBMAKEPKG_EXECUTABLE_OPTIPNG_SH" ]] && return
+LIBMAKEPKG_EXECUTABLE_OPTIPNG_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/option.sh"
+
+executable_functions+=('executable_optipng')
+
+executable_optipng() {
+ if check_option "optipng" "y"; then
+ if ! type -p optipng >/dev/null; then
+ error "$(gettext "Cannot find the %s binary required for optimizing PNG image files.")" "optipng"
+ ret=1
+ fi
+ fi
+}
diff --git a/optipng.sh.in b/optipng.sh.in
new file mode 100644
index 000000000000..344facbdd31e
--- /dev/null
+++ b/optipng.sh.in
@@ -0,0 +1,30 @@
+#!/usr/bin/bash
+#
+# optipng.sh - Compress PNG files using optpng
+#
+
+[[ -n "$LIBMAKEPKG_TIDY_OPTIPNG_SH" ]] && return
+LIBMAKEPKG_TIDY_OPTIPNG_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+packaging_options+=('optipng')
+tidy_modify+=('tidy_optipng')
+
+tidy_optipng() {
+ if check_option "optipng" "y"; then
+ msg2 "$(gettext "Optimizing PNG images...")"
+ local png
+ find . -type f -iname "*.png" 2>/dev/null | while read -r png ; do
+ [ $(jobs -p|wc -l) -gt $(getconf _NPROCESSORS_ONLN) ] && wait -n
+ if [[ $(file --brief --mime-type "$png") = 'image/png' ]]; then
+ { optipng "${OPTIPNGFLAGS[@]}" "$png" &>/dev/null ||
+ warning "$(gettext "Could not optimize PNG image : %s")" "${png/$pkgdir\//}"; } &
+ fi
+ done
+ wait
+ fi
+}
diff --git a/pgo.sh.in b/pgo.sh.in
new file mode 100644
index 000000000000..f2686c89fc53
--- /dev/null
+++ b/pgo.sh.in
@@ -0,0 +1,48 @@
+#!/usr/bin/bash
+#
+# pgo.sh - Compile with, or utilize profile guided optimization
+#
+
+[[ -n "$LIBMAKEPKG_BUILDENV_PGO_SH" ]] && return
+LIBMAKEPKG_BUILDENV_PGO_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+build_options+=('pgo')
+buildenv_functions+=('buildenv_pgo')
+
+buildenv_pgo() {
+ if check_buildoption "pgo" "y"; then
+ [[ -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
+
+ [[ "$INFAKEROOT" == 1 ]] && return
+
+ if [[ ! -d $PROFDEST/$pkgbase.gen ]]; then
+ pgoflags=" -fprofile-generate -fprofile-dir=$PROFDEST/$pkgbase.gen"
+ pgoldflags=" -lgcov --coverage"
+ msg2 "Profile data will be generated."
+ else
+ [[ -d $PROFDEST/$pkgbase.used ]] && rm -rf $PROFDEST/$pkgbase.used
+ mv $PROFDEST/$pkgbase.{gen,used}
+ pgoflags=" -fprofile-correction -fprofile-use -fprofile-dir=$PROFDEST/$pkgbase.used"
+ pgoldflags=" -lgcov"
+ msg2 "Profile data will be applied."
+ fi
+
+ CFLAGS+="$pgoflags"
+ CXXFLAGS+="$pgoflags"
+ LDFLAGS+="$pgoldflags"
+
+ fi
+}
diff --git a/pkgopts-param_ext.conf b/pkgopts-param_ext.conf
new file mode 100644
index 000000000000..8c497a018a4c
--- /dev/null
+++ b/pkgopts-param_ext.conf
@@ -0,0 +1,6 @@
+#-- Compression parameters for UPX
+#UPXFLAGS="--ultra-brute"
+#-- Compression parameters for optiPNG
+#OPTIPNGFLAGS=" -o7 -zm1-9"
+#-- Compression parameters for SVGO
+#SVGOFLAGS="--multipass"
diff --git a/pkgopts_ext.conf b/pkgopts_ext.conf
new file mode 100644
index 000000000000..c784efc2d77d
--- /dev/null
+++ b/pkgopts_ext.conf
@@ -0,0 +1,3 @@
+#-- upx: Compress binary executable files using UPX
+#-- optipng: Optimize PNG images with optipng
+#-- svgo: Optimize SVG images with nodejs-svgo
diff --git a/rice.sh.in b/rice.sh.in
new file mode 100644
index 000000000000..933e2692165a
--- /dev/null
+++ b/rice.sh.in
@@ -0,0 +1,27 @@
+#!/usr/bin/bash
+#
+# rice.sh - Compile with extreme and unsafe optimization
+#
+
+[[ -n "$LIBMAKEPKG_BUILDENV_RICE_SH" ]] && return
+LIBMAKEPKG_BUILDENV_RICE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/option.sh"
+
+build_options+=('rice' 'rice-clang')
+buildenv_functions+=('buildenv_rice')
+
+buildenv_rice() {
+ if check_buildoption "rice" "y" || check_buildoption "rice-clang" "y"; then
+ riceflags=" -Ofast -fdata-sections -ffloat-store -fgcse-las -fgcse-sm -fmodulo-sched -fmodulo-sched-allow-regmoves -funsafe-math-optimizations -fno-threadsafe-statics -fomit-frame-pointer -fopenmp -fPIC -fshort-wchar -fvariable-expansion-in-unroller -Wno-sizeof-pointer-memaccess -pthread" #
+ check_buildoption "rice" "y" && \
+ riceflags+=" -fbranch-target-load-optimize2 -fcx-fortran-rules -fipa-pta -fno-enforce-eh-specs -fnothrow-opt -fno-var-tracking-assignments -freschedule-modulo-scheduled-loops -fsched-pressure -freg-struct-return -fsched-spec-load -fsched-spec-load-dangerous -fsched-stalled-insns=0 -fsched2-use-superblocks -fselective-scheduling -fselective-scheduling2 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -ftree-lrs -maccumulate-outgoing-args" # -fmerge-all-constants
+
+ riceldflags=" -lpthread -lgomp" # -shared
+ CFLAGS+="$riceflags"
+ CXXFLAGS+="$riceflags"
+ LDFLAGS+="$riceldflags"
+ fi
+}
diff --git a/svgo-exec.sh.in b/svgo-exec.sh.in
new file mode 100644
index 000000000000..b4a7e4ed8b8a
--- /dev/null
+++ b/svgo-exec.sh.in
@@ -0,0 +1,22 @@
+#!/usr/bin/bash
+#
+# svgo.sh - Confirm presence of svgo executable
+#
+
+[[ -n "$LIBMAKEPKG_EXECUTABLE_SVGO_SH" ]] && return
+LIBMAKEPKG_EXECUTABLE_SVGO_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/option.sh"
+
+executable_functions+=('executable_svgo')
+
+executable_svgo() {
+ if check_option "svgo" "y"; then
+ if ! type -p svgo >/dev/null; then
+ error "$(gettext "Cannot find the %s binary required for optimizing SVG image files.")" "svgo"
+ ret=1
+ fi
+ fi
+}
diff --git a/svgo.sh.in b/svgo.sh.in
new file mode 100644
index 000000000000..5faf42e424e7
--- /dev/null
+++ b/svgo.sh.in
@@ -0,0 +1,30 @@
+#!/usr/bin/bash
+#
+# svgo.sh - Compress SVG files using optsvg
+#
+
+[[ -n "$LIBMAKEPKG_TIDY_SVGO_SH" ]] && return
+LIBMAKEPKG_TIDY_SVGO_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+packaging_options+=('svgo')
+tidy_modify+=('tidy_svgo')
+
+tidy_svgo() {
+ if check_option "svgo" "y"; then
+ msg2 "$(gettext "Optimizing SVG images...")"
+ local svg
+ find . -type f -iname "*.svg" 2>/dev/null | while read -r svg ; do
+ [ $(jobs -p|wc -l) -gt $(getconf _NPROCESSORS_ONLN) ] && wait -n
+ if [[ $(file --brief --mime-type "$svg") = 'image/svg' ]]; then
+ { svgo "${SVGOFLAGS[@]}" "$svg" &>/dev/null ||
+ warning "$(gettext "Could not optimize SVG image : %s")" "${svg/$pkgdir\//}"; } &
+ fi
+ done
+ wait
+ fi
+}
diff --git a/upx-exec.sh.in b/upx-exec.sh.in
new file mode 100644
index 000000000000..ce2ecf56d25e
--- /dev/null
+++ b/upx-exec.sh.in
@@ -0,0 +1,22 @@
+#!/usr/bin/bash
+#
+# upx.sh - Confirm presence of upx executable
+#
+
+[[ -n "$LIBMAKEPKG_EXECUTABLE_UPX_SH" ]] && return
+LIBMAKEPKG_EXECUTABLE_UPX_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/option.sh"
+
+executable_functions+=('executable_upx')
+
+executable_upx() {
+ 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
+}
diff --git a/upx.sh.in b/upx.sh.in
new file mode 100644
index 000000000000..cbe3c8e6dd65
--- /dev/null
+++ b/upx.sh.in
@@ -0,0 +1,38 @@
+#!/usr/bin/bash
+#
+# upx.sh - Compress package binaries with UPX
+#
+
+[[ -n "$LIBMAKEPKG_TIDY_UPX_SH" ]] && return
+LIBMAKEPKG_TIDY_UPX_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+packaging_options+=('upx')
+tidy_modify+=('tidy_upx')
+
+tidy_upx() {
+ if check_option "upx" "y"; then
+ msg2 "$(gettext "Compressing binaries with %s...")" "UPX"
+ local binary
+ find . -type f -perm -u+w 2>/dev/null | while read -r binary ; do
+ [ $(jobs -p|wc -l) -gt $(getconf _NPROCESSORS_ONLN) ] && wait -n
+ case "$(file -S --brief --mime-type "$binary")" in
+ application/x-executable | application/x-dosexec | \
+ application/x-pie-executable | application/x-sharedlib )
+ { upx "${UPXFLAGS[@]}" "$binary" &>/dev/null &&
+ info "$(gettext "Compressed binary : %s")" "${binary/$pkgdir\//}" ||
+ warning "$(gettext "Could not compress binary : %s")" "${binary/$pkgdir\//}"; } &
+ ;;
+ #application* )
+ # warning "$(gettext "Not compressing %s, $(file --brief --mime-type "$binary")")" \
+ # "${binary/$pkgdir\//}"
+ # ;;
+ esac
+ done
+ wait
+ fi
+}