Skip to content

Commit

Permalink
Fixed macOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
aglab2 committed Mar 17, 2022
1 parent e0cd5ca commit bb8a4d5
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Release/
**/*.sln
**/*.vcxproj
**/*.vcxproj.filters
.DS_Store
26 changes: 8 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -285,39 +285,23 @@ else ifneq (,$(findstring osx,$(platform)))
LDFLAGS += -stdlib=libc++
fpic = -fPIC

HAVE_THR_AL=1
HAVE_PARALLEL=0
PLATCFLAGS += -D__MACOSX__ -DOSX
PLATFORM_EXT := unix
PLATCFLAGS += -DHAVE_POSIX_MEMALIGN

# Disable hardware rendered graphics plugins for ARM for now
ifeq ($(shell uname -p),arm)
WITH_DYNAREC =
CFLAGS += -DDONT_WANT_ARM_OPTIMIZATIONS
HAVE_OPENGL=0
else
# OpenGL is broken on non-ARM now, too
HAVE_OPENGL=0
endif
COREFLAGS += -DOS_MAC_OS_X -stdlib=libc++

# Target Dynarec
ifeq ($(ARCH), $(filter $(ARCH), ppc))
WITH_DYNAREC =
endif

ifeq ($(CROSS_COMPILE),1)
TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM)
CFLAGS += $(TARGET_RULE)
CPPFLAGS += $(TARGET_RULE)
CXXFLAGS += $(TARGET_RULE)
LDFLAGS += $(TARGET_RULE)

ifeq ($(arch),arm)
HAVE_OPENGL=0
WITH_DYNAREC =
CFLAGS += -DDONT_WANT_ARM_OPTIMIZATIONS
endif
endif

CFLAGS += $(ARCHFLAGS)
Expand Down Expand Up @@ -1032,6 +1016,12 @@ else
$(CC_AS) $(ASFLAGS) -c $< $(OBJOUT)$@
endif

mupen64plus-video-gliden64/src/%.o: mupen64plus-video-gliden64/src/%.c
$(CC) -I$(VIDEODIR_GLIDEN64)/src -I$(VIDEODIR_GLIDEN64)/src/osal $(CPPFLAGS) $(CFLAGS) -c $< $(OBJOUT)$@

mupen64plus-video-gliden64/src/%.o: mupen64plus-video-gliden64/src/%.cpp
$(CXX) -I$(VIDEODIR_GLIDEN64)/src -I$(VIDEODIR_GLIDEN64)/src/osal $(CPPFLAGS) $(CXXFLAGS) -c $< $(OBJOUT)$@

%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< $(OBJOUT)$@

Expand Down
2 changes: 0 additions & 2 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ INCFLAGS += \
-I$(CORE_DIR)/src \
-I$(CORE_DIR)/src/api \
-I$(ROOT_DIR)/include \
-I$(VIDEODIR_GLIDEN64)/src \
-I$(VIDEODIR_GLIDEN64)/src/osal \
-I$(AUDIO_LIBRETRO_DIR) \
-I$(LIBRETRO_COMM_DIR)/include \
-I$(LIBRETRO_DIR)
Expand Down
2 changes: 1 addition & 1 deletion custom/dependencies/libpng/config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h. Generated from .in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */

/* Define to 1 if you have the <dlfcn.h> header file. */
Expand Down
6 changes: 6 additions & 0 deletions custom/dependencies/libzlib/gzguts.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/

#ifdef __APPLE__
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#endif

#ifdef _LARGEFILE64_SOURCE
# ifndef _LARGEFILE_SOURCE
# define _LARGEFILE_SOURCE 1
Expand Down
6 changes: 6 additions & 0 deletions gles2rice/src/osal_opengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@
#define glTexEnvi(x,y,z)
#define glTexEnvfv(x,y,z)

#ifdef __APPLE__
#define GL_CLAMP 0x2900
#define GL_MAX_TEXTURE_UNITS 8
#define GL_INTERPOLATE 0x8575
#endif

#endif // OSAL_OPENGL_H
7 changes: 7 additions & 0 deletions glide2gl/src/Glitch64/glitch64_textures.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
#include "glitchmain.h"
#include "uthash.h"

#ifdef __APPLE__
#define GL_LUMINANCE8 0x8040
#define GL_INTENSITY8 0x804b
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE8_ALPHA8 0x8045
#endif

/* Napalm extensions to GrTextureFormat_t */
#define GR_TEXFMT_ARGB_8888 0x12
#define GR_TEXFMT_YUYV_422 0x13
Expand Down
4 changes: 4 additions & 0 deletions include/GL/glext.h
Original file line number Diff line number Diff line change
Expand Up @@ -6162,8 +6162,12 @@ typedef ptrdiff_t GLsizeiptrARB;
#ifndef GL_ARB_shader_objects
/* GL types for program/shader text and shader object handles */
typedef char GLcharARB;
#ifdef __APPLE__
typedef void *GLhandleARB;
#else
typedef unsigned int GLhandleARB;
#endif
#endif

