Skip to content

Instantly share code, notes, and snippets.

@dangsonbk
Created March 6, 2019 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dangsonbk/7092c27763fcac928848869a87acd315 to your computer and use it in GitHub Desktop.
Save dangsonbk/7092c27763fcac928848869a87acd315 to your computer and use it in GitHub Desktop.
Simple makefile for C++ project, build with g++
ARTIFACT = AoE
TARGET = $(OUTPUT_DIR)/$(ARTIFACT)
LIBS = -L../SFML/lib -lsfml-graphics -lsfml-window -lsfml-system
INCS = -IInc
CPP = g++
LD = $(CXX)
CCFLAGS = -g -Wall
OUTPUT_DIR = build
.PHONY: default all clean
default: $(TARGET)
all: default
OBJECTS = $(addprefix $(OUTPUT_DIR)/,$(patsubst %.cpp, %.o, $(wildcard *.cpp)))
HEADERS = $(wildcard *.h)
$(OUTPUT_DIR)/%.o: %.cpp $(HEADERS)
$(CPP) $(CCFLAGS) $(INCS) -c $< -o $@
.PRECIOUS: $(TARGET) $(OBJECTS)
$(TARGET): $(OBJECTS)
$(LD) -mwindows $(OBJECTS) -Wall $(LIBS) $(INCS) -o $@
clean:
-rm -f $(OUTPUT_DIR)/*.o
-rm -f $(TARGET)
rebuild: clean all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment