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
42
votes
1answer
4k views

How does this Makefile makes C program without even specifying a compiler?

I was using a Makefile from the book "Advanced Linux Programming (2001)" [code]. It was strange for me to see that GNU make does compile the code correctly, without even specifying a compiler in the ...
28
votes
2answers
149k views

Where can I find a list of 'make' error codes?

I am trying to compile a program written in Fortran using make (I have a Makefile and, while in the directory containing the Makefile, I type the command $ make target, where "target" is a system-...
27
votes
3answers
67k views

Don't stop make'ing if a command fails, but check exit status

I am trying to instruct GNU Make 3.81 to not stop if a command fails (so I prefix the command with -) but I also want to check the exit status on the next command and print a more informative message. ...
25
votes
4answers
18k views

How to display dependencies given in a makefile as a tree?

Problem I want to see the dependencies for one or more targets of a makefile. So I am looking for a program that can parse makefiles and then will represent the dependencies in some tree-like format (...
15
votes
1answer
3k views

Restricting GNU‑Make to POSIX Make behaviour

Is there a known way to make Linux's make reject unintended use of GNU‑Make specific extensions in Makefile when editing or using other's Makefile in Linux? I mean, restricting GNU‑Make to behave as ...
14
votes
2answers
25k views

What does % symbol in Makefile mean

I am playing around with makefiles and I came across %.o or %.c. From what I understood, it specify all c or o files. But why this work: %.o: %.c $(CC) -c $^ -o $@ and this doesn't work ...
12
votes
1answer
17k 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 ...
11
votes
2answers
2k views

How can I use files from HTTP as prerequisites in GNU make?

I want to use files from the World Wide Web as prerequisites in my makefiles: local.dat: http://example.org/example.gz curl -s $< | gzip -d | transmogrify >$@ I only want to "transmogrify" ...
8
votes
2answers
6k views

gnuMake, How to have an environment variable override

Currently I am working with Makefiles that have definitions like MYLIB=/.../mylib-1.2.34 The problem is that these are different for different developers, and it is a pain having to re-edit the file ...
8
votes
1answer
2k views

Visualizing dependencies coded up in makefiles as a graph

Closely related to How to display dependencies given in a makefile as a tree? But the answers given there is not satisfactory (i.e. do not work). Is there a tool to visualize the Directed Acylic ...
7
votes
3answers
9k views

Using wildcard in GNU Make pattern rule

Assume doc.pdf is the target. The following rule triggers a regeneration of doc.pdf whenever doc.refer is updated, but is also happy when doc.refer does not exist at all: doc.pdf: doc.mom $(wildcard ...
7
votes
1answer
2k views

Strange behavior automating with “make -f”

I have a set of directories, some of which contain makefiles, and some of the makefiles have clean targets. In the parent directory, I have a simple script: #!/bin/bash for f in *; do if [[ ...
7
votes
4answers
1k views

How can I get gmake to give me a list of all included makefiles?

I've inherited a major mess of a makefile network that was itself inherited from another project, with makefiles included all over the place. I'm trying to make a simple change without gutting the ...
5
votes
3answers
5k 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 ...
5
votes
1answer
2k views

GNU Make does not ignore failed command

I have written a rule where a directory should be removed if it exists: .PHONY: distclean distclean: -rmdir release make distclean prints: rmdir release rmdir: failed to remove ‘release’: No ...
4
votes
3answers
1k views

How to list prerequisites externally in GNU Make?

How can I query prerequisites of a target from a GNU Make makefile? E.g. if the targets specified like this: fred: wilma barney betty I want to print prerequisites of fred like this: $ make ...
4
votes
1answer
2k 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: ...
4
votes
2answers
3k views

Target-specific make variables

How can I force a target-specific variable to be set immediately (line 2)? I want the output of make to be release and make debug to be debug. X = release debug: X = debug debug: all # the rest is ...
3
votes
3answers
317 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 ...
3
votes
3answers
2k views

How to tell whether GNU make is being used in a makefile?

I know GNU Make is by far the most commonly used, but I'm looking for a way to verify that GNU Make is the actual make program that is being used. Is there a special variable I can print from within ...
3
votes
2answers
2k views

Make target with two words

I'm using a Makefile to compile my Clean code. My Clean files have file names of the format *.icl and are compiled to binaries with the same name but without .icl. This is done with the rule: $(EXE): ...
3
votes
1answer
361 views

Is there a way to disable recursive make?

If I have a makefile I have to use that is using recursive make, is there an easy option to disable that? http://aegis.sourceforge.net/auug97.pdf
3
votes
1answer
3k views

What does make[number] mean in make V=s?

When I enable make V=s to read the full log of make. I always see make[numer] in the log. e.g: datle@debian:~/workspace/cpx/trunk$ make rm -rf openwrt/tmp cp config/defaut.config openwrt/.config cd ...
3
votes
1answer
1k views

Why does make behave strangely when writing multiple targets using the % character?

According to GNU Make Manual A rule with multiple targets is equivalent to writing many rules, each with one target, and all identical aside from that. The same recipe applies to all the targets, ...
3
votes
2answers
177 views

How to prevent Make from randomly overriding files?

Suppose I am in an empty directory. If I now create a Makefile containing nothing but all: randomFilename and an empty file called randomFilename.sh, then GNU Make will perform cat randomFilename.sh &...
3
votes
2answers
2k views

What is the order order-only prerequisites are processed in a GNU Make file?

I've been reading the documentation but it's still unclear to me how the order is processed. In the example: myrule: | myrule_step1 myrule_step2 @echo "$(@)" myrule_step1: @echo "$(@)" ...
3
votes
1answer
4k views

gcc compiles gcc with errors 'template with C linkage' and 'template specialization with C linkage'

I am working with Ubuntu 14.04 LTS. This already ships a packaged gcc 4.8.4 but I wanted to have a later version of gcc. Using the existing version 4.8.4, I built version 4.9.4 from the source code ...
3
votes
2answers
18k views

Why does make stop with “Makefile:6: *** multiple target patterns. Stop.”?

Goal I write my slides in a markdown file and compile it to reveal afterwards, uploading it to my webserver and do other things. I wanted to organise the steps after the markdown is written in a ...
2
votes
2answers
1k 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 ...
2
votes
2answers
1k 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 ...
2
votes
2answers
85 views

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

The Question(s) 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 ...
2
votes
1answer
3k views

Percentage symbol in $(shell) in GNU Makefile dependency

I am aware of LatexMk, but can't install that on the machine where I want to run pdflatex, so I need to write a Makefile of which %.pdf files are targets that depend on %.tex and the *.tex files that %...
2
votes
3answers
5k views

How to make OpenWrt Makefile compile faster?

I have recorded that it took 50 minutes for an initial compilation of the OpenWrt firmware image, assuming all the necessary packages have been installed via sudo apt-get install. My BuildRoot Root ...
2
votes
1answer
172 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 ...
2
votes
0answers
765 views

Is there an automatic translator from Makefile to CMakeLists.txt?

I have several inherited projects - on RHEL 7, part of which are created using make, and the rest are utilising cmake. I'm wondering: is there an automatic translator that will take a Makefile as ...
2
votes
0answers
109 views

How to check if a target will be run?

I know that the variable MAKECMDGOALS In GNU Make will contain the names of final goals for the run, i.e. the targets included on the command line. However I'd like to check if a target will be made, ...
1
vote
2answers
215 views

Check in bash if make has done something

I'm calling make from a bash script. Part of the rest of the script only needs to be executed if make actually did something (i.e. it doesn't say nothing to be done for...). How would I check on ...
1
vote
1answer
39 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 ...
1
vote
1answer
114 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 ...
1
vote
1answer
2k views

GNU make - How to concatenate to variable depending on shell command result (GCC version)?

I want to add another option to the CFLAGS make variable, depending on the result of a shell command that i want to execute outside of a recipe in my "configuration" section of the makefile. This is ...
1
vote
4answers
915 views

Using environment variables for shorter recipes in GNU Make

I would like recipes in GNU Make to use environment variables instead of command line arguments, to make them shorter, so that I can concentrate better on what changes in each command. For example, ...
1
vote
1answer
572 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, ...
1
vote
1answer
35 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 -...
1
vote
1answer
610 views

apply rules in a list of files in GNU Make (or 'for' instruction in GNU Make)

I have this rules in my GNU Makefile: FITXER = fitxa.md $(FITXER).html: $(FITXER) pandoc --from markdown --to html $(FITXER) -o $(FITXER).html $(FITXER).jpeg: $(FITXER).html wkhtmltoimage $(...
1
vote
1answer
635 views

Recursive Make passing targets in OS X

I am trying to write a recursive clean target for GNU Makefile on OS X (GNU Make 3.81 - from XCode). Following GNU Make documentation, I came up with the following: Main Makefile ALLSUBMAKES=$(...
1
vote
1answer
571 views

'pkglibexecdir' is not a legitimate directory

I'm following some outdated instructions in an attempt to compile some proprietary, closed-source, unsupported, legacy code. Here is what a typical shell session looks like: $ autoreconf -fi src/...
1
vote
1answer
92 views

What do I install into a given install prefix

Which directories should I expect to have in an install prefix when I'm writing makefiles? I've noticed that in the common prefix /usr, there is no /etc, yet there is an /include dir, which isn't in ...
1
vote
0answers
23 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 ...
1
vote
1answer
526 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 "...
1
vote
2answers
2k views

Makefile, sqare brackets built-in, variable expansion and command substitution

To embrace the DRY (Don’t Repeat Yourself) principle, I sometimes need to share pieces of shell commands in a Makefile. So there is a recipe somewhere in that file like: shell=/bin/bash # … .ONESHELL:...