vengi/Makefile

324 lines
12 KiB
Makefile
Raw Normal View History

-include Makefile.local
2016-05-13 11:56:58 -07:00
# Building
## Release or Debug
#
# make BUILD_TYPE=Debug
# make BUILD_TYPE=Release
#
# To build either in debug mode, or in release mode
#
# Debugging
2016-09-09 11:59:04 -07:00
## Run in debugger
#
2016-09-09 11:59:04 -07:00
# make tests DEBUG=1 ARGS=--gtest_filter=World*
#
# to only build the tests targets, and run it via gdb afterwards.
# It will automatically start the execution and forward the arguments
# that are given via ARGS to the target
#
## Verbose output
#
# make Q=
#
# This will print out information about the commands that are executed to build
# and run the target(s)
2016-05-13 11:56:58 -07:00
Q = @
2016-09-09 11:59:04 -07:00
OS := $(shell uname)
2016-05-13 11:56:58 -07:00
LOCAL_CONFIG_DIR = ~/.local/share/engine
UPDATEDIR := /tmp
VALGRIND ?=
ifeq ($(VALGRIND),)
VALGRIND_OPTIONS ?=
VALGRIND_CMD ?=
else
VALGRIND_OPTIONS ?=
VALGRIND_CMD ?= valgrind $(VALGRIND_OPTIONS)
endif
2017-06-28 12:12:02 -07:00
PERF ?=
ifeq ($(PERF),)
PERF_OPTIONS ?=
PERF_CMD ?=
PERF_REPORT_CMD ?=
else
2017-07-05 13:45:12 -07:00
PERF_OPTIONS ?= --call-graph dwarf
2017-06-28 12:12:02 -07:00
PERF_CMD ?= sudo perf record $(PERF_OPTIONS)
2017-07-05 13:57:24 -07:00
PERF_REPORT_CMD ?= sudo perf report -g srcline -s dso,sym,srcline --inline -n --stdio
2017-06-28 12:12:02 -07:00
endif
2016-09-09 11:59:04 -07:00
DEBUG ?=
ifeq ($(DEBUG),)
DEBUG_CMD ?=
else
2016-09-09 11:59:04 -07:00
DEBUGGER := $(shell (gdb --help >/dev/null 2>&1 && echo GDB) || (lldb --help >/dev/null 2>&1 && echo LLDB))
ifeq ($(DEBUGGER),GDB)
DEBUG_CMD ?= gdb -ex run --args
else ifeq ($(DEBUGGER),LLDB)
DEBUG_CMD ?= lldb -b -o run
2016-09-09 11:59:04 -07:00
else
DEBUG_CMD ?=
endif
endif
2016-06-16 11:10:23 -07:00
2016-12-07 11:30:56 -08:00
CMAKE_OPTIONS ?=
GPROF ?=
2016-05-13 11:56:58 -07:00
BUILD_TYPE ?= Debug
# override this in your Makefile.local to use a different directory
BUILDDIRPATH ?= ./
2016-11-10 11:51:02 -08:00
#BUILDDIR ?= $(BUILDDIRPATH)build-$(shell echo $(BUILD_TYPE) | tr '[:upper:]' '[:lower:]')
2016-12-07 11:30:56 -08:00
ifeq ($(GPROF),)
2016-11-10 11:51:02 -08:00
BUILDDIR ?= $(BUILDDIRPATH)build/$(BUILD_TYPE)
2016-12-07 11:30:56 -08:00
else
BUILDDIR ?= $(BUILDDIRPATH)build/$(BUILD_TYPE)/gprof
CMAKE_OPTIONS += -DUSE_GPROF=True
endif
ifneq ($(THREADS),)
BUILDDIR ?= $(BUILDDIRPATH)build/$(BUILD_TYPE)/threads
CMAKE_OPTIONS += -DSANITIZER_THREADS=True
endif
2016-06-16 11:10:23 -07:00
#VOGL_OPTIONS ?= --vogl_force_debug_context --vogl_exit_after_x_frames 2000
VOGL_OPTIONS ?= --vogl_force_debug_context
VOGL ?=
ifeq ($(VOGL),)
VOGL_CMD ?=
else
VOGL_BIN ?= vogl
VOGL_CMD ?= $(VOGL_BIN) trace --vogl_tracepath $(BUILDDIR) --vogl_tracefile $@.trace.bin $(VOGL_OPTIONS)
2016-06-16 11:10:23 -07:00
ARGS_TMP := $(ARGS)
ARGS = "--args $(ARGS_TMP)"
endif
MAKE_PID := $$PPID
JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)")))
MAKE_OPTIONS := --no-print-directory -C $(BUILDDIR)
ifeq ($(OS),Darwin)
CMAKE_GENERATOR ?= "Xcode"
2017-08-27 08:50:19 -07:00
CMAKE_BINARY ?= $(shell which cmake)
ifeq ($(CMAKE_BINARY),)
2016-09-04 13:26:07 -07:00
CMAKE_BINARY ?= /Applications/CMake.app/Contents/bin/cmake
2017-08-27 08:50:19 -07:00
endif
DARWIN := 1
2016-09-09 11:59:04 -07:00
else ifeq ($(OS),Linux)
CMAKE_GENERATOR ?= "Eclipse CDT4 - Unix Makefiles"
2016-09-04 13:26:07 -07:00
CMAKE_BINARY ?= cmake
LINUX := 1
2016-09-09 11:59:04 -07:00
else
CMAKE_GENERATOR ?= "MSYS Makefiles"
CMAKE_BINARY ?= cmake
WINDOWS := 1
endif
2016-09-04 13:26:07 -07:00
INSTALL_DIR ?= $(BUILDDIRPATH)$(OS)
all: build
2016-03-14 05:48:05 -07:00
2016-05-13 11:56:58 -07:00
run: shapetool
2016-11-27 10:48:04 -08:00
.PHONY: clangtidy
clangtidy:
$(Q)mkdir -p $(BUILDDIR)/tidy
2016-11-27 10:48:05 -08:00
$(Q)cd $(BUILDDIR)/tidy; $(CMAKE_BINARY) -DCMAKE_CXX_CLANG_TIDY:STRING="clang-tidy-4.0;-checks=readability-uniqueptr-delete-release,readability-non-const-parameter,readability-redundant-smartptr-get,performance-unnecessary-value-param,performance-unnecessary-copy-initialization,performance-inefficient-string-concatenation,performance-implicit-cast-in-loop,performance-for-range-copy,performance-faster-string-find,modernize-make-shared,clang-analyzer-security.*;-fix" $(CURDIR) $(CMAKE_OPTIONS) && cmake --build .
2016-11-27 10:48:04 -08:00
.PHONY: cmake
cmake:
2016-05-13 11:56:58 -07:00
$(Q)mkdir -p $(BUILDDIR)
2016-09-04 13:26:07 -07:00
$(Q)cd $(BUILDDIR); $(CMAKE_BINARY) -G$(CMAKE_GENERATOR) -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) $(CURDIR) $(CMAKE_OPTIONS)
define COMPILE
$(if $(LINUX),\
$(Q)$(MAKE) $(MAKE_OPTIONS) $(JOB_FLAG) $(1) \
$(else),\
$(if $(DARWIN),\
2017-10-12 09:25:47 -07:00
$(Q)cd $(BUILDDIR); xcodebuild build -target $(1) install -project tests.xcodeproj -configuration $(BUILD_TYPE) CODE_SIGNING_ALLOWED=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO && exit ${PIPESTATUS[0]} \
$(else),\
$(Q)$(MAKE) $(MAKE_OPTIONS) $(JOB_FLAG) $(1) \
)
)
endef
.PHONY: build
build: cmake
$(call COMPILE, install)
2016-03-14 05:48:05 -07:00
clean:
$(Q)rm -rf $(BUILDDIR)
2016-03-14 05:48:05 -07:00
2016-04-22 11:33:15 -07:00
clean-local-config:
$(Q)rm -rf $(LOCAL_CONFIG_DIR)
2016-04-22 11:33:15 -07:00
edit-local-config:
2017-03-08 07:30:42 -08:00
$(Q)$(EDITOR) $(LOCAL_CONFIG_DIR)/worldrenderertool/worldrenderertool.vars
2016-08-05 11:05:55 -07:00
doc: cmake
$(call COMPILE, $@)
2016-08-05 11:55:11 -07:00
server client voxedit shapetool worldrenderertool shadertool noisetool noisetool2 databasetool uitool tests tests-math tests-core tests-persistence tests-voxel benchmarks-voxel tests-noise tests-computeshadertool testmesh testcamera testdepthbuffer testtexture testvoxelfont testplane testimgui testoctree testoctreevisit testshapebuilder tests-shadertool flatc computeshadertool: cmake
$(call COMPILE, $@)
$(call COMPILE, copy-data-shared)
$(call COMPILE, copy-data-$@)
2017-06-28 12:12:02 -07:00
$(Q)cd $(BUILDDIR); $(PERF_CMD) $(VALGRIND_CMD) $(DEBUG_CMD) $(VOGL_CMD) ./$@ $(ARGS)
2017-02-25 06:01:49 -08:00
backward flatbuffers glm libenet nativefiledialog restclient-cpp selene zlib lua53 luac libcurl assimp turbobadger sdl2: cmake
$(call COMPILE, $@)
2017-10-09 08:07:50 -07:00
rcon: cmake
$(call COMPILE, $@)
2016-09-09 11:59:04 -07:00
$(Q)cd $(BUILDDIR); $(VALGRIND_CMD) $(DEBUG_CMD) $(VOGL_CMD) ./$@ $(ARGS)
2016-12-03 10:38:38 -08:00
define UPDATE_GIT
$(Q)if [ ! -d $(UPDATEDIR)/$(1).sync ]; then \
2017-08-08 23:54:36 -07:00
git clone --depth=1 $(2) $(UPDATEDIR)/$(1).sync; \
2016-12-03 10:38:38 -08:00
else \
2017-08-08 23:54:36 -07:00
cd $(UPDATEDIR)/$(1).sync && git pull --depth=1 --rebase; \
2016-12-03 10:38:38 -08:00
fi;
endef
define UPDATE_HG
$(Q)if [ ! -d $(UPDATEDIR)/$(1).sync ]; then \
hg clone $(2) $(UPDATEDIR)/$(1).sync; \
2016-12-03 10:38:38 -08:00
else \
cd $(UPDATEDIR)/$(1).sync && hg pull && hg update; \
2016-12-03 10:38:38 -08:00
fi;
endef
2017-09-10 21:47:47 -07:00
update-restclient-cpp:
$(call UPDATE_GIT,restclient-cpp,https://github.com/mrtazz/restclient-cpp.git)
rm -rf contrib/libs/restclient-cpp/restclient-cpp/*.h
rm -rf contrib/libs/restclient-cpp/*.cc
cp $(UPDATEDIR)/restclient-cpp.sync/include/restclient-cpp/*.h contrib/libs/restclient-cpp/restclient-cpp
cp $(UPDATEDIR)/restclient-cpp.sync/source/*.cc contrib/libs/restclient-cpp
2017-09-10 21:47:47 -07:00
update-libuv:
2017-09-06 10:34:12 -07:00
$(call UPDATE_GIT,libuv,https://github.com/libuv/libuv.git)
rm -rf contrib/libs/libuv/include/*.[ch]
rm -rf contrib/libs/libuv/src/unix/*.[ch]
rm -rf contrib/libs/libuv/src/win32/*.[ch]
rm -rf contrib/libs/libuv/src/*.[ch]
2017-09-06 10:34:12 -07:00
cp $(UPDATEDIR)/libuv.sync/include/*.h contrib/libs/libuv/include
cp $(UPDATEDIR)/libuv.sync/src/unix/*.[ch] contrib/libs/libuv/src/unix
cp $(UPDATEDIR)/libuv.sync/src/win/*.[ch] contrib/libs/libuv/src/win
cp $(UPDATEDIR)/libuv.sync/src/*.[ch] contrib/libs/libuv/src
2017-09-10 21:47:47 -07:00
update-stb:
2017-08-20 11:25:59 -07:00
$(call UPDATE_GIT,stb,https://github.com/nothings/stb.git)
cp $(UPDATEDIR)/stb.sync/stb_image.h src/modules/image/stb_image.h
cp $(UPDATEDIR)/stb.sync/stb_image_write.h src/modules/image/stb_image_write.h
cp $(UPDATEDIR)/stb.sync/stb_truetype.h src/modules/voxel/font/stb_truetype.h
cp $(UPDATEDIR)/stb.sync/stb_image.h contrib/libs/turbobadger/tb/thirdparty
cp $(UPDATEDIR)/stb.sync/stb_truetype.h contrib/libs/turbobadger/tb/thirdparty
2017-09-10 21:47:47 -07:00
update-simplecpp:
$(call UPDATE_GIT,simplecpp,https://github.com/danmar/simplecpp.git)
cp $(UPDATEDIR)/simplecpp.sync/simplecpp.* contrib/libs/simplecpp
2017-09-10 21:47:47 -07:00
update-googletest:
2017-06-26 20:58:18 -07:00
$(call UPDATE_GIT,googletest,https://github.com/google/googletest.git)
2017-07-24 12:40:17 -07:00
rm -rf contrib/libs/gtest/src
rm -rf contrib/libs/gtest/include
cp -r $(UPDATEDIR)/googletest.sync/googletest/src contrib/libs/gtest
cp -r $(UPDATEDIR)/googletest.sync/googletest/include contrib/libs/gtest/include
git checkout -f contrib/libs/gtest/include/gtest/internal/custom
2017-09-10 21:47:47 -07:00
update-benchmark:
2017-06-20 11:35:23 -07:00
$(call UPDATE_GIT,benchmark,https://github.com/google/benchmark.git)
cp -r $(UPDATEDIR)/benchmark.sync/src/* contrib/libs/benchmark/src
cp -r $(UPDATEDIR)/benchmark.sync/include/* contrib/libs/benchmark/include
2017-09-10 21:47:47 -07:00
update-backward:
2017-06-11 10:41:00 -07:00
$(call UPDATE_GIT,backward-cpp,https://github.com/bombela/backward-cpp.git)
cp $(UPDATEDIR)/backward-cpp.sync/backward.cpp contrib/libs/backward
cp -f $(UPDATEDIR)/backward-cpp.sync/backward.hpp contrib/libs/backward/backward.h
sed -i 's/backward.hpp/backward.h/g' contrib/libs/backward/backward.cpp
2017-09-10 21:47:47 -07:00
update-dearimgui:
2017-08-08 23:54:36 -07:00
$(call UPDATE_GIT,imgui-addons,https://github.com/Flix01/imgui.git)
$(call UPDATE_GIT,imgui,https://github.com/ocornut/imgui.git)
2017-06-11 10:41:00 -07:00
cp $(UPDATEDIR)/imgui.sync/imgui*.h $(UPDATEDIR)/imgui.sync/imgui*.cpp $(UPDATEDIR)/imgui.sync/stb_*.h contrib/libs/dearimgui/dearimgui
2017-08-08 23:27:47 -07:00
mv contrib/libs/dearimgui/dearimgui/imgui_demo.cpp src/tests/testimgui/Demo.cpp
sed -i 's/"imgui.h"/"imgui\/IMGUI.h"/g' src/tests/testimgui/Demo.cpp
2017-09-10 21:47:47 -07:00
update-assimp:
2016-12-03 10:38:38 -08:00
$(call UPDATE_GIT,assimp,https://github.com/assimp/assimp.git)
rm -rf contrib/libs/assimp/code/* contrib/libs/assimp/include/*
cp -r $(UPDATEDIR)/assimp.sync/code/* contrib/libs/assimp/code
cp -r $(UPDATEDIR)/assimp.sync/include/* contrib/libs/assimp/include
2016-12-03 10:38:38 -08:00
git checkout contrib/libs/assimp/include/assimp/revision.h
2017-09-10 21:47:47 -07:00
update-flatbuffers:
2016-12-03 10:38:38 -08:00
$(call UPDATE_GIT,flatbuffers,https://github.com/google/flatbuffers.git)
rm -rf contrib/libs/flatbuffers/flatbuffers/* contrib/libs/flatbuffers/compiler/*
mkdir -p contrib/libs/flatbuffers/compiler/src
cp -r $(UPDATEDIR)/flatbuffers.sync/include/flatbuffers/* contrib/libs/flatbuffers/flatbuffers
cp -r $(UPDATEDIR)/flatbuffers.sync/src/* contrib/libs/flatbuffers/compiler
cp -r $(UPDATEDIR)/flatbuffers.sync/grpc/src/* contrib/libs/flatbuffers/compiler/src
2016-12-03 10:38:38 -08:00
rm contrib/libs/flatbuffers/compiler/flathash.cpp
2017-09-10 21:47:47 -07:00
update-enet:
2016-12-03 10:38:38 -08:00
$(call UPDATE_GIT,libenet,https://github.com/lsalzman/enet.git)
cp -r $(UPDATEDIR)/libenet.sync/*.[ch] contrib/libs/libenet
cp -r $(UPDATEDIR)/libenet.sync/include/* contrib/libs/libenet/include
2017-09-10 21:47:47 -07:00
update-glm:
2016-12-03 10:38:38 -08:00
$(call UPDATE_GIT,glm,https://github.com/g-truc/glm.git)
rm -rf contrib/libs/glm/glm/*
cp -r $(UPDATEDIR)/glm.sync/glm/* contrib/libs/glm/glm
2016-12-03 10:38:38 -08:00
rm contrib/libs/glm/glm/CMakeLists.txt
2017-09-10 21:47:47 -07:00
update-sdl2:
2016-12-03 10:38:38 -08:00
$(call UPDATE_HG,sdl2,https://hg.libsdl.org/SDL)
2017-10-15 03:55:18 -07:00
rm -rf contrib/libs/sdl2/src/* contrib/libs/sdl2/include/* contrib/libs/sdl2/cmake/*
cp -r $(UPDATEDIR)/sdl2.sync/src/* contrib/libs/sdl2/src
cp -r $(UPDATEDIR)/sdl2.sync/include/* contrib/libs/sdl2/include
2017-10-15 03:55:18 -07:00
cp -r $(UPDATEDIR)/sdl2.sync/cmake/* contrib/libs/sdl2/cmake
2017-09-10 21:47:47 -07:00
update-turbobadger:
2016-12-12 11:26:15 -08:00
$(call UPDATE_GIT,turbobadger,https://github.com/fruxo/turbobadger.git)
rm -rf contrib/libs/turbobadger/tb/*
cp -r $(UPDATEDIR)/turbobadger.sync/src/tb/* contrib/libs/turbobadger/tb
git checkout master contrib/libs/turbobadger/tb/tb_clipboard_sdl.cpp
2016-12-12 11:26:15 -08:00
git checkout master contrib/libs/turbobadger/tb/tb_system_sdl.cpp
git checkout master contrib/libs/turbobadger/tb/tb_file_sdl.cpp
git checkout contrib/libs/turbobadger/tb/thirdparty/
rm contrib/libs/turbobadger/tb/CMakeLists.txt
rm -rf contrib/libs/turbobadger/tb/utf8/test\ files
rm -rf contrib/libs/turbobadger/tb/tests
git diff contrib/libs/turbobadger/ > $(UPDATEDIR)/turbobadger.sync/upstream.diff
2016-12-12 11:26:15 -08:00
git checkout contrib/libs/turbobadger/tb/tb_id.cpp
2017-09-11 07:54:07 -07:00
update-glslang:
$(call UPDATE_GIT,glslang,https://github.com/KhronosGroup/glslang.git)
rm -rf src/tools/glslang/External
cp -r $(UPDATEDIR)/glslang.sync/External src/tools/glslang/
rm -rf src/tools/glslang/glslang
cp -r $(UPDATEDIR)/glslang.sync/glslang src/tools/glslang/
rm -rf src/tools/glslang/OGLCompilersDLL
cp -r $(UPDATEDIR)/glslang.sync/OGLCompilersDLL src/tools/glslang/
rm -rf src/tools/glslang/SPIRV
cp -r $(UPDATEDIR)/glslang.sync/SPIRV src/tools/glslang/
rm -rf src/tools/glslang/StandAlone
cp -r $(UPDATEDIR)/glslang.sync/StandAlone src/tools/glslang/
2017-09-10 22:28:06 -07:00
update-json:
$(call UPDATE_GIT,json,https://github.com/nlohmann/json)
cp $(UPDATEDIR)/json.sync/src/json.hpp src/modules/core
2017-09-10 21:47:47 -07:00
# currently not part of updatelibs - intentional - we adopted the original code.
update-simplexnoise:
$(call UPDATE_GIT,simplexnoise,https://github.com/simongeilfus/SimplexNoise.git)
cp $(UPDATEDIR)/simplexnoise.sync/include/Simplex.h src/modules/noise
2017-10-08 11:00:56 -07:00
update-stringview:
$(call UPDATE_GIT,string_view,https://github.com/satoren/string_view.git)
cp $(UPDATEDIR)/string_view.sync/string_view.hpp contrib/libs/string_view
2017-12-10 11:27:27 -08:00
updatelibs: update-stringview update-restclient-cpp update-libuv update-stb update-googletest update-benchmark update-backward update-dearimgui update-flatbuffers update-assimp update-enet update-glm update-sdl2 update-turbobadger update-glslang
updategl:
cd tools/flextGL && ./flextgl.sh