Make
make is a computer program to help to compile needed files automatically by parsing a make file and dealing with a program's dependencies on other software or files.
Other installation and configuration methods are used for programs without dependencies.
Although this is its most typical use, Make is also used in other programs as a way of defining what to do when something has changed, and thus triggering appropriate responses within the program.
Makefile utilities are frequently used to handle the compilation and/or installation of large pieces of software.
Make reads the makefile at current working directory by default, which is a common practice among computer programmers.
It can be used to compile only certain subsets of an item or suite of software, and can account for dependencies between various parts of the software.
Its input is a list of specifications (usually known as a makefile) describing dependency relationships between the generation of files and programs.
Make has its roots in Unix. Since it is old, many derived tools have appeared that work better. Among these are BSD make, GNU make and A-A-P.
The file commonly is maintained in the base directory of a project during the development process. This file lists all of the files in the project and describes the action that needed to be taken on that file to create it or bring it up to date.
The Makefile is used by the command 'make'.
The 'make' program has some intelligence built in and will not attempt to re-make files that are not out of date.
For example it will typically not recompile source that has not changed since its last compile (determined by comparison of dates of files).
A Makefile consists of commands like this:
foo.o: foo.c foo.h bar.h
gcc -o foo.o foo.c
logobig.ppm: logo.pov
$(POVRAY) logo.pov -k0 -o logobig.ppm
The first command means that if foo.c, foo.h, or bar.h is newer than foo.o, then foo.o should be remade by running gcc. foo.o is said to depend on foo.c, foo.h, and bar.h.
The second says that logobig.ppm depends on logo.pov and can be made by running POV-Ray.
Most Makefiles are used to compile programs, but they can be used in any situation where files are made from one another by programs that can be called from the command line.
A sample makefile
# Specify compiler
CC = g++
# Specify compiler options
CFLAGS = -g
LDFLAGS = -L/usr/openwin/lib
LDLIBS = -lX11 -lXext
# Needed to recognize .cpp as a file suffix
.SUFFIXES: $(SUFFIXES) .cpp
# Executable name
PROG = life
# List of object file needed for the final program
OBJS = main.o window.o Board.o Life.o BoundedBoard.o
all: $(PROG)
# Program compilation and linking steps
$(PROG): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $(PROG) $(OBJS)
.cpp.o:
$(CC) $(CFLAGS) -c $*.cpp
Obtaining Make
GNU/Linux users should utilize the directory at http://www.gnu.org/directory/.
Cygwin users should consult their administrator for more information. Individual users without an administrator should consult the Cygwin package search on the cygwin website at www.cygwin.com.
What's wrong with Make
Some people feel that Make is broken.
Some reasons include:
- Make doesn't scale up to projects well, often encouraging use of recursive makefiles: - Recursive Make considered harmful.]
- Make's support for target configuration is extremely poor and implemented via global variables. This means that only one configuration exists and there can be no per-target configuration. It also means that targets cannot configure their subtargets, requiring a "fork" of an entire target tree whenever a target at the bottom of the tree needs to be configured in a different way.
- Make's lack of support for configuration-depency management. When configuration changes, make does not know it needs to rebuild things.
- Make's lack of cache for builds: When changing configurations back and forth, make will rebuild again and again. This can be addressed by installing - CCache] but that only addresses very specific target-assembly types and is slower.
- Make's lack of command-line abstraction: Configuration is given as specific command line options. Rules are written as specific-tool invocations. This makes Makefiles platform-dependant and even specific-tool dependant.
Other versions of Make
- cmake is a portable makefile utility. It requires the Cmake lists file to be present and does not seem at present to support the diving makefile concept. You must specify the path "." even if it is the current directory. Example:
cmake [space] . to specify the current directory.
- SCons: Improved, cross-platform build system which is implemented using Python, which integrates some features of Automake/Autoconf. Its strength is that the 'makefiles' (which are generically called "SConscript" files; the top-level one is named "SConstruct") can use all the features of the Python programming language. See http://www.scons.org/.
See also
External links
Referenced By
Jakarta Ant | List of basic software engineering topics | List of software engineering topics
|