Advertisement
KanjiCoder

RAYLIB/MAKEFILE

Feb 26th, 2022
1,175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 29.40 KB | None | 0 0
  1. #******************************************************************************
  2. #
  3. #  raylib makefile
  4. #
  5. #  Platforms supported:
  6. #    PLATFORM_DESKTOP:  Windows (Win32, Win64)
  7. #    PLATFORM_DESKTOP:  Linux (i386, x64)
  8. #    PLATFORM_DESKTOP:  OSX/macOS (arm64, x86_64)
  9. #    PLATFORM_DESKTOP:  FreeBSD, OpenBSD, NetBSD, DragonFly
  10. #    PLATFORM_ANDROID:  Android (arm, i686, arm64, x86_64)
  11. #    PLATFORM_RPI:      Raspberry Pi (Raspbian)
  12. #    PLATFORM_DRM:      Linux native mode, including Raspberry Pi 4 with V3D fkms driver
  13. #    PLATFORM_WEB:      HTML5 (Chrome, Firefox)
  14. #
  15. #  Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline.
  16. #  Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline.
  17. #
  18. #  Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
  19. #
  20. #  This software is provided "as-is", without any express or implied warranty.
  21. #  In no event will the authors be held liable for any damages arising from
  22. #  the use of this software.
  23. #
  24. #  Permission is granted to anyone to use this software for any purpose,
  25. #  including commercial applications, and to alter it and redistribute it
  26. #  freely, subject to the following restrictions:
  27. #
  28. #    1. The origin of this software must not be misrepresented; you must not
  29. #    claim that you wrote the original software. If you use this software in a
  30. #    product, an acknowledgment in the product documentation would be
  31. #    appreciated but is not required.
  32. #
  33. #    2. Altered source versions must be plainly marked as such, and must not
  34. #    be misrepresented as being the original software.
  35. #
  36. #    3. This notice may not be removed or altered from any source distribution.
  37. #
  38. #******************************************************************************
  39.  
  40. # Please read the wiki to know how to compile raylib, because there are different methods.
  41. # https://github.com/raysan5/raylib/wiki
  42.  
  43. .PHONY: all clean install uninstall
  44.  
  45. # Define required raylib variables
  46. RAYLIB_VERSION        = 4.0.0
  47. RAYLIB_API_VERSION    = 400
  48.  
  49. # Define raylib source code path
  50. RAYLIB_SRC_PATH      ?= ../src
  51.  
  52. # Define output directory for compiled library, defaults to src directory
  53. # NOTE: If externally provided, make sure directory exists
  54. RAYLIB_RELEASE_PATH  ?= $(RAYLIB_SRC_PATH)
  55.  
  56. # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
  57. RAYLIB_LIBTYPE       ?= STATIC
  58.  
  59. # Build mode for library: DEBUG or RELEASE
  60. RAYLIB_BUILD_MODE    ?= RELEASE
  61.  
  62. # Build output name for the library
  63. RAYLIB_LIB_NAME      ?= raylib
  64.  
  65. # Define resource file for DLL properties
  66. RAYLIB_RES_FILE      ?= ./raylib.dll.rc.data
  67.  
  68. # Define raylib platform
  69. # Options:  PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
  70. PLATFORM             ?= PLATFORM_DESKTOP
  71.  
  72. # Include raylib modules on compilation
  73. # NOTE: Some programs like tools could not require those modules
  74. RAYLIB_MODULE_AUDIO  ?= TRUE
  75. RAYLIB_MODULE_MODELS ?= TRUE
  76. RAYLIB_MODULE_RAYGUI ?= FALSE
  77. RAYLIB_MODULE_PHYSAC ?= FALSE
  78.  
  79. RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/extras
  80. RAYLIB_MODULE_PHYSAC_PATH ?= $(RAYLIB_SRC_PATH)/extras
  81.  
  82. # Use external GLFW library instead of rglfw module
  83. USE_EXTERNAL_GLFW    ?= FALSE
  84.  
  85. # Use Wayland display server protocol on Linux desktop
  86. # by default it uses X11 windowing system
  87. USE_WAYLAND_DISPLAY  ?= FALSE
  88.  
  89. # Use cross-compiler for PLATFORM_RPI
  90. ifeq ($(PLATFORM),PLATFORM_RPI)
  91.     USE_RPI_CROSS_COMPILER ?= FALSE
  92.     ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
  93.         RPI_TOOLCHAIN ?= C:/SysGCC/Raspberry
  94.         RPI_TOOLCHAIN_SYSROOT ?= $(RPI_TOOLCHAIN)/arm-linux-gnueabihf/sysroot
  95.     endif
  96. endif
  97.  
  98. # Determine if the file has root access (only for installing raylib)
  99. # "whoami" prints the name of the user that calls him (so, if it is the root
  100. # user, "whoami" prints "root").
  101. ROOT = $(shell whoami)
  102.  
  103. # By default we suppose we are working on Windows
  104. HOST_PLATFORM_OS ?= WINDOWS
  105.  
  106. # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
  107. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  108.     # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
  109.     # ifeq ($(UNAME),Msys) -> Windows
  110.     ifeq ($(OS),Windows_NT)
  111.         PLATFORM_OS = WINDOWS
  112.     else
  113.         UNAMEOS = $(shell uname)
  114.         ifeq ($(UNAMEOS),Linux)
  115.             PLATFORM_OS = LINUX
  116.         endif
  117.         ifeq ($(UNAMEOS),FreeBSD)
  118.             PLATFORM_OS = BSD
  119.         endif
  120.         ifeq ($(UNAMEOS),OpenBSD)
  121.             PLATFORM_OS = BSD
  122.         endif
  123.         ifeq ($(UNAMEOS),NetBSD)
  124.             PLATFORM_OS = BSD
  125.         endif
  126.         ifeq ($(UNAMEOS),DragonFly)
  127.             PLATFORM_OS = BSD
  128.         endif
  129.         ifeq ($(UNAMEOS),Darwin)
  130.             PLATFORM_OS = OSX
  131.         endif
  132.     endif
  133. endif
  134. ifeq ($(PLATFORM),PLATFORM_RPI)
  135.     UNAMEOS = $(shell uname)
  136.     ifeq ($(UNAMEOS),Linux)
  137.         PLATFORM_OS = LINUX
  138.     endif
  139. endif
  140. ifeq ($(PLATFORM),PLATFORM_DRM)
  141.     UNAMEOS = $(shell uname)
  142.     ifeq ($(UNAMEOS),Linux)
  143.         PLATFORM_OS = LINUX
  144.     endif
  145. endif
  146.  
  147. # RAYLIB_SRC_PATH adjustment for different platforms.
  148. # If using GNU make, we can get the full path to the top of the tree. Windows? BSD?
  149. # Required for ldconfig or other tools that do not perform path expansion.
  150. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  151.     ifeq ($(PLATFORM_OS),LINUX)
  152.         RAYLIB_PREFIX  ?= ..
  153.         RAYLIB_SRC_PATH = $(realpath $(RAYLIB_PREFIX))
  154.     endif
  155. endif
  156.  
  157. ifeq ($(PLATFORM),PLATFORM_WEB)
  158.     # Emscripten required variables
  159.     EMSDK_PATH         ?= C:/emsdk
  160.     EMSCRIPTEN_PATH    ?= $(EMSDK_PATH)/upstream/emscripten
  161.     CLANG_PATH          = $(EMSDK_PATH)/upstream/bin
  162.     PYTHON_PATH         = $(EMSDK_PATH)/python/3.9.2-1_64bit
  163.     NODE_PATH           = $(EMSDK_PATH)/node/14.15.5_64bit/bin
  164.     export PATH         = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH)
  165. endif
  166.  
  167. ifeq ($(PLATFORM),PLATFORM_ANDROID)
  168.     # Android architecture
  169.     # Starting at 2019 using arm64 is mandatory for published apps,
  170.     # Starting on August 2020, minimum required target API is Android 10 (API level 29)
  171.     ANDROID_ARCH ?= arm64
  172.     ANDROID_API_VERSION ?= 29
  173.  
  174.     # Android required path variables
  175.     # NOTE: Starting with Android NDK r21, no more toolchain generation is required, NDK is the toolchain on itself
  176.     ifeq ($(OS),Windows_NT)
  177.         ANDROID_NDK ?= C:/android-ndk
  178.         ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64
  179.     else
  180.         ANDROID_NDK ?= /usr/lib/android/ndk
  181.         ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64
  182.     endif
  183.  
  184.     # NOTE: Sysroot can also be reference from $(ANDROID_NDK)/sysroot
  185.     ANDROID_SYSROOT ?= $(ANDROID_TOOLCHAIN)/sysroot
  186.  
  187.     ifeq ($(ANDROID_ARCH),arm)
  188.         ANDROID_COMPILER_ARCH = armv7a
  189.     endif
  190.     ifeq ($(ANDROID_ARCH),arm64)
  191.         ANDROID_COMPILER_ARCH = aarch64
  192.     endif
  193.     ifeq ($(ANDROID_ARCH),x86)
  194.         ANDROID_COMPILER_ARCH = i686
  195.     endif
  196.     ifeq ($(ANDROID_ARCH),x86_64)
  197.         ANDROID_COMPILER_ARCH = x86_64
  198.     endif
  199.  
  200. endif
  201.  
  202. # Define raylib graphics api depending on selected platform
  203. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  204.     # By default use OpenGL 3.3 on desktop platforms
  205.     GRAPHICS ?= GRAPHICS_API_OPENGL_33
  206.     #GRAPHICS = GRAPHICS_API_OPENGL_11  # Uncomment to use OpenGL 1.1
  207.     #GRAPHICS = GRAPHICS_API_OPENGL_21  # Uncomment to use OpenGL 2.1
  208. endif
  209. ifeq ($(PLATFORM),PLATFORM_RPI)
  210.     # On RPI OpenGL ES 2.0 must be used
  211.     GRAPHICS = GRAPHICS_API_OPENGL_ES2
  212. endif
  213. ifeq ($(PLATFORM),PLATFORM_DRM)
  214.     # On DRM OpenGL ES 2.0 must be used
  215.     GRAPHICS = GRAPHICS_API_OPENGL_ES2
  216. endif
  217. ifeq ($(PLATFORM),PLATFORM_WEB)
  218.     # On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0
  219.     GRAPHICS = GRAPHICS_API_OPENGL_ES2
  220. endif
  221. ifeq ($(PLATFORM),PLATFORM_ANDROID)
  222.     # By default use OpenGL ES 2.0 on Android
  223.     GRAPHICS = GRAPHICS_API_OPENGL_ES2
  224. endif
  225.  
  226. # Define default C compiler and archiver to pack library
  227. CC = gcc
  228. AR = ar
  229.  
  230. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  231.     ifeq ($(PLATFORM_OS),OSX)
  232.         # OSX default compiler
  233.         CC = clang
  234.         GLFW_OSX = -x objective-c
  235.     endif
  236.     ifeq ($(PLATFORM_OS),BSD)
  237.         # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
  238.         CC = clang
  239.     endif
  240. endif
  241. ifeq ($(PLATFORM),PLATFORM_RPI)
  242.     ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
  243.         # Define RPI cross-compiler
  244.         #CC = armv6j-hardfloat-linux-gnueabi-gcc
  245.         CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
  246.         AR = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-ar
  247.     endif
  248. endif
  249. ifeq ($(PLATFORM),PLATFORM_WEB)
  250.     # HTML5 emscripten compiler
  251.     CC = emcc
  252.     AR = emar
  253. endif
  254. ifeq ($(PLATFORM),PLATFORM_ANDROID)
  255.     # Android toolchain (must be provided for desired architecture and compiler)
  256.     ifeq ($(ANDROID_ARCH),arm)
  257.         CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-androideabi$(ANDROID_API_VERSION)-clang
  258.     endif
  259.     ifeq ($(ANDROID_ARCH),arm64)
  260.         CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang
  261.     endif
  262.     # It seems from Android NDK r22 onwards we need to use llvm-ar
  263.     AR = $(ANDROID_TOOLCHAIN)/bin/llvm-ar
  264. endif
  265.  
  266. # Define compiler flags:
  267. #  -O1                      defines optimization level
  268. #  -g                       include debug information on compilation
  269. #  -s                       strip unnecessary data from build
  270. #  -Wall                    turns on most, but not all, compiler warnings
  271. #  -std=c99                 defines C language mode (standard C from 1999 revision)
  272. #  -std=gnu99               defines C language mode (GNU C from 1999 revision)
  273. #  -Wno-missing-braces      ignore invalid warning (GCC bug 53119)
  274. #  -D_DEFAULT_SOURCE        use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
  275. #  -Werror=pointer-arith    catch unportable code that does direct arithmetic on void pointers
  276. #  -fno-strict-aliasing     jar_xm.h does shady stuff (breaks strict aliasing)
  277. CFLAGS += -Wall -D_DEFAULT_SOURCE -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing
  278.  
  279. ifeq ($(PLATFORM), PLATFORM_WEB)
  280.     CFLAGS += -std=gnu99
  281. else
  282.     CFLAGS += -std=c99
  283. endif
  284.  
  285. ifeq ($(PLATFORM_OS), LINUX)
  286.     CFLAGS += -fPIC
  287. endif
  288.  
  289. ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
  290.     CFLAGS += -g
  291. endif
  292.  
  293. ifeq ($(RAYLIB_BUILD_MODE),RELEASE)
  294.     ifeq ($(PLATFORM),PLATFORM_WEB)
  295.         CFLAGS += -Os
  296.     endif
  297.     ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  298.         CFLAGS += -s -O1
  299.     endif
  300.     ifeq ($(PLATFORM),PLATFORM_ANDROID)
  301.         CFLAGS += -O2
  302.     endif
  303. endif
  304.  
  305. # Additional flags for compiler (if desired)
  306. #  -Wextra                  enables some extra warning flags that are not enabled by -Wall
  307. #  -Wmissing-prototypes     warn if a global function is defined without a previous prototype declaration
  308. #  -Wstrict-prototypes      warn if a function is declared or defined without specifying the argument types
  309. #  -Werror=implicit-function-declaration   catch function calls without prior declaration
  310. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  311.     CFLAGS += -Werror=implicit-function-declaration
  312. endif
  313. ifeq ($(PLATFORM),PLATFORM_WEB)
  314.     # -Os                        # size optimization
  315.     # -O2                        # optimization level 2, if used, also set --memory-init-file 0
  316.     # -s USE_GLFW=3              # Use glfw3 library (context/input management) -> Only for linker!
  317.     # -s ALLOW_MEMORY_GROWTH=1   # to allow memory resizing -> WARNING: Audio buffers could FAIL!
  318.     # -s TOTAL_MEMORY=16777216   # to specify heap memory size (default = 16MB)
  319.     # -s USE_PTHREADS=1          # multithreading support
  320.     # -s FORCE_FILESYSTEM=1      # force filesystem to load/save files data
  321.     # -s ASSERTIONS=1            # enable runtime checks for common memory allocation errors (-O1 and above turn it off)
  322.     # --profiling                # include information for code profiling
  323.     # --memory-init-file 0       # to avoid an external memory initialization code file (.mem)
  324.     # --preload-file resources   # specify a resources folder for data compilation
  325.     ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
  326.         CFLAGS += -s ASSERTIONS=1 --profiling
  327.     endif
  328. endif
  329. ifeq ($(PLATFORM),PLATFORM_ANDROID)
  330.     # Compiler flags for arquitecture
  331.     ifeq ($(ANDROID_ARCH),arm)
  332.         CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
  333.     endif
  334.     ifeq ($(ANDROID_ARCH),arm64)
  335.         CFLAGS += -target aarch64 -mfix-cortex-a53-835769
  336.     endif
  337.     ifeq ($(ANDROID_ARCH),x86)
  338.         CFLAGS += -march=i686
  339.     endif
  340.     ifeq ($(ANDROID_ARCH),x86_64)
  341.         CFLAGS += -march=x86-64
  342.     endif
  343.     # Compilation functions attributes options
  344.     CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIE -fPIC
  345.     # Compiler options for the linker
  346.     # -Werror=format-security
  347.     CFLAGS += -Wa,--noexecstack -Wformat -no-canonical-prefixes
  348.     # Preprocessor macro definitions
  349.     CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) -DMAL_NO_OSS
  350. endif
  351.  
  352. # Define required compilation flags for raylib SHARED lib
  353. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  354.     # make sure code is compiled as position independent
  355.     # BE CAREFUL: It seems that for gcc -fpic is not the same as -fPIC
  356.     # MinGW32 just doesn't need -fPIC, it shows warnings
  357.     CFLAGS += -fPIC -DBUILD_LIBTYPE_SHARED
  358. endif
  359. ifeq ($(PLATFORM),PLATFORM_DRM)
  360.     # without EGL_NO_X11 eglplatform.h tears Xlib.h in which tears X.h in
  361.     # which contains a conflicting type Font
  362.     CFLAGS += -DEGL_NO_X11
  363. endif
  364.  
  365. # Use Wayland display on Linux desktop
  366. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  367.     ifeq ($(PLATFORM_OS), LINUX)
  368.         ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
  369.             CFLAGS += -D_GLFW_WAYLAND
  370.         else
  371.             LDLIBS = -lX11
  372.         endif
  373.     endif
  374. endif
  375.  
  376. # Define include paths for required headers
  377. # NOTE: Several external required libraries (stb and others)
  378. INCLUDE_PATHS = -I. -Iexternal/glfw/include -Iexternal/glfw/deps/mingw
  379.  
  380. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  381.     ifeq ($(PLATFORM_OS),BSD)
  382.         INCLUDE_PATHS += -I/usr/local/include
  383.         LDFLAGS += -L. -Lsrc -L/usr/local/lib -L$(RAYLIB_RELEASE_PATH)
  384.     endif
  385.     ifeq ($(USE_EXTERNAL_GLFW),TRUE)
  386.         # Check the version name. If GLFW3 was built manually, it may have produced
  387.         # a static library known as libglfw3.a. In that case, the name should be -lglfw3
  388.         LDFLAGS += -lglfw
  389.     endif
  390. endif
  391.  
  392. # Define additional directories containing required header files
  393. ifeq ($(PLATFORM),PLATFORM_RPI)
  394.     # RPI required libraries
  395.     INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include
  396.     INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vmcs_host/linux
  397.     INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vcos/pthreads
  398. endif
  399. ifeq ($(PLATFORM),PLATFORM_DRM)
  400.     # DRM required libraries
  401.     INCLUDE_PATHS += -I/usr/include/libdrm
  402. endif
  403. ifeq ($(PLATFORM),PLATFORM_ANDROID)
  404.     NATIVE_APP_GLUE = $(ANDROID_NDK)/sources/android/native_app_glue
  405.     # Include android_native_app_glue.h
  406.     INCLUDE_PATHS += -I$(NATIVE_APP_GLUE)
  407.  
  408.     # Android required libraries
  409.     INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include
  410.     ifeq ($(ANDROID_ARCH),arm)
  411.         INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/arm-linux-androideabi
  412.     endif
  413.     ifeq ($(ANDROID_ARCH),arm64)
  414.         INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/aarch64-linux-android
  415.     endif
  416.     ifeq ($(ANDROID_ARCH),x86)
  417.         INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/i686-linux-android
  418.     endif
  419.     ifeq ($(ANDROID_ARCH),x86_64)
  420.         INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/x86_64-linux-android
  421.     endif
  422. endif
  423.  
  424. # Define linker options
  425. ifeq ($(PLATFORM),PLATFORM_ANDROID)
  426.     LDFLAGS += -Wl,-soname,libraylib.$(API_VERSION).so -Wl,--exclude-libs,libatomic.a
  427.     LDFLAGS += -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
  428.     # Force linking of library module to define symbol
  429.     LDFLAGS += -u ANativeActivity_onCreate
  430.     # Library paths containing required libs
  431.     LDFLAGS += -L. -Lsrc -L$(RAYLIB_RELEASE_PATH)
  432.     # Avoid unresolved symbol pointing to external main()
  433.     LDFLAGS += -Wl,-undefined,dynamic_lookup
  434.  
  435.     LDLIBS += -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lc -lm
  436. endif
  437.  
  438. # Define all object files required with a wildcard
  439. # The wildcard takes all files that finish with ".c",
  440. # and replaces extentions with ".o", that are the object files
  441. # NOTE: Some objects depend on the PLATFORM to be added or not!
  442. # OBJS = $(patsubst %.c, %.o, $(wildcard *.c))
  443.  
  444. # Define object required on compilation
  445. OBJS = rcore.o \
  446.        rshapes.o \
  447.        rtextures.o \
  448.        rtext.o \
  449.        utils.o
  450.  
  451. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  452.     ifeq ($(USE_EXTERNAL_GLFW),FALSE)
  453.         OBJS += rglfw.o
  454.     endif
  455. endif
  456. ifeq ($(RAYLIB_MODULE_MODELS),TRUE)
  457.     OBJS += rmodels.o
  458. endif
  459. ifeq ($(RAYLIB_MODULE_AUDIO),TRUE)
  460.     OBJS += raudio.o
  461. endif
  462. ifeq ($(RAYLIB_MODULE_RAYGUI),TRUE)
  463.     OBJS += raygui.o
  464. endif
  465. ifeq ($(RAYLIB_MODULE_PHYSAC),TRUE)
  466.     OBJS += physac.o
  467. endif
  468.  
  469. ifeq ($(PLATFORM),PLATFORM_ANDROID)
  470.     OBJS += android_native_app_glue.o
  471. endif
  472.  
  473. # Default target entry
  474. all: raylib
  475.  
  476. # Compile raylib library
  477. # NOTE: Release directory is created if not exist
  478. raylib: $(OBJS)
  479. ifeq ($(PLATFORM),PLATFORM_WEB)
  480.     # Compile raylib libray for web
  481.     #$(CC) $(OBJS) -r -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc
  482.     $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS)
  483.     @echo "raylib library generated (lib$(RAYLIB_LIB_NAME).a)!"
  484. else
  485.     ifeq ($(RAYLIB_LIBTYPE),SHARED)
  486.         ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  487.             ifeq ($(PLATFORM_OS),WINDOWS)
  488.                 # NOTE: Linking with provided resource file
  489.                 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/$(RAYLIB_LIB_NAME).dll $(OBJS) $(RAYLIB_RES_FILE) $(LDFLAGS) -static-libgcc -lopengl32 -lgdi32 -lwinmm -Wl,--out-implib,$(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME)dll.a
  490.                 @echo "raylib dynamic library ($(RAYLIB_LIB_NAME).dll) and import library (lib$(RAYLIB_LIB_NAME)dll.a) generated!"
  491.             endif
  492.             ifeq ($(PLATFORM_OS),LINUX)
  493.                 # Compile raylib shared library version $(RAYLIB_VERSION).
  494.                 # WARNING: you should type "make clean" before doing this target
  495.                 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) -lGL -lc -lm -lpthread -ldl -lrt $(LDLIBS)
  496.                 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!"
  497.                 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  498.                 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
  499.             endif
  500.             ifeq ($(PLATFORM_OS),OSX)
  501.                 $(CC) -dynamiclib -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib $(OBJS) $(LDFLAGS) -compatibility_version $(RAYLIB_API_VERSION) -current_version $(RAYLIB_VERSION) -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
  502.                 install_name_tool -id "@rpath/lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib" $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib
  503.                 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib)!"
  504.                 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib
  505.                 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).dylib
  506.             endif
  507.             ifeq ($(PLATFORM_OS),BSD)
  508.                 # WARNING: you should type "gmake clean" before doing this target
  509.                 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so $(OBJS) $(LDFLAGS) -Wl,-soname,lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so -lGL -lpthread
  510.                 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so)!"
  511.                 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so
  512.                 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).so
  513.             endif
  514.         endif
  515.         ifeq ($(PLATFORM),PLATFORM_RPI)
  516.                 # Compile raylib shared library version $(RAYLIB_VERSION).
  517.                 # WARNING: you should type "make clean" before doing this target
  518.                 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) -L/opt/vc/lib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
  519.                 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!"
  520.                 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  521.                 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
  522.         endif
  523.         ifeq ($(PLATFORM),PLATFORM_DRM)
  524.                 # Compile raylib shared library version $(RAYLIB_VERSION).
  525.                 # WARNING: you should type "make clean" before doing this target
  526.                 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) -lGLESv2 -lEGL -ldrm -lgbm -lpthread -lrt -lm -ldl
  527.                 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!"
  528.                 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  529.                 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
  530.         endif
  531.         ifeq ($(PLATFORM),PLATFORM_ANDROID)
  532.             $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so $(OBJS) $(LDFLAGS) $(LDLIBS)
  533.             @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so)!"
  534.             # WARNING: symbolic links creation on Windows should be done using mklink command, no ln available
  535.             ifeq ($(HOST_PLATFORM_OS),LINUX)
  536.                 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so
  537.                 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).so
  538.             endif
  539.         endif
  540.     else
  541.         # Compile raylib static library version $(RAYLIB_VERSION)
  542.         # WARNING: You should type "make clean" before doing this target.
  543.         $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS)
  544.         @echo "raylib static library generated (lib$(RAYLIB_LIB_NAME).a) in $(RAYLIB_RELEASE_PATH)!"
  545.     endif
  546. endif
  547.  
  548. # Compile all modules with their prerequisites
  549.  
  550. # Compile core module
  551. rcore.o : rcore.c raylib.h rlgl.h utils.h raymath.h rcamera.h rgestures.h
  552.     $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
  553.  
  554. # Compile rglfw module
  555. rglfw.o : rglfw.c
  556.     $(CC) $(GLFW_OSX) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
  557.  
  558. # Compile shapes module
  559. rshapes.o : rshapes.c raylib.h rlgl.h
  560.     $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
  561.  
  562. # Compile textures module
  563. rtextures.o : rtextures.c raylib.h rlgl.h utils.h
  564.     $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
  565.  
  566. # Compile text module
  567. rtext.o : rtext.c raylib.h utils.h
  568.     $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
  569.  
  570. # Compile utils module
  571. utils.o : utils.c utils.h
  572.     $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
  573.  
  574. # Compile models module
  575. rmodels.o : rmodels.c raylib.h rlgl.h raymath.h
  576.     $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
  577.  
  578. # Compile audio module
  579. raudio.o : raudio.c raylib.h
  580.     $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
  581.  
  582. # Compile raygui module
  583. # NOTE: raygui header should be distributed with raylib.h
  584. raygui.o : raygui.c
  585.     $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -DRAYGUI_IMPLEMENTATION
  586. raygui.c:
  587.     echo #define RAYGUI_IMPLEMENTATION > raygui.c
  588.     echo #include "$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h" >> raygui.c
  589.  
  590. # Compile physac module
  591. # NOTE: physac header should be distributed with raylib.h
  592. physac.o : physac.c
  593.     $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -DPHYSAC_IMPLEMENTATION
  594. physac.c:
  595.     @echo #define PHYSAC_IMPLEMENTATION > physac.c
  596.     @echo #include "$(RAYLIB_MODULE_PHYSAC_PATH)/physac.h" >> physac.c
  597.  
  598. # Compile android_native_app_glue module
  599. android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
  600.     $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  601.  
  602.  
  603. # Install generated and needed files to desired directories.
  604. # On GNU/Linux and BSDs, there are some standard directories that contain extra
  605. # libraries and header files. These directories (often /usr/local/lib and
  606. # /usr/local/include) are for libraries that are installed manually
  607. # (without a package manager). We'll use /usr/local/lib/raysan5 and /usr/local/include/raysan5
  608. # for our -L and -I specification to simplify management of the raylib source package.
  609. # Customize these locations if you like but don't forget to pass them to make
  610. # for compilation and enable runtime linking with -rpath, LD_LIBRARY_PATH, or ldconfig.
  611. # HINT: Add -L$(RAYLIB_INSTALL_PATH) -I$(RAYLIB_H_INSTALL_PATH) to your own makefiles.
  612. # See below and ../examples/Makefile for more information.
  613. # TODO: Add other platforms. Remove sudo requirement, i.e. add USER mode.
  614.  
  615. # RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths.
  616. DESTDIR ?= /usr/local
  617. RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib
  618. # RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files.
  619. RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include
  620.  
  621. install :
  622. ifeq ($(ROOT),root)
  623.     ifeq ($(PLATFORM_OS),LINUX)
  624.         # Attention! You are root, writing files to $(RAYLIB_INSTALL_PATH)
  625.         # and $(RAYLIB_H_INSTALL_PATH). Consult this Makefile for more information.
  626.         # Prepare the environment as needed.
  627.         mkdir --parents --verbose $(RAYLIB_INSTALL_PATH)
  628.         mkdir --parents --verbose $(RAYLIB_H_INSTALL_PATH)
  629.         ifeq ($(RAYLIB_LIBTYPE),SHARED)
  630.             # Installing raylib to $(RAYLIB_INSTALL_PATH).
  631.             cp --update --verbose $(RAYLIB_RELEASE_PATH)/libraylib.so.$(RAYLIB_VERSION) $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)
  632.             cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  633.             cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
  634.             # Uncomment to update the runtime linker cache with RAYLIB_INSTALL_PATH.
  635.             # Not necessary if later embedding RPATH in your executable. See examples/Makefile.
  636.             ldconfig $(RAYLIB_INSTALL_PATH)
  637.         else
  638.             # Installing raylib to $(RAYLIB_INSTALL_PATH).
  639.             cp --update --verbose $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).a
  640.         endif
  641.         # Copying raylib development files to $(RAYLIB_H_INSTALL_PATH).
  642.         cp --update raylib.h $(RAYLIB_H_INSTALL_PATH)/raylib.h
  643.         cp --update raymath.h $(RAYLIB_H_INSTALL_PATH)/raymath.h
  644.         cp --update rlgl.h $(RAYLIB_H_INSTALL_PATH)/rlgl.h
  645.         cp --update extras/physac.h $(RAYLIB_H_INSTALL_PATH)/physac.h
  646.         @echo "raylib development files installed/updated!"
  647.     else
  648.         @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
  649.     endif
  650. else
  651.     @echo "Error: Root permissions needed for installation. Try sudo make install"
  652. endif
  653.  
  654. # Remove raylib dev files installed on the system
  655. # NOTE: see 'install' target.
  656. uninstall :
  657. ifeq ($(ROOT),root)
  658.     # WARNING: You are root, about to delete items from $(RAYLIB_INSTALL_PATH).
  659.     # and $(RAYLIB_H_INSTALL_PATH). Please confirm each item.
  660.     ifeq ($(PLATFORM_OS),LINUX)
  661.         ifeq ($(RAYLIB_LIBTYPE),SHARED)
  662.         rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so
  663.         rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_API_VERSION)
  664.         rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_VERSION)
  665.         # Uncomment to clean up the runtime linker cache. See install target.
  666.         ldconfig
  667.         else
  668.         rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.a
  669.         endif
  670.         rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raylib.h
  671.         rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raymath.h
  672.         rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rlgl.h
  673.         rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/physac.h
  674.         @echo "raylib development files removed!"
  675.         else
  676.         @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
  677.     endif
  678. else
  679.     @echo "Error: Root permissions needed for uninstallation. Try sudo make uninstall"
  680. endif
  681.  
  682. # Clean everything
  683. clean:
  684. ifeq ($(PLATFORM_OS),WINDOWS)
  685.     del *.o /s
  686.     cd $(RAYLIB_RELEASE_PATH)
  687.     del lib$(RAYLIB_LIB_NAME).a /s
  688.     del lib$(RAYLIB_LIB_NAME)dll.a /s
  689.     del $(RAYLIB_LIB_NAME).dll /s
  690. else
  691.     rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so*
  692. endif
  693. ifeq ($(PLATFORM),PLATFORM_ANDROID)
  694.     rm -rf $(ANDROID_TOOLCHAIN) $(NATIVE_APP_GLUE)/android_native_app_glue.o
  695. endif
  696.     @echo "removed all generated files!"
  697.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement