SDLPP: add .dll target for windows
This commit is contained in:
parent
5f40ffe4e1
commit
730a00b8fa
@ -1,14 +1,17 @@
|
||||
CXX ?= g++
|
||||
CPPFLAGS = -std=c++14 -Wall -Wextra -pedantic
|
||||
|
||||
MAJOR ?= 1
|
||||
MINOR ?= 0
|
||||
RELEASE ?= 0
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
UNAME_S := Windows
|
||||
CXX = cl
|
||||
CXXFLAGS = -MD -EHsc /DDLLEXPORT
|
||||
OBJEXT = obj
|
||||
else
|
||||
UNAME_S := $(shell uname -s)
|
||||
CXX ?= g++
|
||||
CXXFLAGS = -std=c++14 -Wall -Wextra -pedantic
|
||||
OBJEXT = o
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
@ -19,28 +22,41 @@ ifeq ($(UNAME_S),Darwin)
|
||||
SDLPPLIBRARY = libsdlpp.dylib
|
||||
LIBRARYFLAGS =
|
||||
endif
|
||||
ifeq ($(UNAME_S),Windows)
|
||||
SDLPPLIBRARY = libsdlpp.dll
|
||||
LIBRARYFLAGS =
|
||||
endif
|
||||
|
||||
OBJECTFILES = sdlpp_circlecolider.o sdlpp_circlerenderer.o sdlpp_collision.o sdlpp_common.o sdlpp_font.o sdlpp_linerenderer.o sdlpp_rectcolider.o sdlpp_rectrenderer.o sdlpp_renderer.o sdlpp_renderobject.o sdlpp_scene.o sdlpp_textrenderer.o sdlpp_texture.o sdlpp_window.o
|
||||
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}
|
||||
|
||||
all: ${SDLPPLIBRARY}
|
||||
|
||||
%.o: %.cpp
|
||||
${CXX} ${CPPFLAGS} ${LIBRARYFLAGS} -c $< -o $@
|
||||
ifeq ($(UNAME_S),Windows)
|
||||
%.${OBJEXT}: %.cpp
|
||||
${CXX} ${CXXFLAGS} ${LIBRARYFLAGS} /c $< /Fo"$@"
|
||||
else
|
||||
%.${OBJEXT}: %.cpp
|
||||
${CXX} ${CXXFLAGS} ${LIBRARYFLAGS} -c $< -o $@
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
${SDLPPLIBRARY}: ${OBJECTFILES}
|
||||
${CXX} ${CPPFLAGS} -shared -Wl,-soname,libsdlpp.so.${MAJOR}\
|
||||
${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} ${CPPFLAGS} -dynamiclib -install_name ${SDLPPLIBRARY}\
|
||||
${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
|
||||
|
||||
clean:
|
||||
${RM} *.so* *.o *.dylib
|
||||
${RM} *.so* *.${OBJEXT} *.dylib libsdlpp*
|
||||
|
||||
.PHONY: all clean test
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "sdlpp_collision.hpp"
|
||||
|
||||
namespace SDLPP {
|
||||
class CircleColider : public CollisionPolygon {
|
||||
class SDLPPSCOPE CircleColider : public CollisionPolygon {
|
||||
public:
|
||||
CircleColider( double x, double y, double rad );
|
||||
virtual ~CircleColider() {}
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <memory>
|
||||
|
||||
namespace SDLPP {
|
||||
class CircleRender : public RenderObject {
|
||||
class SDLPPSCOPE CircleRender : public RenderObject {
|
||||
public:
|
||||
CircleRender() = delete;
|
||||
virtual ~CircleRender(){};
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "sdlpp_renderer.hpp"
|
||||
|
||||
namespace SDLPP {
|
||||
class CollisionPolygon {
|
||||
class SDLPPSCOPE CollisionPolygon {
|
||||
public:
|
||||
CollisionPolygon( double x, double y );
|
||||
virtual ~CollisionPolygon() {}
|
||||
@ -36,9 +36,9 @@ protected:
|
||||
SDL_Color sdl_outline = { 0, 0, 0, 0 };
|
||||
};
|
||||
|
||||
bool infinityIntersection( const SDLPP::CollisionPolygon &infinite,
|
||||
SDLPPSCOPE bool infinityIntersection( const SDLPP::CollisionPolygon &infinite,
|
||||
const SDLPP::CollisionPolygon &other );
|
||||
bool intersects( const SDLPP::CollisionPolygon &p1,
|
||||
SDLPPSCOPE bool intersects( const SDLPP::CollisionPolygon &p1,
|
||||
const SDLPP::CollisionPolygon &p2 );
|
||||
} // namespace SDLPP
|
||||
#endif
|
||||
|
@ -1,3 +1,16 @@
|
||||
#ifndef SDLPPSCOPE
|
||||
#ifdef _WIN32
|
||||
#ifdef DLLEXPORT
|
||||
#define SDLPPSCOPE __declspec( dllexport )
|
||||
#else
|
||||
#define SDLPPSCOPE __declspec( dllimport )
|
||||
#endif
|
||||
#else
|
||||
#define SDLPPSCOPE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SDLPP_HPP_COMMON
|
||||
#define SDLPP_HPP_COMMON
|
||||
|
||||
@ -22,17 +35,17 @@
|
||||
|
||||
namespace SDLPP {
|
||||
|
||||
int hex2num( char c );
|
||||
SDLPPSCOPE int hex2num( char c );
|
||||
|
||||
bool init();
|
||||
bool init( uint32_t SDL_OPTIONS );
|
||||
bool init( uint32_t SDL_OPTIONS, int IMAGE_OPTIONS );
|
||||
SDLPPSCOPE bool init();
|
||||
SDLPPSCOPE bool init( uint32_t SDL_OPTIONS );
|
||||
SDLPPSCOPE bool init( uint32_t SDL_OPTIONS, int IMAGE_OPTIONS );
|
||||
|
||||
std::tuple< int, int, int, int > getColorsHEX( const std::string &color );
|
||||
SDL_Color getSDLColorHEX( const std::string &color );
|
||||
std::tuple< int, int, int, int > getColorsSDLColor( const SDL_Color &color );
|
||||
SDL_Color getSDLColorTuple( const std::tuple< int, int, int, int > &tuple );
|
||||
SDLPPSCOPE std::tuple< int, int, int, int > getColorsHEX( const std::string &color );
|
||||
SDLPPSCOPE SDL_Color getSDLColorHEX( const std::string &color );
|
||||
SDLPPSCOPE std::tuple< int, int, int, int > getColorsSDLColor( const SDL_Color &color );
|
||||
SDLPPSCOPE SDL_Color getSDLColorTuple( const std::tuple< int, int, int, int > &tuple );
|
||||
|
||||
bool getSDLEvent( SDL_Event &e );
|
||||
SDLPPSCOPE bool getSDLEvent( SDL_Event &e );
|
||||
} // end of namespace SDLPP
|
||||
#endif
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <iostream>
|
||||
|
||||
namespace SDLPP {
|
||||
class Font {
|
||||
class SDLPPSCOPE Font {
|
||||
public:
|
||||
Font() = delete;
|
||||
Font( const std::string &font, int size );
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "sdlpp_renderobject.hpp"
|
||||
|
||||
namespace SDLPP {
|
||||
class LineRenderer : public RenderObject {
|
||||
class SDLPPSCOPE LineRenderer : public RenderObject {
|
||||
public:
|
||||
LineRenderer() = delete;
|
||||
virtual ~LineRenderer(){};
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <limits>
|
||||
|
||||
namespace SDLPP {
|
||||
class RectColider : public CollisionPolygon {
|
||||
class SDLPPSCOPE RectColider : public CollisionPolygon {
|
||||
public:
|
||||
RectColider( double x, double y, double w, double h );
|
||||
virtual ~RectColider() {}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "sdlpp_rectcolider.hpp"
|
||||
|
||||
namespace SDLPP {
|
||||
class RectangleRender : public RenderObject {
|
||||
class SDLPPSCOPE RectangleRender : public RenderObject {
|
||||
public:
|
||||
RectangleRender() = delete;
|
||||
virtual ~RectangleRender(){};
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <iostream>
|
||||
|
||||
namespace SDLPP {
|
||||
class Renderer {
|
||||
class SDLPPSCOPE Renderer {
|
||||
public:
|
||||
Renderer() = delete;
|
||||
Renderer( Window &window );
|
||||
|
@ -10,9 +10,9 @@
|
||||
#include <vector>
|
||||
|
||||
namespace SDLPP {
|
||||
class Scene;
|
||||
class SDLPPSCOPE Scene;
|
||||
|
||||
class RenderObject {
|
||||
class SDLPPSCOPE RenderObject {
|
||||
public:
|
||||
RenderObject( const std::shared_ptr< Renderer > &r ) : renderer( r ) {}
|
||||
virtual ~RenderObject() {}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "sdlpp_renderobject.hpp"
|
||||
|
||||
namespace SDLPP {
|
||||
class Scene {
|
||||
class SDLPPSCOPE Scene {
|
||||
public:
|
||||
Scene( std::shared_ptr< Renderer > &r );
|
||||
void addObject( const std::shared_ptr< RenderObject > &obj );
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
|
||||
namespace SDLPP {
|
||||
class TextRenderer : public RectangleRender {
|
||||
class SDLPPSCOPE TextRenderer : public RectangleRender {
|
||||
public:
|
||||
TextRenderer() = delete;
|
||||
TextRenderer( double x, double y, double w, double h,
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "sdlpp_renderer.hpp"
|
||||
|
||||
namespace SDLPP {
|
||||
class Texture {
|
||||
class SDLPPSCOPE Texture {
|
||||
public:
|
||||
Texture() = delete;
|
||||
Texture( std::shared_ptr< Renderer > &renderer,
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <iostream>
|
||||
|
||||
namespace SDLPP {
|
||||
class Window {
|
||||
class SDLPPSCOPE Window {
|
||||
public:
|
||||
Window();
|
||||
Window( const std::string &window_name );
|
||||
|
Loading…
Reference in New Issue
Block a user