Questions tagged [makefile]

A makefile is an input file for the build control language/tool make. It specifies targets and dependencies along with associated commands to perform (a.k.a. recipes) to update the targets.

A makefile is usually an input file for the build control language/tool make. The make utility and the corresponding makefile format is standardized by POSIX.

Common newbie mistakes:

Makefile variable assignment error in echo - running two distinct commands in a recipe and not realizing the shell from the first will exit and lose any changes to the environment.

Make implementations

More information

25125 questions
53
votes
1 answer

makefile: how to add a prefix to the basename?

I have a list of file path like that: FILE_PATH := a1.so a2.so bla/a3.so bla/a3.so bla/blo/a4.so.... I need to add a prefix to the basename in order to get: FILE_PATH_PREFIXED := liba1.so liba2.so bla/liba3.so bla/liba3.so bla/blo/liba4.so.... any…
dm76
  • 4,130
  • 8
  • 35
  • 46
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
51
votes
10 answers

Is there a good tool for Makefile generation?

I'm looking for a tool which can generate a Makefile for a C/C++ project for different compilers (GCC, Microsoft Visual C++, C++Builder, etc.) and different platforms (Windows, Linux, and Mac).
Serge
  • 7,706
  • 5
  • 40
  • 46
51
votes
5 answers

Common GNU makefile directory path

I'm trying to consolidate some build information by using a common makefile. My problem is that I want to use that makefile from different subdirectory levels, which makes the working directory value (pwd) unpredictable. For example: #…
cdleary
  • 69,512
  • 53
  • 163
  • 191
51
votes
3 answers

Assign a makefile variable value to a bash command result?

I'm trying to assign the output of this command ( that is in my makefile ) to the makefile HEADER var like in this following line of code: HEADER = $(shell for file in `find . -name *.h`;do echo $file; done) The problem is that if I print HEADER in…
Goles
  • 11,599
  • 22
  • 79
  • 140
51
votes
2 answers

How to NOT print in the output a comment in a makefile

I have a makefile that is like this: install: @somecommand #some explanation for next command @lastcommand What happens is that the comment #some explanation for next command is being printed when I execute make install. How can I make…
knocte
  • 16,941
  • 11
  • 79
  • 125
51
votes
13 answers

Program "make" not found in PATH

I'm having the Program "make" not found in PATH error in eclipse. I checked the path variable which is: C:\cygwin\bin; %JAVA_HOME%\bin; %ANT_HOME%\bin; %ANDROID_SDK%\tools; %ANDROID_SDK%\platform-tools; %ANDROID_NDK%; %CommonProgramFiles%\Microsoft…
aerlfredith
  • 1,123
  • 4
  • 12
  • 18
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
1 answer

How do I make make/ninja limit parallelism based on memory pressure?

If I use make -j2, it builds fine, but under-utilizes CPU: If I use make -j4, it builds fast, but for some particular template-heavy files it consumes a lot of memory, slowing down entire system and build process as well due to swapping out to…
Vi.
  • 37,014
  • 18
  • 93
  • 148
50
votes
4 answers

what does "make check" do?

I wonder in the installation process of configure, make, make check and make install, what does make check do? Thanks!
Tim
  • 1
  • 141
  • 372
  • 590
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
3 answers

templates: parent class member variables not visible in inherited class

I have the following 4 files: arrayListType.h: Declare and define arrayListType class as a template unorderedArrayListType.h: Inherited from arrayListType class and Declares and defines unorderedArrayListType as a template. main1.cpp: Test…
Romonov
  • 8,145
  • 14
  • 43
  • 55
49
votes
4 answers

make: *** [ ] Error 1 error

I am trying to compile a Pro*C file on gcc and I am getting this error : make: *** [MedLib_x.o] Error 1 This is the command printed by make: /usr/bin/gcc -g -fPIC -m64 -DSS_64BIT_SERVER -I/home/med/src/common…
QMG
  • 719
  • 2
  • 7
  • 16