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
53
votes
5 answers

why "make" before "make install"

I know the process of installing from source are. ./configure make make install But why "make" before /etc/cups/cupsd.conf, why not just do "make install"? My understanding so far is "make" only compile the source into executable file, and "make…
aggressionexp
  • 690
  • 1
  • 5
  • 10
52
votes
5 answers

Order of processing components in makefile

In a makefile, the dependency line is of the form - abc: x y z All three of the components (x,y,z) are themselves targets in dependency lines further down in the makefile. If make abc is invoked, in what order will the three targets x,y,z be…
Shailesh Tainwala
  • 6,299
  • 12
  • 58
  • 69
52
votes
2 answers

Functions in Makefile

I am writing a Makefile with a lot of repetitive stuff, e.g. debug_ifort_Linux: if [ $(UNAME) = Linux ]; then \ $(MAKE) FC=ifort FFLAGS=$(difort) PETSC_FFLAGS="..." \ TARGET=$@…
Karl Yngve Lervåg
  • 1,714
  • 3
  • 18
  • 34
52
votes
2 answers

How can I capture the current directory as an absolute pathname in a make variable?

I'd like to get the current directory during a GNUmake file run put into a make variable. What is the syntax to do this? Something like this? DIR := $(PWD)
WilliamKF
  • 41,123
  • 68
  • 193
  • 295
50
votes
5 answers

What are double-colon rules in a Makefile for?

Section 4.13 of the GNU Make manual describes the so-called double-colon rules: Double-colon rules are rules written with ‘::’ instead of ‘:’ after the target names. They are handled differently from ordinary rules when the same target appears in…
lindelof
  • 34,556
  • 31
  • 99
  • 140
50
votes
4 answers

Error in make command makefile:18: *** missing separator. Stop

For the following make file copied below, I am getting the missing separator error. Nothing seems to be wrong with the tabspace. OBJS = driver.o snapshot.o SHOBJS = malloc.o mymemory.o CC = g++ DEBUG = -g CFLAGS = -Wall -c $(DEBUG) LFLAGS = -Wall…
subramanian
  • 1,005
  • 2
  • 11
  • 21
49
votes
1 answer

GNU makefile how to and when to quote strings

How and when do I quote a string in a make file? What is best practice? Is the following the way to quote? $(warning $(shell ls -ld "$(CURDIR)" ) ) I'm familiar with Bash where you usually quote variables to allow for embedded spaces. Do you do…
historystamp
  • 1,418
  • 4
  • 14
  • 24
49
votes
1 answer

read input variable in makefile and set variable upon it`s name

I have a makefile where I want to read module name from input and then make directory based on it`s name. here is my code: build: @read -p "Enter Module Name:" module; module_dir=./modules/$$module mkdir -p $$module_dir/build; …
armezit
  • 649
  • 1
  • 7
  • 20
48
votes
3 answers

How to manually call another target from a make target?

I would like to have a makefile like this: cudaLib : # Create shared library with nvcc ocelotLib : # Create shared library for gpuocelot build-cuda : cudaLib make build build-ocelot : ocelotLib make build build : # build and…
Simon A. Eugster
  • 4,114
  • 4
  • 36
  • 31
47
votes
3 answers

Should I name "makefile" or "Makefile"?

Although both names will do the job, what is the correct name for makefiles? GNU `make' homepage uses Makefile, and I guess it is the good way to name it. Any reasons for typing the front M in upper case ?
Benny
  • 4,095
  • 1
  • 26
  • 27
46
votes
2 answers

Change a make variable, and call another rule, from a recipe in same Makefile?

I have already seen How to manually call another target from a make target?, but my question is a bit different; consider this example (note, stackoverflow.com changes the tabs to spaces in display; but tabs are preserved in source, if you try to…
sdaau
  • 36,975
  • 46
  • 198
  • 278
46
votes
3 answers

How to automate the correctness-checking of makefiles?

I know there are many linters for programming languages, like pep8 for python, but I have never come across one for a makefile. Are there any such linters for makefiles? Any other ways to programmatically detect errors or problems in makefiles…
msakya
  • 9,311
  • 5
  • 23
  • 31
44
votes
2 answers

Makefile ifeq logical AND

I would like to check multiple conditions in an if loop of GNU make file. Here's an example: ifeq ($(TEST_FLAG),TRUE && ($(DEBUG_FLAG),FALSE)) true statement else false statement endif What's the right way to do it?
Arun Kumar
  • 441
  • 1
  • 4
  • 6
43
votes
2 answers

Can't assign variable inside recipe

How do I make this work? It errors out with "make: somevariable: Command not found" sometarget: somevariable = somevalue Full example: CXXFLAGS = -I/usr/include/test -shared -fPIC OBJ = main.o Server.o blabla : $(OBJ) ifeq ($(argsexec),true)…
Blub
  • 13,014
  • 18
  • 75
  • 102
43
votes
2 answers

Difference between Cmake, gnu make and manually compiling

I'm new to programming so this is a more of a abstract question than a technical one. I've been using IDE's to learn but I heard they tend to oversimplify the act of compiling,assembling and linking when creating an executable file. I'm trying to…
kristhedemented
  • 531
  • 1
  • 4
  • 4