Questions tagged [gnu-make]

This tag is for questions about `gmake`, the GNU version of the `make` utility to maintain and update programs.

GNU Make is the GNU implementation of the Make utility. It is probably the most common version in use today.

GNU Make supports extensions to the Make language beyond the POSIX standard, therefore GNU Make solutions may not work under other versions, so the gnu-make tag is appropriate for questions from those using GNU Make, or pertaining to makefiles written for it.

Documentation

The latest GNU Make manual can be found in several formats here.

See also

make makefile

4424 questions
1
vote
2 answers

makefiles - the clean as target

can anyone tell me how to execute the clean target which is written in the makefile. here is my code jamm : hello.o ghola.o gcc $^ -o $@ %.o : %.c gcc -c S< clean : rm *.c i have some questions.how to clean all those c files using…
karthik
  • 345
  • 3
  • 5
  • 11
1
vote
1 answer

Makefiles which re-make themselves: makefile not reloaded correctly

I have a top-level makefile which is auto-generated by my custom build tool from various configuration files: I would like the makefile to be able to re-make itself when it is out of date. To do this, I have the following rule:
1
vote
1 answer

Is it possible to export a lazily-evaluated variable to a child Makefile?

This question is hopefully the last one I've been building up to from this and this. I have the following directory structure: . ├── Makefile ├── src │   └── Makefile └── test └── Makefile My top-level Makefile just runs $(MAKE) on the src/ and…
StoneThrow
  • 5,314
  • 4
  • 44
  • 86
1
vote
0 answers

How GNU Make makes a decision which intermediate files to remove and which to keep

I've read the official documentation about chains of implicit rules and I believe that this is the reason why I observe this behavior, although I can't quite comprehend why. Let's say we have the following Makefile: .DELETE_ON_ERROR: .PHONY:…
Daniel
  • 635
  • 1
  • 5
  • 22
1
vote
1 answer

makefile error: “make: *** No rule to make target …”

I'm trying to use GCC (linux) with a makefile to compile my project. I get the following error "No rule to make target 'output/src/main.o', needed by 'test'. Stop." This is the makefile: COMPILE_PREX ?= CC = $(COMPILE_PREX)gcc SOURCE =…
corey chang
  • 11
  • 1
  • 5
1
vote
2 answers

How do you use (GNU) make's "simply expanded" variables in build rules and not get the last definition?

I have a complicated set of rules I need to write to generate a rather large number of "parameterised" output files and thought that, rather than expand them all out by hand, I could repeatedly "include" a template file with sets of rules and use…
Simon F
  • 1,036
  • 8
  • 23
1
vote
1 answer

Include a third makefile with a path relative to second, when second isn't in directory of first

I have a Makefile with only project-level definitions: which source files to use, what binary or library to make, etc.. It includes ../../Make.Arch for architecture-specific definitions (such as compiler command). In turn, Make.Arch is meant to…
Swiss Frank
  • 1,985
  • 15
  • 33
1
vote
1 answer

Is there a way to know that the makefile is running with -j (parallel execution)

The -j option of GNU Make is handy although you have to be careful about your dependencies. In my environment it has sped up build and test times 5-6 times. But I want to run my tests with coverage and this creates a problem since the gcov…
thoni56
  • 3,145
  • 3
  • 31
  • 49
1
vote
1 answer

Why is the make target up to date even when using .phony?

I have a Makefile that looks like this: RENDER_HTML=jupyter nbconvert --execute --to html MATE40001_TARGETS=$(wildcard MATE40001/notes/*.ipynb) .phony: all all: MATE40001 .phony: variables variables: @echo MATE40001_TARGETS: @echo…
d-man
  • 476
  • 4
  • 24
1
vote
3 answers

HOSTNAME set in environment but not visible to gmake

This has plagued me on and off for years. Can anyone explain why $(HOSTNAME) doesn't expand to the environment value HOSTNAME? Googling various combinations of "make", "hostname", "gmake", "not set" and so forth hasn't been fruitful for…
jcomeau_ictx
  • 37,688
  • 6
  • 92
  • 107
1
vote
1 answer

make ARCH=x86_64 CROSS_COMPILE ....... Error 2 while installing rtl8723de wifi drivers

I was trying to install rtl8712de wifi drivers in my Debian 10 PC. I tried the following code: sudo apt update git clone https://github.com/smlinux/rtl8723de.git cd rtl8723de make After I ran the make command, I got the following error: make…
Sai kamal
  • 11
  • 2
1
vote
1 answer

Gnu make: Target in macro from subst

I want to generate a list of equivalent targets: TARGETLIST = a b c d e f define RULE $(subst X,$(1),file_X.txt) $(subst X,$(1),otherfile_X.txt) &: # some dependency # some commands endef $(foreach _t, $(TARGETLIST), $(eval $(call RULE,…
HerpDerpington
  • 3,751
  • 4
  • 27
  • 43
1
vote
1 answer

Run pre-requisite tasks before anything else in GNU Make?

I've got a Makefile with targets like this: all: a b a: a_prereqs a_steps b: b_prereqs b_steps a and b take a while to run and have prerequisites. I'd like both a_prereqs and b_prereqs to run first (so that I don't have to wait for a_steps to…
Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380
1
vote
1 answer

Accessing parent Makefile targets from subdirectory

Say my directory structure is this: foo foo/Makefile foo/bar Now say foo/Makefile has a make target baz. I want to call make baz from foo/bar without creating another Makefile in the bar subdirectory. Is this possible?
1
vote
1 answer

GNU Make can never find perl?

I sometimes get this error when compiling a program: make[1]: /usr/bin/perl: Command not found make[1]: *** [links] Error 127 This happens with any program that requires perl to compile, such as openssl and automake. However: sh-2.05b# perl…
Hamish Milne
  • 31
  • 1
  • 2