bitbake BBPATH confusion - yocto

In the bitbake manual (https://www.yoctoproject.org/docs/1.6/bitbake-user-manual/bitbake-user-manual.html) it says:
3.3.1. Locating Include and Class Files
BitBake uses the BBPATH variable to locate needed include and class files. The BBPATH variable is analogous to the environment variable PATH.
3.3.3. include Directive
BitBake understands the include directive. This directive causes BitBake to parse whatever file you specify, and to insert that file at that location. The directive is much like its equivalent in Make except that if the path specified on the include line is a relative path, BitBake locates the first file it can find within BBPATH.
As an example, suppose you needed a recipe to include some self-test definitions:
include test_defs.inc
However, I see many openembedded-core recipes that include files that seem to be relative to the file they are being included from rather than being in a directory in BBPATH, i.e.
Assume we have this directory structure:
mything.bb
mything.inc
include/mything.inc
And mything.bb contains:
require mything.inc
require include/mything2.inc
However, these files are not in the BBPATH. I run bitbake -e mything.bb and BBPATH clearly does not contain the directory containing mything.inc or include/mything2.inc.
So the question is, is it true that include/require directives first search for the file relative to the file the directive appears in? Then and the falls back to searching for it in the BBPATH? If so, is this feature just missing from the bitbake user manual documentation?

Related

How to compile to custom libdir path postgresql

I want to custom libdir to bindir. by default prefix is root. so sub-dir (bin, lib, include, share) will inside prefix. after i custom it. i got this error. like i wrong to use --libdir command. but it tells to put absolute path.
58P01: could not open directory "C:postgresql-14.uilin":
./configure --prefix="c:/postgresql/build" --libdir="c:/postgresql/build/bin"
make
make install

Does a recipe provided as DEPENDS can have own do_install() in yocto?

I am trying to build a custom recipe with Yocto (Rocko) for my Linux i.MX6 based embedded system.
The main recipe had dependency on a other custom recipe(as the main recipe is using header-files from this recipe) which is also creating some binaries which needs to be included in the final image.
I have added other_recipe(nbdkit) in the "DEPENDS" of main_recipe.bb
DEPENDS += "nbdkit"
the main recipe is creating a .so with the help of its own source file which is including header-files from the 'kit' recipe. I am able to install the binaries & .so generated using this main_recipe by adding it in do_install().
Now in the other_recipe(nbdkit http://cgit.openembedded.org/meta-openembedded/tree/meta-networking/recipes-support/nbdkit/nbdkit_git.bb?h=master), When I add do_install()to include the binaries generated from that recipe the main_recipe build gets failed with PKG_CONFIG error as follow,
| Package nbdkit was not found in the pkg-config search path.
| Perhaps you should add the directory containing `nbdkit.pc'
| to the PKG_CONFIG_PATH environment variable
| No package 'nbdkit' found
Other build errors says that the header-files of kit included in the main_recipe is not found.
app-nbdkit-plugin.c:2:10: fatal error: nbdkit-plugin.h: No such file or directory
Where app-nbdkit-plugin.c is source file of main_recipe & kit-plugin.h is header file of other_recipe.
The strange thing is, when I remove do_install() from other_recipe(nbdkit) the main_recipe is getting built successfully.
Now I doubt, Is it possible to set a recipe as DEPENDS of other recipe and at the same time it provides output file as do_install()?
Will sharing header-files from other_recipe to main_recipe resolves the issue? If yes, how to do that?
Thanks.
[EDIT] Added nbdkit recipe link.

Yocto using .bbappend file to override writing of default init scripts for initramfs

I am trying to write a .bbappend file that will append to the initramfs-live-boot_1.0.bb which has a statement inside the do_install() that writes the contents of init-live.sh, a shell script that manages the boot procedure, to init, an initialisation script that runs upon boot. The purpose of my .bbappend file is to reference a modified version of the startup script to be copied in place of the original without changing the base openembedded-core and/or poky environments. The .bbappend file and my version of the script is therefore placed in my project directory with the rest of my own recipes to be built.
My initramfs-live-boot_1.0.bbappend looks like this:
SUMMARY = "Replacement recipe"
FILESEXTRAPATH_prepend := "${THISDIR}/files:"
SRC_URI += "file://init.sh"
do_install_append() {
install -m 0755 ${WORKDIR}/init.sh ${D}/init
}
I have a folder files in the same directory as the .bbappend file that contains the init.sh script it should be reading from.
The problem is when I try to build the image, it spits out this error:
WARNING: Failed to fetch URL file://init.sh, attempting MIRRORS if available
and then attempts to search through the poky directory for the missing files rather than in my project directory.
Have I written my .bbappend file wrong? How would I go about editing the initramfs scripts using the .bbappend file?
FILESEXTRAPATH_prepend := "${THISDIR}/files:" should be FILESEXTRAPATHS_prepend := "${THISDIR}/files:". Note the last S in FILESEXTRAPATHS.
That should make it work for you.
Another improvement would be to rename you file file from init.sh to init-live.sh. I.e. use the same name as the file in the original initramfs-live-bootrecipe. That would allow you to remove your do_install_append()-function as well as SRC_URI += "file://init.sh" from the bbappend. The recipe itself would handle those for you. Thus, the only line you'd actually need is the FILESEXTRAPATHS_prepend := "${THISDIR}/files:".

How can I make ExtUtils::Manifest include empty directories?

I am trying to build a Perl module for distribution. The directory structure looks like this:
demo
demo/files
demo/examples/example1.pl
demo/scripts
lib
I used this command to generate the MANIFEST file:
perl -e "use ExtUtils::Manifest qw(mkmanifest); mkmanifest();"
The file is created but all of the empty folders are ignored, so demo/files and demo/scripts are not in the MANIFEST.
How can I tell ExtUtils::Manifest to include empty folders?
Create a zero byte file called .exists in the otherwise empty directories.

Using Makefile to add new source code files to Postgresql

I'm working on adding some functionality to the storage manager module in Postgresql.
I have added few source files already to the smgr folder, and I was able to have the Make system includes them by adding their names to the OBJS list in the Makefile inside the smgr folder. (i.e. When I add A.c, I would add A.o to the OBJS list).
That was working fine. Now I'm trying to add a new file hdfs_test.c to the project. The problem with this file is that it requires some extra directives in its compilation command (-I and -L directives).
The gcc command is:
gcc hdfs_test.c -I/HDFS_HOME/hdfs/src/c++/libhdfs -I/usr/lib/jvm/default-java/include -L/HDFS_HOME/hdfs/src/c++/libhdfs -L/HDFS_HOME/build/c++/Linux-i386-32/lib -L/usr/lib/jvm/default-java/jre/lib/i386/server -ljvm -lhdfs -o hdfs_test
Therefore, simply adding hdfs_test.o to the OBJS list doesn't work.
I tried editing the Makefile to look like this:
OBJS = md.o smgr.o smgrtype.o A.o B.o hdfs_test.o
MyRule1 : hdfs_test.c
gcc tati.c -c -I/diskless/taljab1/Workspace/HDFS_Append/hdfs/src/c++/libhdfs -I/usr/lib/jvm/default-java/include -L/diskless/taljab1/Workspace/HDFS_Append/hdfs/src/c++/libhdfs -L/diskless/taljab1/Workspace/HDFS_Append/build/c++/Linux-i386-32/lib -L/usr/lib/jvm/default-java/jre/lib/i386/server -ljvm -lhdfs
but it didn't work out, and I kept getting errors message of the Make trying to compile hdfs_test.c without including the directives.
How do I enforce the Make to include my compilation directives for hdfs_test.c ?
Thanks
You don't need to pass -l and -L at compile time, only at link time. At compile time only -I (include path) directives are required to help the compiler find any extra headers.
You should compile your source file to a .o file, same as all the others. Then add the -L and -l directives to the link command line when the linker is invoked to create the postgres executable. That means all you need to edit in src/backend/storage/smgr/Makefile is the OBJS line to add your output object, as you've already done below. Remove your custom rule, it's unnecessary as well as incorrect.
Just add your extra libraries to the $(LIBS) make variable and add your -L paths to $(LDFLAGS) via src/Makefile.global. src/Makefile.global is generated by configure from src/Makefile.global.in so you actually need to modify configure's behavior to add your includes, library paths and libraries. Don't edit configure directly either; edit configure.in and re-generate it with autoconf.
Yes, GNU Autotools is sometimes referred to as autohell for a reason. It's a bit ... interesting ... to work with sometimes, and there can be a lot of indirection involved in doing simple things.