diff --git a/examples/Makefile.Web b/examples/Makefile.Web index 9765a2ff..e1d93bc0 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -23,97 +23,94 @@ .PHONY: all clean +# Define required environment variables +#------------------------------------------------------------------------------------------------ +# Define target platform: PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB +PLATFORM ?= PLATFORM_WEB + # Define required raylib variables -PROJECT_NAME ?= raylib_examples -RAYLIB_VERSION ?= 4.0.0 -RAYLIB_PATH ?= .. - -# Define default options - -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - -# Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that -# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. -# To enable compile-time linking to a special version of libraylib.so, change these variables here. -# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. -# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, -# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. -# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. -DESTDIR ?= /usr/local -RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib -# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. -RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) +PROJECT_NAME ?= raylib_examples +RAYLIB_VERSION ?= 4.0.0 +RAYLIB_PATH ?= .. + +# Locations of raylib.h and libraylib.a/libraylib.so +# NOTE: Those variables are only used for PLATFORM_OS: LINUX, BSD +RAYLIB_INCLUDE_PATH ?= /usr/local/include +RAYLIB_LIB_PATH ?= /usr/local/lib + +# Library type compilation: STATIC (.a) or SHARED (.so/.dll) RAYLIB_LIBTYPE ?= STATIC # Build mode for project: DEBUG or RELEASE BUILD_MODE ?= RELEASE # Use external GLFW library instead of rglfw module -# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 USE_EXTERNAL_GLFW ?= FALSE -# Use Wayland display server protocol on Linux desktop -# by default it uses X11 windowing system +# Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system) +# NOTE: This variable is only used for PLATFORM_OS: LINUX USE_WAYLAND_DISPLAY ?= FALSE +# Use cross-compiler for PLATFORM_RPI +ifeq ($(PLATFORM),PLATFORM_RPI) + USE_RPI_CROSS_COMPILER ?= FALSE + ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) + RPI_TOOLCHAIN ?= C:/SysGCC/Raspberry + RPI_TOOLCHAIN_SYSROOT ?= $(RPI_TOOLCHAIN)/arm-linux-gnueabihf/sysroot + endif +endif + # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) # No uname.exe on MinGW!, but OS=Windows_NT on Windows! # ifeq ($(UNAME),Msys) -> Windows ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS + PLATFORM_OS = WINDOWS else - UNAMEOS=$(shell uname) + UNAMEOS = $(shell uname) ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX + PLATFORM_OS = LINUX endif ifeq ($(UNAMEOS),FreeBSD) - PLATFORM_OS=BSD + PLATFORM_OS = BSD endif ifeq ($(UNAMEOS),OpenBSD) - PLATFORM_OS=BSD + PLATFORM_OS = BSD endif ifeq ($(UNAMEOS),NetBSD) - PLATFORM_OS=BSD + PLATFORM_OS = BSD endif ifeq ($(UNAMEOS),DragonFly) - PLATFORM_OS=BSD + PLATFORM_OS = BSD endif ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX + PLATFORM_OS = OSX endif endif endif ifeq ($(PLATFORM),PLATFORM_RPI) - UNAMEOS=$(shell uname) + UNAMEOS = $(shell uname) ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX + PLATFORM_OS = LINUX endif endif ifeq ($(PLATFORM),PLATFORM_DRM) - UNAMEOS=$(shell uname) + UNAMEOS = $(shell uname) ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX + PLATFORM_OS = LINUX endif endif -# RAYLIB_PATH adjustment for different platforms. -# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? -# Required for ldconfig or other tools that do not perform path expansion. +# RAYLIB_PATH adjustment for LINUX platform +# TODO: Do we really need this? ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PREFIX ?= .. - RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) + RAYLIB_PREFIX ?= .. + RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) endif endif -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. -# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. + +# Default path for raylib on Raspberry Pi ifeq ($(PLATFORM),PLATFORM_RPI) RAYLIB_PATH ?= /home/pi/raylib endif @@ -121,6 +118,9 @@ ifeq ($(PLATFORM),PLATFORM_DRM) RAYLIB_PATH ?= /home/pi/raylib endif +# Define raylib release directory for compiled library +RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src + ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables EMSDK_PATH ?= C:/emsdk @@ -131,26 +131,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB) export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH) endif -# Define raylib release directory for compiled library. -# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src - -# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries -# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH -# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux -# without formal installation from ../src/Makefile. It aids portability and is useful if you have -# multiple versions of raylib, have raylib installed to a non-standard location, or want to -# bundle libraylib.so with your game. Change it to your liking. -# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, -# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) -# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. -# To see which libraries a built example is linking to, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. -EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) - -# Define default C compiler: gcc -# NOTE: define g++ compiler if using C++ +# Define default C compiler: CC +#------------------------------------------------------------------------------------------------ CC = gcc ifeq ($(PLATFORM),PLATFORM_DESKTOP) @@ -177,7 +159,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB) CC = emcc endif -# Define default make program +# Define default make program: MAKE +#------------------------------------------------------------------------------------------------ MAKE ?= make ifeq ($(PLATFORM),PLATFORM_DESKTOP) @@ -192,7 +175,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB) MAKE = mingw32-make endif -# Define compiler flags: +# Define compiler flags: CFLAGS +#------------------------------------------------------------------------------------------------ # -O1 defines optimization level # -g include debug information on compilation # -s strip unnecessary data from build @@ -202,7 +186,7 @@ endif # -Wno-missing-braces ignore invalid warning (GCC bug 53119) # -Wno-unused-value ignore unused return values of some functions (i.e. fread()) # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wno-unused-value +CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result ifeq ($(BUILD_MODE),DEBUG) CFLAGS += -g -D_DEBUG @@ -218,6 +202,10 @@ else endif # Additional flags for compiler (if desired) +# -Wextra enables some extra warning flags that are not enabled by -Wall +# -Wmissing-prototypes warn if a global function is defined without a previous prototype declaration +# -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types +# -Werror=implicit-function-declaration catch function calls without prior declaration #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),LINUX) @@ -226,7 +214,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) endif ifeq ($(RAYLIB_LIBTYPE),SHARED) # Explicitly enable runtime link to libraylib.so - CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) + CFLAGS += -Wl,-rpath,$(RAYLIB_RELEASE_PATH) endif endif endif @@ -237,51 +225,47 @@ ifeq ($(PLATFORM),PLATFORM_DRM) CFLAGS += -std=gnu99 -DEGL_NO_X11 endif -# Define include paths for required headers +# Define include paths for required headers: INCLUDE_PATHS # NOTE: Some external/extras libraries could be required (stb, easings...) +#------------------------------------------------------------------------------------------------ INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external # Define additional directories containing required header files -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DRM) - # DRM required libraries - INCLUDE_PATHS += -I/usr/include/libdrm -endif ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_H_INSTALL_PATH) - INCLUDE_PATHS += -I/usr/local/include + INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH) endif ifeq ($(PLATFORM_OS),LINUX) - INCLUDE_PATHS += -I$(RAYLIB_H_INSTALL_PATH) + INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH) endif endif +ifeq ($(PLATFORM),PLATFORM_RPI) + INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include + INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vmcs_host/linux + INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vcos/pthreads +endif +ifeq ($(PLATFORM),PLATFORM_DRM) + INCLUDE_PATHS += -I/usr/include/libdrm +endif -# Define library paths containing required libs. +# Define library paths containing required libs: LDFLAGS +#------------------------------------------------------------------------------------------------ LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) - # resource file contains windows executable icon and properties + # NOTE: The resource .rc file contains windows executable icon and properties LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data # -Wl,--subsystem,windows hides the console window ifeq ($(BUILD_MODE), RELEASE) LDFLAGS += -Wl,--subsystem,windows endif endif - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_INSTALL_PATH) - LDFLAGS += -L. -Lsrc -L/usr/local/lib - endif ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH) + LDFLAGS += -L$(RAYLIB_LIB_PATH) + endif + ifeq ($(PLATFORM_OS),BSD) + LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH) endif endif ifeq ($(PLATFORM),PLATFORM_WEB) @@ -314,11 +298,12 @@ ifeq ($(PLATFORM),PLATFORM_WEB) EXT = .html endif ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib + LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib endif -# Define any libraries required on linking -# if you want to link libraries (libname.so or libname.a), use the -lname +# Define libraries required on linking: LDLIBS +# NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name> +#------------------------------------------------------------------------------------------------ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) # Libraries for Windows desktop compilation @@ -365,19 +350,23 @@ endif ifeq ($(PLATFORM),PLATFORM_RPI) # Libraries for Raspberry Pi compiling # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl + LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -latomic + ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) + LDLIBS += -lvchiq_arm -lvcos + endif endif ifeq ($(PLATFORM),PLATFORM_DRM) # Libraries for DRM compiling # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl + LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic endif ifeq ($(PLATFORM),PLATFORM_WEB) # Libraries for web (HTML5) compiling LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.a endif -# Define all object files required +# Define source code object files required +#------------------------------------------------------------------------------------------------ CORE = \ core/core_basic_window \ core/core_basic_screen_manager \ @@ -389,13 +378,13 @@ CORE = \ core/core_input_gestures \ core/core_2d_camera \ core/core_2d_camera_platformer \ + core/core_2d_camera_mouse_zoom \ core/core_3d_camera_mode \ core/core_3d_camera_free \ core/core_3d_camera_first_person \ core/core_3d_picking \ core/core_world_screen \ core/core_custom_logging \ - core/core_window_letterbox \ core/core_drop_files \ core/core_random_values \ core/core_scissor_test \ @@ -403,6 +392,8 @@ CORE = \ core/core_vr_simulator \ core/core_loading_thread \ core/core_window_flags \ + core/core_window_letterbox \ + core/core_window_should_close \ core/core_split_screen \ core/core_smooth_pixelperfect \ core/core_custom_frame_control @@ -422,7 +413,8 @@ SHAPES = \ shapes/shapes_easings_rectangle_array \ shapes/shapes_draw_ring \ shapes/shapes_draw_circle_sector \ - shapes/shapes_draw_rectangle_rounded + shapes/shapes_draw_rectangle_rounded \ + shapes/shapes_top_down_lights TEXTURES = \ textures/textures_logo_raylib \ @@ -444,7 +436,9 @@ TEXTURES = \ textures/textures_bunnymark \ textures/textures_blend_modes \ textures/textures_draw_tiled \ - textures/textures_polygon + textures/textures_polygon \ + textures/textures_gif_player \ + textures/textures_fog_of_war TEXT = \ text/text_raylib_fonts \ @@ -457,7 +451,8 @@ TEXT = \ text/text_writing_anim \ text/text_rectangle_bounds \ text/text_unicode \ - text/text_draw_3d + text/text_draw_3d \ + text/text_codepoints_loading MODELS = \ models/models_animation \ @@ -503,10 +498,13 @@ AUDIO = \ audio/audio_music_stream \ audio/audio_raw_stream \ audio/audio_sound_loading \ - audio/audio_multichannel_sound + audio/audio_multichannel_sound \ + audio/audio_stream_effects CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST)) +# Define processes to execute +#------------------------------------------------------------------------------------------------ # Default target entry all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO)