Git Product home page Git Product logo

makefile_template's Introduction

makefile_template

便于移植的 makefile 模板

1. 介绍

这是 makefile 模板,支持gccarm-none-eabi-gcc两种编译器,只需要修改少量文件就能移植。

1.1 目录结构

通俗地说,makefile是主驱动,makefile.build是通用的规则和工具,build.mk则是数据。

.
├── app
│   ├── b.c
│   ├── build.mk
│   └── main.c
├── build.mk
├── component
│   ├── build.mk
│   └── mt.c
├── drv
│   ├── build.mk
│   ├── c.c
│   └── led
│       ├── build.mk
│       └── d.c
├── include
│   └── demo.h
├── lib
│   ├── build.mk
│   └── hal_drv
│       ├── inc
│       └── src
│           └── e.c
├── Makefile
├── Makefile.build
└── readme.md

1.2 许可证

makefile_template 遵循 LGPLV2.1 许可,详见LICENSE文件。

1.3 版本日志

  • v1.0
    • makefile 初版

2. 如何使用

2.1 移植到新的工程,哪些文件需要修改?

  • build.mk
  • makefile

换句话说,此 makefile 模板想应用于新工程,只需要带上MakefileMakefile.build即可,build.mk要重新写。

2.2 build.mk怎么写(如何添加文件、目录)?

build.mk 的作用是添加要编译的文件,那么如果目录存在嵌套呢?

  • 如何添加main.c?(.s, .S也是一样的做法)

    • obj-y += main.o

    注意:写的是.o

  • 如何添加demo.h

    • CCFLAGS += -I$(src)/include
  • 如何添加目录?

    • obj-y += tuzi/

    注意:tuzi后面的/一定不能漏掉!!!

2.3 何时需要添加build.mk

  • 如果想方便看清目录结构

    • 例如ipc组件,内存管理组件,有各自的build.mk
  • 如果此目录的内容,想比较方便地增删

    • 例如驱动组件

2.4 何时不需要添加build.mk

  • 添加库
    • 例如上面目录结构的lib/

总的来说,整个工程里build.mk可以只有一个,也可以有多个,只要能清晰划分组件结构以及方便增删就可以了。

2.5 makefile如何修改?

makefile里的CCFLAGSASFLAGSLDFLAGS参数根据具体的需求修改

makefile_template's People

Watchers

James Cloos 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.