From 4d2b9dd875c7abe12daa0983dc54abd8de4eeb15 Mon Sep 17 00:00:00 2001 From: Coeuvre Date: Sat, 14 Jun 2014 09:56:49 +0800 Subject: [PATCH] Build with ENV 'SDL_MODE' --- Makefile | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 706c1b6f..eed43e4c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Rust-Empty: An Makefile to get started with Rust # https://github.com/bvssvni/rust-empty -# +# # The MIT License (MIT) # # Copyright (c) 2014 Sven Nilsen @@ -41,10 +41,28 @@ SOURCE_FILES = $(shell test -e src/ && find src -type f) COMPILER = rustc # For release: - COMPILER_FLAGS = -O --cfg mac_framework + COMPILER_FLAGS = -O # For debugging: # COMPILER_FLAGS = -g +ifeq ($(UNAME),Darwin) + # If the user wasn't explicit, see if SDL2 library exists + ifeq ("$(strip $(SDL_MODE))","") + SDL_CHECK=$(shell pkg-config --exists sdl2) + ifeq ($(SDL_CHECK),0) + SDL_MODE = dylib + else + SDL_MODE = framework + endif + endif + + ifeq ($(SDL_MODE),framework) + COMPILER_FLAGS+=--cfg mac_framework + else + COMPILER_FLAGS+=--cfg mac_dylib + endif +endif + RUSTDOC = rustdoc # Extracts target from rustc.