Skip to content

Instantly share code, notes, and snippets.

@icorbrey
Last active February 20, 2019 15:20
Show Gist options
  • Save icorbrey/dabd669beaac1c84b7c37e6d28083fdf to your computer and use it in GitHub Desktop.
Save icorbrey/dabd669beaac1c84b7c37e6d28083fdf to your computer and use it in GitHub Desktop.
My standard makefile, no frills
DIR_CURR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
DIR_DEPS = $(DIR_CURR)/include
DIR_SRC = $(DIR_CURR)/src
DIR_OBJ = $(DIR_CURR)/obj
DIR_BUILD = $(DIR_CURR)/build
SOURCES = $(wildcard $(DIR_SRC)/*.cpp)
OBJECTS = $(patsubst $(DIR_SRC)/%.cpp, $(DIR_OBJ)/%.o, $(SOURCES))
DEPS = $(wildcard $(DIR_DEPS)/*.h)
COMPILER = clang++
FLAGS = -I$(DIR_DEPS) -Wall -std=c++14
$(DIR_OBJ)/%.o: $(DIR_SRC)/%.cpp $(DEPS)
$(COMPILER) $(FLAGS) -c $< -o $@
$(DIR_BUILD)/build: $(OBJECTS)
$(COMPILER) $(FLAGS) $^ -o $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment