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

3761 questions
829
votes
6 answers

What is the difference between the GNU Makefile variable assignments =, ?=, := and +=?

Can anybody give a clear explanation of how variable assignment really works in Makefiles. What is the difference between : VARIABLE = value VARIABLE ?= value VARIABLE := value VARIABLE += value I have read the section in GNU Make's manual,…
mmoris
  • 8,790
  • 3
  • 16
  • 12
391
votes
7 answers

How do I write the 'cd' command in a makefile?

For example, I have something like this in my makefile: all: cd some_directory But when I typed make I saw only 'cd some_directory', like in the echo command.
Davit Siradeghyan
  • 4,983
  • 5
  • 21
  • 28
307
votes
6 answers

Using CMake with GNU Make: How can I see the exact commands?

I use CMake with GNU Make and would like to see all commands exactly (for example how the compiler is executed, all the flags etc.). GNU make has --debug, but it does not seem to be that helpful are there any other options? Does CMake provide…
Nils
  • 12,129
  • 17
  • 78
  • 103
289
votes
15 answers

How to print out a variable in makefile

In my makefile, I have a variable 'NDK_PROJECT_PATH', my question is how can I print it out when it compiles? I read Make file echo displaying "$PATH" string and I tried: @echo $(NDK_PROJECT_PATH) @echo $(value NDK_PROJECT_PATH) Both gives me…
michael
  • 93,094
  • 111
  • 230
  • 334
243
votes
22 answers

How do you get the list of targets in a makefile?

I've used rake a bit (a Ruby make program), and it has an option to get a list of all the available targets, eg > rake --tasks rake db:charset # retrieve the charset for your data... rake db:collation # retrieve the collation for your…
Brian Burns
  • 14,953
  • 5
  • 69
  • 59
240
votes
4 answers

Define make variable at rule execution time

In my GNUmakefile, I would like to have a rule that uses a temporary directory. For example: out.tar: TMP := $(shell mktemp -d) echo hi $(TMP)/hi.txt tar -C $(TMP) cf $@ . rm -rf $(TMP) As written, the above rule creates…
Emil Sit
  • 21,140
  • 6
  • 49
  • 73
235
votes
12 answers

How to get current relative directory of your Makefile?

I have a several Makefiles in app specific directories like this: /project1/apps/app_typeA/Makefile /project1/apps/app_typeB/Makefile /project1/apps/app_typeC/Makefile Each Makefile includes a .inc file in this path one level…
boltup_im_coding
  • 5,337
  • 5
  • 35
  • 49
203
votes
2 answers

What do @, - and + do as prefixes to recipe lines in Make?

In the GNU Makefile manual, it mentions these prefixes. If .ONESHELL is provided, then only the first line of the recipe will be checked for the special prefix characters (‘@’, ‘-’, and ‘+’). What do these prefixes do, and where are they…
Matt Joiner
  • 100,604
  • 94
  • 332
  • 495
188
votes
7 answers

How can I configure my makefile for debug and release builds?

I have the following makefile for my project, and I'd like to configure it for release and debug builds. In my code, I have lots of #ifdef DEBUG macros in place, so it's simply a matter of setting this macro and adding the -g3 -gdwarf2 flags to the…
samoz
  • 51,592
  • 52
  • 138
  • 190
175
votes
10 answers

How to install and use "make" in Windows?

I'm following the instructions of someone whose repository I cloned to my machine. What I want is simple: to be able to use the make command as part of setting up the code environment. But I'm using Windows, and I searched online only to find a…
Hashem Elezabi
  • 1,893
  • 2
  • 9
  • 7
174
votes
2 answers

What does @: (at symbol colon) mean in a Makefile?

What does the following do in a Makefile? rule: $(deps) @: I can't seem to find this in the make manual.
cdwilson
  • 3,658
  • 4
  • 21
  • 29
142
votes
4 answers

Difference between CPPFLAGS and CXXFLAGS in GNU Make

What's the difference between CPPFLAGS and CXXFLAGS in GNU Make?
Paul Robinson
  • 6,790
  • 3
  • 33
  • 36
139
votes
4 answers

How to call Makefile from another Makefile?

I'm getting some unexpected results calling one makefile from another. I have two makefiles, one called /path/to/project/makefile and one called /path/to/project/gtest-1.4.0/make/Makefile. I'm attempting to have the former call the latter. In…
Chris Tonkinson
  • 12,213
  • 12
  • 52
  • 87
135
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,205
  • 3
  • 31
  • 38
124
votes
12 answers

Check if a program exists from a Makefile

How can I check if a program is callable from a Makefile? (That is, the program should exist in the path or otherwise be callable.) It could be used to check for which compiler is installed, for instance. E.g. something like this question, but…
Prof. Falken
  • 22,327
  • 18
  • 94
  • 163
1
2 3
99 100