Improve Makefile organization

This commit is contained in:
Ray 2022-01-11 11:20:04 +01:00
parent aaf0175d07
commit cabb5518e5
2 changed files with 63 additions and 51 deletions

View file

@ -22,18 +22,18 @@
#************************************************************************************************** #**************************************************************************************************
.PHONY: all clean .PHONY: all clean
# Define required environment variables
#------------------------------------------------------------------------------------------------
# Define required raylib variables # Define required raylib variables
PROJECT_NAME ?= raylib_examples PROJECT_NAME ?= raylib_examples
RAYLIB_VERSION ?= 4.0.0 RAYLIB_VERSION ?= 4.0.0
RAYLIB_PATH ?= .. RAYLIB_PATH ?= ..
# Define default options
# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB # One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
PLATFORM ?= PLATFORM_DESKTOP PLATFORM ?= PLATFORM_DESKTOP
# Locations of your newly installed library and associated headers. See ../src/Makefile # Locations of your newly installed library and associated headers.
# On Linux, if you have installed raylib but cannot compile the examples, check that # 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. # 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 system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED.
@ -158,8 +158,8 @@ RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. # Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing.
EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH)
# Define default C compiler: gcc # Define default C compiler: CC
# NOTE: define g++ compiler if using C++ #------------------------------------------------------------------------------------------------
CC = gcc CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@ -186,7 +186,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
CC = emcc CC = emcc
endif endif
# Define default make program # Define default make program: MAKE
#------------------------------------------------------------------------------------------------
MAKE ?= make MAKE ?= make
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@ -201,7 +202,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
MAKE = mingw32-make MAKE = mingw32-make
endif endif
# Define compiler flags: # Define compiler flags: CFLAGS
#------------------------------------------------------------------------------------------------
# -O1 defines optimization level # -O1 defines optimization level
# -g include debug information on compilation # -g include debug information on compilation
# -s strip unnecessary data from build # -s strip unnecessary data from build
@ -245,7 +247,8 @@ ifeq ($(PLATFORM),PLATFORM_DRM)
CFLAGS += -std=gnu99 -DEGL_NO_X11 CFLAGS += -std=gnu99 -DEGL_NO_X11
endif endif
# Define include paths for required headers # Define include paths for required headers: INCLUDE_PATHS
#------------------------------------------------------------------------------------------------
# NOTE: Some external/extras libraries could be required (stb, physac, easings...) # NOTE: Some external/extras libraries could be required (stb, physac, easings...)
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLIB_PATH)/src/extras INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLIB_PATH)/src/extras
@ -270,7 +273,8 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
endif endif
# Define library paths containing required libs. # Define library paths containing required libs: LDFLAGS
#------------------------------------------------------------------------------------------------
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@ -322,8 +326,9 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib
endif endif
# Define any libraries required on linking # Define libraries required on linking: LDLIBS
# if you want to link libraries (libname.so or libname.a), use the -lname # NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name>
#------------------------------------------------------------------------------------------------
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compilation # Libraries for Windows desktop compilation
@ -387,7 +392,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.a LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.a
endif endif
# Define all object files required # Define source code object files required
#------------------------------------------------------------------------------------------------
CORE = \ CORE = \
core/core_basic_window \ core/core_basic_window \
core/core_basic_screen_manager \ core/core_basic_screen_manager \
@ -526,6 +532,8 @@ PHYSICS = \
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST)) CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
# Define processes to execute
#------------------------------------------------------------------------------------------------
# Default target entry # Default target entry
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(PHYSICS) all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(PHYSICS)

View file

