game/mario/Makefile

97 lines
3.7 KiB
Makefile
Raw Normal View History

2021-04-25 20:42:55 +00:00
PREFIX ?= /usr/local/bin
EDITORFLAGS = -DEDITOR
2021-04-25 20:42:55 +00:00
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
2021-05-26 12:17:07 +00:00
COMMON_OBJECTS = global_vars.${OBJEXT} sprites.${OBJEXT} maploader.${OBJEXT}
ifneq ($(UNAME_S),Windows)
COMMON_OBJECTS += libsdlpp.a
endif
MARIO_OBJECTS = main.${OBJEXT} blocks.${OBJEXT} mario_visitor.${OBJEXT} mario.${OBJEXT} ${COMMON_OBJECTS}
EDITOR_OBJECTS = editor.${OBJEXT} editor_blocks.${OBJEXT} edit_box.${OBJEXT} tool_box.${OBJEXT} editor_visitor.${OBJEXT} ${COMMON_OBJECTS}
2021-04-25 20:42:55 +00:00
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
2021-05-26 12:17:07 +00:00
EDITOR_OBJECTS += ../sdlpp/SDL2/SDL2_framerate.c ../sdlpp/SDL2/SDL2_gfxPrimitives.c ../sdlpp/SDL2/SDL2_imageFilter.c ../sdlpp/SDL2/SDL2_rotozoom.c
SDLLIB = libsdlpp.dll
2021-04-25 20:42:55 +00:00
endif
.PHONY: default
default: mario
ifeq ($(UNAME_S),Windows)
mario: ${MARIO_OBJECTS} ${SDLLIB}
2021-05-26 12:17:07 +00:00
$(CXX) $(CXXFLAGS) -Fe"$@" ${MARIO_OBJECTS} /link ..\sdlpp\SDL2.lib ..\sdlpp\SDL2_ttf.lib ..\sdlpp\SDL2_image.lib libsdlpp.lib
2021-04-30 19:02:14 +00:00
editor: ${EDITOR_OBJECTS} ${SDLLIB}
2021-05-26 12:17:07 +00:00
$(CXX) $(CXXFLAGS) ${EDITORFLAGS} -Fe"$@" ${EDITOR_OBJECTS} /link ..\sdlpp\SDL2.lib ..\sdlpp\SDL2_ttf.lib ..\sdlpp\SDL2_image.lib libsdlpp.lib
2021-04-25 20:42:55 +00:00
else
mario: ${MARIO_OBJECTS}
2021-05-26 07:28:59 +00:00
$(CXX) $(CXXFLAGS) -o $@ $^ ${LDFLAGS} -L $(shell pwd)
2021-04-30 19:02:14 +00:00
editor: ${EDITOR_OBJECTS}
2021-05-26 07:28:59 +00:00
$(CXX) $(CXXFLAGS) ${EDITORFLAGS} -o $@ $^ ${LDFLAGS} -L $(shell pwd)
2021-04-25 20:42:55 +00:00
endif
2021-05-22 21:13:26 +00:00
main.${OBJEXT}: main.cpp ../sdlpp/sdlpp.hpp sprites.hpp
2021-04-25 20:42:55 +00:00
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
blocks.${OBJEXT}: blocks.cpp ../sdlpp/sdlpp.hpp blocks.hpp sprites.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
editor_blocks.${OBJEXT}: blocks.cpp ../sdlpp/sdlpp.hpp blocks.hpp sprites.hpp
$(CXX) $(CXXFLAGS) ${EDITORFLAGS} -c ${OUTPUTFLAG}$@ $<
2021-04-25 20:42:55 +00:00
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}$@ $<
2021-04-30 19:02:14 +00:00
editor.${OBJEXT}: editor.cpp ../sdlpp/sdlpp.hpp sprites.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
2021-05-02 12:14:11 +00:00
edit_box.${OBJEXT}: edit_box.cpp ../sdlpp/sdlpp.hpp sprites.hpp edit_box.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
2021-05-07 07:43:57 +00:00
tool_box.${OBJEXT}: tool_box.cpp ../sdlpp/sdlpp.hpp sprites.hpp tool_box.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
2021-05-02 12:14:11 +00:00
editor_visitor.${OBJEXT}: editor_visitor.cpp ../sdlpp/sdlpp.hpp sprites.hpp editor_visitor.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
2021-05-22 21:13:26 +00:00
mario.${OBJEXT}: mario.cpp ../sdlpp/sdlpp.hpp mario.hpp global_vars.hpp objectids.hpp sprites.hpp ../sdlpp/sdlpp_rectrenderer.hpp
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
libsdlpp.a: ../sdlpp
2021-04-25 20:42:55 +00:00
$(MAKE) clean -C ../sdlpp
$(MAKE) libsdlpp.a -C ../sdlpp
cp ../sdlpp/libsdlpp.a .
2021-04-25 20:42:55 +00:00
2021-05-26 12:17:07 +00:00
libsdlpp.dll:
$(MAKE) clean -C ../sdlpp
$(MAKE) -C ../sdlpp
cp ../sdlpp/libsdlpp.dll .
cp ../sdlpp/libsdlpp.lib .
windows_release: ../Release/Mario mario editor ${SDLLIB}
cp -R ${SDLLIB} mario.exe editor.exe sprites testfont.ttf ../Release/Mario
rm -f ../Release/Mario.zip
cd ../Release && zip -r Mario.zip Mario
2021-04-25 20:42:55 +00:00
start:
LD_LIBRARY_PATH=$$(pwd) ./mario
2021-04-30 19:02:14 +00:00
start_edit:
LD_LIBRARY_PATH=$$(pwd) ./editor
2021-04-25 20:42:55 +00:00
clean:
2021-05-26 12:17:07 +00:00
${RM} *.dll *.lib *.a *.${OBJEXT} mario editor