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.

GNU Make is an implementation of make, which is one of the most widely used build tools in the UNIX family of operating systems. It takes a file called a Makefile which contains one or more targets that specify how to perform a specific task.

103 questions
42
votes
1 answer

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 Makefile. It's like baking without any…
Ho1
  • 2,552
  • 3
  • 20
  • 25
39
votes
4 answers

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 (indentation, ascii-art, ...) or as a graph (dot,…
Lucas
  • 2,805
  • 1
  • 14
  • 24
34
votes
4 answers

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. However my Makefile below fails: $ cat Makefile…
Marcus Junius Brutus
  • 4,427
  • 11
  • 43
  • 63
31
votes
2 answers

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-specific target specification is present in my…
Andrew
  • 16,315
  • 34
  • 73
  • 77
26
votes
2 answers

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 SOURCE := $(wildcard *.c) $(SOURCE:.c=.o):…
Mero
  • 363
  • 1
  • 3
  • 6
17
votes
1 answer

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 'hello\nworld' > test.txt When I run make, I would…
Dominick Pastore
  • 805
  • 1
  • 9
  • 19
17
votes
1 answer

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 the make specified in POSIX and reject any…
Hibou57
  • 845
  • 2
  • 9
  • 20
16
votes
1 answer

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 shell script and the value required by the makefile…
Porcupine
  • 1,680
  • 2
  • 19
  • 45
11
votes
2 answers

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" if the remote file is newer than the local file, just…
pipe
  • 921
  • 10
  • 25
11
votes
2 answers

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 after every checkout. So I tried exporting a…
Tuntable
  • 213
  • 1
  • 2
  • 6
10
votes
1 answer

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 Graphs (DAGs) coded up in standard Makefiles? eg, a…
8
votes
1 answer

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 clean) command results in: rm rm: missing…
7
votes
1 answer

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 [[ -d $f && -f $f/makefile ]]; then …
goldilocks
  • 86,451
  • 30
  • 200
  • 258
7
votes
3 answers

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 dir: mkdir dir dir/file: cp source…
schily
  • 18,806
  • 5
  • 38
  • 60
7
votes
3 answers

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 doc.refer) pdfmom -e -k < $< > $@ However the…
not-a-user
  • 1,497
  • 3
  • 15
  • 16
1
2 3 4 5 6 7