@ -15,33 +15,33 @@
# Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline. # Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline.
# Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline. # Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline.
# #
# Copyright (c) 2014-2022 Ramon Santamaria (@raysan5) # Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. # This software is provided "as-is", without any express or implied warranty. In no event
# In no event will the authors be held liable for any damages arising from # will the authors be held liable for any damages arising from the use of this software.
# the use of this software.
# #
# Permission is granted to anyone to use this software for any purpose, # Permission is granted to anyone to use this software for any purpose, including commercial
# including commercial applications, and to alter it and redistribute it # applications, and to alter it and redistribute it freely, subject to the following restrictions:
# freely, subject to the following restrictions:
# #
# 1. The origin of this software must not be misrepresented; you must not # 1. The origin of this software must not be misrepresented; you must not claim that you
# claim that you wrote the original software. If you use this software in a # wrote the original software. If you use this software in a product, an acknowledgment
# product, an acknowledgment in the product documentation would be # in the product documentation would be appreciated but is not required.
# appreciated but is not required.
# #
# 2. Altered source versions must be plainly marked as such, and must not # 2. Altered source versions must be plainly marked as such, and must not be misrepresented
# be misrepresented as being the original software. # as being the original software.
# #
# 3. This notice may not be removed or altered from any source distribution. # 3. This notice may not be removed or altered from any source distribution.
# #
#****************************************************************************** #**************************************************************************************************
# Please read the wiki to know how to compile raylib, because there are different methods. # Please read the wiki to know how to compile raylib, because there are different methods.
# https://github.com/raysan5/raylib/wiki # https://github.com/raysan5/raylib/wiki
.PHONY: all clean install uninstall .PHONY: all clean install uninstall
# Define required environment variables
#------------------------------------------------------------------------------------------------
# Define required raylib variables # Define required raylib variables
RAYLIB_VERSION = 4.0.0 RAYLIB_VERSION = 4.0.0
RAYLIB_API_VERSION = 400 RAYLIB_API_VERSION = 400
@ -220,7 +220,8 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
GRAPHICS = GRAPHICS_API_OPENGL_ES2 GRAPHICS = GRAPHICS_API_OPENGL_ES2
endif endif
# Define default C compiler and archiver to pack library # Define default C compiler and archiver to pack library: CC, AR
#------------------------------------------------------------------------------------------------
CC = gcc CC = gcc
AR = ar AR = ar
@ -266,7 +267,8 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
AR = $(ANDROID_TOOLCHAIN)/bin/llvm-ar AR = $(ANDROID_TOOLCHAIN)/bin/llvm-ar
endif endif
# Define compiler flags: # Define compiler flags: CFLAGS
#------------------------------------------------------------------------------------------------
# -O1 defines optimization level # -O1 defines optimization level
# -g include debug information on compilation # -g include debug information on compilation
# -s strip unnecessary data from build # -s strip unnecessary data from build
@ -377,7 +379,8 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
endif endif
# Define include paths for required headers # Define include paths for required headers: INCLUDE_PATHS
#------------------------------------------------------------------------------------------------
# NOTE: Several external required libraries (stb and others) # NOTE: Several external required libraries (stb and others)
INCLUDE_PATHS = -I. -Iexternal/glfw/include -Iexternal/glfw/deps/mingw INCLUDE_PATHS = -I. -Iexternal/glfw/include -Iexternal/glfw/deps/mingw
@ -418,7 +421,9 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
endif endif
endif endif
# Define linker flags (required for dynamic library generation) # Define library paths containing required libs: LDFLAGS
# NOTE: This is only required for dynamic library generation
#------------------------------------------------------------------------------------------------
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH)
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@ -452,7 +457,9 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
LDFLAGS += -Wl,-undefined,dynamic_lookup LDFLAGS += -Wl,-undefined,dynamic_lookup
endif endif
# Define linker libraries (required for dynamic library generation) # Define libraries required on linking: LDLIBS
# NOTE: This is only required for dynamic library generation
#------------------------------------------------------------------------------------------------
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
LDLIBS = -static-libgcc -lopengl32 -lgdi32 -lwinmm LDLIBS = -static-libgcc -lopengl32 -lgdi32 -lwinmm
@ -485,13 +492,8 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
LDLIBS = -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lc -lm LDLIBS = -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lc -lm
endif endif
# Define all object files required with a wildcard # Define source code object files required
# The wildcard takes all files that finish with ".c", #------------------------------------------------------------------------------------------------
# and replaces extentions with ".o", that are the object files
# NOTE: Some objects depend on the PLATFORM to be added or not!
# OBJS = $(patsubst %.c, %.o, $(wildcard *.c))
# Define object required on compilation
OBJS = rcore.o \ OBJS = rcore.o \
rshapes.o \ rshapes.o \
rtextures.o \ rtextures.o \
@ -520,6 +522,8 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
OBJS += android_native_app_glue.o OBJS += android_native_app_glue.o
endif endif
# Define processes to execute
#------------------------------------------------------------------------------------------------
# Default target entry # Default target entry
all: raylib all: raylib