Unable to `make clean`: "No rule to make target ...Plo" - makefile

Question Summary
I'm trying to make clean and I'm getting the following output:
Makefile:835: /absolute/path/to/server/server/example/.deps/libfoo-bar.Plo: No such file or directory
Makefile:836: /absolute/path/to/server/server/example/.deps/libfoo-baz.Plo: No such file or directory
Makefile:837: /absolute/path/to/server/server/example/.deps/libfoo-qux.Plo: No such file or directory
Makefile:838: /absolute/path/to/server/server/example/.deps/libfoo-quux.Plo: No such file or directory
Makefile:839: /absolute/path/to/server/server/example/.deps/libfoo-quuz.Plo: No such file or directory
Makefile:840: /absolute/path/to/server/server/example/.deps/libfoo-corge.Plo: No such file or directory
Makefile:841: /absolute/path/to/server/server/example/.deps/libfoo-grault.Plo: No such file or directory
Makefile:842: /absolute/path/to/server/server/example/.deps/libfoo-garply.Plo: No such file or directory
Makefile:843: /absolute/path/to/server/server/example/.deps/libfoo-waldo.Plo: No such file or directory
Makefile:844: /absolute/path/to/server/server/example/.deps/libfoo-fred.Plo: No such file or directory
Makefile:845: /absolute/path/to/server/server/example/.deps/libfoo-plugh.Plo: No such file or directory
Makefile:846: /absolute/path/to/server/server/example/.deps/libfoo-xyzzy.Plo: No such file or directory
Makefile:847: /absolute/path/to/server/server/example/.deps/libfoo-babble.Plo: No such file or directory
Makefile:848: /absolute/path/to/server/server/example/.deps/libfoo-thud.Plo: No such file or directory
Makefile:848: /absolute/path/to/server/server/example/.deps/libfoo-flarp.Plo: No such file or directory
make: *** No rule to make target '/absolute/path/to/server/server/example/.deps/libfoo-flarp.Plo'. Stop.
How can I successfully do a make clean? I don't understand what these .Plo files are, and they are usually something I don't mess with.
Investigation
My Makefile.am
The Makefile.am which is used to generate the Makefile from which I'm trying to run the clean contains this preamble:
include $(top_srcdir)/server/include.am
include $(top_srcdir)/server/tests/include.am
...
The first $(top_srcdir)/server/include.am includes the following:
...
server_libdir = $(exec_prefix)/lib
serverdir = $(top_srcdir)/server
...
and in the specified $(top_srcdir)/server/tests/include.am, I have a lot of things including:
...
server_lib_LTLIBRARIES = libfoo.la
libfoo_la_SOURCES = \
/absolute/path/to/server/server/example/bar.c \
/absolute/path/to/server/server/example/baz.c \
/absolute/path/to/server/server/example/qux.c \
/absolute/path/to/server/server/example/quux.c \
/absolute/path/to/server/server/example/quuz.c \
/absolute/path/to/server/server/example/corge.c \
/absolute/path/to/server/server/example/grault.c \
/absolute/path/to/server/server/example/garply.c \
/absolute/path/to/server/server/example/waldo.c \
/absolute/path/to/server/server/example/fred.c \
/absolute/path/to/server/server/example/plugh.c \
/absolute/path/to/server/server/example/xyzzy.c \
...
Investigating the Makefile Contents
If I look at the Makefile directly and find the lines generating these errors, I see the following:
include /absolute/path/to/server/server/example/$(DEPDIR)/libfoo-bar.Plo
include /absolute/path/to/server/server/example/$(DEPDIR)/libfoo-baz.Plo
include /absolute/path/to/server/server/example/$(DEPDIR)/libfoo-qux.Plo
...
Where are the .Plo files generated?
Frustratingly, there seems to be the exact .Plo files that I need generated all over the place, just not in the right place; for example these files exist:
/absolute/path/to/server/tests/absolute/path/to/server/server/example/$(DEPDIR)/libfoo-bar.Plo
/absolute/path/to/server/tests/absolute/path/to/server/server/example/$(DEPDIR)/libfoo-baz.Plo
/absolute/path/to/server/tests/absolute/path/to/server/server/example/$(DEPDIR)/libfoo-qux.Plo
...
and there are 7 other directories where these .Plo files are created.
Unsuccessful Attempts
Running config.status directly
I found this message on the GNU mailing list:
Actually, these .P files are created by config.status for each
directory it creates an Automake Makefile in. (BTW, make sure
./config.status --help' lists the relevant Makfiles in the Configuration files' section).
You can request the creation of the .P files for a given directory
by running
% rm -Rf kernel/framework/.deps
% ./config.status kernel/framework/Makefile depfiles
And ran ./config.status as described but the output of make clean hasn't changed
According to this other Stack Overflow question, they were able to generate .Plo files, but I don't know what is different for them.

