Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aldantanneo/makefile-template
Modulable Cross-platform Makefile for C/C++ executables
https://github.com/aldantanneo/makefile-template
Last synced: 6 days ago
JSON representation
Modulable Cross-platform Makefile for C/C++ executables
- Host: GitHub
- URL: https://github.com/aldantanneo/makefile-template
- Owner: AldanTanneo
- License: mit
- Created: 2022-11-15T19:36:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-12T18:23:59.000Z (about 1 year ago)
- Last Synced: 2023-10-14T19:22:51.848Z (about 1 year ago)
- Language: Makefile
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Modulable Cross-platform Makefile for C/C++ executables
This Makefile has been elaborated to compile executable C or C++ projects in
an incremental fashion with minimal setup and sensible defaults.## Usage
Edit the variables near the top of the file:
### Project name
```Makefile
PROJECT_NAME := your-project-name-here
```### Location of the source files
```Makefile
PROJECT_ROOT := src
```### Location of the header files
This folder will be added to the `-I` flag, making the headers discoverable through
`#include <...>` instead of `#include "..."`. Using this is of course optional.```Makefile
HEADERS_ROOT := include
```### File extensions
For instance: `cpp`/`hpp`, `c`/`h`, etc.
```Makefile
FILE_EXTENSION := c
HEADER_EXTENSION := h
```### Compiler executable path
This can be any compiler that accepts gcc-like flags (clang, etc)
```Makefile
COMPILER := gcc
```### Customisable compile flags
`OPT_DEBUG` only applies to debug builds, `OPT_RELEASE` to release builds, and `COMMON` applies to both.
```Makefile
OPT_DEBUG := -O0
OPT_RELEASE := -O3
COMMON :=
```## Available commands:
* `build`: builds a debug version of the project, as `main` or `main.exe` depending on the platform.
* `release`: builds a release version of the project, as `project-name(.exe)`. Optimisation flags are configurable.
* `run`: builds and runs a debug version of the project.
* `bench`: builds and runs a release version of the project.
* `clean`: cleans the current object files and executables.
* `rebuild`: cleans and rebuilds the project in debug mode.It is recommended to add the executables and the `./obj` folder
to your .gitignore