pavement

Make

From FreeBSDwiki
Revision as of 13:20, 16 October 2007 by 80.73.220.216 (Talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

make is, to quote the GNU make page,

Make is a tool which controls the generation of executables and other 
non-source files of a program from the program's source files.

Make gets its knowledge of how to build your program from a file called 
the makefile, which lists each of the non-source files and how to compute 
it from other files. When you write a program, you should write a makefile 
for it, so that it is possible to use Make to build and install the program. 

Which roughly means that it helps you compile stuff easily, if the proper makefile has been created. The directories in ports all have at least one thing in common: they all have a makefile that helps the building and installation of the port. A makefile will have "targets" which tell make to do different things depending on what target you specify. For example, running

make

by itself runs the makefile's build options, running

make install

will run the make command against the "install" target in the makefile and do what it says, which is usually installing the port and registering it against the FreeBSD package database, and running

make clean

will run it through the "clean" target in the makefile, which normally does cleanup stuff (like emptying out the particular port's "workdir", where temporary files are put during the compile and install of the port.)

Some ports will present a screen containing various optional components that can be selected (or deselected) when make is run. A good example of such a port is Samba that presents options to add support for LDAP, Active Directory, CUPS, WINBIND, ACLs as well as other Samba specific features. Once the options have been selected the choices are noted into a file that make continues to use during compiling. Running make again later will use these saved settings and not bring up the configuration screen. To force the option screen to display run either

make config

or to remove the saved configuration altogether (and thereby revert to the default options) run

make rmconfig
make

Thanks in no small part to the makefile (and the FreeBSD maintainers who take care of the ports tree) make is usually "smart" enough to know that when you type in

make install clean

all in one go, you're really asking to do

make
make install
make clean

which is functionally the same as

make && make install && make clean

FreeBSD's use of make can be customized further by putting the make.conf file to good use.

See the GNU make page for more info.

Personal tools