game/sdlpp/Makefile

64 lines
1.8 KiB
Makefile
Raw Normal View History

2020-11-21 19:57:40 +00:00
MAJOR ?= 1
MINOR ?= 0
RELEASE ?= 0
2020-11-22 20:58:37 +00:00
ifeq ($(OS),Windows_NT)
UNAME_S := Windows
2020-11-22 22:37:55 +00:00
CXX = cl
CXXFLAGS = -MD -EHsc /DDLLEXPORT
OBJEXT = obj
RM = del
2020-11-22 20:58:37 +00:00
else
UNAME_S := $(shell uname -s)
2020-11-22 22:37:55 +00:00
CXX ?= g++
CXXFLAGS = -std=c++14 -Wall -Wextra -pedantic -g
2020-11-22 22:37:55 +00:00
OBJEXT = o
2020-11-22 20:58:37 +00:00
endif
ifeq ($(UNAME_S),Linux)
2020-11-21 19:57:40 +00:00
SDLPPLIBRARY = libsdlpp.so.${MAJOR}.${MINOR}.${RELEASE}
2020-11-22 20:58:37 +00:00
LIBRARYFLAGS = -fPIC
endif
ifeq ($(UNAME_S),Darwin)
SDLPPLIBRARY = libsdlpp.dylib
LIBRARYFLAGS =
endif
2020-11-22 22:37:55 +00:00
ifeq ($(UNAME_S),Windows)
SDLPPLIBRARY = libsdlpp.dll
LIBRARYFLAGS =
endif
2020-11-21 19:57:40 +00:00
OBJECTFILES = sdlpp_circlecolider.${OBJEXT} sdlpp_circlerenderer.${OBJEXT} sdlpp_collision.${OBJEXT} sdlpp_common.${OBJEXT} sdlpp_font.${OBJEXT} sdlpp_linerenderer.${OBJEXT} sdlpp_rectcolider.${OBJEXT} sdlpp_rectrenderer.${OBJEXT} sdlpp_renderer.${OBJEXT} sdlpp_renderobject.${OBJEXT} sdlpp_scene.${OBJEXT} sdlpp_textrenderer.${OBJEXT} sdlpp_texture.${OBJEXT} sdlpp_window.${OBJEXT} sdlpp_fontconfiguration.${OBJEXT}
2020-11-21 19:57:40 +00:00
all: ${SDLPPLIBRARY}
2020-11-22 22:37:55 +00:00
ifeq ($(UNAME_S),Windows)
%.${OBJEXT}: %.cpp
${CXX} ${CXXFLAGS} ${LIBRARYFLAGS} /c $< /Fo"$@"
else
%.${OBJEXT}: %.cpp
${CXX} ${CXXFLAGS} ${LIBRARYFLAGS} -c $< -o $@
endif
2020-11-21 19:57:40 +00:00
2020-11-22 20:58:37 +00:00
ifeq ($(UNAME_S),Linux)
2020-11-21 19:57:40 +00:00
${SDLPPLIBRARY}: ${OBJECTFILES}
2020-11-22 22:37:55 +00:00
${CXX} ${CXXFLAGS} -shared -Wl,-soname,libsdlpp.so.${MAJOR}\
2020-11-21 19:57:40 +00:00
-o ${SDLPPLIBRARY} $^
ln -sf ${SDLPPLIBRARY} libsdlpp.so
ln -sf ${SDLPPLIBRARY} libsdlpp.so.${MAJOR}
2020-11-22 20:58:37 +00:00
endif
ifeq ($(UNAME_S),Darwin)
${SDLPPLIBRARY}: ${OBJECTFILES}
2020-11-22 22:37:55 +00:00
${CXX} ${CXXFLAGS} -dynamiclib -install_name ${SDLPPLIBRARY}\
2020-11-22 20:58:37 +00:00
-current_version ${MAJOR}.${MINOR} $^ -lSDL2 -lSDL2_image -lSDL2_gfx -lSDL2_ttf -o $@
endif
2020-11-22 22:37:55 +00:00
ifeq ($(UNAME_S),Windows)
${SDLPPLIBRARY}: ${OBJECTFILES}
${CXX} /LD $^ /link SDL2.lib SDL2_ttf.lib SDL2_image.lib /OUT:$@ /IMPLIB:libsdlpp.lib
endif
2020-11-21 19:57:40 +00:00
clean:
2020-11-22 22:37:55 +00:00
${RM} *.so* *.${OBJEXT} *.dylib libsdlpp*
2020-11-21 19:57:40 +00:00
.PHONY: all clean test