GenericMakefile

一个通用的makefile,用于小型/中型C和C++项目。「A generic makefile for use with small/medium C and C++ projects.」

Github星跟蹤圖

GenericMakefile

A generic makefile for use with small/medium C and C++ projects. Allows for
easy project setup without the need to create tedious build rules or
dependency lists. The c directory contains a makefile configured for C, while
the makefile in the cpp directory is configured for C++.

Features

  • Automatically finds and compiles all source files within the source directory.
  • Compiles most recently modified files first, to hopefully find problems earlier.
  • Automatically generates dependecies as files are compiled, ensuring that files are correctly recompiled when dependecies have updated.
  • Includes configurations for normal (release) build and debug build suitable for GDB debugging.
  • Times the compilation of each file and the entire build.
  • Generates version numbers based on git tags (see below), which are passed the compiler as preprocessor macros.
  • By default, builds in a "quiet" mode that only lists the actions being performed. By passing V=true to make, you can compile in verbose mode to see the full compiler commands being issued.

Versioning

Tags should be made in the format vMAJOR.MINOR.PATCH[-description], where MAJOR, MINOR, and PATCH are numeric. The following macros will be generated and passed to the preprocessor:

  • VERSION_MAJOR (int) - The major version number from the most recent tag.
  • VERSION_MINOR (int) - The minor version number from the most recent tag.
  • VERSION_PATCH (int) - The patch version number from the most recent tag.
  • VERSION_REVISION (int) - The number of commits since the most recent tag.
  • VERSION_HASH (string) - The SHA of the current commit. Includes the "-dirty" suffix if there are uncommited changes.

If the makefile is not used in a git repository, or is in a repository with no tags, the version macros are not created.

Limitations

  • Assumes GNU make.
  • Timing does not work correctly with MacOS. See issue #6 for a workaround patch that allows timing in seconds on Mac.
  • Doesn't really support multiple types of source files in the same project.
  • No easy way to exclude files from the build. You can either change the
    extension of files to be excluded, or use preprocessor flags for
    conditional compilation.

Thanks to

  • My friend Jay and people on Stack Overflow for help with regex to parse the version info.
  • The residents of /r/programming for suggesting numerous tweaks and improvements.

主要指標

概覽
名稱與所有者mbcrawfo/GenericMakefile
主編程語言Makefile
編程語言Makefile (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2014-03-27 11:11:19
推送於2020-10-04 12:22:30
最后一次提交2017-07-01 22:32:47
發布數0
用户参与
星數1.7k
關注者數69
派生數319
提交數35
已啟用問題?
問題數13
打開的問題數2
拉請求數8
打開的拉請求數0
關閉的拉請求數3
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?