Skip to content

Instantly share code, notes, and snippets.

@Eskalol
Last active February 2, 2017 05:43
Show Gist options
  • Save Eskalol/3fc67c85a6a3ed2157cefc113cf07439 to your computer and use it in GitHub Desktop.
Save Eskalol/3fc67c85a6a3ed2157cefc113cf07439 to your computer and use it in GitHub Desktop.
Makefile template
CC = gcc
CFLAGS = -g -Wall -Wextra
OBJECTS = #insert objects here example: cool.o
PHONY: clean all
all: main
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
main: #insert objects needed to precompile example: cool.o
$(CC) $(CFLAGS) $^ -o $@
clean:
$(RM) $(OBJECTS) main
# Useful things to have in your makefile ;)
valgrind:
valgrind --leak-check=full ./main
gdb:
gdb -ex=r --args ./main
kcachegrind:
valgrind --tool=callgrind ./main && kcachegrind &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment