MAKE(1)
โจ MAKE(1) โจ
๐ This page is filed under User Commands ๐
๐ธ NAME ๐ธ
make - GNU Make utility to maintain groups of programs ๐
๐ฆ SYNOPSIS ๐ฆ
make [OPTION]... [TARGET]...
๐ DESCRIPTION ๐
okay so make is literally the utility that figures out which bits of a big program need recompiling and then goes and does it for you ๐ญโจ it's giving automation, bestie.
This manual describes the GNU version of make. It was written by Richard Stallman and Roland McGrath, and it's currently looked after by Paul Smith ๐ซถ The examples use C programs because C is everywhere, but make works with any language whose compiler can be run from a shell command. ngl make isn't even only for programs. You can use it for any task where some files need updating from other files whenever those others change ๐ง
To get started, you write a file called the makefile. This file describes how the files in your program relate to each other, and it includes the commands for updating each one. In a typical program, the executable gets updated from object files, and those object files get made by compiling source files ๐ฅ
Once you have a decent makefile, every time you change some source files you just type this simple shell command:
make
and boom, all the necessary recompilations happen ๐ make uses the makefile plus the last-modification times of the files to work out which ones need updating. For each of those, it runs the commands recorded in the makefile. iconic behaviour, honestly ๐
make runs the commands in the makefile to update one or more targets, and a target is usually a program. If there's no -f option, make goes looking for the makefiles GNUmakefile, makefile, and Makefile, in that order ๐ฆ
Normally you should name your makefile either makefile or Makefile. I'm team Makefile because it shows up right near the top of a directory listing, next to other important stuff like README โจ The first name checked, GNUmakefile, is not recommended for most makefiles. Only use that name if your makefile is specific to GNU Make and other versions of make wouldn't understand it ๐ If the makefile is -, make reads from the standard input.
make updates a target when it depends on prerequisite files that have been modified since the target was last modified, or when the target doesn't exist at all ๐
๐ OPTIONS ๐
-b,-mโ these are ignored, just there for compatibility with other versions of make ๐ซถ-B,--always-makeโ makes every target, no questions asked ๐-C dir,--directory=dirโ switches to the directorydirbefore reading the makefiles or doing anything else. If you pass several-Coptions, each one is read relative to the one before it, so-C / -C etcis the same as-C /etc๐บ๏ธ This is usually used when make calls itself recursively ๐-dโ prints debugging info alongside the normal stuff. The debugging info tells you which files are being considered for remaking, which file-times are being compared and what those comparisons come out to, which files actually need remaking, and which implicit rules get considered and which ones get applied. literally everything interesting about how make decides what to do ๐ต๏ธโโ๏ธ๐--debug[=FLAGS]โ also prints debugging info alongside normal processing. If you leave outFLAGS, it behaves exactly like-d.FLAGScan be any mix of the following names, separated by commas or spaces. Only the first character matters, so the rest can be dropped:allfor all debugging output (same as-d) ๐basicfor basic debugging ๐verbosefor more verbose basic debugging ๐ฃimplicitfor showing implicit rule search operations ๐jobsfor details on how commands are invoked ๐งmakefilefor debugging while remaking makefiles ๐ ๏ธprintshows every recipe that runs, even the silent ones ๐คซwhyshows the reason make decided to rebuild each target ๐ญnoneturns off all the debugging flags you set before it ๐ โโ๏ธ
-e,--environment-overridesโ gives variables from the environment priority over variables set in makefiles ๐ฟ-E string,--eval stringโ runsstringthrough the eval function before any makefiles get parsed ๐ช-f file,--file=file,--makefile=FILEโ usesfileas the makefile ๐-i,--ignore-errorsโ ignores all errors from the commands run while remaking files. chaotic, but sometimes that's the vibe ๐-I dir,--include-dir=dirโ names a directorydirto search for included makefiles. If you use several-Ioptions, the directories get searched in the order you gave them. Unlike the arguments to other make flags, directories given with-Ican come right after the flag, so-Idirworks as well as-I dir. This is allowed so it matches the-Iflag of the C preprocessor ๐-j [jobs],--jobs[=jobs]โ sets how many jobs (commands) can run at the same time. If you give more than one-j, the last one is the one that counts. If you give-jwith no number, make won't limit how many jobs run at once ๐๏ธโจ--jobserver-style=styleโ picks the jobserver style to use.stylecan befifo,pipe, orsem(Windows only) ๐ช-k,--keep-goingโ keeps going as far as possible after an error. The target that failed, plus anything depending on it, can't be remade, but the other dependencies of those targets still get processed ๐ฆ-l [load],--load-average[=load]โ says no new jobs (commands) should start if other jobs are already running and the load average is at leastload(a floating-point number). With no argument, it removes any load limit you set before ๐ก๏ธ-L,--check-symlink-timesโ uses the latest mtime between the symlinks and the target ๐-n,--just-print,--dry-run,--reconโ prints the commands that would run, but doesn't actually run them (except in certain circumstances ๐) ๐ฎ-o file,--old-file=file,--assume-old=fileโ doesn't remakefile, even if it's older than its dependencies, and doesn't remake anything just becausefilechanged. Basicallyfilegets treated as super old and its rules get ignored ๐ง-O[type],--output-sync[=type]โ when you're running several jobs in parallel with-j, this keeps each job's output collected together instead of mixed in with everyone else's ๐ง- no
type, ortypeistarget: the whole recipe for each target gets grouped together ๐ typeisline: the output from each command line in a recipe gets grouped together ๐typeisrecurse: the output from an entire recursive make gets grouped together ๐typeisnone: output synchronization is turned off ๐ โโ๏ธ
- no
-p,--print-data-baseโ prints the data base (the rules and variable values) you get from reading the makefiles, and then carries on executing as usual or however else you specified. This also prints the version information you'd get with the-vswitch (see below). If you want to print the data base without remaking any files, usemake -p -f/dev/null๐๏ธ๐
โ ๏ธ the next batch of options (-q and friends) is coming up in part 2, bestie, so stay tuned ๐๐ง
โจ COPYRIGHT โจ
okay so bestie, the legal stuff matters too ๐ Copyright ยฉ 1992-1993, 1996-2023 Free Software Foundation, Inc. This file is part of GNU Make. ๐
GNU Make is free software, so you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. Pick either version 3 of the License, or (at your option) any later version. It's giving freedom ๐ฆ
GNU Make is distributed in the hope that it'll be useful, but WITHOUT ANY WARRANTY ๐ญ that means no guarantee at all, not even the implied kind of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For the full tea, check out the GNU General Public License. ๐ซถ
You should have received a copy of the GNU General Public License along with this program. If you didn't, go see https://www.gnu.org/licenses/ โจ
GNU ๐ธ 26 May 2023 ๐ธ MAKE(1)
Source: GNU Make, dated 26 May 2023. Bye bestie, go make some magic ๐ง๐
๐ฆ where this page comes from
- alpine 3.22: make-doc 4.4.1-r3 ยท GPL-3.0-or-later
- alpine 3.23: make-doc 4.4.1-r3 ยท GPL-3.0-or-later
- alpine 3.24: make-doc 4.4.1-r4 ยท GPL-3.0-or-later
- arch rolling: make 4.4.1-3 ยท GPL3
- centos-stream 10: make 1:4.4.1-9.el10 ยท GPL-3.0-or-later AND LGPL-2.1-or-later AND GFDL-1.3-or-later AND FSFULLR
- centos-stream 9: make441 1:4.4.1-3.el9 ยท GPLv3+
- debian trixie: make 4.4.1-2 ยท GPL-3.0-or-later
- debian trixie: make-guile 4.4.1-2 ยท GPL-3.0-or-later
- fedora 43: make 1:4.4.1-11.fc43 ยท GPL-3.0-or-later AND LGPL-2.1-or-later AND GFDL-1.3-or-later AND FSFULLR
- fedora 44: make 1:4.4.1-12.fc44 ยท GPL-3.0-or-later AND LGPL-2.1-or-later AND GFDL-1.3-or-later AND FSFULLR
- nixos 26.05: gnumake-musl 4.4.1
- nixos 26.05: gnumake-static 4.4.1
- nixpkgs unstable: gnumake 4.4.1
- nixpkgs unstable: gnumake-musl 4.4.1
- opensuse-leap 16.0: make 4.4.1-160000.3.2 ยท GPL-3.0-or-later
- opensuse-leap 16.0: make 4.4.1-160000.3.2 ยท GPL-3.0-or-later
- opensuse-leap 16.0: make 4.4.1-160000.3.2 ยท GPL-3.0-or-later
- opensuse-leap 16.0: make 4.4.1-160000.3.2 ยท GPL-3.0-or-later
- ubuntu questing: make 4.4.1-2 ยท GPL-3.0-or-later
- ubuntu questing: make-guile 4.4.1-2
- ubuntu resolute: make 4.4.1-3 ยท GPL-3.0-or-later
- ubuntu resolute: make-guile 4.4.1-3 ยท GPL-3.0-or-later
- ubuntu stonking: make 4.4.1-3 ยท GPL-3.0-or-later
- ubuntu stonking: make-guile 4.4.1-3 ยท GPL-3.0-or-later
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms