Trying to switch to more object-oriented
This commit is contained in:
@@ -1,25 +1,65 @@
|
||||
CXX ?= g++
|
||||
CFLAGS ?= -O2 -Wall -Wextra -g
|
||||
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
|
||||
|
||||
TEST_OBJECTS = test.${OBJEXT}
|
||||
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
TEST_OBJECTS += libsdlpp.so
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
TEST_OBJECTS += libsdlpp.dylib
|
||||
endif
|
||||
ifeq ($(UNAME_S),Windows)
|
||||
TEST_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: demo
|
||||
default: test
|
||||
|
||||
demo: main.o sdlpp.o
|
||||
$(CXX) $(CFLAGS) -o $@ $^ ${LDFLAGS}
|
||||
test: test.o sdlpp.o
|
||||
$(CXX) $(CFLAGS) -o $@ $^ ${LDFLAGS}
|
||||
ifeq ($(UNAME_S),Windows)
|
||||
test: ${TEST_OBJECTS} ${SDLLIB}
|
||||
$(CXX) $(CXXFLAGS) -Fe"$@" ${TEST_OBJECTS} /link sdlpp\SDL2.lib sdlpp\SDL2_ttf.lib sdlpp\SDL2_image.lib libsdlpp.lib
|
||||
|
||||
main.o: main.cpp sdlpp.hpp
|
||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
||||
sdlpp.o: sdlpp.cpp sdlpp.hpp
|
||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
||||
test.o: tests/test.cpp sdlpp.hpp tests/catch.hpp
|
||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
||||
else
|
||||
test: ${TEST_OBJECTS}
|
||||
$(CXX) $(CXXFLAGS) -o $@ $^ ${LDFLAGS} -L $(shell pwd) -lsdlpp
|
||||
endif
|
||||
|
||||
windows_tetris: sdlpp.hpp sdlpp.cpp tetris/tetris.cpp tetris/config.cpp tetris/global_vars.cpp tetris/scenes.cpp tetris/functions.cpp tetris/config.hpp tetris/global_vars.hpp tetris/scenes.hpp tetris/functions.hpp
|
||||
cl -MD -EHsc -Fe"Tetris" sdlpp.cpp tetris/tetris.cpp tetris/config.cpp tetris/global_vars.cpp tetris/scenes.cpp tetris/functions.cpp SDL2/SDL2_framerate.c SDL2/SDL2_gfxPrimitives.c SDL2/SDL2_imageFilter.c SDL2/SDL2_rotozoom.c /link SDL2.lib SDL2_ttf.lib SDL2_image.lib
|
||||
test.${OBJEXT}: test.cpp
|
||||
$(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 .
|
||||
|
||||
start:
|
||||
LD_LIBRARY_PATH=$$(pwd) ./test
|
||||
|
||||
clean:
|
||||
rm -Rf *.o test demo
|
||||
rm -Rf *.${OBJEXT} test
|
||||
|
||||
Reference in New Issue
Block a user