MAKE(1)

๐Ÿ“ฆ
version 4.4.1 ยท 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

โœจ 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 directory dir before reading the makefiles or doing anything else. If you pass several -C options, each one is read relative to the one before it, so -C / -C etc is 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 out FLAGS, it behaves exactly like -d. FLAGS can be any mix of the following names, separated by commas or spaces. Only the first character matters, so the rest can be dropped:
    • all for all debugging output (same as -d) ๐ŸŒˆ
    • basic for basic debugging ๐Ÿ“
    • verbose for more verbose basic debugging ๐Ÿ“ฃ
    • implicit for showing implicit rule search operations ๐Ÿ”
    • jobs for details on how commands are invoked ๐Ÿงš
    • makefile for debugging while remaking makefiles ๐Ÿ› ๏ธ
    • print shows every recipe that runs, even the silent ones ๐Ÿคซ
    • why shows the reason make decided to rebuild each target ๐Ÿ’ญ
    • none turns 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 โ€” runs string through the eval function before any makefiles get parsed ๐Ÿช„
  • -f file, --file=file, --makefile=FILE โ€” uses file as 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 directory dir to search for included makefiles. If you use several -I options, the directories get searched in the order you gave them. Unlike the arguments to other make flags, directories given with -I can come right after the flag, so -Idir works as well as -I dir. This is allowed so it matches the -I flag 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 -j with no number, make won't limit how many jobs run at once ๐ŸŽ๏ธโœจ
  • --jobserver-style=style โ€” picks the jobserver style to use. style can be fifo, pipe, or sem (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 least load (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 remake file, even if it's older than its dependencies, and doesn't remake anything just because file changed. Basically file gets 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, or type is target: the whole recipe for each target gets grouped together ๐ŸŽ€
    • type is line: the output from each command line in a recipe gets grouped together ๐Ÿ“
    • type is recurse: the output from an entire recursive make gets grouped together ๐Ÿ”
    • type is none: output synchronization is turned off ๐Ÿ™…โ€โ™€๏ธ
  • -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 -v switch (see below). If you want to print the data base without remaking any files, use make -p -f/dev/null ๐Ÿ—ƒ๏ธ๐Ÿ’…
โš ๏ธ the next batch of options (-q and friends) is coming up in part 2, bestie, so stay tuned ๐Ÿ’œ๐Ÿงš

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