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