Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

The following sections introduce some of the programming and project
management tools included with Ubuntu. If you have some previous UNIX
experience, you will be familiar with most of these programs because they are
traditional complements to a programmer’s suite of software.


Building Programs with make


You use the make command to automatically build and install a C program,
and for that use it is an easy tool. If you want to create your own automated
builds, however, you need to learn the special syntax that make uses; the
following sections walk you through a basic make setup.


Using Makefiles

The make command automatically builds and updates applications by using a
makefile. A makefile is a text file that contains instructions about which
options to pass on to the compiler preprocessor, the compiler, the assembler,
and the linker. The makefile also specifies, among other things, which source
code files have to be compiled (and the compiler command line) for a
particular code module and which code modules are needed to build the
program—a mechanism called dependency checking.


The beauty of the make command is its flexibility. You can use make with a
simple makefile, or you can write complex makefiles that contain numerous
macros, rules, or commands that work in a single directory or traverse your
file system recursively to build programs, update your system, and even
function as document management systems. The make command works with
nearly any program, including text processing systems such as TeX.


You could use make to compile, build, and install a software package, using a
simple command like this:


Click here to view code image
matthew@seymour:~$ sudo make install


You can use the default makefile (usually called Makefile, with a capital
M), or you can use make’s -f option to specify any makefile, such as
MyMakeFile, like this:


Click here to view code image
matthew@seymour:~$ sudo make -f MyMakeFile


Other options might be available, depending on the contents of your makefile.

Free download pdf