Twighter
Twighter

Reputation: 43

What is the reason for fatal error: *** No rule to make target 'install'. Stop

The error occurs when I tried to run the command make install under Ubuntu 16.04 that

*** No rule to make target 'install'. Stop.

I have already run make command with several errors fatal: bad revision 'HEAD', which didn't lead to halting the command. I have no idea whether these errors matter.

My makefile is:

SUBDIRS := $(wildcard */.)

all: $(SUBDIRS)

$(SUBDIRS):
    make -C $@

install:
    for dir in $(SUBDIRS); do \
        make -C $$dir install; \
    done

.PHONY: all $(SUBDIRS)

Specifically, I want to know how the makefile works after install:.

The project should install an APP on the connected phone Nexus 5. But actually, there's no such APP on my phone.

Upvotes: 4

Views: 24761

Answers (1)

Dario
Dario

Reputation: 2713

I suppose your Makefile is properly formatted, with tabs where they should be, etc.

Then, when you run make install in the top level directory, your Makefile does have a rule to make the target install: it says to loop on your subdirectories, enter each one of them, and run make install there (this is what the -C option does). One of those sub-makes fails, most probably because, in its respective subdirectory, it doesn’t find a Makefile with an install recipe in it. When the sub-make fails, the loop goes on with the remaining sub-makes (unless the shell was instructed otherwise by means of the -e switch), and the final return code of the whole recipe will be the return code of the last sub-make.

There are some points worth discussing in your Makefile (for example, install should be listed as a .PHONY target), but you don’t provide enough information to clarify them: for example, is it really necessary to have the shell loop through the subdirectories in a particular order? Usually, a better policy is to have make parallelize the sub-makes whenever possible (and, as a side effect, have make stop when the first submake fails...)

Upvotes: 1

Related Questions