From c81948357ba720ea23ed849083cc930b17f14ac0 Mon Sep 17 00:00:00 2001 From: David Gallardo Date: Sun, 4 Jan 2015 20:08:39 +0100 Subject: [PATCH] Modifications to build library on mac os x Added os and architecture detection in makefile --- src/makefile | 73 +++++++++++++++++++++++++++++++++++++++++++++++++--- src/rlgl.c | 7 +++-- 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/src/makefile b/src/makefile index 501bd0c91..db25aa369 100644 --- a/src/makefile +++ b/src/makefile @@ -21,10 +21,59 @@ # #************************************************************************************************** +PLATFORM_OS = UNDEFINED +PLATFORM_ARCH = UNDEFINED + +# detect OS and architecture +ifeq ($(OS),Windows_NT) + PLATFORM_OS = WIN + ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) + PLATFORM_ARCH = 64 + endif + ifeq ($(PROCESSOR_ARCHITECTURE),x86) + PLATFORM_ARCH = 32 + endif +else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Linux) + UNAME_P := $(shell uname -mp) + PLATFORM_OS = LINUX + endif + ifeq ($(UNAME_S),Darwin) + UNAME_P := $(shell uname -m) + PLATFORM_OS = OSX + endif + + ifeq ($(UNAME_P),x86_64) + PLATFORM_ARCH = 64 + endif + ifneq ($(filter %86,$(UNAME_P)),) + PLATFORM_ARCH = 32 + endif +endif + # define raylib platform to compile for # possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB PLATFORM ?= PLATFORM_DESKTOP +# define default targets to compile for +TARGET_OS ?= $(PLATFORM_OS) +TARGET_ARCH ?= $(PLATFORM_ARCH) + +ifeq ($(PLATFORM),PLATFORM_RPI) + TARGET_OS = LINUX + TARGET_ARCH = ARM +endif + +ifeq ($(PLATFORM),PLATFORM_WEB) + TARGET_OS = WEB + TARGET_ARCH = WEB +endif + +# prompt current target +$(info **** RUNNING OS = $(PLATFORM_OS), RUNNING ARCH = $(PLATFORM_ARCH)) +$(info **** TARGET PLATFORM = $(PLATFORM), TARGET OS = $(TARGET_OS), TARGET ARCH = $(TARGET_ARCH)) + # define raylib graphics api depending on selected platform ifeq ($(PLATFORM),PLATFORM_RPI) # define raylib graphics api to use (on RPI, OpenGL ES 2.0 must be used) @@ -46,8 +95,13 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # define emscripten compiler CC = emcc else - # define default gcc compiler - CC = gcc + ifeq ($(PLATFORM_OS),OSX) + # define llvm compiler for mac + CC = clang + else + # define default gcc compiler + CC = gcc + endif endif # define compiler flags: @@ -69,6 +123,14 @@ else INCLUDES = -I. endif +# include external libraries +#glfw3 +INCLUDES += -I. -I../external/glfw3/include +#glew +INCLUDES += -I. -I../external/glew/include +#Open AL +INCLUDES += -I. -I../external/openal_soft/include + # define all object files required OBJS = core.o rlgl.o raymath.o shapes.o text.o textures.o models.o audio.o utils.o stb_vorbis.o @@ -130,16 +192,21 @@ clean: ifeq ($(PLATFORM),PLATFORM_RPI) rm -f *.o libraylib.a else -ifeq ($(PLATFORM),PLATFORM_DESKTOP_LINUX) +ifeq ($(PLATFORM_OS),LINUX) find . -type f -executable -delete rm -f *.o libraylib.a else +ifeq ($(PLATFORM_OS),OSX) + find . -type f -perm +ugo+x -delete + rm -f *.o libraylib.a +else ifeq ($(PLATFORM),PLATFORM_WEB) del *.o libraylib.bc else del *.o libraylib.a endif endif +endif endif @echo Cleaning done diff --git a/src/rlgl.c b/src/rlgl.c index 6f2027c77..2ffb61f9d 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -32,8 +32,11 @@ #include // Declares malloc() and free() for memory management, rand() #if defined(GRAPHICS_API_OPENGL_11) - #include // Basic OpenGL include - //#include // Basic OpenGL include (OSX) + #if defined(__APPLE__) && defined(__MACH__) + #include // Basic OpenGL include (OSX) + #else + #include // Basic OpenGL include + #endif #endif #if defined(GRAPHICS_API_OPENGL_33)