Compiling Emacs 23.2 From Source (Part 1)

As part of my goal to learn Linux internals from LFS, I’ve done some reading and experimentation with compiling software. Learning to compile software from source is widely considered an essential *nix skill, as many patches, tweaks, and settings can only be added or modified at compile-time. Also, building a LFS system requires compiling everything from source yourself, so I’ve got to learn some time.

Emacs, a text editor (in)famous for its extensibility, is the first software package I’ll practice compiling from source. Why start with Emacs? Emacs can be bent into doing pretty much anything you’d expect from a full-featured OS — e-mail, web browsing, music playback, Tetris, psychiatry… even text editing! — so there are obviously plenty of opportunities to learn how to compile special abilities into Emacs. Also, along with vi/vim, Emacs is a standard text editor for *nix systems, so I need to become at least somewhat proficient with it. Even the LFS essential prereading guide recommends Emacs as a starting point for package-building practice, so it’s probably a pretty good place to start… right?

So I began my dance with Emacs by grabbing the source for Emacs 23.2 from the gnu.org FTP server (~45MB) and extracting the .tar.gz to my Desktop folder (this is a good time to read any README files).

Next, I ran ./configure, a shell script for Emacs that generates makefiles (detailed instructions for compiling from source) based on a computer’s hardware/software configuration (and any special parameters you give it), and I hit my first snag:

Running ./configure

Running ./configure

As you can see, ./configure ran, but complained that several libraries were missing (image libraries in this case). I reran ./configure with the --with-xpm=no --with-jpeg=no --with-png=no --with-gif=no --with-tiff=no options that the first run said were missing, to see if I could bypass the error and get Emacs running at all.

Running A Slightly Different ./configure

Running A Slightly Different ./configure

Success! Once the ./configure script ran successfully (i.e., created valid Makefiles for compilation), I ran make, the slightly automagical compile-from-source tool. After about one or two minutes, make finished with no errors.

NOTE: make compiles the source code into the specified directory (by default the same directory as the source code), which makes it ideal for testing (run make clean to “reset” and try again if something breaks). make install, however, installs it to the normal program installation directories, so mistakes have more dire consequences for your time, as you have to hunt down many more loose ends.

This Means It's Finished, Right?

This Means It's Finished, Right?

I opened up Dolphin and browsed to the ~/Desktop/emacs-23.2/src/ folder, and ran the freshly-compiledd emacs:

Very... 1990s

Very... 1990s

It looked pretty shabby, but I suspect Emacs would be perfectly serviceable in this state. Compared to the Ubuntu package, you can see that there are definitely a few things missing from my homebrew build, including color image support and (semi-)native theming.

Very... 2000s

Very... 2000s

It seems I have a way to go before I get something as polished as Ubuntu’s tweaked-out version. However, I did manage to compile a program from source for the first time! Next time, I’ll try to get those image libraries working, along with a few other tricks and tweaks. Until next time, happy hacking!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s