Questions tagged [gnu-make]

This tag is for questions about `gmake`, the GNU version of the `make` utility to maintain and update programs.

GNU Make is the GNU implementation of the Make utility. It is probably the most common version in use today.

GNU Make supports extensions to the Make language beyond the POSIX standard, therefore GNU Make solutions may not work under other versions, so the gnu-make tag is appropriate for questions from those using GNU Make, or pertaining to makefiles written for it.

Documentation

The latest GNU Make manual can be found in several formats here.

See also

make makefile

4424 questions
152
votes
4 answers

What is the difference between gmake and make?

I am trying to understand the difference between 'gmake' and 'make'? On my linux box they are identical: % gmake --version GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying…
Nick Haddad
  • 8,767
  • 3
  • 34
  • 38
115
votes
7 answers

Recursive wildcards in GNU make?

It's been a while since I've used make, so bear with me... I've got a directory, flac, containing .FLAC files. I've got a corresponding directory, mp3 containing MP3 files. If a FLAC file is newer than the corresponding MP3 file (or the…
Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380
109
votes
10 answers

GNU make: should the number of jobs equal the number of CPU cores in a system?

There seems to be some controversy on whether the number of jobs in GNU make is supposed to be equal to the number of cores, or if you can optimize the build time by adding one extra job that can be queued up while the others "work". Is it better to…
Johan
  • 20,067
  • 28
  • 92
  • 110
104
votes
1 answer

How to change the extension of each file in a list with multiple extensions in GNU make?

In a GNU makefile, I am wondering if it is possible, with an file list input, to make a file list output with new extensions. In input, I get this list: FILES_IN=file1.doc file2.xls And I would like to build this variable in my makefile from…
TheFrancisOne
  • 2,667
  • 9
  • 38
  • 58
101
votes
7 answers

How to use GNU Make on Windows?

I installed MinGW and MSYS, added C:\MinGW\bin to PATH but I still can't run Makefile on Windows' cmd. I would like to run cmd.exe and there type, for example, make all but my cmd says that there is no such command. What should I do? I don't want…
yak
  • 3,770
  • 19
  • 60
  • 111
100
votes
16 answers

List goals/targets in GNU make that contain variables in their definition

I have a fairly large makefile that creates a number of targets on the fly by computing names from variables. (eg foo$(VAR) : $(PREREQS)). Is there any way that gnu make can be convinced to spit out a list of targets after it has expanded these…
BitShifter
  • 1,208
  • 2
  • 10
  • 9
97
votes
3 answers

Remove item from a Makefile variable?

I have a makefile, which includes several other makefiles, which in turn all add to a variable like this: VAR := Something SomethingElse VAR += SomeOtherThing (...) Now I wish to remove SomethingElse from the VAR variable. What do I put in place…
Bjarke Freund-Hansen
  • 28,728
  • 25
  • 92
  • 135
93
votes
1 answer

Makefile - missing separator

Possible Duplicate: Make error: missing separator Have this code in makefile: PROG = semsearch all: $(PROG) %: %.c gcc -o $@ $< -lpthread clean: rm $(PROG) and the error missing separator. stop. Can someone help me?
user1827257
  • 1,600
  • 4
  • 17
  • 24
91
votes
1 answer

:= vs = in make macros

Possible Duplicate: What is the difference between the GNU Makefile variable assignments =, ?=, := and +=? I only know very basic makefile syntax, and was reading through another project's makefile and came across := for macro declaration. Why…
Aaron Yodaiken
  • 19,163
  • 32
  • 103
  • 184
89
votes
9 answers

Run make in each subdirectory

I have a directory (root_dir), that contains a number of sub-directories (subdir1, subdir2, ...). I want to run the make in each directory in root_dir, using a Makefile placed in it. (Obviously supposed that each of subdir... has inside its own…
Alex
  • 9,891
  • 11
  • 53
  • 87
82
votes
9 answers

How to place object files in separate subdirectory

I'm having trouble with trying to use make to place object files in a separate subdirectory, probably a very basic technique. I have tried to use the information in this…
RussellG
  • 1,075
  • 1
  • 9
  • 9
82
votes
4 answers

Making CMake print commands before executing

I'm working on a large C++ project built with CMake on Linux. CMake runs okay, producing a horde of Makefiles in the tree of modules and applications. Running GNU make leads to linker errors. How can I get make to print out the exact commands…
DarenW
  • 16,549
  • 7
  • 63
  • 102
82
votes
7 answers

Debugging GNU make

Is there a command line way in make to find out which of the prerequisites of a target is not updated?
mithuna
  • 1,011
  • 1
  • 9
  • 9
80
votes
3 answers

How to force an error in a gnumake file

I want to detect a condition in my makefile where a tool is the wrong version and force the make to fail with an error message indicating the item is not the right version. Can anyone give an example of doing this? I tried the following but it is…
WilliamKF
  • 41,123
  • 68
  • 193
  • 295
75
votes
4 answers

Append to GNU make variables via command line

I am using a GNU-make Makefile to build a C project with several targets (all, clean, and a few project specific targets). In the process of debugging, I would like to append some flags to a single build without permanently editing the Makefile…
Michael Koval
  • 8,207
  • 5
  • 42
  • 53