Mario: use .a library instead of dynamic

This commit is contained in:
zv0n 2021-05-25 16:34:44 +02:00
parent df61983f55
commit 91df7c3f63
2 changed files with 18 additions and 28 deletions

View File

@ -1,5 +1,7 @@
PREFIX ?= /usr/local/bin PREFIX ?= /usr/local/bin
EDITORFLAGS = -DEDITOR
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
UNAME_S := Windows UNAME_S := Windows
CXX = cl CXX = cl
@ -16,19 +18,12 @@ LDFLAGS ?= -lSDL2 -lSDL2_image -lSDL2_gfx -lSDL2_ttf -pthread
OUTPUTFLAG = -o OUTPUTFLAG = -o
endif endif
COMMON_OBJECTS = blocks.${OBJEXT} global_vars.${OBJEXT} sprites.${OBJEXT} maploader.${OBJEXT} COMMON_OBJECTS = global_vars.${OBJEXT} sprites.${OBJEXT} maploader.${OBJEXT} libsdlpp.a
MARIO_OBJECTS = main.${OBJEXT} mario_visitor.${OBJEXT} mario.${OBJEXT} ${COMMON_OBJECTS} MARIO_OBJECTS = main.${OBJEXT} blocks.${OBJEXT} mario_visitor.${OBJEXT} mario.${OBJEXT} ${COMMON_OBJECTS}
EDITOR_OBJECTS = editor.${OBJEXT} edit_box.${OBJEXT} tool_box.${OBJEXT} editor_visitor.${OBJEXT} ${COMMON_OBJECTS} EDITOR_OBJECTS = editor.${OBJEXT} editor_blocks.${OBJEXT} edit_box.${OBJEXT} tool_box.${OBJEXT} editor_visitor.${OBJEXT} ${COMMON_OBJECTS}
ifeq ($(UNAME_S),Linux)
MARIO_OBJECTS += libsdlpp.so
endif
ifeq ($(UNAME_S),Darwin)
MARIO_OBJECTS += libsdlpp.dylib
endif
ifeq ($(UNAME_S),Windows) ifeq ($(UNAME_S),Windows)
MARIO_OBJECTS += ../sdlpp/SDL2/SDL2_framerate.c ../sdlpp/SDL2/SDL2_gfxPrimitives.c ../sdlpp/SDL2/SDL2_imageFilter.c ../sdlpp/SDL2/SDL2_rotozoom.c MARIO_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 endif
.PHONY: default .PHONY: default
@ -36,21 +31,23 @@ default: mario
ifeq ($(UNAME_S),Windows) ifeq ($(UNAME_S),Windows)
mario: ${MARIO_OBJECTS} ${SDLLIB} mario: ${MARIO_OBJECTS} ${SDLLIB}
$(CXX) $(CXXFLAGS) -Fe"$@" ${MARIO_OBJECTS} /link ..\sdlpp\SDL2.lib ..\sdlpp\SDL2_ttf.lib ..\sdlpp\SDL2_image.lib libsdlpp.lib $(CXX) $(CXXFLAGS) -Fe"$@" ${MARIO_OBJECTS} /link ..\sdlpp\SDL2.lib ..\sdlpp\SDL2_ttf.lib ..\sdlpp\SDL2_image.lib
editor: ${EDITOR_OBJECTS} ${SDLLIB} editor: ${EDITOR_OBJECTS} ${SDLLIB}
$(CXX) $(CXXFLAGS) -Fe"$@" ${EDITOR_OBJECTS} /link ..\sdlpp\SDL2.lib ..\sdlpp\SDL2_ttf.lib ..\sdlpp\SDL2_image.lib libsdlpp.lib $(CXX) $(CXXFLAGS) ${EDITORFLAGS} -Fe"$@" ${EDITOR_OBJECTS} /link ..\sdlpp\SDL2.lib ..\sdlpp\SDL2_ttf.lib ..\sdlpp\SDL2_image.lib
else else
mario: ${MARIO_OBJECTS} mario: ${MARIO_OBJECTS}
$(CXX) $(CXXFLAGS) -o $@ $^ ${LDFLAGS} -L $(shell pwd) -lsdlpp $(CXX) $(CXXFLAGS) -o $@ $^ ${LDFLAGS} -L $(shell pwd) -lsdlpp
editor: ${EDITOR_OBJECTS} editor: ${EDITOR_OBJECTS}
$(CXX) $(CXXFLAGS) -o $@ $^ ${LDFLAGS} -L $(shell pwd) -lsdlpp $(CXX) $(CXXFLAGS) ${EDITORFLAGS} -o $@ $^ ${LDFLAGS} -L $(shell pwd) -lsdlpp
endif endif
main.${OBJEXT}: main.cpp ../sdlpp/sdlpp.hpp sprites.hpp main.${OBJEXT}: main.cpp ../sdlpp/sdlpp.hpp sprites.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $< $(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
blocks.${OBJEXT}: blocks.cpp ../sdlpp/sdlpp.hpp blocks.hpp sprites.hpp blocks.${OBJEXT}: blocks.cpp ../sdlpp/sdlpp.hpp blocks.hpp sprites.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $< $(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
editor_blocks.${OBJEXT}: blocks.cpp ../sdlpp/sdlpp.hpp blocks.hpp sprites.hpp
$(CXX) $(CXXFLAGS) ${EDITORFLAGS} -c ${OUTPUTFLAG}$@ $<
global_vars.${OBJEXT}: global_vars.cpp ../sdlpp/sdlpp.hpp global_vars.hpp global_vars.${OBJEXT}: global_vars.cpp ../sdlpp/sdlpp.hpp global_vars.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $< $(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
sprites.${OBJEXT}: sprites.cpp ../sdlpp/sdlpp.hpp sprites.hpp sprites.${OBJEXT}: sprites.cpp ../sdlpp/sdlpp.hpp sprites.hpp
@ -69,23 +66,13 @@ editor_visitor.${OBJEXT}: editor_visitor.cpp ../sdlpp/sdlpp.hpp sprites.hpp edit
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $< $(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
mario.${OBJEXT}: mario.cpp ../sdlpp/sdlpp.hpp mario.hpp global_vars.hpp objectids.hpp sprites.hpp ../sdlpp/sdlpp_rectrenderer.hpp mario.${OBJEXT}: mario.cpp ../sdlpp/sdlpp.hpp mario.hpp global_vars.hpp objectids.hpp sprites.hpp ../sdlpp/sdlpp_rectrenderer.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $< $(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
libsdlpp.so: ../sdlpp libsdlpp.a: ../sdlpp
$(MAKE) clean -C ../sdlpp $(MAKE) clean -C ../sdlpp
$(MAKE) -C ../sdlpp $(MAKE) libsdlpp.a -C ../sdlpp
cp ../sdlpp/libsdlpp.so . cp ../sdlpp/libsdlpp.a .
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 windows_release: ../Release/Tetris
cp mario.exe testfont.ttf libsdlpp.dll block.png ../Release/Tetris cp mario.exe testfont.ttf block.png ../Release/Tetris
rm ../Release/Tetris.zip rm ../Release/Tetris.zip
cd ../Release && zip -r Tetris.zip Tetris cd ../Release && zip -r Tetris.zip Tetris
@ -95,4 +82,4 @@ start_edit:
LD_LIBRARY_PATH=$$(pwd) ./editor LD_LIBRARY_PATH=$$(pwd) ./editor
clean: clean:
rm -Rf *.${OBJEXT} mario editor rm -Rf *.${OBJEXT} mario editor *.a

View File

@ -15,6 +15,7 @@ MarioBlock::MarioBlock( int x, int y,
_destructible = destructible; _destructible = destructible;
} }
void MarioBlock::visit( SDLPP::Visitor &visitor ) { void MarioBlock::visit( SDLPP::Visitor &visitor ) {
#ifdef EDITOR
if ( !_tool && _terrain && if ( !_tool && _terrain &&
visitor.getVisitorType() == VisitorType::Terrain ) { visitor.getVisitorType() == VisitorType::Terrain ) {
destroy(); destroy();
@ -23,9 +24,11 @@ void MarioBlock::visit( SDLPP::Visitor &visitor ) {
visitor.getVisitorType() == VisitorType::Modifier ) { visitor.getVisitorType() == VisitorType::Modifier ) {
destroy(); destroy();
} }
#else
if(visitor.getFromId() == MARIO_TOP_DETECT && _destructible && dynamic_cast<MarioVisitor&>(visitor).canDestroy()) { if(visitor.getFromId() == MARIO_TOP_DETECT && _destructible && dynamic_cast<MarioVisitor&>(visitor).canDestroy()) {
destroy(); destroy();
} }
#endif
visitor.visit( *this ); visitor.visit( *this );
} }
void MarioBlock::setTool( bool tool ) { void MarioBlock::setTool( bool tool ) {