|
How to Compile the ExamplesThis page explains how to compile the examples using some simple makefiles. The method used here is inappropriate for most software development, mainly because the makefiles don't describe all the dependencies. But, it's a fairly simple method that will at least get you started. Each source directory that contains C code (other than ux) contains a file named makebuild.spec. Here's the file in c1, the directory for Chapter 1:
The file resembles a makefile, in that each line starts with the name of an executable followed by the source files that need to be compiled to create it. Some lines, like the one for ckvers, have compiler options. (The language used in a makebuild.spec is my own invention, not something you'll find elsewhere.) You'll have to modify the makebuild.spec in the common directory (referred to by the first line) for your system; more on that below. To get an actual makefile, you process a makebuild.spec file with an Awk script. To see it, click here. To download it to your machine, right click on the link and choose "Save Link As" or "Save Target As" or whatever your browser calls it. You run the Awk script, named makebuild.awk, with a shell command file that looks like this:
AUPSRC is the location of the source tree; if you've downloaded it to, say, /usr/marc/aupsrc, you would change the line to:
If you've named the command file makebuild, you would run it like this to build the makefile for directory c1:
As I mentioned, you may need to change the makebuild.spec file in the common directory, the start of which looks like this when you first download it:
The stuff in the comments about OS, LIBS, TLIBS, PTHREADSTUB, and INCLUDES applies when you run make--it has nothing to do with running the Awk script that creates the makefile. What you may have to change in common/makebuild.spec are the last four lines shown. (The line for CFLAGS may have been wrapped by your browser, but in the makebuild.spec file it must be on one line.) When you've made the necessary changes, run the makebuild script (shown above) to get a makefile. To see the one I got for directory c1 on my FreeBSD system, which happens to be the one in the download archive, click here. Now, as I said, to run the makefile you need to specify some environment variables, which you can either do permanently by changing whatever profile executes when you log in, or every time you execute make, which is what I do. On FreeBSD, I use a this command file named k:
So, to compile the example program c1/timetst, I run this:
For threading examples (in Chapter 5), I have a similar command file named kt:
(Which is not to imply that the FreeBSD implementation of linuxthreads actually works; see Section 5.17 of the book.) My Linux version of k looks like this:
You'll probably want to run your k and kt commands from a working directory different from where the source is. They're set up to do that. I usually work in a directory called something like /usr/marc/aup (where my k and kt files are), whereas the source is rooted at /aup, which is mounted (always as /aup) on several machines. If you set up common/makebuild.spec and your compiling command file for any other systems, please email them to me so I can post them here for others to use. The code on this page is Open Source, covered by this license. |