add pithos, update emacs
[buildscripts] / emacs
1 #!/bin/bash -l
2 # Copyright (C) 2016 Ian Kelling
3
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
7
8 # http://www.apache.org/licenses/LICENSE-2.0
9
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.
15
16 set -eE -o pipefail
17 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
18
19 #set -x
20 # arg = git commit to check out
21
22 update=false
23 recompile=true
24 show_pkgs=false
25
26 while [[ $1 == -* ]]; do
27 case $1 in
28 --no-r) recompile=false; shift ;;
29 -u) update=true; shift ;;
30 -p) show_pkgs=true; shift ;;
31 --) break ;;
32 esac
33 done
34
35 e() { echo "$*"; "$@"; }
36
37 # Og = optmize, but keep gdb working
38 export CFLAGS="-Og -g3"
39
40 pkgs=(gawk attr autoconf-archive)
41 if $show_pkgs; then
42 echo ${pkgs[*]}
43 for x in emacs25 maildir-utils; do
44 apt-rdepends --build-depends --follow=DEPENDS $x|sed -rn 's/^\s*Build-Depends: (\S+).*/\1/p'
45 done
46 exit 0
47 fi
48
49
50 # gawk and attr were no longer automatically installed in stretch,
51 # looking back, i assume i got some error.
52 # autoconf-archive due to come error
53 pi ${pkgs[@]}
54
55
56 case $(distro-name) in
57 fedora )
58 logq s yum-builddep -y emacs
59 logq pi texlive-dvipng
60 ;;&
61 debian|ubuntu|trisquel)
62 # todo: unknown for other distros, this will fail
63 logq p -y build-dep maildir-utils
64 # oddly, on ubuntu 14.04 this installs postfix, but I dun care
65 # ubuntu 14.04 gave this error message
66 # Unable to satisfy the build-depends: Build-Depends: libpng-dev
67 # this is satisfied by dvipng. the build-dep is just wrong
68 # minor bug I'm not going to bother reporting.
69 #
70 # note, useful command to see build dep packagages:
71 # apt-rdepends --build-depends --follow=DEPENDS emacs25
72 logq p -y build-dep emacs25
73 ;;&
74 esac
75
76
77
78 #building emacs, INSTALL.BZR
79
80 #git repo
81 dir=/a/opt/emacs-`distro-name`
82 dir+=`debian-archive` ||: # we may not be on debian
83
84 if [[ ! -e $dir ]]; then
85 e cp -ar /a/opt/emacs $dir
86 recompile=true
87 fi
88 e cd $dir
89
90 if $recompile; then
91 # todo, consider when this should be uncommented
92 #logq s make uninstall
93 find ~/.emacs.d/ -name '*.elc' -delete
94
95 # git version
96 if [[ $1 ]]; then
97 e i clean -xxxfd
98 elif $update; then
99 e i fetch
100 e i clean -xxxffd
101 e i reset --hard origin/master
102 e i clean -xxxffd
103 fi
104
105 # autogen is usually only for the first build, assume it works
106 logq ./autogen.sh all
107 # I tried changing O2 to O3, don't know if it made it faster or slower so I went back to 02.
108 # Also, link-time-optimization based on ./INSTALL
109
110 # for debugging, use -Og, or -O0 to make debug really correspond to sources
111 # dunno why I have had -std=gnu99 in the past
112 #CFLAGS='-std=gnu99 -g3 -Og'
113 export CFLAGS='-g3 -Og'
114 #CFLAGS='-std=gnu99 -g3 -O2' logq ./configure --enable-link-time-optimization
115 # on ubuntu 12.04, the above fails, says my c compiler won't work, so intead, just use defaults
116 logq ./configure
117 logq make -j `nproc` bootstrap
118 fi
119
120 # temporarily for testing multiple versions
121 logq make -j `nproc`
122 logq sudo make install
123
124 # make emacs always work for root
125 s lnf /usr/local/bin/emacs /usr/bin
126
127
128 #git clone https://github.com/djcb/mu
129 # from its HACKING file
130 cd /a/opt/mu
131 ./autogen.sh
132 make
133 s make install
134 # note uninstall is implemented
135
136 if $recompile; then
137 # note, not totally sure its right to put this within recompile, but its taking up most of the time, so going for it.
138 logq emacs --batch -l ~/.emacs.d/init.el -l ~/.emacs.d/compile-init-dir.el
139 fi
140
141 # as of 01-2017, built-in org mode has a bug that
142 # org-edit-src-exit does not get bound, so using latest
143 /a/bin/buildscripts/org-mode
144
145 if $update; then
146 logq pi bzr
147 cd ~/.emacs.d/src/mediawiki-el
148 bzr pull
149 fi
150
151
152 # not keeping up with the latest gnus development.
153 # # instructions from the README
154 # # the byte-recompile-directory seems to compile gnus,
155 # # but gnus complains that it should be compiled when it starts
156 # cd ~/.emacs.d/src/gnus
157 # if [[ $1 == *u* ]]; then
158 # i pull
159 # fi
160 # logq ./configure
161 # logq make