2020-09-11 12:29:06 +00:00
|
|
|
PREFIX ?= /usr/local/bin
|
|
|
|
|
2020-11-22 20:58:37 +00:00
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
UNAME_S := Windows
|
2020-11-22 22:39:49 +00:00
|
|
|
CXX = cl
|
|
|
|
CXXFLAGS = -MD -EHsc
|
|
|
|
OBJEXT = obj
|
2021-03-09 08:27:15 +00:00
|
|
|
LDFLAGS =
|
2020-11-22 22:39:49 +00:00
|
|
|
OUTPUTFLAG = -Fo
|
2020-11-22 20:58:37 +00:00
|
|
|
else
|
|
|
|
UNAME_S := $(shell uname -s)
|
2020-11-22 22:39:49 +00:00
|
|
|
CXX ?= g++
|
2021-03-09 08:27:15 +00:00
|
|
|
CXXFLAGS = -std=c++14 -Wall -Wextra -pedantic -O2 # -DDEBUG -DFEATURE # -g -fsanitize=address
|
2020-11-22 22:39:49 +00:00
|
|
|
OBJEXT = o
|
|
|
|
LDFLAGS ?= -lSDL2 -lSDL2_image -lSDL2_gfx -lSDL2_ttf -pthread
|
2021-03-09 08:27:15 +00:00
|
|
|
OUTPUTFLAG = -o
|
2020-11-22 20:58:37 +00:00
|
|
|
endif
|
|
|
|
|
2021-01-30 21:18:15 +00:00
|
|
|
TETRIS_OBJECTS = tetris.${OBJEXT} scenes.${OBJEXT} config.${OBJEXT} functions.${OBJEXT} global_vars.${OBJEXT} custom_classes.${OBJEXT}
|
2020-11-22 20:58:37 +00:00
|
|
|
|
|
|
|
ifeq ($(UNAME_S),Linux)
|
|
|
|
TETRIS_OBJECTS += libsdlpp.so
|
|
|
|
endif
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
|
|
TETRIS_OBJECTS += libsdlpp.dylib
|
|
|
|
endif
|
2020-11-22 22:39:49 +00:00
|
|
|
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
|
2020-11-22 20:58:37 +00:00
|
|
|
|
2020-09-11 12:29:06 +00:00
|
|
|
.PHONY: default
|
|
|
|
default: tetris
|
|
|
|
|
2020-11-22 22:39:49 +00:00
|
|
|
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
|
2020-11-22 20:58:37 +00:00
|
|
|
tetris: ${TETRIS_OBJECTS}
|
2020-11-22 22:39:49 +00:00
|
|
|
$(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}$@ $<
|
2021-01-30 21:18:15 +00:00
|
|
|
custom_classes.${OBJEXT}: custom_classes.cpp custom_classes.hpp
|
|
|
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
2020-11-21 19:58:52 +00:00
|
|
|
libsdlpp.so: ../sdlpp
|
2020-12-18 14:14:08 +00:00
|
|
|
$(MAKE) clean -C ../sdlpp
|
2020-11-21 19:58:52 +00:00
|
|
|
$(MAKE) -C ../sdlpp
|
|
|
|
cp ../sdlpp/libsdlpp.so .
|
|
|
|
ln -sf libsdlpp.so libsdlpp.so.1
|
2020-11-22 20:58:37 +00:00
|
|
|
libsdlpp.dylib: ../sdlpp
|
2020-12-18 14:14:08 +00:00
|
|
|
$(MAKE) clean -C ../sdlpp
|
2020-11-22 20:58:37 +00:00
|
|
|
$(MAKE) -C ../sdlpp
|
|
|
|
cp ../sdlpp/libsdlpp.dylib .
|
2020-11-22 22:39:49 +00:00
|
|
|
libsdlpp.dll: ../sdlpp
|
2020-12-18 14:14:08 +00:00
|
|
|
$(MAKE) clean -C ../sdlpp
|
2020-11-22 22:39:49 +00:00
|
|
|
$(MAKE) -C ../sdlpp
|
|
|
|
cp ../sdlpp/libsdlpp.dll .
|
|
|
|
cp ../sdlpp/libsdlpp.lib .
|
2020-11-21 19:58:52 +00:00
|
|
|
|
2021-01-30 22:14:12 +00:00
|
|
|
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
|
|
|
|
|
2020-11-21 19:58:52 +00:00
|
|
|
start:
|
|
|
|
LD_LIBRARY_PATH=$$(pwd) ./tetris
|
2020-09-11 12:29:06 +00:00
|
|
|
|
|
|
|
clean:
|
2020-11-22 22:39:49 +00:00
|
|
|
rm -Rf *.${OBJEXT} tetris
|