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
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
75
votes
9 answers

Hunk #1 FAILED at 1. What's that mean?

I get the following error when running make, and I have no idea what it means or what to do about it. Can anyone illuminate me or point me in the right direction? (cd libdvdnav-git && patch -p1) < ../../contrib/src/dvdnav/dvdnav.patch patching file…
JellicleCat
  • 28,480
  • 24
  • 109
  • 162
74
votes
10 answers

Automatically setting jobs (-j) flag for a multicore machine?

I have a Makefile on a machine that has a ton of cores in it, but I always seem to forget to write -jX when compiling my project and it takes way longer than it should. Is there some way I can set the -j flag through an environment variable or some…
KarateSnowMachine
  • 1,490
  • 2
  • 13
  • 17
74
votes
11 answers

Using 'make' on OS X

I have a MacBook Pro that I'm trying to do some development on. I have a program I want to build, and when I went to use make to build it, I got a "command not found" error. I did some googling and Stack Overflow searches and it doesn't look like…
Alex
  • 14,973
  • 13
  • 59
  • 94
73
votes
3 answers

How to print a var using echo o print in a NDK-build Android.mk file to debug compilation?

I'm trying to print some extra info when in compile a library using ndk-build. For example: LOCAL_PATH := $(call my-dir) all:;echo $(LOCAL_PATH) echo: $(LOCAL_PATH) print:echo "i'm not working" When i do ndk-build, just compile all the Android.mk,…
vgonisanz
  • 11,831
  • 13
  • 78
  • 130
73
votes
8 answers

Disable make builtin rules and variables from inside the make file

I want to disable builtin rules and variables as per passing the -r and -R options to GNU make, from inside the make file. Other solutions that allow me to do this implicitly and transparently are also welcome. I've found several references to using…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
72
votes
2 answers

cmake, print compile/link commands

Can somebody please enlighten me as to what the command line flag to CMake might be that will make it print out all the compile/link commands it executes? I can't find this anywhere in the documentation. Many hours of my life have just evaporated.…
mr grumpy
  • 1,513
  • 1
  • 10
  • 17
72
votes
5 answers

multiple makefiles in one directory

I have a makefile in a directory of mine which builds scripts with certain environment variables set. What if I want to create another makefile in the same directory with different environment variables set? How should I name the two make files?…
William Jia
  • 1,057
  • 2
  • 9
  • 12
71
votes
1 answer

What does a percent symbol do in a makefile?

I have a makefile that looks like this : include $(patsubst %,$(src)/%/Make.tests, $(TEST_SUBDIRS)) %-test: Something here I understand what it is intended for in the target rule line. What is the % sign doing in the first line ? Does it…
AnkurVj
  • 7,958
  • 10
  • 43
  • 55
71
votes
11 answers

MINGW64 "make build" error: "bash: make: command not found"

I am working on Windows 10. I want to run a "make build" in MINGW64 but following error comes up: $ make build bash: make: command not found I want to build Glide for Golang I tried following: $ sudo yum install build-essential bash: sudo: command…
user5845158
71
votes
3 answers

What does a typical ./configure do in Linux?

Why is it necessary even though everything is specified in a makefile?
Mask
  • 33,129
  • 48
  • 101
  • 125
70
votes
8 answers

In GNU Make, how do I convert a variable to lower case?

This is a silly question, but.... with GNU Make: VAR = MixedCaseText LOWER_VAR = $(VAR,lc) default: @echo $(VAR) @echo $(LOWER_VAR) In the above example, what's the correct syntax for converting VAR's contents to lower case? The…
DonGar
  • 7,344
  • 8
  • 29
  • 32
70
votes
12 answers

Windows 7 - 'make' is not recognized as an internal or external command, operable program or batch file

I have Windows 7 and tried to use the 'make' command but 'make' is not recognized as an internal or external command. I did Start -> cmd -> run -> make, which outputs: 'make' is not recognized as an internal or external command,operable program or…
programmer
  • 4,571
  • 13
  • 49
  • 59
69
votes
3 answers

What is the difference between -I and -L in makefile?

What is the usage of the -I and -L flags in a makefile?
MainID
  • 29,070
  • 19
  • 57
  • 70
69
votes
4 answers

Makefile issue: smart way to scan directory tree for .c files

I am doing a project which is growing pretty fast and keeping the object files up date is no option. The problem beyond wildcard command lies somewhere between "I do not want recursive makefiles" and "I do not want it to list by hand". The objects…
drahnr
  • 6,782
  • 5
  • 48
  • 75