From 73774aadd63bba93908ee57f1e711c9bf2c70b53 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 3 May 2017 14:16:42 +0200 Subject: Review makefiles --- src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Makefile') diff --git a/src/Makefile b/src/Makefile index b616b583..7dce33b9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -39,7 +39,7 @@ PLATFORM ?= PLATFORM_DESKTOP SHARED ?= NO # define NO to use OpenAL Soft as static library (or shared by default) -SHARED_OPENAL ?= YES +SHARED_OPENAL ?= NO # on PLATFORM_WEB force OpenAL Soft shared library ifeq ($(PLATFORM),PLATFORM_WEB) @@ -304,7 +304,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) -- cgit v1.2.3 From 0ebd8b0f6ec1887f281f840052218d4ff0363cca Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 8 May 2017 00:47:15 +0200 Subject: Review Android compiling --- src/Makefile | 126 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 75 insertions(+), 51 deletions(-) (limited to 'src/Makefile') diff --git a/src/Makefile b/src/Makefile index 7dce33b9..c580a5b8 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 @@ -70,47 +79,55 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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 +145,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID) endif endif +# RPI cross-compiler ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(CROSS_COMPILE),YES) # rpi compiler @@ -135,13 +153,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 @@ -171,6 +191,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces endif endif +ifeq ($(PLATFORM),PLATFORM_RPI) + CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces +endif ifeq ($(PLATFORM),PLATFORM_WEB) CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources # -O2 # if used, also set --memory-init-file 0 @@ -179,8 +202,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # -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 +ifeq ($(PLATFORM),PLATFORM_ANDROID) + CFLAGS = -O1 -Wall -std=c99 -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) @@ -379,7 +403,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 -- cgit v1.2.3 From a522914183d87e64ec78bfe68c9cfdb39d58ac1c Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 8 May 2017 01:33:34 +0200 Subject: Included required paths for web compilation --- src/Makefile | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'src/Makefile') diff --git a/src/Makefile b/src/Makefile index c580a5b8..f2e09988 100644 --- a/src/Makefile +++ b/src/Makefile @@ -47,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) +# 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) @@ -78,6 +82,17 @@ 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) # Android NDK path # NOTE: Required for standalone toolchain generation @@ -179,32 +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 -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces -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_ANDROID) - CFLAGS = -O1 -Wall -std=c99 -fgnu89-inline -Wno-missing-braces -endif #CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes @@ -377,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. -- cgit v1.2.3