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