diff options
| author | Ray <raysan5@gmail.com> | 2017-03-24 10:43:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-24 10:43:34 +0100 |
| commit | 3f0c29642225f4da40e29e83117a4589f95be538 (patch) | |
| tree | 3ab4d3ef3a49e0f75dac253098611d1f3e6a70b9 /src | |
| parent | 6ba5217c28dd8b2bb29ce9ebb4660b5022cfbd1a (diff) | |
| parent | ff44cb02e754a7d408e33ad7d9af11e8b561720c (diff) | |
| download | raylib-3f0c29642225f4da40e29e83117a4589f95be538.tar.gz raylib-3f0c29642225f4da40e29e83117a4589f95be538.zip | |
Merge pull request #248 from RDR8/linux-c99
linux-c99
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 36 | ||||
| -rw-r--r-- | src/core.c | 10 | ||||
| -rw-r--r-- | src/gestures.h | 4 | ||||
| -rw-r--r-- | src/physac.h | 6 |
4 files changed, 39 insertions, 17 deletions
diff --git a/src/Makefile b/src/Makefile index 4c2278f5..598a9be4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ #****************************************************************************** # # raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) -# +# # Many Thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline. # # Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) @@ -153,12 +153,34 @@ endif # define compiler flags: # -O1 defines optimization level +# -Og enable debugging # -Wall turns on most, but not all, compiler warnings # -std=c99 defines C language mode (standard C from 1999 revision) # -std=gnu99 defines C language mode (GNU C from 1999 revision) # -fgnu89-inline declaring inline functions support (GCC optimized) # -Wno-missing-braces ignore invalid warning (GCC bug 53119) -CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces +# -D_DEFAULT_SOURCE use with -std=c99 on Linux to enable timespec and drflac +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces + endif + ifeq ($(PLATFORM_OS),LINUX) + CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE + endif + ifeq ($(PLATFORM_OS),OSX) + CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces + endif +endif +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 +ifeq ($(PLATFORM),PLATFORM_RPI) + CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces +endif + +#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes # if shared library required, make sure code is compiled as position independent ifeq ($(SHARED),YES) @@ -243,7 +265,7 @@ OBJS += external/stb_vorbis.o # typing 'make' will invoke the default target entry called 'all', # in this case, the 'default' target entry is raylib -all: toolchain raylib +all: toolchain raylib # make standalone Android toolchain toolchain: @@ -266,7 +288,7 @@ else ifeq ($(SHARED),YES) ifeq ($(PLATFORM_OS),LINUX) # compile raylib to shared library version for GNU/Linux. - # WARNING: you should type "make clean" before doing this target + # WARNING: you should type "make clean" before doing this target $(CC) -shared -o $(OUTPUT_PATH)/libraylib.so $(OBJS) @echo "raylib shared library (libraylib.so) generated!" endif @@ -299,11 +321,11 @@ core.o : core.c raylib.h rlgl.h utils.h raymath.h gestures.h # compile rlgl module rlgl.o : rlgl.c rlgl.h raymath.h $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(GRAPHICS) - + # compile shapes module shapes.o : shapes.c raylib.h rlgl.h $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(SHAREDFLAG) - + # compile textures module textures.o : textures.c rlgl.h utils.h $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(GRAPHICS) -D$(SHAREDFLAG) @@ -319,7 +341,7 @@ models.o : models.c raylib.h rlgl.h raymath.h # compile audio module audio.o : audio.c raylib.h $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(SHAREDFLAG) -D$(SHAREDOPENALFLAG) - + # compile stb_vorbis library external/stb_vorbis.o: external/stb_vorbis.c external/stb_vorbis.h $(CC) -c -o $@ $< -O1 $(CFLAGS) $(INCLUDES) -D$(PLATFORM) @@ -105,7 +105,7 @@ #include <string.h> // Required for: strcmp() //#include <errno.h> // Macros for reporting and retrieving error conditions through error codes -#if defined __linux || defined(PLATFORM_WEB) +#if defined __linux__ || defined(PLATFORM_WEB) #include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX #elif defined __APPLE__ #include <unistd.h> // Required for: usleep() @@ -115,7 +115,7 @@ //#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3 #include <GLFW/glfw3.h> // GLFW3 library: Windows, OpenGL context and Input management - #ifdef __linux + #ifdef __linux__ #define GLFW_EXPOSE_NATIVE_X11 // Linux specific definitions for getting #define GLFW_EXPOSE_NATIVE_GLX // native functions like glfwGetX11Window #include <GLFW/glfw3native.h> // which are required for hiding mouse @@ -641,7 +641,7 @@ int GetScreenHeight(void) void ShowCursor() { #if defined(PLATFORM_DESKTOP) - #ifdef __linux + #ifdef __linux__ XUndefineCursor(glfwGetX11Display(), glfwGetX11Window(window)); #else glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); @@ -654,7 +654,7 @@ void ShowCursor() void HideCursor() { #if defined(PLATFORM_DESKTOP) - #ifdef __linux + #ifdef __linux__ XColor col; const char nil[] = {0}; @@ -2036,7 +2036,7 @@ static void Wait(float ms) #else #if defined _WIN32 Sleep(ms); - #elif defined __linux || defined(PLATFORM_WEB) + #elif defined __linux__ || defined(PLATFORM_WEB) struct timespec req = { 0 }; time_t sec = (int)(ms/1000.0f); ms -= (sec*1000); diff --git a/src/gestures.h b/src/gestures.h index 42ced889..c97871e5 100644 --- a/src/gestures.h +++ b/src/gestures.h @@ -147,7 +147,7 @@ float GetGesturePinchAngle(void); // Get gesture pinch ang // Functions required to query time on Windows int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount); int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency); -#elif defined(__linux) +#elif defined(__linux__) #include <sys/time.h> // Required for: timespec #include <time.h> // Required for: clock_gettime() #endif @@ -517,7 +517,7 @@ static double GetCurrentTime(void) time = (double)currentTime/clockFrequency*1000.0f; // Time in miliseconds #endif -#if defined(__linux) +#if defined(__linux__) // NOTE: Only for Linux-based systems struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); diff --git a/src/physac.h b/src/physac.h index ff56615d..1aa0adee 100644 --- a/src/physac.h +++ b/src/physac.h @@ -249,7 +249,7 @@ PHYSACDEF void ClosePhysics(void); // Functions required to query time on Windows int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount); int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency); -#elif defined(__linux) || defined(PLATFORM_WEB) +#elif defined(__linux__) || defined(PLATFORM_WEB) #include <sys/time.h> // Required for: timespec #include <time.h> // Required for: clock_gettime() #include <stdint.h> @@ -277,7 +277,7 @@ PHYSACDEF void ClosePhysics(void); static unsigned int usedMemory = 0; // Total allocated dynamic memory static bool physicsThreadEnabled = false; // Physics thread enabled state static double currentTime = 0; // Current time in milliseconds -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(__linux) || defined(PLATFORM_WEB) +#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(__linux__) || defined(PLATFORM_WEB) static double baseTime = 0; // Android and RPI platforms base time #endif static double startTime = 0; // Start time in milliseconds @@ -1906,7 +1906,7 @@ static double GetCurrentTime(void) time = (double)((double)currentTime/clockFrequency)*1000; #endif - #if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(__linux) || defined(PLATFORM_WEB) + #if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(__linux__) || defined(PLATFORM_WEB) struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); uint64_t temp = (uint64_t)ts.tv_sec*1000000000LLU + (uint64_t)ts.tv_nsec; |
