CPPFLAGS=-Wall -Wno-misleading-indentation -Werror --std=c++1z
LDFLAGS=
INCLUDES=-I../pge/include
ifeq ($(OS),Windows_NT)
	LIBRARIES=-luser32 -lgdi32 -lgdiplus
	EXECUTABLE=packer.exe
	CPP=i686-w64-mingw32-g++
	CC=i686-w64-mingw32-gcc
else
	EXECUTABLE=packer
	LIBRARIES=-lpng
	CC=gcc
	CPP=g++
endif
ifeq ($(DEBUG),1)
	CPPFLAGS+=-g -Og
else
	CPPFLAGS+=-flto -O3
endif
SOURCES=packer.cpp ../pge/src/olcPGE_ResourcePack.cpp ../pge/src/olcPGE_Sprite.cpp ../pge/src/olcPGE_Pixel.cpp ../pge/src/olcPGE_Common.cpp
OBJECTS=$(SOURCES:.cpp=.o)

all: $(SOURCES) $(EXECUTABLE)

clean: 
	$(RM) $(OBJECTS) $(EXECUTABLE)
	
$(EXECUTABLE): $(OBJECTS) 
	$(CPP) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBRARIES)

.cpp.o:
	$(CPP) $(INCLUDES) -c $(CPPFLAGS) $< -o $@
