Automate compiler flags selection.
This commit is contained in:
parent
9875198a56
commit
e23c120c8b
3 changed files with 55 additions and 31 deletions
|
@ -40,7 +40,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
else
|
else
|
||||||
UNAMEOS:=$(shell uname)
|
UNAMEOS:=$(shell uname)
|
||||||
ifeq ($(UNAMEOS),Linux)
|
ifeq ($(UNAMEOS),Linux)
|
||||||
PLATFORM_OS=linux
|
PLATFORM_OS=LINUX
|
||||||
LIBPATH=linux
|
LIBPATH=linux
|
||||||
else
|
else
|
||||||
ifeq ($(UNAMEOS),Darwin)
|
ifeq ($(UNAMEOS),Darwin)
|
||||||
|
@ -67,14 +67,23 @@ endif
|
||||||
|
|
||||||
# define compiler flags:
|
# define compiler flags:
|
||||||
# -O2 defines optimization level
|
# -O2 defines optimization level
|
||||||
|
# -Og enable debugging
|
||||||
# -s strip unnecessary data from build
|
# -s strip unnecessary data from build
|
||||||
# -Wall turns on most, but not all, compiler warnings
|
# -Wall turns on most, but not all, compiler warnings
|
||||||
# -std=c99 use standard C from 1999 revision
|
# -std=c99 defines C language mode (standard C from 1999 revision)
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
||||||
CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline
|
# -fgnu89-inline declaring inline functions support (GCC optimized)
|
||||||
else
|
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
|
||||||
|
# -D_DEFAULT_SOURCE use with -std=c99 on Linux to enable timespec and drflac
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
|
CFLAGS = -O2 -s -Wall -std=c99
|
||||||
|
endif
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
CFLAGS = -O2 -s -Wall -std=c99 --D_DEFAULT_SOURCE
|
CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE
|
||||||
|
endif
|
||||||
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
|
CFLAGS = -O2 -s -Wall -std=c99
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
@ -82,7 +91,9 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
#-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
|
#-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
|
||||||
#-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
|
#-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
|
CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline
|
||||||
|
endif
|
||||||
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
||||||
|
|
||||||
# define raylib release directory for compiled library
|
# define raylib release directory for compiled library
|
||||||
|
@ -90,7 +101,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
RAYLIB_PATH = ../release/win32/mingw32
|
RAYLIB_PATH = ../release/win32/mingw32
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),linux)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
RAYLIB_PATH = ../release/linux
|
RAYLIB_PATH = ../release/linux
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
|
@ -112,9 +123,7 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
# add standard directories for GNU/Linux
|
# add standard directories for GNU/Linux
|
||||||
ifeq ($(PLATFORM_OS),linux)
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
INCLUDES += -I/usr/local/include/raylib/
|
|
||||||
else ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
# external libraries headers
|
# external libraries headers
|
||||||
# GLFW3
|
# GLFW3
|
||||||
INCLUDES += -I../src/external/glfw3/include
|
INCLUDES += -I../src/external/glfw3/include
|
||||||
|
@ -143,7 +152,7 @@ endif
|
||||||
# define any libraries to link into executable
|
# define any libraries to link into executable
|
||||||
# if you want to link libraries (libname.so or libname.a), use the -lname
|
# if you want to link libraries (libname.so or libname.a), use the -lname
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),linux)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
# libraries for Debian GNU/Linux desktop compiling
|
# libraries for Debian GNU/Linux desktop compiling
|
||||||
# requires the following packages:
|
# requires the following packages:
|
||||||
# libglfw3-dev libopenal-dev libegl1-mesa-dev
|
# libglfw3-dev libopenal-dev libegl1-mesa-dev
|
||||||
|
@ -187,11 +196,6 @@ ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
WINFLAGS = ../src/resources -Wl,--subsystem,windows
|
WINFLAGS = ../src/resources -Wl,--subsystem,windows
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Linux Fix to timespect from
|
|
||||||
ifeq ($(PLATFORM_OS),linux)
|
|
||||||
CFLAGS += -D_DEFAULT_SOURCE
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
EXT = .html
|
EXT = .html
|
||||||
endif
|
endif
|
||||||
|
@ -536,7 +540,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
find . -type f -perm +ugo+x -delete
|
find . -type f -perm +ugo+x -delete
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
else
|
else
|
||||||
ifeq ($(PLATFORM_OS),linux)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f
|
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f
|
||||||
else
|
else
|
||||||
del *.o *.exe
|
del *.o *.exe
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
|
||||||
#if defined(__linux)
|
#if defined(__linux__)
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
|
36
src/Makefile
36
src/Makefile
|
@ -60,7 +60,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
else
|
else
|
||||||
UNAMEOS:=$(shell uname)
|
UNAMEOS:=$(shell uname)
|
||||||
ifeq ($(UNAMEOS),Linux)
|
ifeq ($(UNAMEOS),Linux)
|
||||||
PLATFORM_OS=linux
|
PLATFORM_OS=LINUX
|
||||||
else
|
else
|
||||||
ifeq ($(UNAMEOS),Darwin)
|
ifeq ($(UNAMEOS),Darwin)
|
||||||
PLATFORM_OS=OSX
|
PLATFORM_OS=OSX
|
||||||
|
@ -152,16 +152,36 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# define compiler flags:
|
# define compiler flags:
|
||||||
# -O1 defines optimization level
|
# -O2 defines optimization level
|
||||||
# -Og enable debugging
|
# -Og enable debugging
|
||||||
# -Wall turns on most, but not all, compiler warnings
|
# -Wall turns on most, but not all, compiler warnings
|
||||||
# -std=c99 defines C language mode (standard C from 1999 revision)
|
# -std=c99 defines C language mode (standard C from 1999 revision)
|
||||||
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
||||||
# -fgnu89-inline declaring inline functions support (GCC optimized)
|
# -fgnu89-inline declaring inline functions support (GCC optimized)
|
||||||
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
|
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
|
||||||
# -D_DEFAULT_SOURCE use with -std=c99 on Linux to enable timespec and audio
|
# -D_DEFAULT_SOURCE use with -std=c99 on Linux to enable timespec and drflac
|
||||||
#CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces
|
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
|
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
|
# if shared library required, make sure code is compiled as position independent
|
||||||
|
@ -217,7 +237,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
OUTPUT_PATH = ../release/win32/mingw32
|
OUTPUT_PATH = ../release/win32/mingw32
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),linux)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
OUTPUT_PATH = ../release/linux
|
OUTPUT_PATH = ../release/linux
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
|
@ -268,7 +288,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
@echo "libraylib.bc generated (web version)!"
|
@echo "libraylib.bc generated (web version)!"
|
||||||
else
|
else
|
||||||
ifeq ($(SHARED),YES)
|
ifeq ($(SHARED),YES)
|
||||||
ifeq ($(PLATFORM_OS),linux)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
# compile raylib to shared library version for GNU/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)
|
$(CC) -shared -o $(OUTPUT_PATH)/libraylib.so $(OBJS)
|
||||||
|
@ -337,7 +357,7 @@ utils.o : utils.c utils.h
|
||||||
# TODO: add other platforms.
|
# TODO: add other platforms.
|
||||||
install :
|
install :
|
||||||
ifeq ($(ROOT),root)
|
ifeq ($(ROOT),root)
|
||||||
ifeq ($(PLATFORM_OS),linux)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
# On GNU/Linux there are some standard directories that contain
|
# On GNU/Linux there are some standard directories that contain
|
||||||
# libraries and header files. These directory (/usr/local/lib and
|
# libraries and header files. These directory (/usr/local/lib and
|
||||||
# /usr/local/include/) are for libraries that are installed
|
# /usr/local/include/) are for libraries that are installed
|
||||||
|
@ -360,7 +380,7 @@ endif
|
||||||
# TODO: see 'install' target.
|
# TODO: see 'install' target.
|
||||||
unistall :
|
unistall :
|
||||||
ifeq ($(ROOT),root)
|
ifeq ($(ROOT),root)
|
||||||
ifeq ($(PLATFORM_OS),linux)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
rm --force /usr/local/include/raylib.h
|
rm --force /usr/local/include/raylib.h
|
||||||
ifeq ($(SHARED),YES)
|
ifeq ($(SHARED),YES)
|
||||||
rm --force /usr/local/lib/libraylib.so
|
rm --force /usr/local/lib/libraylib.so
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue