2 # Copyright (C) 2016 Ian Kelling
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
20 # arg = git commit to check out
24 export FORCE_RECOMPILE
=true
27 while [[ $1 == -* ]]; do
29 --no-r) recompile
=false
; unset FORCE_RECOMPILE
; shift ;;
30 -u) update
=true
; shift ;;
31 -p) show_pkgs
=true
; shift ;;
36 e
() { echo "$*"; "$@"; }
38 # Og = optmize, but keep gdb working
39 export CFLAGS
="-Og -g3"
42 if apt-cache showsrc emacs
$x 2>/dev
/null |
grep .
&>/dev
/null
; then
49 pkgs
=(gawk attr autoconf-archive git install-info
)
50 ##### warning, apt-rdepends seems to look at the newest version of the package,
51 ##### not the one that build-dep would install.
54 for x
in $latest_emacs maildir-utils
; do
55 # todo, this gives fake provided packages like mailx, and then
57 # https://askubuntu.com/questions/21379/how-do-i-find-the-build-dependencies-of-a-package
58 if ! type -p apt-rdepends
&>/dev
/null
; then
59 sudo apt-get
-y install --purge --auto-remove apt-rdepends
61 apt-rdepends
-p --build-depends --follow=DEPENDS
$x/$
(debian-codename
)|
sed -rn 's/^\s*Build-Depends: (\S+).*/\1/p'
67 #building emacs, INSTALL.BZR
69 # gawk and attr were no longer automatically installed in stretch,
70 # looking back, i assume i got some error.
71 # autoconf-archive due to come error
75 dir
=/a
/opt
/emacs-
`distro-name`
76 dir
+=`debian-archive` ||
: # we may not be on debian
78 if [[ ! -e $dir ]]; then
79 e
cp -ar /a
/opt
/emacs
$dir
84 rev=$
(cat ~
/.local
/emacs-build-git-revision
2>/dev
/null
) ||
:
85 head=$
(git rev-parse HEAD
)
89 if $recompile ||
[[ $rev != "$head" ]]; then
91 case $
(distro-name
) in
93 logq s yum-builddep
-y emacs
94 logq pi texlive-dvipng
96 debian|ubuntu|trisquel
)
97 # todo: unknown for other distros, this will fail
98 logq p
-y build-dep maildir-utils
/$
(debian-codename
)
99 # oddly, on ubuntu 14.04 this installs postfix, but I dun care
100 # ubuntu 14.04 gave this error message
101 # Unable to satisfy the build-depends: Build-Depends: libpng-dev
102 # this is satisfied by dvipng. the build-dep is just wrong
103 # minor bug I'm not going to bother reporting.
105 # note, useful command to see build dep packagages:
106 # apt-rdepends --build-depends --follow=DEPENDS emacs25
107 logq p
-y build-dep
$latest_emacs
114 # todo, consider when this should be uncommented
115 #logq s make uninstall
116 find ~
/.emacs.d
/ -name '*.elc' -delete
124 e i
reset --hard origin
/master
128 # autogen is usually only for the first build, assume it works
129 logq .
/autogen.sh all
130 # I tried changing O2 to O3, don't know if it made it faster or slower so I went back to 02.
131 # Also, link-time-optimization based on ./INSTALL
133 # for debugging, use -Og, or -O0 to make debug really correspond to sources
134 # dunno why I have had -std=gnu99 in the past
135 #CFLAGS='-std=gnu99 -g3 -Og'
136 export CFLAGS
='-g3 -Og'
137 #CFLAGS='-std=gnu99 -g3 -O2' logq ./configure --enable-link-time-optimization
138 # on ubuntu 12.04, the above fails, says my c compiler won't work, so intead, just use defaults
140 logq
make -j `nproc` bootstrap
144 # temporarily for testing multiple versions
146 logq sudo
make install
148 # make emacs always work for root
149 s
/a
/exe
/lnf
/usr
/local
/bin
/emacs
/usr
/bin
151 echo $head >~
/.local
/emacs-build-git-revision
154 #git clone https://github.com/djcb/mu
155 # note: master failed, i moved back to the commit before a bug https://github.com/djcb/mu/issues/1400
156 # from its HACKING file
160 rev=$
(cat ~
/.local
/mu-build-git-revision
2>/dev
/null
) ||
:
161 head=$
(git rev-parse HEAD
)
162 if $recompile ||
[[ $rev != "$head" ]]; then
164 if [[ $
(distro-name
) == trisquel
]]; then
165 # use the flidas branch, stuck behind because
166 # needs newer crypt libraries that are too troublesome.
169 # newer version than build-dep installs for buster
170 sudo apt-get
-y install --purge --auto-remove libgmime-3.0
-dev
176 echo $head >~
/.local
/mu-build-git-revision
177 # note uninstall is implemented
181 # note, not totally sure its right to put this within recompile, but its taking up most of the time, so going for it.
182 logq emacs
--batch -l ~
/.emacs.d
/compile-init-dir.el
185 # as of 01-2017, built-in org mode has a bug that
186 # org-edit-src-exit does not get bound, so using latest
187 #/a/bin/buildscripts/org-mode
189 # disabled as i haven't used it in a while
192 # cd ~/.emacs.d/src/mediawiki-el
197 # not keeping up with the latest gnus development.
198 # # instructions from the README
199 # # the byte-recompile-directory seems to compile gnus,
200 # # but gnus complains that it should be compiled when it starts
201 # cd ~/.emacs.d/src/gnus
202 # if [[ $1 == *u* ]]; then