# VSCode Makefile
###### tags: `VSCode` `Work`
Note: Tutorial made based on mac.
[TOC]
## Set Up
1. Open VSCode.
2. Go to Extensions.
3. Type Makefile and download **Makefile Tools**.
>[color=pink]
4. Go to **Code > Preferences > Settings > Extensions > Makefile Tools**.
5. Edit **Makefile: Extension Output Folder** as below.
>[color=pink]
6. Adjust **Makefile: Makefile Path** if your Makefile file is not in the project's root.
>[color=pink]
7. Adjust **Makefile: Make Path**
Must state the path to the make tool. If path is unknown, use `which make` to find the path and fill it in the input space.
>[color=pink]
8. Add a **Makefile file** by new a file and named it **Makefile**. It will be detected automatically by the extension.
9. Edit your Makefile by adding targets and commands.
## Makefile Structure
Makefile is composed by **many targets** that are stated by the developer. By using the target name we can execute an specific target by using `make targetName`.
``` linux=
# Comments are preceded by the hash symbol
target: dependencies
command 1
command 2
...
command n
target1: dependencies
command 1
command 2
...
command n
#...
```
## Make commands
* `make` will directly run the first target appearing in the Makefile file.
* `make -n` will specify what commands will be runned if actually runned.
* `make targetName` will run an specific target.
* `make -v` get make version number.
* `make -k`, tells make to keep going when an error is found, rather than stopping as soon as the first problem is detected. You can use this, for example, to find out in one go which source files fail to compile.
## Set Makefile show in VSCode activity bar
>[color=pink]
In extension's settings.json add **"workbench.activityBar.visible": true**
``` linux=
{
"workbench.colorTheme": "Default Dark+",
"workbench.iconTheme": "material-icon-theme",
"dart.debugExternalPackageLibraries": true,
"dart.debugSdkLibraries": true,
"window.zoomLevel": 1,
"makefile.makePath": "/usr/bin/make",
"makefile.extensionOutputFolder": "./.vscode",
"makefile.configurations": [
],
"workbench.activityBar.visible": true
}
```
**How to find settings.json?**
VSCode > Preferences > Settings > Extensions > Makefile Tools > settings.json
**Ref:** https://code.visualstudio.com/docs/getstarted/settings
## Reference
* https://earthly.dev/blog/vscode-make/
* https://www.gnu.org/software/make/