Updated Makefile to include automatic setup instructions

This commit is contained in:
Jonathan Moallem 2020-11-23 03:23:28 +11:00
parent b56420d6dc
commit cdf74e8c30

View File

@ -1,44 +1,62 @@
# Set macros # Set general macros
buildFile = ./build/app buildFile = build/app
# Check for Windows # Check for Windows
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
# Set Windows macros # Set Windows compile macros
platform = Windows platform = Windows
compiler = g++ compiler = g++
options = -pthread -lopengl32 -lgdi32 -lwinmm -mwindows options = -pthread -lopengl32 -lgdi32 -lwinmm -mwindows
# Windows-specific commands for creation and deletion
initCommand = -mkdir build # Set Windows commands
mkdirCommand = -mkdir
cleanCommand = del build\app.exe cleanCommand = del build\app.exe
else else
# Check for MacOS/Linux # Check for MacOS/Linux
UNAMEOS := $(shell uname) UNAMEOS := $(shell uname)
ifeq ($(UNAMEOS), Linux) ifeq ($(UNAMEOS), Linux)
# Set Linux macros # Set Linux compile macros
platform = Linux platform = Linux
compiler = g++ compiler = g++
options = -l GL -l m -l pthread -l dl -l rt -l X11 options = -l GL -l m -l pthread -l dl -l rt -l X11
endif endif
ifeq ($(UNAMEOS), Darwin) ifeq ($(UNAMEOS), Darwin)
# Set macOS macros # Set macOS compile macros
platform = macOS platform = macOS
compiler = clang++ compiler = clang++
options = -framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL options = -framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL
endif endif
initCommand = mkdir -p build # Set UNIX commands
mkdirCommand = mkdir -p
cleanCommand = rm $(buildFile) cleanCommand = rm $(buildFile)
endif endif
all: init compile run clean run: compile execute clean
init: all: setup compile execute clean
$(initCommand)
setup: include lib
pull:
git submodule init; git submodule update
cd vendor/raylib-cpp; git submodule init ; git submodule update
include: pull
$(mkdirCommand) include
cp vendor/raylib-cpp/vendor/raylib/src/{raylib.h,raymath.h} include
cp vendor/raylib-cpp/include/*.hpp include
lib: pull
cd vendor/raylib-cpp/vendor/raylib/src; make PLATFORM=PLATFORM_DESKTOP
$(mkdirCommand) lib/$(platform)
cp vendor/raylib-cpp/vendor/raylib/src/libraylib.a lib/macOS/libraylib.a
compile: compile:
$(compiler) -std=c++17 -I ./include/ -L ./lib/$(platform) ./src/main.cpp -o $(buildFile) -l raylib $(options) $(mkdirCommand) build
$(compiler) -std=c++17 -I include -L lib/$(platform) src/main.cpp -o $(buildFile) -l raylib $(options)
run: execute:
$(buildFile) $(buildFile)
clean: clean: