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
946
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
  • 9,970
  • 3
  • 18
  • 12
491
votes
8 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
  • 6,053
  • 6
  • 24
  • 29
366
votes
14 answers

How to install and use "make" in Windows?

I'm following the instructions of someone whose repository I cloned to my machine. I want to use the make command as part of setting up the code environment, but I'm using Windows. I searched online, but I could only find a make.exe file, a…
Hashem Elezabi
  • 3,827
  • 3
  • 12
  • 7
360
votes
16 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
  • 106,540
  • 116
  • 246
  • 346
350
votes
8 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
  • 13,319
  • 19
  • 86
  • 108
317
votes
28 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
  • 20,575
  • 8
  • 83
  • 77
310
votes
14 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
  • 6,345
  • 6
  • 40
  • 52
287
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
  • 22,894
  • 7
  • 53
  • 75
255
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
  • 112,946
  • 110
  • 377
  • 526
230
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
  • 4,310
  • 4
  • 26
  • 32
209
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
  • 56,849
  • 55
  • 141
  • 195
191
votes
7 answers

What's the difference between := and = in Makefile?

For variable assignment in Make, I see := and = operator. What's the difference between them?
prosseek
  • 182,215
  • 215
  • 566
  • 871
159
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
  • 13,823
  • 14
  • 58
  • 90
156
votes
14 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
  • 24,226
  • 19
  • 100
  • 173
156
votes
4 answers

Difference between CPPFLAGS and CXXFLAGS in GNU Make

What's the difference between CPPFLAGS and CXXFLAGS in GNU Make?
elasticrat
  • 7,060
  • 5
  • 36
  • 36
1
2 3
99 100