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
8
votes
1 answer

Confused about install -m and install -d using Yocto

I have taken over a Yocto project, and inside a .bb recipe file, I see the following lines to install new directories in the image: do_install() { install -m 0755 -d ${DEPLOY_DIR_IMAGE}/app install -m 0755 -d…
Engineer999
  • 3,683
  • 6
  • 33
  • 71
8
votes
2 answers

File format not recognized; treating as linker script using GCC

I am pretty new to Makefiles and i am trying to build an executable from 3 files, file1.c, file2.c, and file1.h into an executable called exFile. Here's what I got: all: exFile exFile: file1.o file2.o gcc -Wall -g -m32 repeat.o show.o -o…
user695978
  • 83
  • 1
  • 1
  • 3
8
votes
3 answers

If-equals statement in makefile as a one-liner

The following works as intended: branch := $(shell git rev-parse --abbrev-ref HEAD) ifeq ($(branch), master) ami_regions = us-west-2 endif show_regions: echo $(ami_regions) How could this ifeq statement be written as a one-liner, where…
alkalinecoffee
  • 1,003
  • 8
  • 20
8
votes
1 answer

Removing values from Make Variables

Using GNU Make I want to remove values from a variable: VAR := x.c y.c z.c VAR += x_x.c y_y.c I now want to remove the "x.c" and "y.c" from the variable. I have tried using subst command but the x_x.c is removed as well. Are there any ways…
user626201
  • 1,623
  • 3
  • 19
  • 36
8
votes
2 answers

Compiling the wrong file?

I have 3 files — SwimMill.c, Fish.c, and Pellets.c — each of which is compiled into an executable. When SwimMill is run, it uses fork() and exec() to run Fish and Pellets. However, for some reason, when I use the terminal, compile the programs with…
Slay
  • 101
  • 6
8
votes
2 answers

How to conditionally assign value to a variable in a Makefile (BSD + GNU)?

I have a (from my point of view) rather complicated Makefile. That is mostly because I wanted colors there and other unnecessary things. Anyway, might I jump right into my question: Apart from Linux I newly support *BSD, thus I need to check for the…
Vlastimil Burián
  • 3,024
  • 2
  • 31
  • 52
8
votes
1 answer

Symbol "|" in dependency

What does symbol | mean in dependency list, e.g. foobar: foo | bar do_something .... Where foo and bar are targets generated by makefile.
quantum_well
  • 869
  • 1
  • 9
  • 17
8
votes
3 answers

make file with source subdirectories

My latest project is in C++ and I am using GNU Make. The project directory layout is as follows: project |-src |-subdir1 |-subdir2 (containing tests) |-doc |-bin I would like to be able to call make in the top level directory (i.e. need a…
Jakob
  • 83
  • 1
  • 1
  • 3
8
votes
3 answers

GNU Make with patsubst: need two substitutions

I need to reference the stem twice in the replacement for a variable substitution: O23=$(OROOTS:%=$(ODIR)/overx-%2wk-%3wk.mlb) I need to perform two replacements with the same stem, but the substitution uses patsubst which only does the first. How…
Alexy
  • 1,520
  • 2
  • 16
  • 30
8
votes
2 answers

How to use bear with make to auto-create the json compilation database?

I'm using vim with YouCompleteMe (YCM) plugin for C programming. YCM needs a json file to show code completion suggestions or a manually crafted .ycm_extra_conf.py file. Build systems like cmake and ninja provide a switch to generate the json file…
Zeta.Investigator
  • 911
  • 2
  • 14
  • 31
8
votes
3 answers

Could not find a supported mac sdk: ["10.10" "10.11" "10.12" "10.13"]

I see the error when I try to build Android Open Project Source . ninja: no work to do. [1/1] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja FAILED: out/soong/build.ninja out/soong/.bootstrap/bin/soong_build -t -l…
haizhih
  • 97
  • 1
  • 8
8
votes
2 answers

makefile: ignore dependency when running target

I have this setup in my Makefile. action1: does something action2: action1 does something else I want to keep my configuration in case I want to use action1 as a dependency for action2, but sometimes I'd like to ignore action1 when running…
user3226932
  • 2,042
  • 6
  • 39
  • 76
8
votes
2 answers

Variables in makefiles (How to use arrays)

I have compiler flag in a makefile which looks like: MYVARIABLE1=HELLO 4.5.6 MYVARIABLE2"="{0x95,0x04,0x05,0x06,' ','A','A'}" CFLAGS+=-DMYVARIABLE2=${MYVARIABLE2} which works fine. But if I want to use already known info in VARIABLE1 to create…
Sharky
  • 323
  • 1
  • 3
  • 11
8
votes
2 answers

patsubst on makefile

I have to create different *.o files from a same set of *.c using various CFLAGS. I wanted to use patsubst to generate different *.o files from same *.c. I am doing something wrong the following statement, please help (I want to generate one set of…
Sayan
  • 2,662
  • 10
  • 41
  • 56
8
votes
8 answers

How to set GNUMAKE variable for ndk-build to work

I am trying to make ndk-build to work within Cygwin on windows. As per the NDK documentation (specifically INSTALL.htm), "The NDK requires GNU Make 3.81 or later being available on your development." I have Gnu Make installed on my computer. So far,…
OceanBlue
  • 9,142
  • 21
  • 62
  • 84