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"
@lyqscmy
Copy link

lyqscmy commented Sep 3, 2015

Very helpful!

@androclus
Copy link

hi! thank you for this. i am trying to get it running but it bombs out. i have ubuntu (KXStudio) 14.04.3 LTS. For some reason, github won't let me attach a file here, so here is a link to the output of running this script:

out.txt

And here are the first few lines of the contents of /usr/local/stow/emacs24.5/share/info/dir -- in case that helps -- tho' i'm not sure if that's what's really causing the abort.

This is the file .../info/dir, which contains the
topmost node of the Info hierarchy, called (dir)Top.
The first time you invoke Info you start off looking at this node.

File: dir,      Node: Top       This is the top of the INFO tree

The Info Directory
******************

  The Info Directory is the top-level menu of major Info topics.
  Type "d" in Info to return to the Info Directory.  Type "q" to exit Info.
  Type "?" for a list of Info commands, or "h" to visit an Info tutorial.
  Type "m" to choose a menu item--for instance,
....

@androclus
Copy link

okay, i don't have the complete answer, but stow was bombing out at the end:

WARNING! stowing emacs-24.5 would cause conflicts:
  * existing target is neither a link nor a directory: share/info/dir
All operations aborted.

(a clearer error message from stow would have saved me - a first time user of stow - a lot of time)

i had to learn about targets. the target was not "share/info/dir" but "/usr/local/share/info/dir". This dir file did already exist on the system.

so the problem is that stow wanted to symlink /usr/local/share/info/dir --> /usr/local/stow/emacs-24.5/share/info/dir but it couldn't do that because the /usr/local/share/info/dir file already existed.

to rectify the problem, i had to move the previously-existing /usr/local/share/info/dir file. Now I was able to run stow without error.

The previously-existing /usr/local/share/info/dir file had very little in it, so merging it with the new dir file coming in from stow was not a problem.

Still, this became a hand-editing/manual problem. I wonder if there should be a fix done, so that scripts can work still?

Also, similar information about compiling emacs and installing with stow is
here , and does not mention the dir merge conflict problem, either.

This problem would only happen if you have a dir file already existing there (which I did).

How to merge two dir files gracefully?

@androclus
Copy link

Okay, I've made a fork which gets around the stow dir conflict mentioned above. The fork also fixes a couple of other minor issues that can come up: mkdir now has "-p" and libtiff4-dev changed to libtiff5-dev (for some newer Ubuntu systems), etc.

Apparently we can't (yet) submit Pull-requests on gists, so you are welcome to pull changes from my fork, if you like.

Thanks for the script, Diep!

@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