diff options
Diffstat (limited to 'src/Makefile')
| -rw-r--r-- | src/Makefile | 185 |
1 files changed, 119 insertions, 66 deletions
diff --git a/src/Makefile b/src/Makefile index 4c2278f5..1eac71f6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,10 +1,19 @@ #****************************************************************************** # -# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) -# -# Many Thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline. +# raylib makefile # -# Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) +# Platforms supported: +# PLATFORM_DESKTOP: Windows (win32/Win64) +# PLATFORM_DESKTOP: Linux +# PLATFORM_DESKTOP: OSX (Mac) +# PLATFORM_ANDROID: Android (ARM or ARM64) +# PLATFORM_RPI: Raspberry Pi (Raspbian) +# PLATFORM_WEB: HTML5 (Chrome, Firefox) +# +# Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline. +# Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline. +# +# Copyright (c) 2014-2017 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. # In no event will the authors be held liable for any damages arising from @@ -29,21 +38,28 @@ # Please read the wiki to know how to compile raylib, because there are # different methods. -.PHONY: all clean install unistall +.PHONY: all clean install uninstall # define raylib platform to compile for # possible platforms: PLATFORM_DESKTOP PLATFORM_ANDROID PLATFORM_RPI PLATFORM_WEB PLATFORM ?= PLATFORM_DESKTOP +# define raylib default path, required to look for emsdk and android-toolchain +RAYLIB_PATH ?= C:/raylib + # define YES if you want shared/dynamic version of library instead of static (default) -SHARED ?= NO +SHARED_RAYLIB ?= NO -# define NO to use OpenAL Soft as static library (or shared by default) -SHARED_OPENAL ?= YES +# use OpenAL Soft as shared library (.so / .dll) +# NOTE: If defined NO, static OpenAL Soft library should be provided +SHARED_OPENAL ?= NO # on PLATFORM_WEB force OpenAL Soft shared library ifeq ($(PLATFORM),PLATFORM_WEB) - SHARED_OPENAL ?= YES + SHARED_OPENAL = YES +endif +ifeq ($(PLATFORM),PLATFORM_ANDROID) + SHARED_OPENAL = YES endif # determine if the file has root access (only for installing raylib) @@ -69,48 +85,67 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) endif endif +ifeq ($(PLATFORM),PLATFORM_WEB) + # Emscripten required variables + EMSDK_PATH = $(RAYLIB_PATH)/emsdk + EMSCRIPTEN_VERSION = 1.37.9 + CLANG_VERSION=e1.37.9_64bit + PYTHON_VERSION=2.7.5.3_64bit + NODE_VERSION=4.1.1_64bit + export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH) + EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION) +endif + ifeq ($(PLATFORM),PLATFORM_ANDROID) - # path to Android NDK + # Android NDK path + # NOTE: Required for standalone toolchain generation ANDROID_NDK = $(ANDROID_NDK_HOME) + + # Android standalone toolchain path + # NOTE: This path is also used if toolchain generation + #ANDROID_TOOLCHAIN = $(CURDIR)/toolchain + ANDROID_TOOLCHAIN = $(RAYLIB_PATH)/android-toolchain - # possible Android architectures: ARM ARM64 + # Android architecture: ARM or ARM64 ANDROID_ARCH ?= ARM - # define YES to use clang instead of gcc + # Android compiler: gcc or clang + # NOTE: Define YES to use clang instead of gcc ANDROID_LLVM ?= NO - - # standalone Android toolchain install dir - ANDROID_TOOLCHAIN = $(CURDIR)/toolchain endif ifeq ($(PLATFORM),PLATFORM_RPI) + # RPI cross-compiler CROSS_COMPILE ?= NO endif # define raylib graphics api depending on selected platform -ifeq ($(PLATFORM),PLATFORM_ANDROID) - GRAPHICS = GRAPHICS_API_OPENGL_ES2 -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # define raylib graphics api to use (on RPI, OpenGL ES 2.0 must be used) - GRAPHICS = GRAPHICS_API_OPENGL_ES2 -else - # define raylib graphics api to use (OpenGL 3.3 by default) +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # by default use OpenGL 3.3 on desktop platforms GRAPHICS ?= GRAPHICS_API_OPENGL_33 #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1 #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1 endif +ifeq ($(PLATFORM),PLATFORM_RPI) + # on RPI OpenGL ES 2.0 must be used + GRAPHICS = GRAPHICS_API_OPENGL_ES2 +endif ifeq ($(PLATFORM),PLATFORM_WEB) + # on HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0 + GRAPHICS = GRAPHICS_API_OPENGL_ES2 +endif +ifeq ($(PLATFORM),PLATFORM_ANDROID) + # by default use OpenGL ES 2.0 on Android GRAPHICS = GRAPHICS_API_OPENGL_ES2 endif # NOTE: makefiles targets require tab indentation - -# define compiler: gcc for C program, define as g++ for C++ +# NOTE: define compiler: gcc for C program, define as g++ for C++ # default gcc compiler CC = gcc +# Android toolchain compiler ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(ANDROID_ARCH),ARM) ifeq ($(ANDROID_LLVM),YES) @@ -128,6 +163,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID) endif endif +# RPI cross-compiler ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(CROSS_COMPILE),YES) # rpi compiler @@ -135,13 +171,15 @@ ifeq ($(PLATFORM),PLATFORM_RPI) endif endif +# HTML5 emscripten compiler ifeq ($(PLATFORM),PLATFORM_WEB) - # emscripten compiler CC = emcc endif +# default archiver program to pack libraries AR = ar +# Android archiver ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(ANDROID_ARCH),ARM) AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar @@ -153,15 +191,28 @@ endif # define compiler flags: # -O1 defines optimization level +# -Og enable debugging # -Wall turns on most, but not all, compiler warnings # -std=c99 defines C language mode (standard C from 1999 revision) # -std=gnu99 defines C language mode (GNU C from 1999 revision) # -fgnu89-inline declaring inline functions support (GCC optimized) # -Wno-missing-braces ignore invalid warning (GCC bug 53119) -CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces +# -D_DEFAULT_SOURCE use with -std=c99 +CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces + +ifeq ($(PLATFORM),PLATFORM_WEB) + CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources + # -O2 # if used, also set --memory-init-file 0 + # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) + # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing + # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) + # -s USE_PTHREADS=1 # multithreading support +endif + +#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes # if shared library required, make sure code is compiled as position independent -ifeq ($(SHARED),YES) +ifeq ($(SHARED_RAYLIB),YES) CFLAGS += -fPIC SHAREDFLAG = BUILDING_DLL SHAREDLIBS = -Lexternal/glfw3/lib/win32 -Lexternal/openal_soft/lib/win32 -lglfw3 -lgdi32 @@ -180,32 +231,33 @@ endif #CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes -# define any directories containing required header files -ifeq ($(PLATFORM),PLATFORM_ANDROID) -# STB libraries and others - INCLUDES = -I. -Iexternal +# external required libraries (stb and others) +INCLUDES = -I. -Iexternal + # OpenAL Soft library - INCLUDES += -Iexternal/openal_soft/include -# Android includes - INCLUDES += -I$(ANDROID_TOOLCHAIN)/sysroot/usr/include - INCLUDES += -I$(ANDROID_NDK)/sources/android/native_app_glue -else -# STB libraries and others - INCLUDES = -I. -Iexternal -# GLFW3 library +INCLUDES += -Iexternal/openal_soft/include + +# define any directories containing required header files +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # GLFW3 library INCLUDES += -Iexternal/glfw3/include -# OpenAL Soft library - INCLUDES += -Iexternal/openal_soft/include endif ifeq ($(PLATFORM),PLATFORM_RPI) -# STB libraries and others - INCLUDES = -I. -Iexternal -# RPi libraries + # RPI requried libraries INCLUDES += -I/opt/vc/include INCLUDES += -I/opt/vc/include/interface/vmcs_host/linux INCLUDES += -I/opt/vc/include/interface/vcos/pthreads -# OpenAL Soft library - INCLUDES += -Iexternal/openal_soft/include +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + # GLFW3 library + INCLUDES += -Iexternal/glfw3/include +endif +ifeq ($(PLATFORM),PLATFORM_ANDROID) + # Android required libraries + INCLUDES += -I$(ANDROID_TOOLCHAIN)/sysroot/usr/include + # Include android_native_app_glue.h + INCLUDES += -Iexternal/android/native_app_glue + #INCLUDES += -I$(ANDROID_NDK)/sources/android/native_app_glue endif # define output directory for compiled library @@ -220,6 +272,12 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) OUTPUT_PATH = ../release/osx endif endif +ifeq ($(PLATFORM),PLATFORM_RPI) + OUTPUT_PATH = ../release/rpi +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + OUTPUT_PATH = ../release/html5 +endif ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(ANDROID_ARCH),ARM) OUTPUT_PATH = ../release/android/armeabi-v7a @@ -228,12 +286,6 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID) OUTPUT_PATH = ../release/android/arm64-v8a endif endif -ifeq ($(PLATFORM),PLATFORM_WEB) - OUTPUT_PATH = ../release/html5 -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - OUTPUT_PATH = ../release/rpi -endif # define all object files required with a wildcard # The wildcard takes all files that finish with ".c", then it replaces the @@ -243,9 +295,10 @@ OBJS += external/stb_vorbis.o # typing 'make' will invoke the default target entry called 'all', # in this case, the 'default' target entry is raylib -all: toolchain raylib +all: raylib -# make standalone Android toolchain +# generate standalone Android toolchain +# NOTE: Android toolchain could already be provided toolchain: ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(ANDROID_ARCH),ARM) @@ -263,10 +316,10 @@ ifeq ($(PLATFORM),PLATFORM_WEB) emcc -O1 $(OBJS) -o $(OUTPUT_PATH)/libraylib.bc @echo "libraylib.bc generated (web version)!" else - ifeq ($(SHARED),YES) + ifeq ($(SHARED_RAYLIB),YES) ifeq ($(PLATFORM_OS),LINUX) # compile raylib to shared library version for GNU/Linux. - # WARNING: you should type "make clean" before doing this target + # WARNING: you should type "make clean" before doing this target $(CC) -shared -o $(OUTPUT_PATH)/libraylib.so $(OBJS) @echo "raylib shared library (libraylib.so) generated!" endif @@ -276,12 +329,12 @@ else endif ifeq ($(PLATFORM),PLATFORM_ANDROID) $(CC) -shared -o $(OUTPUT_PATH)/libraylib.so $(OBJS) - @echo "raylib shared library (libraylib.so) generated!" + @echo "raylib shared library generated (libraylib.so)!" endif else - # compile raylib static library. + # compile raylib static library. $(AR) rcs $(OUTPUT_PATH)/libraylib.a $(OBJS) - @echo "libraylib.a generated (static library)!" + @echo "raylib static library generated (libraylib.a)!" ifeq ($(SHARED_OPENAL),NO) @echo "expected OpenAL Soft static library linking" else @@ -299,11 +352,11 @@ core.o : core.c raylib.h rlgl.h utils.h raymath.h gestures.h # compile rlgl module rlgl.o : rlgl.c rlgl.h raymath.h $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(GRAPHICS) - + # compile shapes module shapes.o : shapes.c raylib.h rlgl.h $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(SHAREDFLAG) - + # compile textures module textures.o : textures.c rlgl.h utils.h $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(GRAPHICS) -D$(SHAREDFLAG) @@ -319,7 +372,7 @@ models.o : models.c raylib.h rlgl.h raymath.h # compile audio module audio.o : audio.c raylib.h $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(SHAREDFLAG) -D$(SHAREDOPENALFLAG) - + # compile stb_vorbis library external/stb_vorbis.o: external/stb_vorbis.c external/stb_vorbis.h $(CC) -c -o $@ $< -O1 $(CFLAGS) $(INCLUDES) -D$(PLATFORM) @@ -338,7 +391,7 @@ ifeq ($(ROOT),root) # libraries and header files. These directory (/usr/local/lib and # /usr/local/include/) are for libraries that are installed # manually (without a package manager). - ifeq ($(SHARED),YES) + ifeq ($(SHARED_RAYLIB),YES) cp --update $(OUTPUT_PATH)/libraylib.so /usr/local/lib/libraylib.so else cp --update raylib.h /usr/local/include/raylib.h @@ -354,11 +407,11 @@ endif # it removes raylib dev files installed on the system. # TODO: see 'install' target. -unistall : +uninstall : ifeq ($(ROOT),root) ifeq ($(PLATFORM_OS),LINUX) rm --force /usr/local/include/raylib.h - ifeq ($(SHARED),YES) + ifeq ($(SHARED_RAYLIB),YES) rm --force /usr/local/lib/libraylib.so else rm --force /usr/local/lib/libraylib.a |
