2022 Developer Survey is open! Take survey.

Questions tagged [gnu-make]

GNU Make is the GNU project's implementation of the `make` utility. On BSD systems, the GNU Make executable is sometimes called `gmake` to differentiate it from BSD Make.

Filter by
Sorted by
Tagged with
2 votes
1 answer
14 views

Remake included makefile only when needed

Let's say that I have a Makefile that has two “main” targets: foo.o and clean. The former one has a recipe to create the foo.o file. The latter one removes all the temporary files. To remove the need ...
user avatar
  • 772
1 vote
1 answer
22 views

Serialize all rules in GNU make: best practise?

I have a makefile and want to make sure that all the rules are executed sequentially, that is, that no parallel execution is performed. I believe I have three ways of achieving this: With ....
user avatar
  • 366
13 votes
1 answer
1k views

Why is echo -e behaving weird in a Makefile?

I was writing a Makefile (on Ubuntu 20.04, if it's relevant) and noticed some interesting behavior with echo. Take this simple Makefile: test.txt: @echo -e 'hello\nworld' @echo -e '...
user avatar
1 vote
0 answers
12 views

Permission denied error when using make all-recursive?

I am using autotools and GNU make to build a C library, there is a line all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive In the Makefile, and I get an error compiling make all-recursive make: ...
user avatar
0 votes
1 answer
59 views

Same make command fails in macOS, but succeeds in Linux

I'm using below Makefile and make publish fails on macOS while succeeding in Linux (alpine, Ubuntu, Debian) with the below error: $ make publish "docker images" requires at most 1 argument. ...
user avatar
  • 287
0 votes
0 answers
27 views

CMake, specify (or ensure) compilation order

I am migrating a library from one platform to another, so there are tons of problems in each and every source file. The problem I have is that make compiles all these files in some random order, and ...
user avatar
  • 1,188
0 votes
1 answer
48 views

why is this makefile command running so frequently

I have the makefile below. Why does the rule for the data/vix.csv target always execute when I run make, though? In a recent answer on SO, someone showed me how to update last_updated.txt on 24 hour ...
user avatar
  • 123
1 vote
2 answers
128 views

Spike in number of page faults with make -j`nproc`

I am running a benchmark to figure out the number of jobs I should allow GNU Make to use in order to have optimal compile time. To do so, I am compiling Glibc with make -j<N> with N an integer ...
user avatar
1 vote
0 answers
63 views

Editting Makefile in VS Code

I have many questions about writing makefiles in visual studio (vs) code. The first question is, how to make vs code recognize certain files as makefiles. For instance, when a file's suffix is "....
user avatar
  • 145
0 votes
0 answers
74 views

Escape Dollar Symbol '$' in the "define" Struct of GNU make

I am confused with the following piece of code in our makefile: define rules $(TARGET_DIR)/%.$(OBJ_SUFFIX): $(1)/%.s $$(call message,Assembling "$$<" to make object file "$$@&...
user avatar
  • 145
0 votes
0 answers
18 views

Identical .so shared libraries (with no symbols) are generated when compiling different C source files

At the institution I work for we have a User Exit made in Pro*C (SQL embedded in C language). We are having some troubles because identical shared libraries are generated when compiling different ...
user avatar
0 votes
2 answers
156 views

How can I execute recipe iff a file exists?

I'm writing a Makefile recipe that needs to execute IF AND ONLY IF a certain file exists... Here's what I have: clean: $(if $(shell test -s ${MFN_LSTF}), \ $(foreach mfn, $(shell cat ${...
user avatar
1 vote
1 answer
374 views

Makefile command substitution

My Makefile: all: ...(other rules) clean clean: rm $(find . -type f -executable) When I delete clean rule from the above Makefile everything works as expected. After adding, make (also make ...
user avatar
2 votes
1 answer
434 views

Why are the pkg-config commands in the makefile not being recognized when I run the script?

I am trying to run make for an open-source project on my Debian virtual machine but I do not understand why the commands based on pkg-config are not being recognized. One of the commands is as follows:...
user avatar
  • 247
2 votes
1 answer
151 views

multiple target specific gnu make variables?

How do I set more than one target specific variable? If I try: x: Y := foo Z := bar I end up with Y = "foo Z := bar". There must be some syntax which will allow for multiple variables...
user avatar
0 votes
1 answer
132 views

Error when using Makefile..sed

An app is trying to configure with sudo make configure (cd /opt/ioapi-3.2/ioapi ; sed -e 's|IOAPI_BASE|/opt/ioapi-3.2|' -e 's|LIBINSTALL||' -e 's|BININSTALL||' -e 's|IOAPI_DEFS||' -e 's|NCFLIBS|-L/...
user avatar
1 vote
2 answers
165 views

Is it possible to display variables outside rules using GNU Make?

Is it possible to display variables outside rules using GNU Make? Consider the following Makefile: x = foo bar baz ifdef x @echo $(x) endif This results in Makefile:4: *** commands commence ...
user avatar
  • 3,317
0 votes
0 answers
103 views

Makefile setting library path based on user input

im writing a makefile for a java aplication using javaFX, so when the app is compiled or run the command needs to specify the path to the javaFX library, with an option that looks like this: --module-...
user avatar
1 vote
1 answer
91 views

Using `$@.o` in Makefile dependency won't work

Trying a Makefile rule like the following did not work (GNU Make 4.0): foo: $@.o other.o bar: bar.o other.o The file foo.c was compiled (to foo.o), but the link command was cc -o .o. In contrast,...
user avatar
  • 801
0 votes
1 answer
51 views

FreeBSD - problem with linking protobuf

I have a small application that was tested on Linux and it worked. Now I would like to build the same code on FreeBSD. To build it on FreeBSD I needed to change a little my Makefile. Here is my ...
user avatar
1 vote
1 answer
26 views

Use an interactive shell under Make

I'm trying to use an interactive shell under Make. Here's an example with Docker: ubuntu: docker run -it ubuntu bash This ubuntu target doesn't work well. For example, when I type I can't see the ...
user avatar
0 votes
0 answers
49 views

Clang Exits with Error Code 1

gmake (with Clang10) complains that in file m_file.cpp there is "no matching function for call to 'fileno'". Also, that it "cannot initialize a param of type 'FILE *' ::fclose(m_fp). ...
user avatar
0 votes
2 answers
259 views

If function in Makefile seems to disregard conditional and executes unexpectedly

The following is a simple recipe that is not behaving as I want it to: $(eval PkgName := $(shell pacman -Qq zsh | awk '{print $$1}')) $(if ifeq ($(strip ${PkgName}),), pacman -Sy --noconfirm zsh) All ...
user avatar
0 votes
0 answers
26 views

Valid bash won't execute in make [duplicate]

# Makefile test : while true; do echo test done test2 : while true; do echo test; done make test throws the error while true; do /bin/sh: -c: line 1: syntax error: unexpected ...
user avatar
  • 439
0 votes
1 answer
72 views

How can I run make on file update?

I would like to be able to watch the files in my project and have make run every time one of the targets gets updated (unless it's changed by make itself I suppose). This is a common feature in many ...
user avatar
  • 439
3 votes
3 answers
873 views

How do I build PKGCONF and LIBFFI and subsequently Python3.9 with ctypes support without sudo and write access to /usr/local?

How do I properly configure pkgconf and libffi to allow the python3 build process to correctly use my libffi version at every step of the build process, in order to import the _ctypes module correctly?...
user avatar
  • 33
0 votes
1 answer
42 views

Determining the type of makefile recipe

I want to determine the type of recipe the user entered in the shell. However the below code always return false . all clean: ifeq ("$@", "clean") echo "This is an ...
user avatar
2 votes
1 answer
841 views

is there any way to skip a make's target?

I am trying to add a patch so that a software can compile and run correctly, unfortunately in order to add the change I am trying I always run into an annoying code style check error. Is there any way ...
user avatar
-1 votes
1 answer
83 views

How to introduce variables in Makefile

I'm using Bash on Ubuntu and GNU Make 4.2.1. I'm trying to write a Makefile that would perform simple operations on some data (.TXT files) I have. My different .TXT files are stored in 3 directories ...
user avatar
  • 33
1 vote
2 answers
2k views

Variable not found in makefile recipe

why doesn't this simple recipe work ? .PHONY: test test: foo := $(shell ls | grep makefile) ;\ echo $(foo) results in $> make test makefile:65: warning: undefined variable 'foo' foo := ...
user avatar
0 votes
1 answer
329 views

Compiling drivers/staging

I need to compile all staging drivers. I am using make allyesconfig and I have also set CONFIG_BROKEN=y and CONFIG_COMPILE_TEST=y . Right now, make modules C=1 M=drivers/staging prints MODPOST drivers/...
user avatar
0 votes
1 answer
1k views

What is the meaning of shell in $(shell uname -r)

I was reading a makefile where I found this statement make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules Can anyone explain what is shell here. Command substitution is being tried here ...
user avatar
0 votes
1 answer
193 views

Why is only the first prerequisite executed?

Here is the makefile. .PHONY: all target1 target2 target all: target1 target2 target1: NUM = 1 target2: NUM = 2 target1 target2: target target: @echo "this is target ${NUM}" And the output is: ...
user avatar
  • 1
1 vote
0 answers
373 views

Custom error message in GNU make if required but not otherwise?

In GNU's make is it possible to print a custom error message instead of GNU's default one, possibly with the line number as well? I am fine with make's default behavior in all other scenarios. Here ...
user avatar
  • 507
1 vote
0 answers
33 views

Pattern-specific make variable based on the highest level target name

Goal In the usual case of a target (mother target) calling another target (child target) as prerequisite, I'd like to assign a pattern-specific variable (see the manual page) with the following ...
user avatar
  • 121
2 votes
1 answer
2k views

What's the difference between percent vs asterisk (star) makefile prerequisite

I'm trying to understand why some Makefiles have prerequisites with %.txt and others have *.txt. I've created this folder layout. $ tree . . ├── hi1.txt ├── hi2.txt ├── hi3.txt └── Makefile First, ...
user avatar
  • 327
0 votes
1 answer
14 views

Outputing the predefined variables `make -R` references?

According to the docs on make there is a -R switch, -R, --no-builtin-variables Don't define any built-in variables. How can I find those builtin variables and their values?
user avatar
  • 22.5k
2 votes
2 answers
449 views

How to get the relative path between two directories?

Say I have a variable with a path release/linux/x86, and want the relative path from a different directory (i.e. ../../.. for current working directory), how would I get that in a shell command (or ...
user avatar
  • 187
2 votes
2 answers
3k views

"Command not found" passing argument from Makefile to shell script

I have a info.properties file where I have this MY_NAME property and I can use this property on my Makefile. I already tried but I can't use that property directly on myScript.sh file. So I'm trying ...
user avatar
  • 134
1 vote
2 answers
1k views

Makefile - Set multiple variables on a single stage

I have this Makefile where I'm having some troubles on simply set some variables: my_stage: echo "FULL_NAME=$(FULL_NAME)" echo "MY_NAME=$(MY_NAME)" $(eval SOME_NAME=$(shell sh -c "...
user avatar
  • 134
0 votes
1 answer
3k views

Simple shell loop fail in Makefile

Why does the shell loop l='abc de f'; for k in $l ;{ echo $k; } inside Makefile not work ? instead only give abc de f at once How to solve such in the definitive way?
user avatar
-1 votes
1 answer
29 views

Makefile not linking required dependency

The two target executables are made successfully at first: $ rm build/* bin/* $ make g++ -Wall -g -c -o build/Person.o src/Person.cpp g++ -Wall -g -c -o build/PersonTests.o test/PersonTests.cpp g++ -...
user avatar
1 vote
1 answer
39 views

How do I get Make to acknowledge two intermediate dependencies from one recipe?

I am converting .sup files to .ass files using the following recipes: %.idx %.sub: %.sup bdsup2subpp --language en -o $*.sub $< %.srt: %.sub vobsub2srt $* %.ass: %.srt ffmpeg -...
user avatar
3 votes
3 answers
417 views

What is "sed -i 's,-m64,,g'" doing to this Makefile?

What is the meaning of sed command sed -i 's,-m64,,g' Makefile? Does it simply remove -m64 argument from Makefile? Is it the same with sed -i 's/-m64//g' Makefile, just use / delimiter in place of ...
user avatar
  • 437
2 votes
1 answer
357 views

alternatives to using make as a script runner [closed]

tl;dr make is working for me, but I'm looking for the appropriate tool. I'm currently using Makefiles as script runners for my projects. In order to standardize each project, I just create a makefile ...
user avatar
  • 21
0 votes
1 answer
675 views

Process continues to run after receiving uncaught SIGINT (Ctrl-C from terminal)

I am trying to interrupt some running processes with Ctrl-C from the terminal in Centos7; some do, some don't. One of the problematic processes (Process-A) is a GNU makefile with nothing fancy; just ...
user avatar
  • 137
14 votes
1 answer
25k views

Makefile: Default Value of Variable that is set but has null value

I have a Makefile that has a variable that needs to have a default value in case when variable is unset or if set but has null value. How can I achieve this? I need this, as I invoke make inside a ...
user avatar
  • 1,364
4 votes
1 answer
4k views

Make - How to suppress make error messages without suppressing other output

I'm implementing a simple build system that's actually just a wrapper around Make. Since this build system already emits its own error messages, I don't want Make to produce error messages like make: ...
user avatar
2 votes
2 answers
2k views

Why don't here strings in Makefiles using Bash work?

I just solved a problem with my Makefile(s). Make trips over every <<< with the error message /bin/sh: 1: Syntax error: redirection unexpected And I would like to know why. (I am using Bash ...
user avatar
  • 7,241
7 votes
3 answers
7k views

How can I partially serialize with GNU make

When I have a make task where a specific target needs to be made before another, while in parallel mode, this is simple when using SunPro Make (dmake). The following makefile: install: dir dir/file ...
user avatar
  • 17.9k