Skip to content

Instantly share code, notes, and snippets.

@ecerulm
Last active December 10, 2015 21:48
Show Gist options
  • Select an option

  • Save ecerulm/4498068 to your computer and use it in GitHub Desktop.

Select an option

Save ecerulm/4498068 to your computer and use it in GitHub Desktop.
Makefile template
CC = g++
# CFLAGS for the C compiler, CXXFLAGS for C++, and CPPFLAGS for both.
CXXFLAGS= -pedantic -Wall -Wextra -Werror -ggdb3
TARGET = my-executable
SOURCES = test.cpp
HEADERS = test.h
OBJECTS = $(SOURCES:.c=.o)
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(CC) $(CXXFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(OBJECTS)
%.o: %.c $(HEADERS) $(COMMON)
$(CC) $(CXXFLAGS) $(DEBUGFLAGS) -c -o $@ $<
profile: CXXFLAGS += -pg
profile: $(TARGET)
clean:
-rm -f $(TARGET)
-rm -f $(OBJECTS)
-rm -f gmon.out
.PHONY : all profile release clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment