Skip to content

Instantly share code, notes, and snippets.

@favadi
Last active June 5, 2021 15:25
Show Gist options
  • Save favadi/18438172892bc4178b27 to your computer and use it in GitHub Desktop.
Save favadi/18438172892bc4178b27 to your computer and use it in GitHub Desktop.
Compile latest emacs version (24.5) in Ubuntu 14.04
#!/bin/bash
# Build latest version of Emacs, version management with stow
# OS: Ubuntu 14.04 LTS
# version: 24.5
# Toolkit: lucid
# Warning, use updated version of this script in: https://github.com/favadi/build-emacs
set -e
readonly version="24.5"
# install dependencies
sudo apt-get install -y stow build-essential libx11-dev xaw3dg-dev \
libjpeg-dev libpng12-dev libgif-dev libtiff4-dev libncurses5-dev \
libxft-dev librsvg2-dev libmagickcore-dev libmagick++-dev \
libxml2-dev libgpm-dev libghc-gconf-dev libotf-dev libm17n-dev \
libgnutls-dev
# download source package
if [[ ! -d emacs-"$version" ]]; then
wget http://ftp.gnu.org/gnu/emacs/emacs-"$version".tar.xz
tar xvf emacs-"$version".tar.xz
fi
# buil and install
sudo mkdir /usr/local/stow
cd emacs-"$version"
./configure \
--with-xft \
--with-x-toolkit=lucid
make
sudo make install prefix=/usr/local/stow/emacs-"$version"
cd /usr/local/stow
sudo stow emacs-"$version"
@biocyberman
Copy link

Comment on line #13-17. It would be a bit more robust to do this for dependencies instead:
sudo apt-get build-dep emacs24
If later the major version supported by Ubuntu changes to emacs25 or emacs23 for that matters, one only need to change one digit instead of dealing with a long list of packages.

@favadi
Copy link
Author

favadi commented Oct 28, 2015

@jastern I setup a repo with travis integration here: https://github.com/favadi/build-emacs

Builds pass for trusty, vivid and wily. I don't see /usr/local/share/info/dir exists in fresh install of Ubuntu, so I remove the code to handle conflict.

@biocyberman: build-dep emacs24 will pull some unnecessary development packages, like gtk things.

@androclus
Copy link

@favadi While I can see the value in testing with travis against vanilla/fresh environments, I can also see that this is not the case under which folks would want to install emacs-via-stow. Are you expecting this script to be run only on fresh-installed systems?

Also, in the revisions of the above script, I don't see any changes since April. (?)

@BrianZbr
Copy link

Thanks for sharing this... It seemed to work ok for me but the frame of the emacs 24.5 window is grey (and very thick/ugly) instead of black. I take it that's not normal? Here's the config.log. Any suggestions? I'm running vanilla Ubuntu 14.04.

@favadi
Copy link
Author

favadi commented Nov 12, 2015

@dowcet it is expected because we use lucid toolkit.

@fuyunv
Copy link

fuyunv commented Dec 19, 2015

It works. Thanks a lot.

@ozdigennaro
Copy link

I suggest you change one line
sudo mkdir -p /usr/local/stow
to make it a bit more robust.

@quang-ha
Copy link

quang-ha commented Apr 4, 2016

Agree with @ozdigennaro. In case someone has installed emacs before already, the script will failed at creating /usr/local/stow

@davestroud
Copy link

Excellent!!!! Thank you!

Copy link

ghost commented Jun 10, 2016

Hey - I think the file needs to be renamed to build-emacs as it's a bash not sh file

@xiaohl0913
Copy link

Hi Thanks for sharing. However, this is version is not what I need. How should I uninstall this, after I installed using your script?
Basically, I have the same question in
http://askubuntu.com/questions/754251/uninstall-packages-with-stow

@favadi
Copy link
Author

favadi commented Jun 16, 2016

@xiaohl0913 I answered this question here: favadi/build-emacs#5

@tom4everitt
Copy link

tom4everitt commented Sep 27, 2016

Hi, trying to compile emacs 25.1 on Ubuntu 16.04. The installed packages gives me a lot, except for:

Should Emacs use a relocating allocator for buffers? no
Should Emacs use mmap(2) for buffer allocation? no
Does Emacs use cairo? no
Does Emacs have dynamic modules support? no
Does Emacs support Xwidgets (requires gtk3)? no

Especially the last one would be useful to have, I think. For some reason the mouse still behaves a little weirdly inside the emacs window.

@tom4everitt
Copy link

For Ubuntu 16.04 and Emacs 25.1, suggesting to add:

sudo apt-get install libgtk-3-dev libwebkitgtk-3.0-dev

and to configure with

./configure --with-cairo --with-xwidgets --with-x-toolkit=gtk3

Otherwise the menus seem not to work properly.

@yaitloutou
Copy link

yaitloutou commented Feb 8, 2017

Emacs 25 now has dynamic module support. from Emacs ./configure --help

  --with-modules          compile with dynamic modules support

for more information about this feature cf. http://diobla.info/blog-archive/modules-tut.html

@SeaDude
Copy link

SeaDude commented Oct 14, 2017

EDIT:
Just saw the message at the top of the script pointing me to the github repo where the newest script resides! Forget the items below.

===

Hello. Thanks for the script.

On a fresh install of Ubuntu 16.04.3 LTS (with apt-get update, apt-get upgrade, apt-get autoremove). First stop was your script. Thanks to your commentors, I changed the following to get things working:

  1. Removed libghc-gconf-dev as it does not appear to be a dependency in 16.04.3
  2. Added sudo mkdir -p /usr/local/stow per @ozdigennaro

I'm not adept enough at scripting to pose a change, but hope this helps others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment