Tetris: update to use dll library on windows
This commit is contained in:
parent
f6f4307169
commit
a5bcb3f547
@ -1,15 +1,22 @@
|
|||||||
CXX ?= g++
|
|
||||||
CFLAGS ?= -O2 -Wall -Wextra -std=c++14
|
|
||||||
PREFIX ?= /usr/local/bin
|
PREFIX ?= /usr/local/bin
|
||||||
LDFLAGS ?= -lSDL2 -lSDL2_image -lSDL2_gfx -lSDL2_ttf -pthread
|
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
UNAME_S := Windows
|
UNAME_S := Windows
|
||||||
|
CXX = cl
|
||||||
|
CXXFLAGS = -MD -EHsc
|
||||||
|
OBJEXT = obj
|
||||||
|
LDFLAGS =
|
||||||
|
OUTPUTFLAG = -Fo
|
||||||
else
|
else
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
|
CXX ?= g++
|
||||||
|
CXXFLAGS = -std=c++14 -Wall -Wextra -pedantic -O2
|
||||||
|
OBJEXT = o
|
||||||
|
LDFLAGS ?= -lSDL2 -lSDL2_image -lSDL2_gfx -lSDL2_ttf -pthread
|
||||||
|
OUTPUTFLAG = -o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TETRIS_OBJECTS = tetris.o scenes.o config.o functions.o global_vars.o
|
TETRIS_OBJECTS = tetris.${OBJEXT} scenes.${OBJEXT} config.${OBJEXT} functions.${OBJEXT} global_vars.${OBJEXT}
|
||||||
|
|
||||||
ifeq ($(UNAME_S),Linux)
|
ifeq ($(UNAME_S),Linux)
|
||||||
TETRIS_OBJECTS += libsdlpp.so
|
TETRIS_OBJECTS += libsdlpp.so
|
||||||
@ -17,23 +24,33 @@ endif
|
|||||||
ifeq ($(UNAME_S),Darwin)
|
ifeq ($(UNAME_S),Darwin)
|
||||||
TETRIS_OBJECTS += libsdlpp.dylib
|
TETRIS_OBJECTS += libsdlpp.dylib
|
||||||
endif
|
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
|
.PHONY: default
|
||||||
default: tetris
|
default: tetris
|
||||||
|
|
||||||
tetris: ${TETRIS_OBJECTS}
|
ifeq ($(UNAME_S),Windows)
|
||||||
$(CXX) $(CFLAGS) -o $@ $^ ${LDFLAGS} -L $(shell pwd) -lsdlpp
|
tetris: ${TETRIS_OBJECTS} ${SDLLIB}
|
||||||
|
$(CXX) $(CXXFLAGS) -Fe"$@" ${TETRIS_OBJECTS} /link ..\sdlpp\SDL2.lib ..\sdlpp\SDL2_ttf.lib ..\sdlpp\SDL2_image.lib libsdlpp.lib
|
||||||
|
|
||||||
tetris.o: tetris.cpp ../sdlpp/sdlpp.hpp config.hpp custom_classes.hpp scenes.hpp global_vars.hpp functions.hpp
|
else
|
||||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
tetris: ${TETRIS_OBJECTS}
|
||||||
scenes.o: scenes.cpp ../sdlpp/sdlpp.hpp config.hpp scenes.hpp functions.hpp global_vars.hpp
|
$(CXX) $(CXXFLAGS) -o $@ $^ ${LDFLAGS} -L $(shell pwd) -lsdlpp
|
||||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
endif
|
||||||
config.o: config.cpp config.hpp
|
|
||||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
tetris.${OBJEXT}: tetris.cpp ../sdlpp/sdlpp.hpp config.hpp custom_classes.hpp scenes.hpp global_vars.hpp functions.hpp
|
||||||
functions.o: functions.cpp config.hpp functions.hpp global_vars.hpp scenes.hpp
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
scenes.${OBJEXT}: scenes.cpp ../sdlpp/sdlpp.hpp config.hpp scenes.hpp functions.hpp global_vars.hpp
|
||||||
global_vars.o: global_vars.cpp config.hpp global_vars.hpp functions.hpp
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
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}$@ $<
|
||||||
libsdlpp.so: ../sdlpp
|
libsdlpp.so: ../sdlpp
|
||||||
$(MAKE) -C ../sdlpp
|
$(MAKE) -C ../sdlpp
|
||||||
cp ../sdlpp/libsdlpp.so .
|
cp ../sdlpp/libsdlpp.so .
|
||||||
@ -41,9 +58,13 @@ libsdlpp.so: ../sdlpp
|
|||||||
libsdlpp.dylib: ../sdlpp
|
libsdlpp.dylib: ../sdlpp
|
||||||
$(MAKE) -C ../sdlpp
|
$(MAKE) -C ../sdlpp
|
||||||
cp ../sdlpp/libsdlpp.dylib .
|
cp ../sdlpp/libsdlpp.dylib .
|
||||||
|
libsdlpp.dll: ../sdlpp
|
||||||
|
$(MAKE) -C ../sdlpp
|
||||||
|
cp ../sdlpp/libsdlpp.dll .
|
||||||
|
cp ../sdlpp/libsdlpp.lib .
|
||||||
|
|
||||||
start:
|
start:
|
||||||
LD_LIBRARY_PATH=$$(pwd) ./tetris
|
LD_LIBRARY_PATH=$$(pwd) ./tetris
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -Rf *.o tetris
|
rm -Rf *.${OBJEXT} tetris
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "../SDL2/SDL2_framerate.h"
|
#include "../sdlpp/SDL2/SDL2_framerate.h"
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user