Coder Social home page Coder Social logo

z08053520 / kbuild_skeleton Goto Github PK

View Code? Open in Web Editor NEW

This project forked from masahir0y/kbuild_skeleton

0.0 2.0 0.0 340 KB

A template with Linux kernel like build system.

License: GNU General Public License v2.0

Makefile 6.88% C 73.84% Shell 0.68% C++ 11.47% Perl 2.21% Lex 1.48% Yacc 3.45%

kbuild_skeleton's Introduction

kbuild_skeleton

A template with Linux Kernel like build system (Kbuild).

Writing a basic makefile for a small project is fairly simple. But when you maintain a large project, you will probably need more than just basics: automatic dependency tracking, recursive builds in subdirectories, and so on. Instead of implementing those functions by yourself, you can use Autotools (Autoconf/Automake/Libtool). Especially, you are following GNU Coding Standards, Autotools would be a best choice. Otherwise, Kbuild are also quite powerful, recommended build system. Now some open source projects such as busybox, are using Kbuild, although, originally, kbuild system were written for Linux Kernel.

This project includes a pretty simple application with Kbuild system. Some files needed for Kbuild features were copied from Linux Kernel. Copied files include the top-level Makefile and some helper programs and makefiles under scripts/ directory. They were modified for simplisity because modules support are not necessary for general applications.

I hope this template will be a good startpoint of your new project.

Building

    make config    # This creates a file called ".config"
    make           # This creates an executable

These steps generate a small application myapp, which just print some messages to the console.

The full list of configuration and build targets is available by:

    make help

How to use this template?

This project includes a small program called myapp just for example. So when you start your own project, replace C source files of myapp with those of your own. C source files of myapp are located under lib/ and main/ and include/. If you don't need them, delete all of them. Although, of course, you can still reuse them for your own project. You will also need to modify Kconfig for your project.

In order to change the name of application, modify the top-level Makefile.

    grep -i myapp *

will show the lines where myapp string are used. Modify those myapp strings with your application name.

You can add more subdirectories by adding to objs-y or libs-y variables of top-level Makefile. For myapp, these variable are set as follows:

    objs-y          := main
    libs-y          := lib

In this case, all objectes under main/ subdirectory are combined together into main/builtin.o, and all objects under lib/ subdirectory are archived as lib/lib.a. Finally, they are linked to generate the final application, myapp.

About the detail of how to write makefiles under subdirectories, refer to: Documentation/kbuild/makefiles.txt.

About how to write Kconfig, refer to: Documentation/kbuild/kconfig-language.txt.

Both of them were copied from Linux Kernel Documentation.

kbuild_skeleton's People

Contributors

masahir0y avatar

Watchers

James Cloos avatar SkyZhang avatar

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.