re-run configure with the --disable-dependency-tracking option

Related

Old .Po file references old directory, how to start fresh?

Introduction
I just deleted the directory nested and removed the reference to it in my Makefile.am
I'm running ./configure && make and I get the following:
*** No rule to make target 'nested/main.c', needed by 'main.o'. Stop.
How can I run make so that it doesn't reference old directories?
Supplemental Info
I was curious if I could find where this reference is, so I did a grep -r nested . I think the only relevant hit is:
./src/.deps/main.Po:main.o nested/main.c /usr/include/stdc-predef.h /usr/include/stdio.h \
Answering this question from OP's comment:
Run
make distclean

How to tar a directory with using makefile

I have few files in sub directories, all the files are just text files like faq, user guides.There are no c/cpp src code
in it. Following is the file and directory structure.
scr
|_Makefile #Top level Makefile
|_other_dirs
|_some_other_dirs
|_mydir
|_Makefile #Makefile of mydir, need to put some code here
|_dir1
| |_textfile0
| |_textfile1
|_dir2
|_textfile2
|_textfile3
Question, How can I tar the contents of dir1 and dir2 into one tar ball? I tried searching over internet about the Makefile and how to use it to create the take ball from top Makefile but no success yet. I am not very familiar with Makefiles, any starting point will be appreciated. Thanks.
Following is my novice attempt to have a very basic Makefile:
-->cat Makefile
mydir.tgz : *
tar -zcvf mydir.tgz mydir/
-->make
Makefile:1: *** missing separator. Stop.
Idea is to run top Makefile and have tar file generated for mydir.
You can add all files and directories in mydir recursively as a prerequisite of mydir.tgz. That way, your tar file will be executed if, and only if, a change occurs somewhere under mydir. For example like this:
mydir.tgz: $(shell find mydir)
tar -zcvf mydir.tgz mydir
The line with the tar command should start with at TAB.
Most of the mechanisms of this answer are also described in this SO question, but it seemed to make sense to me to add it here to concisely answer your specific question.

Makefile processing files with same extension

