game/sdlpp/Makefile
2021-05-26 14:17:07 +02:00

65 lines
1.7 KiB
Makefile

MAJOR ?= 1
MINOR ?= 0
RELEASE ?= 0
ifeq ($(OS),Windows_NT)
UNAME_S := Windows
CXX = cl
CXXFLAGS = -MD -EHsc /DDLLEXPORT
OBJEXT = obj
RM = del
else
UNAME_S := $(shell uname -s)
CXX ?= g++
CXXFLAGS = -std=c++14 -Wall -Wextra -pedantic -g
OBJEXT = o
endif
ifeq ($(UNAME_S),Linux)
SDLPPLIBRARY = libsdlpp.a
endif
ifeq ($(UNAME_S),Darwin)
SDLPPLIBRARY = libsdlpp.a
endif
ifeq ($(UNAME_S),Windows)
SDLPPLIBRARY = libsdlpp.dll
endif
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} sdlpp_mouse.${OBJEXT}
all: ${SDLPPLIBRARY}
ifeq ($(UNAME_S),Windows)
%.${OBJEXT}: %.cpp
${CXX} ${CXXFLAGS} /c $< /Fo"$@"
else
%.${OBJEXT}: %.cpp
${CXX} ${CXXFLAGS} -c $< -o $@
endif
ifeq ($(UNAME_S),Linux)
${SDLPPLIBRARY}: ${OBJECTFILES}
${CXX} ${CXXFLAGS} -shared -Wl,-soname,libsdlpp.so.${MAJOR}\
-o ${SDLPPLIBRARY} $^
ln -sf ${SDLPPLIBRARY} libsdlpp.so
ln -sf ${SDLPPLIBRARY} libsdlpp.so.${MAJOR}
endif
ifeq ($(UNAME_S),Darwin)
${SDLPPLIBRARY}: ${OBJECTFILES}
${CXX} ${CXXFLAGS} -dynamiclib -install_name ${SDLPPLIBRARY}\
-current_version ${MAJOR}.${MINOR} $^ -lSDL2 -lSDL2_image -lSDL2_gfx -lSDL2_ttf -o $@
endif
ifeq ($(UNAME_S),Windows)
${SDLPPLIBRARY}: ${OBJECTFILES}
${CXX} /LD $^ /link SDL2.lib SDL2_ttf.lib SDL2_image.lib /OUT:$@ /IMPLIB:libsdlpp.lib
endif
libsdlpp.a: ${OBJECTFILES}
ar ruv $@ $^
ranlib $@
clean:
${RM} *.so* *.${OBJEXT} *.dylib libsdlpp*
.PHONY: all clean test