minor fixes
[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
25 while [[ $1 == -* ]]; do
26 case $1 in
27 --no-r) recompile=false; shift ;;
28 -u) update=true; shift ;;
29 --) break ;;
30 esac
31 done
32
33 e() { echo "$*"; "$@"; }
34
35 # Og = optmize, but keep gdb working
36 export CFLAGS="-Og -g3"
37
38 # gawk and attr were no longer automatically installed in stretch
39 pi eatmydata
40 logq sudo eatmydata apt-get -y install --purge --auto-remove texlive hunspell git gawk attr
41 case $(distro-name) in
42 fedora )
43 # before i learned the builddep command, i identified these
44 # dependencies. Not sure if the builddep took care of them all
45 # 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
46
47 logq s yum-builddep -y emacs
48 logq pi texlive-dvipng
49 ;;&
50 debian|ubuntu|trisquel)
51 # todo: unknown for other distros, this will fail
52 logq p -y build-dep maildir-utils
53 # due to autogen error message
54 p install autoconf-archive
55
56 # oddly, on ubuntu 14.04 this installs postfix, but I dun care
57 # ubuntu 14.04 gave this error message
58 # Unable to satisfy the build-depends: Build-Depends: libpng-dev
59 # this is satisfied by dvipng. the build-dep is just wrong
60 # minor bug I'm not going to bother reporting
61 logq p -y build-dep emacs
62 # fyi libmagick is broken right now because it uses a fork which is waiting for emacs to support it
63 # not sure how many of these are satisfied by the prev command,
64 # but from the log, it looks like none of them
65 logq pi libacl1-dev libselinux-dev libm17n-dev libgtk-3-dev \
66 librsvg2-dev libgpm-dev libgconf2-dev libotf-dev libxml2-dev \
67 automake1.11 libgnutls28-dev libncurses-dev libxpm-dev libjpeg-dev \
68 libgif-dev libtiff-dev texinfo dvipng
69 ;;&
70 debian)
71 # included in dependencies on other distros, todo, check on ubuntu
72 logq pi suckless-tools
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 logq emacs --batch -l ~/.emacs.d/init.el -l ~/.emacs.d/compile-init-dir.el
137
138 # as of 01-2017, built-in org mode has a bug that
139 # org-edit-src-exit does not get bound, so using latest
140 /a/bin/buildscripts/org-mode
141
142 if $update; then
143 logq pi bzr
144 cd ~/.emacs.d/src/mediawiki-el
145 bzr pull
146 fi
147
148
149 # not keeping up with the latest gnus development.
150 # # instructions from the README
151 # # the byte-recompile-directory seems to compile gnus,
152 # # but gnus complains that it should be compiled when it starts
153 # cd ~/.emacs.d/src/gnus
154 # if [[ $1 == *u* ]]; then
155 # i pull
156 # fi
157 # logq ./configure
158 # logq make