Skip to content
Search

Make

lastmod 2024-12-17created 2014-10-1740 edits

(For the automation platform, see Make (Automation Platform).)

make is a program build tool used in software development, mainly on Unix-like operating systems. By defining the dependencies between files and the commands each file needs, it can compile programs, and it has a standard syntax for describing the process of producing the final program. Make interprets a file written in this structure (usually named Makefile) and performs the program build.

Category

Options

-d
Prints Debugging Messages. Same as --debug=a.
-C [dir]
Changes the Directory to run in.
-f [file]
Specifies the path of the Makefile to use.
-j N
Runs N jobs in parallel. Similar to parallel.
-t
Use the -t option when you want to update the creation date without recompiling files. The option stands for Touch: instead of compiling, it only updates the files' creation date to the current time.
--debug[=options]
Prints debugging information. The options are as follows.
  • a (all) All types of debugging output are enabled. This is equivalent to using ‘-d’.
  • b (basic) Basic debugging prints each target that was found to be out-of-date, and whether the build was successful or not.
  • v (verbose) A level above ‘basic’; includes messages about which makefiles were parsed, prerequisites that did not need to be rebuilt, etc. This option also enables ‘basic’ messages.
  • i (implicit) Prints messages describing the implicit rule searches for each target. This option also enables ‘basic’ messages.
  • j (jobs) Prints messages giving details on the invocation of specific subcommands.
  • m (makefile) By default, the above messages are not enabled while trying to remake the makefiles. This option enables messages while rebuilding makefiles, too. Note that the ‘all’ option does enable this option. This option also enables ‘basic’ messages.
--print-data-base or -p
Print make's internal database.
--trace
Flag not available on macOS (Darwin version, i386-apple-darwin11.3.0).

Error code

make's exit codes are as follows.

  • 0: Exit status is 'Successful'
  • 2: Make Encountered Errors
  • 1: Return response to -q (question) flag, indicating that targets require updating

Basic

The basic structure of Make is a continuous list of basic rules, each made up of three parts: target, dependency, and command. The encoding must be ANSI, and the command part must start with a TAB character. The basic form is as follows.

<target>: <dependency>
    <command>
$ make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}' | sort -u | uniq

Operators

:=
Keeps storing a command once it has been given.
+=
Appends to the assignment.
?=
Does not change the macro if it is already set.

File include

To include another Makefile, use include as follows.

include config

DirectorySearch

If a file listed as a target or prerequisite does not exist in the current directory, make searches the directories in VPATH. The syntax is as follows. A colon (:) is used as the separator.

VPATH = <PATH1>:<PATH2>:<PATH3>:...

Multiline

If a command runs longer than one line, you can split it across several lines with the \ character. Think of the preprocessor in the C language.

OBJS = shape.o \
    rectangle.o \
    circle.o \
    line.o

See also

Favorite site

References


  1. Gnu-software-make.zip ↩

  2. Viper.pe.kr-make-ko.7z ↩

  3. Auto-Dependency_Generation-GNU_make.pdf ↩

author Zer0 sitemap