Skip to content

Instantly share code, notes, and snippets.



Last active Jun 16, 2016
What would you like to do?
Generic clang++ (or c++ for that matter) makefile with directory structure
# Requires the following project directory structure:
# /bin
# /obj
# /src
# Use 'make remove' to clean up the hole project
# Name of target file
TARGET = foooooooobar
CXX = clang++
CXXFLAGS = -std=c++11 \
-Weverything -Wall -Wextra -Werror -Wpointer-arith -Wcast-qual \
-Wno-missing-braces -Wempty-body -Wno-error=uninitialized \
-Wno-error=deprecated-declarations \
-pedantic-errors -pedantic \
LD = clang++ -o
LDFLAGS = -Wall -pedantic
SRCDIR = src
OBJDIR = obj
BINDIR = bin
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
INCLUDES := $(wildcard $(SRCDIR)/*.h)
RM = rm -f
@echo "Linking complete!"
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
@$(CXX) $(CXXFLAGS) -c $< -o $@
@echo "Compiled "$<" successfully!"
.PHONY: clean
@echo "Cleanup complete!"
.PHONY: remove
remove: clean
@echo "Executable removed!"

This comment has been minimized.

Copy link
Owner Author

@samuelsmal samuelsmal commented Jun 10, 2016

Thanks /u/Leandros99, /u/skoink and /u/dangerbird2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment