The purpose of this post is to describe how to setup lxr for personal use on Linux – I use Ubuntu Feisty on my machine. Most of the commands need to be run as root, so you may want to do:
$ sudo bash
right at the beginning. Or you can prepend sudo to each command.
Setting up apache on Ubuntu Feisty.
# aptitude install apache
# /etc/init.d/apache start
Note: I don’t think I did any other settings really, but I had setup apache earlier – don’t remember now. I’m including it here for completeness. I am only accessing my webserver as localhost, and have not changed anything anywhere.
Setting up lxr on Ubuntu Feisty.
# aptitude install lxr
This gets lxr 0.3.1-4 – you need to have universe enabled in /etc/apt/sources.list. If you have enabled just now for the first time, then also execute ‘sudo aptitude update’ before installing lxr. And that ends the part about installing lxr. The compile-by-hand folks are just masochistic :).
Add the following lines to /etc/apache/httpd.conf at the end:
# Linux Cross Reference Stuff
Alias /lxr /usr/share/lxr
Create a file /usr/share/lxr/http/.htaccess which contains:
<Files ~ (search|source|ident|diff|find)$>
I now restart apache. Don’t know if this is essential, I guess reloading should be enough. But hey, this is my personal machine, no harm done :).
# /etc/init.d/apache restart
Since I only want to access the cross reference locally, I am not changing any settings in lxr.conf. At least, not yet. You can check /usr/share/doc/lxr/README.Debian.gz for more details.
Now we setup the cross reference.
1. Create /usr/share/lxr/source if it doesn’t exist.
2. Create a directory 2.6.22 inside it – this is the linux version I am cross referencing.
3. Untar the kernel source inside this directory in a subdirectory ‘linux’ .. i.e., you now have /usr/share/lxr/source/2.6.22/linux with the source in the linux directory.
4. Add a line with contents ‘2.6.22’ (without the single quotes) in /usr/share/lxr/source/versions
5. ln -s /usr/share/lxr/source/2.6.22 /usr/share/lxr/source/defversion
6. cd into /usr/share/lxr/source/2.6.22 and execute ‘genxref linux’
7. Make a cup of tea.
8. 10 minutes later (since you must never hurry a good cuppa) visit http://localhost/lxr/http/blurb.html
9. You’re done.
Note: I have not described how to setup the glimpse database, but that is documented in the lxr readme as well. You should read that anyway. Incidentally, generating the glimpse database would be step 8.a, just after the ‘genxref linux’.