This page is kept for historical purposes only. Please see the home page for my current situation. —Luca Saiu.

DLL: TP 4 - Working with sources

When working on the project on your own computer you have had to install some software you probably didn't have before, such as Guile or Texinfo. But when you did that you didn't take the sources written by the authors: instead you used the packaging system of your distribution and just installed binary executables and library, already compiled by somebody else. You didn't see the sources at all.

Today, you will look at how the authors work with well-packaged source packages; we will download a well-written program in source form, we will look at it, configure, compile it and run it.

You will have to do many of the same activities for the project.

By the way, please don't ask me again what the project is all about: there's a whole page about it, and I have explained it again in the mailing list (even in French). If you haven't started yet, start as soon as possible.

When you work at the Institut Galilée labs, before starting, you have to execute the following line on every terminal you use:

source ~10706282/add-prefix ~10706282/usr
That is for using the software I have installed in my home directory on the machines at Institut Galilée; I don't have administrator privileges on the lab machines, so I have installed everything in my home directory.

Of course you don't need to do anything similar at home if you have installed everything correctly, because you are the administrator of your own machines.


If you haven't enabled history support for Guile (for example, pressing the "up arrow" key should let you see and edit the last line you typed) yet, you can copy my Guile configuration file which enables it:

cp ~10706282/.guile ~
You only need to do that once. If you want to enable history at home (strongly recommended), you can create a file ~/.guile containing the two lines:
(use-modules (ice-9 readline))
(activate-readline)

You can find some practical suggestions at the bottom of the first TP page.



Just to be clear: today we're speaking about what the software authors do, not about distribution packagers (distribution packagers are people who prepare compiled binary packages, for example for debian); they are usually different people.

When I say "source package" here I'm referring to what the software authors prepare. The software as provided by the software authors is often called upstream. We will only work with upstream software today.

Some people, me included, like to use the sources instead of binary compiled by somebody else whenever possible. Today you will see some advantages.

Task -1: Subscribe to the mailing list

If for some crazy reason you are not subscribed to the mailing list yet, please do it now. Use the web interface linked above; it's easy and you shouldn't need my assistance.
A student noticed that the page may ask you to accept certificates. Don't worry, the server is at LIPN, Université Paris 13; it's safe.

Some people gave me their e-mail address handwritten on paper. I've tried interpreting their handwriting to the best of my ability, but some addresses were written in a very indistinct way. If in doubt, subscribe now; the system will not let you subscribe more than once using the same address, so you will never get more than one copy of each message.


Task 0: Download the software

We will use GNU Hello. It's just a very well-packaged "hello world" program, which is used in GNU as an example of how a good source package should look.

Download the latest version GNU Hello from ftp://ftp.gnu.org/gnu/hello/, and uncompress the tarball into some temporary directory; then enter the new directory containing the sources.

For example (before trying this, go to ftp://ftp.gnu.org/gnu/hello/ and explore a little; also look at ftp://ftp.gnu.org/gnu/):

cd /tmp
wget ftp://ftp.gnu.org/gnu/hello/hello-2.7.tar.gz
tar xfv hello-2.7.tar.gz
cd hello-2.7


Task 1: Explore the source distribution

What's there in hello-2.7 ? Look around:

ls -XFsh --color
There are many files and subdirectories. You should recognize at least some of them.

Open some files with an editor. Are they binary files, or source files? Why, in your opinion?

What programming language is GNU Hello written in? Is it more or less complex than you thought? Why?

What license is GNU Hello distributed under? Where are copyright and license notices?


Task 2: Read about how software should be configured, compiled and installed

Read the complete INSTALL file, top-to-bottom. You will understand most of it, and it is something everybody should have read at least once.

Before going on, you should know the answers to the following questions:

If you don't know the answer to one of the questions above and you can't easily find an answer by searching on the web, ask me.


Task 3: We are not administrators in the lab... Is it a problem?

You don't have administrator privileges on the lab machines, and I don't either. So, can we still install the software?

Yes, but in our own directories. It's the same trick I use to let you access Guile (compiled and installed by me): the command line written in red at the top of the page gives you access to my directories (read-only, just because I chose so). Today you will use your directories.

Create a new prefix directory in your home directory: we will install everything there and in its subdirectories. We will call your prefix directory ~/usr (which is to say, the usr directory will be directly contained by your home directory).

Let's create the prefix directory:

mkdir ~/usr

Let's add the appropriate subdirectories of ~/usr to the directories which are automatically searched for executables, libraries, man pages and so on. We will use my add-prefix script for this:

source ~10706282/add-prefix ~/usr

The subdirectories of ~/usr don't exist yet, but they will be automatically created when installing GNU Hello.

Just like the "red" line above, you have to re-execute the line above if you open a new shell, so that your prefix is actually searched for when needed.

I will not explain how my add-prefix script works, but you can read it if you're interested. Ask me if you want to know some detail.


Task 4: Configure the software

So, since we're not the machine administrators, we can't follow the simplified instruction shown at the top of INSTALL; but we can still do something very simple.

Let's configure the software (what does it mean? You should know it now if you read INSTALL; otherwise ask me) so that it will use your prefix. It's very simple. Go to source directory:

cd /tmp/hello-2.7
And configure:
./configure --prefix=~/usr
Damn, that didn't work! That's because we used the ~ abbreviation.

Let's write the path in extended form:

./configure --prefix=$HOME/usr

The last line should work. configure dynamically examines the system to check its features. You should understand most of its output.


Task 5: Build

A Makefile has been generated now. Where does it come from? Can you understand it? Why is it so difficult to read, in your opinion?

We can finally compile:

make

It shouldn't take long, because of course Hello is a simple porgram.


Task 5: Install

Run

make install

Now the software is installed. Does it work? Let's run GNU Hello:

hello

It works! Oh, the excitement.

We have installed the software in your own prefix. It was easy, wasn't it? Look at what has been created:

find ~/usr

You should recognize many files.


Task 6: A look at the sources

Change your language environment so that messages are displayed in a language different from English. Run hello again. Did it greet you in a different language?

How did it do that? Look at the sources to find the answer.

Where is the hello documentation? Look for it. In which format is it? Where is the documentation source? Can you generate other formats? (The answer is yes). Do it.

Can you understand how configure was generated? And Makefile?


Task 7: How did they do it?

Who are the authors of GNU Hello? How do they work? Do they use bzr? Can you get the latest source snapshot? Do they have a mailing list similar to ours? Do they have a bug tracking system similar to our Bugzilla installation?


Task 8: Do it all over again

Choose another GNU source package which seems simple, configure it, compile it and install it from sources in your private prefix.

Tell me which one you want to try, I can help and give you suggestions.


Task 9: ...and Guile?

How should we package Scheme programs, such as our turtle graphics project? What is different, compared to GNU Hello? Search for answers.


In the end: why do I like sources?

I've said before that some people, me included, like to use the sources instead of binary compiled by somebody else whenever possible.

Can you recognize some advantages in working with sources? Do you also see disadvantages?



Notes for myself, in case of problems with the SERCAL installation or with student accounts:
My id is 10706282 .



Back to my home page...


Luca Saiu
Last modified: 2011-12-14
Copyright © 2010,2011 Luca Saiu
Verbatim copying and redistribution of this entire page are permitted provided this notice is preserved.