Skip to content

Instantly share code, notes, and snippets.

@angrykoala
Last active August 16, 2017 20:26
Show Gist options
  • Save angrykoala/2079e5a62ce4d2fe34794c0dcb8028f1 to your computer and use it in GitHub Desktop.
Save angrykoala/2079e5a62ce4d2fe34794c0dcb8028f1 to your computer and use it in GitHub Desktop.
Basic makefile
# Basic Makefile
# by @angrykoala
CXX = g++
CPPFLAGS = -Wall -O1 -std=c++11 -g
ASTYLE_FLAGS = --style=java --align-pointer=name --delete-empty-lines --indent-col1-comments --unpad-paren -n -Q
EXE = output_file
BIN_DIR = bin
INCLUDE_DIR = include
SRC_DIR = src
SRC = $(wildcard $(SRC_DIR)/*.cpp $(SRC_DIR)/*/*.cpp)
INC = $(wildcard $(INCLUDE_DIR)/*.hpp $(INCLUDE_DIR)/*/*.hpp)
main: $(BIN_DIR)/ $(BIN_DIR)/$(EXE)
.PHONY: clean
clean:
rm -rf $(BIN_DIR)
.PHONY: astyle
astyle:
astyle $(ASTYLE_FLAGS) $(SRC) $(INC)
#print makefile variable (for makefile debug purposes)
.PHONY: print-%
print-% : ; @echo $* = $($*)
$(BIN_DIR)/$(EXE): $(SRC) $(INC)
$(CXX) -o $@ $(SRC) $(CPPFLAGS) -I $(INCLUDE_DIR)
$(BIN_DIR)/:
mkdir $(BIN_DIR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment