Modifications to build library on mac os x

Added os and architecture detection in makefile
This commit is contained in:
David Gallardo 2015-01-04 20:08:39 +01:00
parent fad81f36e4
commit c81948357b
2 changed files with 75 additions and 5 deletions

View File

@ -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 # define raylib platform to compile for
# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB # possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
PLATFORM ?= PLATFORM_DESKTOP 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 # define raylib graphics api depending on selected platform
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# define raylib graphics api to use (on RPI, OpenGL ES 2.0 must be used) # define raylib graphics api to use (on RPI, OpenGL ES 2.0 must be used)
@ -45,10 +94,15 @@ endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# define emscripten compiler # define emscripten compiler
CC = emcc CC = emcc
else
ifeq ($(PLATFORM_OS),OSX)
# define llvm compiler for mac
CC = clang
else else
# define default gcc compiler # define default gcc compiler
CC = gcc CC = gcc
endif endif
endif
# define compiler flags: # define compiler flags:
# -O2 defines optimization level # -O2 defines optimization level
@ -69,6 +123,14 @@ else
INCLUDES = -I. INCLUDES = -I.
endif 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 # 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 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) ifeq ($(PLATFORM),PLATFORM_RPI)
rm -f *.o libraylib.a rm -f *.o libraylib.a
else else
ifeq ($(PLATFORM),PLATFORM_DESKTOP_LINUX) ifeq ($(PLATFORM_OS),LINUX)
find . -type f -executable -delete find . -type f -executable -delete
rm -f *.o libraylib.a rm -f *.o libraylib.a
else else
ifeq ($(PLATFORM_OS),OSX)
find . -type f -perm +ugo+x -delete
rm -f *.o libraylib.a
else
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
del *.o libraylib.bc del *.o libraylib.bc
else else
del *.o libraylib.a del *.o libraylib.a
endif endif
endif endif
endif
endif endif
@echo Cleaning done @echo Cleaning done

View File

@ -32,8 +32,11 @@
#include <stdlib.h> // Declares malloc() and free() for memory management, rand() #include <stdlib.h> // Declares malloc() and free() for memory management, rand()
#if defined(GRAPHICS_API_OPENGL_11) #if defined(GRAPHICS_API_OPENGL_11)
#if defined(__APPLE__) && defined(__MACH__)
#include <OpenGL/gl.h> // Basic OpenGL include (OSX)
#else
#include <GL/gl.h> // Basic OpenGL include #include <GL/gl.h> // Basic OpenGL include
//#include <OpenGL/gl.h> // Basic OpenGL include (OSX) #endif
#endif #endif
#if defined(GRAPHICS_API_OPENGL_33) #if defined(GRAPHICS_API_OPENGL_33)