game/tetris/Makefile

81 lines
2.5 KiB
Makefile

PREFIX ?= /usr/local/bin
ifeq ($(OS),Windows_NT)
UNAME_S := Windows
CXX = cl
CXXFLAGS = -MD -EHsc
OBJEXT = obj
LDFLAGS =
OUTPUTFLAG = -Fo
else
UNAME_S := $(shell uname -s)
CXX ?= g++
CXXFLAGS = -std=c++14 -Wall -Wextra -pedantic -O2 # -DDEBUG -DFEATURE # -g -fsanitize=address
OBJEXT = o
LDFLAGS ?= -lSDL2 -lSDL2_image -lSDL2_gfx -lSDL2_ttf -pthread
OUTPUTFLAG = -o
endif
TETRIS_OBJECTS = tetris.${OBJEXT} scenes.${OBJEXT} config.${OBJEXT} functions.${OBJEXT} global_vars.${OBJEXT} custom_classes.${OBJEXT}
ifeq ($(UNAME_S),Linux)
TETRIS_OBJECTS += libsdlpp.so
endif
ifeq ($(UNAME_S),Darwin)
TETRIS_OBJECTS += libsdlpp.dylib
endif
ifeq ($(UNAME_S),Windows)
TETRIS_OBJECTS += ../sdlpp/SDL2/SDL2_framerate.c ../sdlpp/SDL2/SDL2_gfxPrimitives.c ../sdlpp/SDL2/SDL2_imageFilter.c ../sdlpp/SDL2/SDL2_rotozoom.c
SDLLIB = libsdlpp.dll
endif
.PHONY: default
default: tetris
ifeq ($(UNAME_S),Windows)
tetris: ${TETRIS_OBJECTS} ${SDLLIB}
$(CXX) $(CXXFLAGS) -Fe"$@" ${TETRIS_OBJECTS} /link ..\sdlpp\SDL2.lib ..\sdlpp\SDL2_ttf.lib ..\sdlpp\SDL2_image.lib libsdlpp.lib
else
tetris: ${TETRIS_OBJECTS}
$(CXX) $(CXXFLAGS) -o $@ $^ ${LDFLAGS} -L $(shell pwd) -lsdlpp
endif
tetris.${OBJEXT}: tetris.cpp ../sdlpp/sdlpp.hpp config.hpp custom_classes.hpp scenes.hpp global_vars.hpp functions.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
scenes.${OBJEXT}: scenes.cpp ../sdlpp/sdlpp.hpp config.hpp scenes.hpp functions.hpp global_vars.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
config.${OBJEXT}: config.cpp config.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
functions.${OBJEXT}: functions.cpp config.hpp functions.hpp global_vars.hpp scenes.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
global_vars.${OBJEXT}: global_vars.cpp config.hpp global_vars.hpp functions.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
custom_classes.${OBJEXT}: custom_classes.cpp custom_classes.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
libsdlpp.so: ../sdlpp
$(MAKE) clean -C ../sdlpp
$(MAKE) -C ../sdlpp
cp ../sdlpp/libsdlpp.so .
ln -sf libsdlpp.so libsdlpp.so.1
libsdlpp.dylib: ../sdlpp
$(MAKE) clean -C ../sdlpp
$(MAKE) -C ../sdlpp
cp ../sdlpp/libsdlpp.dylib .
libsdlpp.dll: ../sdlpp
$(MAKE) clean -C ../sdlpp
$(MAKE) -C ../sdlpp
cp ../sdlpp/libsdlpp.dll .
cp ../sdlpp/libsdlpp.lib .
windows_release: ../Release/Tetris
cp tetris.exe testfont.ttf libsdlpp.dll block.png ../Release/Tetris
rm ../Release/Tetris.zip
cd ../Release && zip -r Tetris.zip Tetris
start:
LD_LIBRARY_PATH=$$(pwd) ./tetris
clean:
rm -Rf *.${OBJEXT} tetris