This seems slightly related to How to write Makefile where target and source files have the same extension?. In that question the extensions are the same, but the input and output files seem to be in the same directory and filenames are being conditionally renamed.
I have a large collection of .txt files in ../src/ that need to be processed, and dumped into ./ (which is a directory called target/) as txt files of the same name. I want to use make, so that only files in ../src/ that have been changed get updated in ./. I would like to get the prototype working before I put the real code in.
My Makefile in ./ is as follows:
DIR = ../src
INPUTS = $(wildcard $(DIR)/*.txt)
OUTPUTS = $(patsubst $(DIR)/%.txt,%.txt,$(INPUTS))
all: $(OUTPUTS)
.PHONY: $(INPUTS)
check:
#echo "DIR = $(DIR)"
#echo "INPUTS = $(INPUTS)"
#echo "OUTPUTS = $(OUTPUTS)"
%.txt: $(DIR)/%.txt
sed -e "s/test/cat/g" "$<" > $#
For now, the contents of ../src/ are test1.txt and test2.txt.
As the Makefile stands now, running make test2.txt generates the file as expected.
target/ $ make test2.txt
sed -e "s/test/cat/g" "../src/test2.txt" > test2.txt
Running make check shows the INPUTS and OUTPUTS correctly.
target/ $ make check
DIR = ../src
INPUTS = ../src/test1.txt ../src/test2.txt
OUTPUTS = test1.txt test2.txt
If I run make all, it generates every file, every time. This is expected with the .PHONY $(INPUTS) line in there.
If I remove the .PHONY $(INPUTS) target, Make gets all bound up in itself trying to find the target to make ../src/test1.txt and keeps prefixing $(DIR) in front of it until it makes too long of a filename and gives up.
make: stat: ../src/../src/../src/ [repeat for a few pages] ../src/../src/test1.txt: File name too long
make: stat: ../src/../src/../src/ [repeat for a few pages] ../src/../src/../src/test1.txt: File name too long
make: *** No rule to make target `../src/../src/../src/[repeat]../src/../src/test1.txt', needed by `../src/[repeat]../src/../src/test1.txt'. Stop.
It never does get to processing test2.txt.
As I was drafting this, I had the idea to remove the ../ from the DIR,
and relocate the Makefile so it was parent to both src/ and target/. That approach seems to work, but isn't ideal. Eventually there would be a chain of these Makefiles, each pulling from one directory to another.
Is there a way to keep the Makefile in 'target/' along with the generated destination files, and base those destination files off of something in a relative path?
Replace
%.txt: $(DIR)/%.txt
with:
${CURDIR}/%.txt: $(DIR)/%.txt
This way %.txt does not match any .txt file in any directory. In other words, you limit this rule's scope to files in ${CURDIR}/ only and this prevents that endless recursion.
See ยง10.5.4 How Patterns Match for more details.
It is also good practice to avoid relative paths:
DIR = $(abspath ../src)

How can I add a folder or file to the root in a recipe with bitbake?

I am trying to put a folder into the root of the filesystem. In the documentation (e.g. here) they use mostly variables and so the files and folders from SRC_URI result in being stored under /usr/bin or something but never in /.
So here is my recipe:
DESCRIPTION = "Example for adding files and folders to rootfs"
SRC_URI += "file://example_folder"
SRC_URI += "file://example_file"
LICENSE = [...]
do_install() {
install -d ${D}/rootfolder
cp -r ${WORKDIR}/example_folder ${D]/rootfolder/
install -m 0755 ${WORKDIR}/example_file ${D}/rootfolder
}
This is just one of very many do_install variants that I tried.Every of them resulted in either Error: example not found in the base feeds [...] or that the files and folders haven't been placed in the root but in /usr/bin as explained above.
In the cases were you get the error "Error: example not found in the base feeds [...]" it's quite likely that you actually have succeeded in building your recipe example.bb. Assuming of course, that you get that error when building your image, which has IMAGE_INSTALL += "example" in it.
If you install your files into /rootfolder, there's nothing in OE itself that knows how to package those files into an rpm, ipk, or deb package. You need to add that yourself to your recipe by adding a line like:
FILES_${PN} += "/rootfolder"
Doing that, your example above should work.
Depending on what files you install, you might want to add some of them to other packages like ${PN}-dbg, ${PN}-dev, etc.

Create directory only once when running makefile in parallel

I'm using make to write a pipeline for biological data analysis. My project directory is:
PROJECT
- DATA
- SAMPLEA
- A1.FASTQ A2.FASTQ
- SAMPLEB
- B1.FASTQ B2.FASTQ
- RESULTS
- SRC
- makefile
My current makefile uses a wildcard to list the directory of all .FASTQ files in the DATA directory. Using pattern rules each .FASTQ file then goes through a series of recipes with the final output file written to the RESULTS directory. Instead, I would like to create a directory for each SAMPLE where the final output file is written:
PROJECT/RESULTS/SAMPLEA/A1.out
PROJECT/RESULTS/SAMPLEA/A2.out
PROJECT/RESULTS/SAMPLEB/B1.out
PROJECT/RESULTS/SAMPLEB/B2.out
I can do this by having the first recipe make the directory, however this throws an error when the second of the FASTQ files from the same SAMPLE also tries to create the directory. A few posts on stack overflow suggest using the -p flag on mkdir to ignore errors, however this apparently causes problems when I run the makefile in parallel using the -j flag. I thought about forcing a shell script at the start of the makefile to run, to check if the results directories are present, and if not then it should create them, but I'd like to try and solve this issue using just make.
Create directory before executing rule.
DATADIR := $(shell cd DATA; find * -type d)
create_results_dir:= $(shell for i in $(DATADIR); \
do test -d DATA/$$i && mkdir -p RESULTS/$$i; \
done)
all:
#echo do something.

Resources