/* GL type for "half" precision (s10e5) float data in host memory */
#ifndef GL_ARB_half_float_pixel
Expand Down
2 changes: 2 additions & 0 deletions libretro/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,8 @@ static void emu_step_initialize(void)
CoreDoCommand(M64CMD_EXECUTE, 0, NULL);
}

extern void gliden64RomOpen();
extern void gliden64RomClosed();
void reinit_gfx_plugin(void)
{
if(first_context_reset)
Expand Down
4 changes: 4 additions & 0 deletions libretro/msvc/GL/glext.h
Original file line number Diff line number Diff line change
Expand Up @@ -6162,8 +6162,12 @@ typedef ptrdiff_t GLsizeiptrARB;
#ifndef GL_ARB_shader_objects
/* GL types for program/shader text and shader object handles */
typedef char GLcharARB;
#ifdef __APPLE__
typedef void *GLhandleARB;
#else
typedef unsigned int GLhandleARB;
#endif
#endif

/* GL type for "half" precision (s10e5) float data in host memory */
#ifndef GL_ARB_half_float_pixel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@
#include <stddef.h>
#include <OpenGL/gl3.h>

// This is going to blow up so badly
typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param);
typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param);
typedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures);
typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers);
typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void);
typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers);

#define GL_MAP_PERSISTENT_BIT 0x0040
#define GL_MAP_COHERENT_BIT 0x0080
#define GL_CLIENT_STORAGE_BIT 0x0200
#elif defined(OS_IOS)
#include <OpenGLES/ES3/gl.h>
#include <OpenGLES/ES3/glext.h>
Expand Down Expand Up @@ -69,6 +84,9 @@ typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloa
#define CHECKED_GL_FUNCTION_WITH_RETURN(proc_name, ReturnType, ...) proc_name(__VA_ARGS__)
#endif

#define CHECKED_GL_FUNCTION_UNCHECKED(proc_name, ...) proc_name(__VA_ARGS__)
#define CHECKED_GL_FUNCTION_UNCHECKED_WITH_RETURN(proc_name, ReturnType, ...) proc_name(__VA_ARGS__)

#define IS_GL_FUNCTION_VALID(proc_name) g_##proc_name != nullptr
#define GET_GL_FUNCTION(proc_name) g_##proc_name

Expand All @@ -87,8 +105,8 @@ typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloa
#define glBindTexture(...) CHECKED_GL_FUNCTION(g_glBindTexture, __VA_ARGS__)
#define glTexImage2D(...) CHECKED_GL_FUNCTION(g_glTexImage2D, __VA_ARGS__)
#define glTexParameteri(...) CHECKED_GL_FUNCTION(g_glTexParameteri, __VA_ARGS__)
#define glGetIntegerv(...) CHECKED_GL_FUNCTION(g_glGetIntegerv, __VA_ARGS__)
#define glGetString(...) CHECKED_GL_FUNCTION_WITH_RETURN(g_glGetString, const GLubyte*, __VA_ARGS__)
#define glGetIntegerv(...) CHECKED_GL_FUNCTION_UNCHECKED(g_glGetIntegerv, __VA_ARGS__)
#define glGetString(...) CHECKED_GL_FUNCTION_UNCHECKED_WITH_RETURN(g_glGetString, const GLubyte*, __VA_ARGS__)
#define glReadPixels(...) CHECKED_GL_FUNCTION(g_glReadPixels, __VA_ARGS__)
#define glTexSubImage2D(...) CHECKED_GL_FUNCTION(g_glTexSubImage2D, __VA_ARGS__)
#define glDrawArrays(...) CHECKED_GL_FUNCTION(g_glDrawArrays, __VA_ARGS__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "Graphics/Context.h"
#include <DisplayWindow.h>

extern "C" void Config_LoadConfig();

PluginAPI & PluginAPI::get()
{
static PluginAPI api;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
#include <sys/stat.h>
#endif

#ifdef __APPLE__
#include <mach-o/dyld.h>
#include <sys/param.h>
#endif

#include <libretro_private.h>

extern retro_environment_t environ_cb;
Expand Down Expand Up @@ -93,8 +98,8 @@ void PluginAPI::FindPluginPath(wchar_t * _strPath)
}
#elif defined(OS_MAC_OS_X)
char path[MAXPATHLEN];
uint32_t pathLen = MAXPATHLEN * 2;
if (_NSGetExecutablePath(path, pathLen) == 0) {
uint32_t pathLen = MAXPATHLEN;
if (_NSGetExecutablePath(path, &pathLen) == 0) {
_getWSPath(path, _strPath);
}
#elif defined(ANDROID)
Expand Down
9 changes: 9 additions & 0 deletions scripts/build-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# To be used on Manjaro with MinGW packages installed
LIBRETRO_APPLE_PLATFORM=x86_64-apple-macos10.7 \
CROSS_COMPILE=1 \
platform=osx \
ARCH=x86_64 \
CC=clang \
CXX=clang++ \
make WITH_DYNAREC=x86_64 HAVE_THR_AL=1 HAVE_PARALLEL=1 HAVE_PARALLEL_RSP=1 -j12

0 comments on commit bb8a4d5

Please sign in to comment.