add mu, fix tor
[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 # -r = don't recompile from scratch
22 # -u = update sources
23
24 # stop if any the command fails
25 update=false
26 recompile=true
27
28 while [[ $1 == -* ]]; do
29 case $1 in
30 --no-r) recompile=false; shift ;;
31 -u) update=true; shift ;;
32 --) break ;;
33 esac
34 done
35
36 e() { echo "$*"; "$@"; }
37
38 # Og = optmize, but keep gdb working
39 export CFLAGS="-Og -g3"
40
41 # gawk and attr were no longer automatically installed in stretch
42 logq pi texlive hunspell git gawk attr
43 case $(distro-name) in
44 fedora )
45 # before i learned the builddep command, i identified these
46 # dependencies. Not sure if the builddep took care of them all
47 # gtk3-devel libXpm-devel libjpeg-turbo-devel libtiff-devel giflib-devel ncurses-devel gnutls-devel libxml2-devel libotf-devel GConf2-devel gpm-devel librsvg2-devel ImageMagick-devel m17n-lib-devel libselinux-devel
48
49 logq s yum-builddep -y emacs
50 logq pi texlive-dvipng
51 ;;&
52 debian|ubuntu)
53 # todo: unknown for other distros, this will fail
54 logq p -y build-dep maildir-utils
55 # due to autogen error message
56 p install autoconf-archive
57
58 # oddly, on ubuntu 14.04 this installs postfix, but I dun care
59 # ubuntu 14.04 gave this error message
60 # Unable to satisfy the build-depends: Build-Depends: libpng-dev
61 # this is satisfied by dvipng. the build-dep is just wrong
62 # minor bug I'm not going to bother reporting
63 logq p -y build-dep emacs
64 # fyi libmagick is broken right now because it uses a fork which is waiting for emacs to support it
65 # not sure how many of these are satisfied by the prev command,
66 # but from the log, it looks like none of them
67 logq pi libacl1-dev libselinux-dev libm17n-dev libgtk-3-dev \
68 librsvg2-dev libgpm-dev libgconf2-dev libotf-dev libxml2-dev \
69 automake1.11 libgnutls28-dev libncurses-dev libxpm-dev libjpeg-dev \
70 libgif-dev libtiff-dev texinfo dvipng
71 ;;&
72 debian)
73 # included in dependencies on other distros, todo, check on ubuntu
74 logq pi suckless-tools
75 ;;
76 esac
77
78
79
80 #building emacs, INSTALL.BZR
81
82 #git repo
83 dir=/a/opt/emacs-`distro-name``debian-archive`
84
85 if [[ ! -e $dir ]]; then
86 e cp -r /a/opt/emacs $dir
87 recompile=true
88 fi
89 e cd $dir
90
91 if $recompile; then
92 # todo, consider when this should be uncommented
93 #logq s make uninstall
94 find ~/.emacs.d/ -name '*.elc' -delete
95
96 # git version
97 if [[ $1 ]]; then
98 e i clean -xxxfd
99 elif $update; then
100 e i fetch
101 e i clean -xxxffd
102 e i reset --hard origin/master
103 e i clean -xxxffd
104 fi
105
106 # autogen is usually only for the first build, assume it works
107 logq ./autogen.sh
108 # I tried changing O2 to O3, don't know if it made it faster or slower so I went back to 02.
109 # Also, link-time-optimization based on ./INSTALL
110
111 # for debugging, use -Og, or -O0 to make debug really correspond to sources
112 # dunno why I have had -std=gnu99 in the past
113 #CFLAGS='-std=gnu99 -g3 -Og'
114 export CFLAGS='-g3 -Og'
115 #CFLAGS='-std=gnu99 -g3 -O2' logq ./configure --enable-link-time-optimization
116 # on ubuntu 12.04, the above fails, says my c compiler won't work, so intead, just use defaults
117 logq ./configure
118 logq make -j `nproc` bootstrap
119 fi
120
121 # temporarily for testing multiple versions
122
123 logq sudo make install
124
125 # make emacs always work for root
126 s lnf /usr/local/bin/emacs /usr/bin
127
128
129 #git clone https://github.com/djcb/mu
130 # from its HACKING file
131 cd /a/opt/mu
132 ./autogen.sh
133 make
134 s make install
135 # note uninstall is implemented
136
137 logq emacs --batch -l ~/.emacs.d/init.el -l ~/.emacs.d/compile-init-dir.el
138
139 # as of 01-2017, built-in org mode has a bug that
140 # org-edit-src-exit does not get bound, so using latest
141 /a/bin/buildscripts/org-mode
142
143 if $update; then
144 logq pi bzr
145 cd ~/.emacs.d/src/mediawiki-el
146 bzr pull
147 fi
148
149
150 # not keeping up with the latest gnus development.
151 # # instructions from the README
152 # # the byte-recompile-directory seems to compile gnus,
153 # # but gnus complains that it should be compiled when it starts
154 # cd ~/.emacs.d/src/gnus
155 # if [[ $1 == *u* ]]; then
156 # i pull
157 # fi
158 # logq ./configure
159 # logq make