Skip to Content
Running Linux, Third Edition
book

Running Linux, Third Edition

by Matthias Kalle Dalheimer, Lar Kaufman, Matt Welsh
August 1999
Beginner
760 pages
23h 55m
English
O'Reilly Media, Inc.
Content preview from Running Linux, Third Edition

Makefiles

Sometime during your life with Linux you will probably have to deal with make, even if you don’t plan to do any programming. It’s likely you’ll want to patch and rebuild the kernel and that involves running make. If you’re lucky, you won’t have to muck with the makefiles—but we’ve tried to direct this book toward unlucky people as well. So in this section, we’ll explain enough of the subtle syntax of make so that you’re not intimidated by a makefile.

For some of our examples, we’ll draw on the current makefile for the Linux kernel. It exploits a lot of extensions in the powerful GNU version of make, so we’ll describe some of those as well as the standard make features. A good introduction to make is provided in Managing Projects with make by Andrew Oram and Steve Talbott. GNU extensions are well documented by the GNU make manual.

Most users see make as a way to build object files and libraries from sources and to build executables from object files. More conceptually, make is a general-purpose program that builds targets from prerequisites. The target can be a program executable, a PostScript document, or whatever. The prerequisites can be C code, a text file, and so on.

While you can write simple shell scripts to execute gcc commands that build an executable program, make is special in that it knows which targets need to be rebuilt and which don’t. An object file needs to be recompiled only if its corresponding source has changed.

For example, say you have a program ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Running Linux, 5th Edition

Running Linux, 5th Edition

Matthias Kalle Dalheimer, Matt Welsh
Linux Under the Hood

Linux Under the Hood

Sander van Vugt

Publisher Resources

ISBN: 156592469XCatalog PageErrata