Skip to content

Instantly share code, notes, and snippets.

@talbenari1
Created December 1, 2015 00:49
Show Gist options
  • Save talbenari1/4000ad6ede2051611573 to your computer and use it in GitHub Desktop.
Save talbenari1/4000ad6ede2051611573 to your computer and use it in GitHub Desktop.
My COMSC-210@DVC makefile.
# The compiler to use. g++ should work as well.
CC = clang++
# CC = g++
# The flags to set during compilation.
CFLAGS = -g -O2 -Wall -MMD -MP --std=c++11 -fdiagnostics-color=always
# My prefix
NAME := BenAriTal
# The files to compile. All source files are located in the /src directory.
SRC := $(wildcard src/$(NAME)Lab*.cpp)
# The names of the lab executables, which are placed in the /labs directory.
OUT := $(SRC:src/$(NAME)Lab%.cpp=labs/%.out)
# The names of the term project executables, which are placed in the /termproject directory.
OUT += termproject/DvcScheduleFinal.out termproject/DvcScheduleCheck.out termproject/DvcScheduleSearch.out
# The `make all` command. Recompiles all executables in need of updates.
all: $(OUT)
# The `make init` command. Run this first to add the correct directories to the project.
init:
mkdir labs src termproject
# Compile a specific lab. Don't worry about this, it's used by `make all`.
labs/%.out:
$(CC) $(CFLAGS) $(patsubst labs/%.out,src/$(NAME)Lab%.cpp,$@) -o $@
# Compile a specific term project. Don't worry about this, it's used by `make all`.
termproject/%.out:
$(CC) $(CFLAGS) $(patsubst termproject/%.out,src/$(NAME)TermProject%.cpp,$@) -o $@
# The `make clean` command. Run this to clean out the output directories if something goes wrong.
clean:
rm -f labs/* termproject/*
# This allows make to know which executables to recompile when you edit `#include`d files.
-include $(OUT:%.out=%.d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment