Makefile : no rule to make target '/constants.py.in' needed by '/constants.py'. Stop - linux

i'm currently working on an ubuntu 18.0.4.5 machine and i've been trying to figure out the whole kernel debugging process.
I've stumbled upon the need to auto run GDB scripts along with the vmlinux file, particulary the script residing under /usr/src/linux../scripts/gdb/vmlinux-gdb.py.
I made sure the script ran on initialization with the vmlinux file and had the following error
gdb vmlinux
File "/usr/src/linux-hwe-5.4-headers-5.4.0-42/scripts/gdb/vmlinux-gdb.py", line 34, in <module>
import linux.proc
File "/usr/share/gdb/auto-load/gdb/linux/proc.py", line 15, in <module>
from linux import constants
ImportError: cannot import name 'constants'
After this error occured I checked the /usr/share/gdb/auto-load/gdb/linux directory to look for the missing file and only found 2 related files:
constants.py.in
Makefile
Inside the constants.py.in file was C code mixed with python and was commented that the build will take care of that.
The exact Makefile and constants.py.in files can be found here for reference: https://elixir.bootlin.com/linux/v5.4/source/scripts/gdb/linux/Makefile
https://elixir.bootlin.com/linux/v5.4/source/scripts/gdb/linux/constants.py.in
Trying to build for the first time resulted in this:
make: *** No rule to make target '/constants.py.in', needed by '/constants.py'. Stop.
After some trial and error (i'm not experienced in Makefile language) I copied constants.py.in to the / directory and tried to build again and recieved the following error:
make: *** No rule to make target 'FORCE', needed by '/constants.py'. Stop.
I don't understand what does that FORCE is, looks like some kind of makefile configuration but i can't find a reasonable explantion or patch, the same errors occur when trying to build anything under /usr/src/linux-.../
trying to understand how to fix the build process and eventually create the correct constants.py that is hopefully the last piece to making the vmlinux-gdb.py work during debugging

Running make scripts_gdb at the top level of the source tree will run through a few other Makefiles and eventually build constants.py. You'll see some make chatter like the following:
builder#localhost:/tmp/linux/linux-5.4.125$ make V=1 scripts_gdb
make -f ./scripts/Makefile.build obj=scripts/basic
...
make -f ./scripts/Makefile.build obj=scripts/gdb
make -f ./scripts/Makefile.build obj=scripts/gdb/linux
gcc -E -E -x c -P -Wp,-MD,scripts/gdb/linux/.constants.py.d ... \
scripts/gdb/linux/constants.py.in > scripts/gdb/linux/constants.py ;\
sed -i '1,/<!-- end-c-headers -->/d;' scripts/gdb/linux/constants.py
ln -fsn /tmp/linux/linux-5.4.125/scripts/gdb/vmlinux-gdb.py
After this completes,vmlinux-gdb.py will be usable.

Related

Compiling fluoride bluetooth stack for embedded linux

Has anyone been able to compile fluoride bluetooth stack separately for an embedded linux device?
There is a guide at https://android.googlesource.com/platform/system/bt/+/181144a50114c824cfe3cdfd695c11a074673a5e/README.md, but following these instructions gn gen fails without getting the common-mk folder and modding some build files so there are no missing variables, folders etc.
I have been able to generate Ninja files, but when building, there are missing gtest and modp_b64 headers. After getting them from Google's source search, Ninja seems to be able to run a bit without errors, but ultimately fails with:
In file included from ../../third_party/libchrome/base/message_loop/message_loop.h:18:
../../third_party/libchrome/base/message_loop/message_loop_current.h:209:3: error: static_assert failed due to requirement 'std::is_same<MessagePumpForUI, MessagePumpLibevent>::value' "MessageLoopCurrentForUI::WatchFileDescriptor is not supported when MessagePumpForUI is not a MessagePumpLibevent."
static_assert(std::is_same<MessagePumpForUI, MessagePumpLibevent>::value,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../third_party/libchrome/base/message_loop/message_loop_current.h:214:28: error: no type named 'Mode' in 'base::MessagePumpGlib'; did you mean 'MessagePumpLibevent::Mode'?
MessagePumpForUI::Mode mode,
^~~~~~~~~~~~~~~~~~~~~~
MessagePumpLibevent::Mode
../../third_party/libchrome/base/message_loop/watchable_io_message_pump_posix.h:55:8: note: 'MessagePumpLibevent::Mode' declared here
enum Mode {
^
In file included from ../../third_party/libchrome/base/run_loop.cc:10:
In file included from ../../third_party/libchrome/base/message_loop/message_loop.h:18:
../../third_party/libchrome/base/message_loop/message_loop_current.h:215:28: error: no type named 'FdWatchController' in 'base::MessagePumpGlib'; did you mean 'MessagePumpLibevent::FdWatchController'?
MessagePumpForUI::FdWatchController* controller,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MessagePumpLibevent::FdWatchController
../../third_party/libchrome/base/message_loop/message_pump_libevent.h:28:9: note: 'MessagePumpLibevent::FdWatchController' declared here
class FdWatchController : public FdWatchControllerInterface {
^
In file included from ../../third_party/libchrome/base/run_loop.cc:10:
In file included from ../../third_party/libchrome/base/message_loop/message_loop.h:18:
../../third_party/libchrome/base/message_loop/message_loop_current.h:216:28: error: no type named 'FdWatcher' in 'base::MessagePumpGlib'; did you mean 'MessagePumpLibevent::FdWatcher'?
MessagePumpForUI::FdWatcher* delegate);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
MessagePumpLibevent::FdWatcher
../../third_party/libchrome/base/message_loop/watchable_io_message_pump_posix.h:17:9: note: 'MessagePumpLibevent::FdWatcher' declared here
class FdWatcher {
^
4 errors generated.
All the errors and missing files are coming from third_party/libchrome
Any help would be much appreciated.
I followed instructions at https://cs.android.com/android/platform/superproject/+/master:system/bt/README.md
In addition to instructions there, I had to resolve issues in the build script manually. I was able to compile the bluetooth stack successfully in Ubuntu 21.04
Replace //bt with /home/udara/fluoride/bt in build files.
Used sed command. Change to your fluoride directory as appropriate.
for file in $(grep -r -l "//bt"); do sed -i 's/\/\/bt/\/home\/udara\/fluoride\/bt/g' $file; done
Copied common-mk symlink generated by bootstrap.py to the fluoride directory.
And replaced //common-mk with /home/udara/fluoride/common-mk.
for file in $(grep -r -l "//common-mk"); do sed -i 's/\/\/common-mk/\/home\/udara\/fluoride\/common-mk/g' $file; done
Installed few missing dependencies
sudo apt install llvm
sudo apt install libc++abi-dev
Copied /home/udara/fluoride/bt/output/out/Default/gen/ABS_PATH/home/udara/fluoride/bt/gd/dumpsys/bundler/bundler_generated.h to /home/udara/fluoride/bt/gd/dumpsys/
cp /home/udara/fluoride/bt/output/out/Default/gen/ABS_PATH/home/udara/fluoride/bt/gd/dumpsys/bundler/bundler_generated.h /home/udara/fluoride/bt/gd/dumpsys/
Created directory named output in the bt directory.
Set environment variables
# this is set by bootstrap.py
export STAGING_DIR=/home/udara/fluoride/staging
# you have to manually set this
export OUTPUT_DIR=/home/udara/fluoride/bt/output
Then compile the bluetooth stack with
./build.py --output ${OUTPUT_DIR} --platform-dir ${STAGING_DIR} --clang
Add the following lines to /etc/dbus-1/system.d/bluetooth.conf
<policy>
...
<allow own="org.chromium.bluetooth"/>
<allow own="org.chromium.bluetooth.Manager"/>
</policy>
Finally run fluoride with
cd /home/udara/fluoride/bt/output/debug
sudo ./btadapterd --hci=0 INIT_gd_hci=true
The reason the common-mk issues are coming up because between the instructions being written, and now, libchrome has added a BUILD.gn file - so it is being used, instead of the substitute one in build/secondary/third-party/libchrome as intended. To fix this part of the build, just delete third-party/libchrome/BUILD.gn - should prevent the need for a lot of build fiddling.
The second part is because of the configuration of libchrome. Once you remove the file mentioned, then you need to modify build/secondary/third-party/libchrome/BUILD.gn to add the following not just to the source_set (as is done in upstream) but also to libchrome_config for downstream users:
defines = [
"__ANDROID_HOST__=1",
]
This will affect the build config so it doesn't try to use glib.
My best work on getting this to build is here, though I haven't gotten it to work entirely. https://github.com/rpavlik/fluoride I did this mostly as an experiment, feel free to continue where I left off.

miss asm/types.h in linux compile

lenge#lenge-pc:/lenge/linux/kernel_online$ git branch
master
* tag_v4.15
CONFIG is defconfig.
when I compile kernel(v4.15), error occurred, as follows:
In file included from
/lenge/linux/kernel_online/include/linux/types.h:6,
from /lenge/linux/kernel_online/include/linux/page-flags.h:9,
from /lenge/linux/kernel_online/kernel/bounds.c:10:
/lenge/linux/kernel_online/include/uapi/linux/types.h:5:10: fatal
error: asm/types.h: No such file or directory #include <asm/types.h>
^~~~~~~~~~~~~ compilation terminated.
That is my compile method:
make ARCH=arm64 -C /lenge/linux/kernel_online O=/lenge/linux/kernel_out_aarch64 CROSS_COMPILE=/lenge/gnu/aarch64/bin/aarch64-lenge-linux-gnu- -j4
I create symbolic link as fallows:
ln -s /lenge/linux/kernel_out_aarch64/source/arch/arm64/include/generated/uapi/asm arch/arm64/include/generated/uapi/asm
It's OK.
I just had the same issue cross-compiling to arm64.
I noticed I had some generated files in my source tree even though I use an output directory for my build (O=). I'm not sure if I accidentally omitted O= one time or what happened, but this was messing things up.
To resolve this, I ran make clean (or make mrproper if you're paranoid) in the source directory to remove all generated files. Rerunning my normal make command with O= succeeded, and did not result in generated files in my source dir (as expected).

Makefile.inc: No such file or directory

I don't have much experience with makefiles, but I am trying to compile and run the program "hdf5ToMds.c" found on this Github repository: https://github.com/MDSplus/mdsplus/tree/alpha/hdf5
My steps towards using the Makefile.in in the folder were as follows:
autoscan
mv configure.scan configure.ac
aclocal
autoheader
autoconf
./configure
make
Now when I run the make I get the error:
Makefile:1: Makefile.inc: No such file or directory
make: *** No rule to make target 'Makefile.inc'. Stop.
Am I missing something obvious? I'm not very familiar with this whole process of getting the code from Github and having to make it. I do have the entire repository cloned, just in case that's relevant.

Find exact point where 'make' fails

I'm working with a modified version of Contiki in conjunction with an extension (a pub/sub system) and had to port some code around. This is on Linux.
Currently, the traditional 'make' execution of the pub/sub system fails, most likely because of a different folder structure.
I'm unable to find where I need to adjust it however and the problem is there are so many nested makefiles and include commands and such that I can't seem to find it. I get the error beneath and I know that the correct uip6.c location is /net/ip/uip6.c but I can't find the place to make that adjustment. Any suggestions on how I can identify that?
selected command: make
execute make command with args:
make -f ../core/Makefile.looci loociCore.hex > debug.txt
/home/looci/looci/lnk/lc_contiki/platform/avr-zigduino/Makefile.early.avr-zigduino:1: loading AVR zigduino early makefile fuses
fatal: Not a git repository: '/home/looci/looci/lnk/lc_contiki_os/.git'
/home/looci/looci/lnk/lc_contiki/core/reconfiguration/reconfigurationEngine.c: In function ‘on_event’:
/home/looci/looci/lnk/lc_contiki/core/reconfiguration/reconfigurationEngine.c:663:2: warning: implicit declaration of function ‘mmem_freememory’
avr-gcc: /home/looci/looci/lnk/lc_contiki_os/core/net/uip6.c: No such file or directory
make[1]: *** [obj_avr-zigduino/uip6.o] Error 1
make: *** [all] Error 2

Changing directories for the makefile in xScreenSaver

I am trying to build an xsreensaver module using the makefile. I downloaded the source from http://www.jwz.org/xscreensaver/, and read the hacking readme.
As my screensaver involves opengl and reading of images, I'm trying to compile the 'photopile' screensaver.
I've run the following
$ cd xscreensaver-5.29
$ cd hacks
$ cd glx
$ make photopile
After running I get the following output errors
cc photopile.c -o photopile
photopile.c:38:23: fatal error: xlockmore.h: No such file or directory compilation terminated.
make: *** [photopile] Error 1
The referenced file is in the "hacks" root folder rather than the "glx" folder. I realize it would be simple enough to just copy that needed file to "glx", but the "xlockmore.h" file is not the only file that its trying to find that is not in the current directory.
It is also looking for "yarandom.h" in the "../../utils" folder.
I'm assuming the makefile was made correctly, and that I am doing something wrong with regards to calling the
make photopile
option from within the "glx" folder.
I'm still learning makefiles and would rather not modify it (or the directory structure by copying header files) anymore than the directions say to.
Any advice?

Resources