Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
117 lines (101 sloc) 3.45 KB
ROOT = $(TUP_CWD)
## Base
CFLAGS += -std=c99 -pedantic
CFLAGS += -D_POSIX_C_SOURCE=200809L
CFLAGS += -I$(ROOT)/src
CFLAGS += -I$(ROOT)/src/modules
CFLAGS += -fvisibility=hidden
CFLAGS += -Wall -Wextra
CFLAGS += -Wno-unused-parameter
CFLAGS_@(OPENVR) += -Wno-typedef-redefinition
CFLAGS_@(STRICT) += -Werror
CFLAGS_@(DEBUG) += -g
CFLAGS_@(OPTIMIZE) += -Os
CFLAGS_@(SANITIZE) += -fsanitize=address,undefined
LDFLAGS_@(SANITIZE) += -fsanitize=address,undefined
## Modules
CFLAGS_@(AUDIO) += -DLOVR_ENABLE_AUDIO
CFLAGS_@(DATA) += -DLOVR_ENABLE_DATA
CFLAGS_@(EVENT) += -DLOVR_ENABLE_EVENT
CFLAGS_@(FILESYSTEM) += -DLOVR_ENABLE_FILESYSTEM
CFLAGS_@(GRAPHICS) += -DLOVR_ENABLE_GRAPHICS
CFLAGS_@(GRAPHICS) += -DLOVR_@(GL)
CFLAGS_@(HEADSET) += -DLOVR_ENABLE_HEADSET
CFLAGS_@(MATH) += -DLOVR_ENABLE_MATH
CFLAGS_@(PHYSICS) += -DLOVR_ENABLE_PHYSICS
CFLAGS_@(THREAD) += -DLOVR_ENABLE_THREAD
CFLAGS_@(TIMER) += -DLOVR_ENABLE_TIMER
CFLAGS_@(JSON) += -DLOVR_ENABLE_JSON
CFLAGS_@(ENET) += -DLOVR_ENABLE_ENET
## Headset backends
CFLAGS_@(SIMULATOR) += -DLOVR_USE_DESKTOP_HEADSET
CFLAGS_@(OPENVR) += -DLOVR_USE_OPENVR
CFLAGS_@(OPENXR) += -DLOVR_USE_OPENXR
CFLAGS_@(OCULUS) += -DLOVR_USE_OCULUS
CFLAGS_@(OCULUS) += -I@(OCULUS_PATH)/LibOVR/Include
CFLAGS_@(VRAPI) += -DLOVR_USE_OCULUS_MOBILE
CFLAGS_@(WEBVR) += -DLOVR_USE_WEBVR
CFLAGS_@(LEAP) += -DLOVR_USE_LEAP
## Platforms
# A little gnarly, but basically you can set CONFIG_PLATFORM to pick a specific one, otherwise
# we use the builtin TUP_PLATFORM which is the current OS (so it won't work with android/web).
# Also macosx gets converted to macos
ifeq (@(PLATFORM),)
PLATFORM = @(TUP_PLATFORM)
else
PLATFORM = @(PLATFORM)
endif
ifeq ($(PLATFORM),macosx)
PLATFORM = macos
endif
ifeq ($(PLATFORM),macos)
LDFLAGS += -lobjc
LDFLAGS += -pagezero_size 10000 -image_base 100000000
ORIGIN = @executable_path
SO = dylib
endif
ifeq ($(PLATFORM),linux)
LDFLAGS += -lm -lpthread
ORIGIN = \$ORIGIN
SO = so
endif
## Libraries
ifeq (@(CMAKE_DEPS),y)
# enet
CFLAGS_@(ENET) += -I$(ROOT)/deps/enet/include
LDFLAGS_@(ENET) += -L$(ROOT)/build/enet -lenet
# LuaJIT
CFLAGS += -I$(ROOT)/deps/luajit/src
LDFLAGS += -L$(ROOT)/build/luajit/src -lluajit
LIBS += $(ROOT)/build/luajit/src/libluajit.$(SO)
# msdfgen
CFLAGS_@(DATA) += -I$(ROOT)/deps/msdfgen
LDFLAGS_@(DATA) += -L$(ROOT)/build/lib_msdfgen -lmsdfgen
LIBS_@(DATA) += $(ROOT)/build/lib_msdfgen/libmsdfgen.$(SO)
# ode
CFLAGS_@(PHYSICS) += -I$(ROOT)/deps/ode/include -I$(ROOT)/build/ode/include
LDFLAGS_@(PHYSICS) += -L$(ROOT)/build/ode -lode
LIBS_@(PHYSICS) += $(ROOT)/build/ode/libode.$(SO)
# glfw
CFLAGS += -I$(ROOT)/deps/glfw/include
LDFLAGS += -L$(ROOT)/build/glfw/src -lglfw
LIBS += $(ROOT)/build/glfw/src/libglfw.*$(SO)*
# OpenVR
CFLAGS_@(OPENVR) += -I$(ROOT)/deps/openvr/headers
LDFLAGS_@(OPENVR) += -L$(ROOT)/build/openvr_api -lopenvr_api
LIBS_@(OPENVR) += $(ROOT)/build/openvr_api/libopenvr_api.$(SO)
# OpenAL
CFLAGS_@(AUDIO) += -I$(ROOT)/deps/openal-soft/include
LDFLAGS_@(AUDIO) += -L$(ROOT)/build/openal -lopenal
LIBS_@(AUDIO) += $(ROOT)/build/openal/libopenal.*$(SO)*
# Configure rpath to look for libraries in a `libs` folder next to the executable
LDFLAGS += -Wl,-rpath,$(ORIGIN)/libs
LIBS += $(LIBS_y)
endif
CFLAGS += @(EXTRA_CFLAGS)
LDFLAGS += @(EXTRA_LDFLAGS)
## Macros
!cc = |> ^ CC %b^ @(CC) $(CFLAGS_y) $(CFLAGS) -c %f -o %o |>
!ld = |> ^ LD %o^ @(CC) -o %o %f $(LDFLAGS_y) $(LDFLAGS) |>
!xd = |> ^ XD %f^ xxd -i %f > %o |>
!cp = |> ^ CP %b^ cp %f %o |>
You can’t perform that action at this time.