A very basic Makefile for C project:
- debug and release mode
- dependency detection
- strict ANSI-C
- copy the Makefile in the source directory
- if using Visual Studio Code, you can also copy
.vscodefolder- add a task to build the program
- add a task to clean the directory
- add a debug launch
- make sure that gcc and gdb is in your PATH environment variable
- have a look at https://code.visualstudio.com/docs/languages/cpp
- configure the Makefile if needed
- build the program
DEBUG can be set to yes to enable debug symbol generation, allowing the usage of a debugger.
EXEC contains the name of the executable file (program.exe by default).
SRC contains the list of source files (*.c by default).
CFLAGS and LDFLAGS respectively contains c compilation flags and link flags.
cd directory_containing_makefile
makecd directory_containing_makefile
make clean