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