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