97 lines
3.3 KiB
Makefile
97 lines
3.3 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
|
|
|
|
COMMON_OBJECTS = blocks.${OBJEXT} global_vars.${OBJEXT} sprites.${OBJEXT} maploader.${OBJEXT}
|
|
MARIO_OBJECTS = mario.${OBJEXT} mario_visitor.${OBJEXT} ${COMMON_OBJECTS}
|
|
EDITOR_OBJECTS = editor.${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)
|
|
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
|
|
|
|
.PHONY: default
|
|
default: mario
|
|
|
|
ifeq ($(UNAME_S),Windows)
|
|
mario: ${MARIO_OBJECTS} ${SDLLIB}
|
|
$(CXX) $(CXXFLAGS) -Fe"$@" ${MARIO_OBJECTS} /link ..\sdlpp\SDL2.lib ..\sdlpp\SDL2_ttf.lib ..\sdlpp\SDL2_image.lib libsdlpp.lib
|
|
editor: ${EDITOR_OBJECTS} ${SDLLIB}
|
|
$(CXX) $(CXXFLAGS) -Fe"$@" ${EDITOR_OBJECTS} /link ..\sdlpp\SDL2.lib ..\sdlpp\SDL2_ttf.lib ..\sdlpp\SDL2_image.lib libsdlpp.lib
|
|
|
|
else
|
|
mario: ${MARIO_OBJECTS}
|
|
$(CXX) $(CXXFLAGS) -o $@ $^ ${LDFLAGS} -L $(shell pwd) -lsdlpp
|
|
editor: ${EDITOR_OBJECTS}
|
|
$(CXX) $(CXXFLAGS) -o $@ $^ ${LDFLAGS} -L $(shell pwd) -lsdlpp
|
|
endif
|
|
|
|
mario.${OBJEXT}: main.cpp ../sdlpp/sdlpp.hpp sprites.hpp
|
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
|
blocks.${OBJEXT}: blocks.cpp ../sdlpp/sdlpp.hpp blocks.hpp sprites.hpp
|
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
|
global_vars.${OBJEXT}: global_vars.cpp ../sdlpp/sdlpp.hpp global_vars.hpp
|
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
|
sprites.${OBJEXT}: sprites.cpp ../sdlpp/sdlpp.hpp sprites.hpp
|
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
|
maploader.${OBJEXT}: maploader.cpp ../sdlpp/sdlpp.hpp maploader.hpp sprites.hpp blocks.hpp
|
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
|
mario_visitor.${OBJEXT}: mario_visitor.cpp ../sdlpp/sdlpp.hpp mario_visitor.hpp objectids.hpp
|
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
|
editor.${OBJEXT}: editor.cpp ../sdlpp/sdlpp.hpp sprites.hpp
|
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
|
edit_box.${OBJEXT}: edit_box.cpp ../sdlpp/sdlpp.hpp sprites.hpp edit_box.hpp
|
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
|
tool_box.${OBJEXT}: tool_box.cpp ../sdlpp/sdlpp.hpp sprites.hpp tool_box.hpp
|
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
|
editor_visitor.${OBJEXT}: editor_visitor.cpp ../sdlpp/sdlpp.hpp sprites.hpp editor_visitor.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 mario.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) ./mario
|
|
start_edit:
|
|
LD_LIBRARY_PATH=$$(pwd) ./editor
|
|
|
|
clean:
|
|
rm -Rf *.${OBJEXT} mario editor
|