Last active
November 2, 2023 12:45
-
-
Save jindraj/95a238e7fb5f2bd8d7b2f7c71a445ac4 to your computer and use it in GitHub Desktop.
build neomutt on macos – deps installed from homebrew (gsasl, lua, pcre2, gettext, gpgme, libidn2, zstd, lmdb, notmuch, openssl@3, docbook-xsl) https://asciinema.org/a/W6hUoRyciHNS2QJa9UjuofmA7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function __mark(){ | |
set +e | |
[[ $TERM_PROGRAM == 'iTerm.app' ]] && printf '\e]1337;SetMark\a' | |
set -e | |
} | |
function __help(){ | |
cat <<-EOF 1>&2 | |
Usage: $0 [-chprqD] [-b <git branch>] [-d <directory>] | |
-p run git pull before building | |
-b checkout git branch before building | |
-D compile for debugging and disable optimizations | |
-c run ./configure | |
-r run make clean | |
-t run tests | |
-d specify directory with source code defaults to $neomutt_source_dir | |
-q be quiet (suppress output of commands) | |
-h print this help | |
# https://gist.github.com/jindraj/95a238e7fb5f2bd8d7b2f7c71a445ac4 | |
EOF | |
exit "$1" | |
} | |
function __command_status(){ | |
[[ $run -ne 1 ]] && return | |
local commands=( "$@" ) ret=0 color | |
[[ $GRC ]] && commands=( "$GRC" "$@" ) | |
__mark | |
{ set -x | |
/usr/bin/time "${commands[@]}" || ret=$? | |
{ set +x; } 2>/dev/null | |
} | |
[[ $ret -ne 0 ]] && color='\e[1;31m' | |
__mark; printf 1>&2 '\e[1;37mcommand exited with: %b%d\e[0m\n\n' "${color:-\e[1;32m}" "$ret" | |
return $ret | |
} | |
function __args(){ | |
while getopts "b:cd:Dhpqrt" opt | |
do | |
case "${opt}" in | |
b) gitcheckout=1 branch=$OPTARG ;; | |
c) configure=1 ;; | |
d) neomutt_source_dir="$OPTARG" ;; | |
D) EXTRA_CFLAGS='-O0 -g' | |
EXTRA_CFLAGS+=' -fsanitize=address,undefined' | |
EXTRA_LDFLAGS+=' -fsanitize=address,undefined' | |
#'--debug-email' # cannot compile with this | |
#'--debug-graphviz' # fails tests for some reason | |
#'--debug-keymap' # fails tests for some reason | |
#'--debug-notify' # fails tests for some reason | |
#'--debug-logging' # fails tests for some reason | |
#'--debug-names' # fails tests for some reason | |
#'--debug-window' # fails tests for some reason | |
#'--debug-queue' # fails tests for some reason | |
CONFIGURE+=( '--debug-color' | |
--debug | |
) ;; | |
p) gitpull=1 ;; | |
q) CONFIGURE+=( '--quiet' ) | |
MAKE+=( '--quiet' ) | |
GIT_OPTS+=( '--quiet' ) | |
output="/dev/null" ;; | |
r) makeclean=1 ;; | |
t) maketest=0; ( cd "${NEOMUTT_TEST_DIR}" || exit ; ./setup.sh; ) ;; | |
\?) __help 1 ;; | |
h) __help 0 ;; | |
esac | |
done | |
shift "$((OPTIND-1))" | |
} | |
function __defaults(){ | |
local HOMEBREW_PATH run | |
HOMEBREW_PATH=$(brew --prefix) | |
GRC=$(set +e;command -v grc;set -e) | |
CFLAGS=( -O3 -pipe ) | |
# keep temporarily to have ability to bisect builds before 202311XX | |
# to do so, comment --with-ncurses option in CONFIGURE array | |
#LDFLAGS=( -L"${HOMEBREW_PATH}/opt/ncurses/lib" ) | |
#CPPFLAGS=( -I"${HOMEBREW_PATH}/opt/ncurses/include" ) | |
EXTRA_CFLAGS=() | |
EXTRA_LDFLAGS=() | |
XML_CATALOG_FILES="${HOMEBREW_PATH}/etc/xml/catalog" | |
NEOMUTT_TEST_DIR="$HOME/projects/github/neomutt-test-files" | |
MAKE=( make "-j$(nproc)" ) | |
CONFIGURE=( | |
./configure | |
--gpgme | |
--gsasl | |
--idn2 | |
--lmdb | |
--lua | |
--notmuch | |
--pcre2 | |
--ssl | |
--with-iconv="${HOMEBREW_PATH}/opt/libiconv" | |
--with-lmdb="${HOMEBREW_PATH}/opt/lmdb" | |
--with-ncurses="${HOMEBREW_PATH}/opt/ncurses" | |
--with-nls="${HOMEBREW_PATH}/opt/gettext" | |
--with-notmuch="${HOMEBREW_PATH}/opt/notmuch" | |
--with-ssl="${HOMEBREW_PATH}/opt/openssl@3" | |
--zstd | |
) | |
} | |
function run(){ | |
trap "exit" INT | |
set +e | |
__defaults | |
__args "$@" | |
cd "${neomutt_source_dir:-$HOME/projects/github/neomutt}" || exit | |
run=${gitcheckout:-0} __command_status time git checkout "${GIT_OPTS[@]}" "$branch" | |
run=${gitpull:-0} __command_status time git pull "${GIT_OPTS[@]}" --rebase | |
run=${configure:-0} __command_status env \ | |
CPPFLAGS="${CPPFLAGS[*]}" \ | |
CFLAGS="${CFLAGS[*]}" \ | |
EXTRA_CFLAGS="${EXTRA_CFLAGS[*]}" \ | |
LDFLAGS="${LDFLAGS[*]}" \ | |
EXTRA_LDFLAGS="${EXTRA_LDFLAGS[*]}" \ | |
XML_CATALOG_FILES="$XML_CATALOG_FILES" \ | |
"${CONFIGURE[@]}" | |
run=${makeclean:-0} __command_status env CFLAGS="${CFLAGS[*]}" EXTRA_CFLAGS="${EXTRA_CFLAGS[*]}" "${MAKE[@]}" clean | |
run=${makeall:-1} __command_status env XML_CATALOG_FILES="$XML_CATALOG_FILES" "${MAKE[@]}" all | |
run=${maketest:-1} __command_status env NEOMUTT_TEST_DIR="$NEOMUTT_TEST_DIR" "${MAKE[@]}" test > "${output:-/dev/stdout}" || true | |
run=${makeinstall:-1} __command_status sudo env XML_CATALOG_FILES="$XML_CATALOG_FILES" "${MAKE[@]}" install > "${output:-/dev/stdout}" | |
set +e | |
} | |
time run "$@" | |
# vim:foldmethod=indent:foldlevel=0:tabstop=4:noexpandtab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment