emacs-build (2632B)
1 #!/bin/bash 2 3 set -eux 4 5 src_dir=$(realpath "${EMACS_SRC:-.}") 6 build_dir=$(realpath "${EMACS_BUILD:-.}") 7 config_h=${build_dir}/src/config.h 8 9 make="make -j$(nproc --all)" 10 configure_flags=( 11 --prefix=${HOME}/apps/.emacs.$(date +%F) 12 --with-cairo 13 # Disable native compilation. trunk is my daily driver, and I 14 # update it regularly, so eln-cache grows a new subdir with every 15 # update. 16 # 17 # I have tried it out unwittingly because as distros start 18 # enabling it, libgccjit becomes part of Emacs build dependencies; 19 # hence package managers install libgccjit when I ask for these 20 # build dependencies, and 'configure' defaults to enabling native 21 # compilation if libgccjit is available. 22 # 23 # I am happy to report that on this workstation, native-comp seems 24 # to Just Workβ’: I remember seeing a grand total of one (1) 25 # compilation-warning popup over the couple of months I have been 26 # using it. So congrats to the devs for a smooth UX π 27 # 28 # Vibes-wise, I have not noticed performance improvements though. 29 # When Emacs feels "slow" to me, it is usually because the UI is 30 # completely unresponsive due to synchronous jobs: e.g. Gnus IMAP 31 # refresh, fontconfig matching, project-wide regexp search. 32 # 33 # So I bow out of native-comp, to avoid the eln-cache spill. 34 --with-native-compilation=no 35 --with-sqlite3 36 --with-xinput2 37 ${CONFIGURE_EXTRA_FLAGS:-} 38 ) 39 40 is-rolling-distro () 41 { 42 ( 43 . /etc/os-release 44 case "${ID}" 45 in 46 opensuse-tumbleweed) return 0;; 47 esac 48 return 1 49 ) 50 } 51 52 cache-file () 53 { 54 local -r cachedir=${XDG_CACHE_HOME:-~/.cache}/emacs 55 test -d "${cachedir}" || mkdir -p "${cachedir}" 56 57 local builddesc=${PWD} 58 builddesc=${builddesc#~} 59 builddesc=${builddesc//\//,} 60 echo ${cachedir}/config${builddesc} 61 } 62 63 if ! is-rolling-distro 64 then 65 configure_flags=( 66 --cache-file="$(cache-file)" 67 "${configure_flags[@]}" 68 ) 69 fi 70 71 if test "${DEBUG:-}" 72 then 73 configure_flags+=( 74 --enable-checking=yes,glyphs 75 --enable-check-lisp-object-type 76 CFLAGS='-O0 -g3' 77 ) 78 fi 79 80 if ! test -f "${src_dir}"/Makefile 81 then 82 ${make} -C "${src_dir}" configure 83 fi 84 85 cd "${build_dir}" 86 87 # Had logic to check src/config.h:EMACS_CONFIG_OPTIONS to determine 88 # whether running 'configure' is redundant. Threw it all to the wind: 89 # date-based --prefix changes everyday; build times are not as long as 90 # they used to be; I can always invoke 'make' if I want fast iteration 91 # over build errors. 92 "${src_dir}"/configure "${configure_flags[@]}" 93 ${make} "$@"