Giter VIP home page Giter VIP logo

kbuild-standalone's Introduction

Standalone kconfig and kbuild

Motivation

KConfig and KBuild are powerful tools for building large projects written in mostly .c. They are parts of Linux kernel source code. Linux uses them to build itself. Some open source projects such as busybox and UBoot also use it as their building framework. However, sinces they are part of Linux kernel, they have to be forked and merged into the project who wish to use it. After forking, the connection between the project and Linux kernel is broken. Projects choose to use them has to maintain these tools by itself to get new features and fix bugs.

The goal of this project is to provide standalone kconfig and kbuild. Other projects can depend on this project as basic tools for building like gcc and make, instead of merging them into their own source code.

Currently, this project contains:

  • kconfig: Standalone conf and mconf executable which reads Kconfig source code and output .config.
  • kbuild: Basic kbuild makefile scripts are brought from Linux kernel. A wrapper is provided to make it work standalone.
  • fixdep, unifdef: Small tools in Linux kernel for building.

kconfig

Building kconfig standalone

 $ git clone https://github.com/WangNan0/kbuild-standalone.git
 $ cd kbuild-standalone
 $ mkdir build
 $ cd build
 $ make -C ../ -f Makefile.sample O=`pwd` -j
 $ ls ./kconfig/*conf
   ./kconfig/conf  ./kconfig/mconf

conf and mconf can be used to config linux kernel:

 $ git clone https://github.com/torvalds/linux.git
 $ cd linux

# menuconfig
 $ SRCARCH=x86 srctree=`pwd` CC=gcc /path/to/mconf ./Kconfig

# allyesconfig
 SRCARCH=x86 srctree=`pwd` CC=gcc /path/to/conf --allyesconfig ./Kconfig

# defconfig
 SRCARCH=arm srctree=`pwd` CC=arm-none-eabi-gcc /path/to/conf \
	--defconfig=arch/arm/configs/vexpress_defconfig ./Kconfig

kbuild

Makefile.sample is also an simple example about how kbuild standalone can be used in other project by simply setting following make variables:

  • KBUILD_STANDALONE_SRCDIRS: source directories of this project.
  • KBUILD_STANDALONE_TARGETS: targets to build using kbuild standalone.
  • KBUILD_STANDALONE_PREPARE: targets to build before KBUILD_STANDALONE_TARGETS
  • <target>_GOAL: make goals list passed to <target>/Makefile.
  • <target>_CONF: config of a target, like need-builtin=1.

Then include Makefile.include which can be found using pkg-config.

Maintenance

This project keeps syncing with Linux kernel. When Linux has a new release, we sync updates from Linux kernel to keep us identical with upstream. Therefore, we will not accept new feature or bugfix by our own. Instead, we try to make them upstream then sync them back.

Version number of this project comes from source version of Linux kernel. It contains 2 or 3 digits. The first 2 digits are version and patchlevel of corresponding Linux kernel (for exmaple, 5.6). The third digit is vesion of this project itself. Each time when bumping Linux kernel version, the third digit would be reset to 0 and ignored.

kbuild-standalone's People

Contributors

mgliga-bd avatar wangnan-pi3orama avatar wangnan0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kbuild-standalone's Issues

how to cross build

trying to (cross) build statically against musl and netbsd-curses

configure does not pickup properly

  • x86_64-linux-musl-gcc
  • -lncursesw
  • -ltinfo

Encountered Makefile.compiler: No such file or directory

I followed the instructions of the README to

make -C ../ -f Makefile.sample O=pwd -j

But, I got an error.

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

.source/scripts/Makefile.build:39: .source/scripts/Makefile.compiler: No such file or directory
make[2]: *** No rule to make target '.source/scripts/Makefile.compiler'. Stop.

I'm not sure I should add '-' before 'include $(srctree)/scripts/Makefile.compiler' at line 39 on kbuild/scripts/Makefile.build or copy Makefile.compiler file from linux.

If I copy Makefile.compiler file from linux, Makefile.am file I did not know if it is affected.

.source/scripts/check-local-export and .kernel.exec.cmd files are not found

I have tried to configure and build the example provided in the tree, I have been able to configure it with menuconfig, but when try to build the example I receive the following error:

$ make O=build
make -f .source/scripts/Makefile.build obj=arch
need-builtin=1
CC arch/x86_64/arch.o
/bin/sh: 1: .source/scripts/check-local-export: not found
make[3]: *** [.source/scripts/Makefile.build:252: arch/x86_64/arch.o] Error 127
make[3]: *** Deleting file 'arch/x86_64/arch.o'
make[2]: *** [.source/scripts/Makefile.build:504: arch/x86_64] Error 2
make[1]: *** [/home/masalkhi/devel/kbuild-standalone/kbuild/Makefile.main:31: _build_arch] Error 2
make: *** [/home/masalkhi/devel/kbuild-standalone/kbuild/Makefile.output:48: sub-make] Error 2

I have look for the kbuild-standalone/kbuild/scripts/check-local-export i did not find it.

One other thing. the example/kbuild/Makefile.main Makefile contain the following:

# Manually include cmd file because we are not in Makefile.build.
# It is required to make if_changes works
-include .kernel.exec.cmd

.kernel.exec.cmd, I did not find this file too

How can I use it for my custom project build

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.