aboutsummaryrefslogtreecommitdiff
path: root/src/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'src/Makefile')
-rw-r--r--src/Makefile163
1 files changed, 94 insertions, 69 deletions
diff --git a/src/Makefile b/src/Makefile
index b616b583..f2e09988 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,10 +1,19 @@
#******************************************************************************
#
-# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten)
+# raylib makefile
#
-# Many Thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline.
+# 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)
#
-# Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
+# 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,7 +38,7 @@
# 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
@@ -38,12 +47,16 @@ PLATFORM ?= PLATFORM_DESKTOP
# define YES if you want shared/dynamic version of library instead of static (default)
SHARED ?= 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 +82,67 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif
endif
+ifeq ($(PLATFORM),PLATFORM_WEB)
+ # Emscripten required variables
+ EMSDK_PATH = C:/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 = C:/raylib/android-standalone-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 +160,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
endif
endif
+# RPI cross-compiler
ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(CROSS_COMPILE),YES)
# rpi compiler
@@ -135,13 +168,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
@@ -159,29 +194,17 @@ endif
# -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)
-# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB
-ifeq ($(PLATFORM),PLATFORM_DESKTOP)
- ifeq ($(PLATFORM_OS),WINDOWS)
- CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces
- endif
- ifeq ($(PLATFORM_OS),LINUX)
- CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE
- endif
- ifeq ($(PLATFORM_OS),OSX)
- CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces
- endif
-endif
+# -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 = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources
+ 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
-ifeq ($(PLATFORM),PLATFORM_RPI)
- CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces
-endif
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
@@ -205,32 +228,32 @@ 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 += -Iandroid/jni/include
+ #INCLUDES += -I$(ANDROID_NDK)/sources/android/native_app_glue
endif
# define output directory for compiled library
@@ -245,6 +268,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
@@ -253,12 +282,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
@@ -268,9 +291,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)
@@ -304,7 +328,7 @@ else
@echo "raylib shared library (libraylib.so) generated!"
endif
else
- # compile raylib static library.
+ # compile raylib static library.
$(AR) rcs $(OUTPUT_PATH)/libraylib.a $(OBJS)
@echo "libraylib.a generated (static library)!"
ifeq ($(SHARED_OPENAL),NO)
@@ -353,6 +377,7 @@ external/stb_vorbis.o: external/stb_vorbis.c external/stb_vorbis.h
utils.o : utils.c utils.h
$(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(SHAREDFLAG)
+
# It installs generated and needed files to compile projects using raylib.
# The installation works manually.
# TODO: add other platforms.
@@ -379,7 +404,7 @@ 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