WangNan0 / kbuild-standalone

Standalone kconfig and kbuild
GNU General Public License v2.0
54 stars 18 forks source link

How can I use it for my custom project build #1

Closed nikitos1550 closed 3 years ago

nikitos1550 commented 3 years ago

Hi!

I found your repo, and it seems the thing I was looking for. I successfully built kbuild-standalone according README.md

I added test dir with test.c and Makefile ( obj-y += test.o ) Added test target to Makefile.sample, but build failed as some cflags were added to .o: .c target, that I was not expected, like there was include some header file (seems from kernel).

So the question is, what is proper way to use this repo (without customization, but as dep) for custom projects? Or was this project created for Linux Kernel build? Could you help a bit and make thing more clear for me, as I was looking for Kconfig for my project, but Kbuild maybe will be also ok, if there is a way to use it without over-complication.

WangNan0 commented 3 years ago

An example project is introduced to demonstrate a standard way to use this project. Hope it help.

nikitos1550 commented 3 years ago

Yep, but actually I wanted point following:

make -f .source/scripts/Makefile.build obj=test test/test.o \

  CC      test/test.o
cc1: fatal error: .source/include/linux/compiler_types.h: No such file or directory
compilation terminated.

Test project was added:

user@PC:./test$ ls
Makefile  test.c
user@PC:./test$ cat ./Makefile 
obj-y += test.o

It fails because of:

./kbuild/scripts/Makefile.lib-200-7469-c_flags        = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
./kbuild/scripts/Makefile.lib:201:7546:      -include $(srctree)/include/linux/compiler_types.h       \
./kbuild/scripts/Makefile.lib-202-7608-      $(_c_flags) $(modkern_cflags)                           \
./kbuild/scripts/Makefile.lib-203-7669-      $(basename_flags) $(modname_flags)

I don`t expect any predefined flags for my project, but there are such flags. The question is, am I doing something wrong, or should I tune scrpts for my project? Could you comment on this?

WangNan0 commented 3 years ago

$(srctree)/include/linux/compiler_types.h is hard coded into Linux kernel source and no way to configure. You should somehow create one to convince kbuild. In our example project, example/kbuild/Makefile.prepare helps you do this job silently.

nikitos1550 commented 3 years ago

I found example, that you mentioned. You just added this. Thanks!