Browse Source

makefiles reorganization

Edited to better accomodate to multiple platforms
raysan5 10 years ago
parent
commit
7ea8326b52
2 changed files with 81 additions and 59 deletions
  1. 52 45
      examples/makefile
  2. 29 14
      src/makefile

+ 52 - 45
examples/makefile

@@ -26,6 +26,23 @@
 # WARNING: To compile examples to HTML5, they must be redesigned to use emscripten.h and emscripten_set_main_loop()
 PLATFORM ?= PLATFORM_DESKTOP
 
+# determine SUBPLATFORM 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)
+        SUBPLATFORM=WINDOWS
+    else
+        UNAMEOS = $(shell uname -s) 
+        ifeq ($(UNAMEOS),Linux)
+            SUBPLATFORM=LINUX
+        else
+        ifeq ($(UNAMEOS),Darwin)
+            SUBPLATFORM=OSX
+        endif
+        endif
+    endif
+endif
+
 # define compiler: gcc for C program, define as g++ for C++
 ifeq ($(PLATFORM),PLATFORM_WEB)
     # define emscripten compiler
@@ -44,14 +61,14 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
 else
     CFLAGS = -O2 -Wall -std=c99
 endif
-#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
-
 ifeq ($(PLATFORM),PLATFORM_WEB)
     CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 -s ASSERTIONS=1 --preload-file resources
     #-s ALLOW_MEMORY_GROWTH=1   # to allow memory resizing
     #-s TOTAL_MEMORY=16777216   # to specify heap memory size (default = 16MB)
 endif
 
+#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
+
 # define any directories containing required header files
 ifeq ($(PLATFORM),PLATFORM_RPI)
     INCLUDES = -I. -I../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
@@ -63,45 +80,37 @@ endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
     LFLAGS = -L. -L../src -L/opt/vc/lib
 else
-    LFLAGS = -L. -L../src
-endif
-
-# define library paths containing required libs
-ifeq ($(PLATFORM),PLATFORM_DESKTOP_OSX)
-	LFLAGS = -L. -L../src -L../external/glfw3/lib/ -I../external/openal_soft/lib/
-else
-	LFLAGS = -L. -L../src
+    LFLAGS = -L. -L../src -L../external/glfw3/lib/ -I../external/openal_soft/lib/
 endif
 
-
 # define any libraries to link into executable
 # if you want to link libraries (libname.so or libname.a), use the -lname
+ifeq ($(PLATFORM),PLATFORM_DESKTOP)
+    ifeq ($(SUBPLATFORM),LINUX)
+        # libraries for Debian GNU/Linux desktop compiling
+        # requires the following packages:
+        # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
+        LIBS = -lraylib -lglfw -lGLEW -lGL -lopenal
+    endif
+    ifeq ($(SUBPLATFORM),OSX)
+    	# libraries for OS X 10.9 desktop compiling
+	# requires the following packages:
+	# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
+	LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa
+
+    else
+        # libraries for Windows desktop compiling
+        # NOTE: GLFW3 and OpenAL Soft libraries should be installed
+        LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32    
+    endif
+endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
     # libraries for Raspberry Pi compiling
     # NOTE: OpenAL Soft library should be installed (libopenal1 package)
     LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
-else
-ifeq ($(PLATFORM),PLATFORM_DESKTOP_LINUX)
-    # libraries for Debian GNU/Linux desktop compiling
-	# requires the following packages:
-	# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
-    LIBS = -lraylib -lglfw -lGLEW -lGL -lopenal
-else
-ifeq ($(PLATFORM),PLATFORM_DESKTOP_OSX)
-    # libraries for OS X 10.9 desktop compiling
-	# requires the following packages:
-	# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
-    LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa
-else
+endif
 ifeq ($(PLATFORM),PLATFORM_WEB)
     LIBS = ../src/libraylib.bc
-else
-    # libraries for Windows desktop compiling
-    # NOTE: GLFW3 and OpenAL Soft libraries should be installed
-    LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32
-endif
-endif
-endif
 endif
 
 # define additional parameters and flags for windows
@@ -280,24 +289,22 @@ audio_music_stream: audio_music_stream.c
 
 # clean everything
 clean:
+ifeq ($(PLATFORM),PLATFORM_DESKTOP)
+    ifeq ($(SUBPLATFORM),LINUX)
+		find . -type f -executable -delete
+		rm -f *.o
+    endif
+    ifeq ($(SUBPLATFORM),OSX)
+		rm -f *.o
+    else
+		del *.o *.exe
+    endif
+endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
 	rm -f *.o
-#	find . -executable -delete
-else
-ifeq ($(PLATFORM),PLATFORM_DESKTOP_LINUX)
-	find . -type f -executable -delete
-	rm -f *.o
-else
-ifeq ($(PLATFORM),PLATFORM_DESKTOP_OSX)
-	rm -f *.o
-else
+endif
 ifeq ($(PLATFORM),PLATFORM_WEB)
 	del *.o *.html *.js
-else
-	del *.o *.exe
-endif
-endif
-endif
 endif
 	@echo Cleaning done
 

+ 29 - 14
src/makefile

@@ -25,6 +25,23 @@
 # possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
 PLATFORM ?= PLATFORM_DESKTOP
 
+# determine SUBPLATFORM 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)
+        SUBPLATFORM=WINDOWS
+    else
+        UNAMEOS = $(shell uname -s) 
+        ifeq ($(UNAMEOS),Linux)
+            SUBPLATFORM=LINUX
+        else
+        ifeq ($(UNAMEOS),Darwin)
+            SUBPLATFORM=OSX
+        endif
+        endif
+    endif
+endif
+
 # define raylib graphics api depending on selected platform
 ifeq ($(PLATFORM),PLATFORM_RPI)
     # define raylib graphics api to use (on RPI, OpenGL ES 2.0 must be used)
@@ -34,7 +51,6 @@ else
     GRAPHICS ?= GRAPHICS_API_OPENGL_11
     #GRAPHICS = GRAPHICS_API_OPENGL_33  # Uncomment to use OpenGL 3.3
 endif
-
 ifeq ($(PLATFORM),PLATFORM_WEB)
     GRAPHICS = GRAPHICS_API_OPENGL_ES2
 endif
@@ -127,23 +143,22 @@ stb_vorbis.o: stb_vorbis.c
 
 # clean everything
 clean:
+ifeq ($(PLATFORM),PLATFORM_DESKTOP)
+    ifeq ($(SUBPLATFORM),LINUX)
+		find . -type f -executable -delete
+		rm -f *.o libraylib.a
+    endif
+    ifeq ($(SUBPLATFORM),OSX)
+		rm -f *.o libraylib.a
+    else
+		del *.o libraylib.a
+    endif
+endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
 	rm -f *.o libraylib.a
-else
-ifeq ($(PLATFORM),PLATFORM_DESKTOP_LINUX)
-	find . -type f -executable -delete
-	rm -f *.o libraylib.a
-else
-ifeq ($(PLATFORM),PLATFORM_DESKTOP_OSX)
-	rm -f *.o libraylib.a
-else
+endif
 ifeq ($(PLATFORM),PLATFORM_WEB)
 	del *.o libraylib.bc
-else
-	del *.o libraylib.a
-endif
-endif
-endif
 endif
 	@echo Cleaning done