From 1fe4e0c239423644f1562d4aadc374495dce81c9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 12 May 2013 16:56:56 +0100 Subject: [PATCH 1/8] Add USE_INTERNAL_LIBS, a default for USE_INTERNAL_* Linux distributions that want to link dependencies externally will generally want to link (almost) every dependency externally; similarly, minimal-dependency builds that want to use the embedded copies of dependencies will generally want to do so for (almost) every dependency. Make it easier to choose one of those by setting USE_INTERNAL_LIBS=0 or USE_INTERNAL_LIBS=1, respectively. The default can still be overridden per-dependency; for instance, "make USE_INTERNAL_LIBS=0 USE_INTERNAL_OPUS=1" will use the system version of everything except Opus. --- Makefile | 16 ++++++++++------ README | 4 ++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f7ae1159..b4d9be64 100644 --- a/Makefile +++ b/Makefile @@ -187,28 +187,32 @@ ifndef USE_FREETYPE USE_FREETYPE=0 endif +ifndef USE_INTERNAL_LIBS +USE_INTERNAL_LIBS=1 +endif + ifndef USE_INTERNAL_SPEEX -USE_INTERNAL_SPEEX=1 +USE_INTERNAL_SPEEX=$(USE_INTERNAL_LIBS) endif ifndef USE_INTERNAL_OGG -USE_INTERNAL_OGG=1 +USE_INTERNAL_OGG=$(USE_INTERNAL_LIBS) endif ifndef USE_INTERNAL_OPUS -USE_INTERNAL_OPUS=1 +USE_INTERNAL_OPUS=$(USE_INTERNAL_LIBS) endif ifndef USE_INTERNAL_ZLIB -USE_INTERNAL_ZLIB=1 +USE_INTERNAL_ZLIB=$(USE_INTERNAL_LIBS) endif ifndef USE_INTERNAL_JPEG -USE_INTERNAL_JPEG=1 +USE_INTERNAL_JPEG=$(USE_INTERNAL_LIBS) endif ifndef USE_LOCAL_HEADERS -USE_LOCAL_HEADERS=1 +USE_LOCAL_HEADERS=$(USE_INTERNAL_LIBS) endif ifndef USE_RENDERER_DLOPEN diff --git a/README b/README index 1f4cf49c..9f10163b 100644 --- a/README +++ b/README @@ -97,6 +97,10 @@ Makefile.local: USE_CODEC_OPUS - enable Ogg Opus support USE_MUMBLE - enable Mumble support USE_VOIP - enable built-in VoIP support + USE_INTERNAL_LIBS - build internal libraries instead of dynamically + linking against system libraries; this just sets + the default for USE_INTERNAL_SPEEX etc. + and USE_LOCAL_HEADERS USE_INTERNAL_SPEEX - build internal speex library instead of dynamically linking against system libspeex USE_FREETYPE - enable FreeType support for rendering fonts From 608347c84d94052311992ed6eca8163f19043c7a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 19 May 2013 20:52:23 +0100 Subject: [PATCH 2/8] Centralize checks for Freetype, with a user override This lets us find a library in a non-standard library directory (via -L in the pkg-config metadata), and allows overrides similar to the Autoconf convention, e.g. make FREETYPE_CFLAGS=-I/opt/freetype/include \ FREETYPE_LIBS="-L/opt/freetype/lib -lfreetype" If pkg-config didn't work, assume that Freetype is in the default location. --- Makefile | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index b4d9be64..9d8d0f26 100644 --- a/Makefile +++ b/Makefile @@ -271,7 +271,6 @@ ifneq ($(BUILD_CLIENT),0) OPENAL_LIBS=$(shell pkg-config --silence-errors --libs openal) SDL_CFLAGS=$(shell pkg-config --silence-errors --cflags sdl|sed 's/-Dmain=SDL_main//') SDL_LIBS=$(shell pkg-config --silence-errors --libs sdl) - FREETYPE_CFLAGS=$(shell pkg-config --silence-errors --cflags freetype2) endif # Use sdl-config if all else fails ifeq ($(SDL_CFLAGS),) @@ -385,10 +384,6 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu")) CLIENT_LIBS += -lrt endif - ifeq ($(USE_FREETYPE),1) - BASE_CFLAGS += $(FREETYPE_CFLAGS) - endif - ifeq ($(ARCH),x86) # linux32 make ... BASE_CFLAGS += -m32 @@ -466,10 +461,6 @@ ifeq ($(PLATFORM),darwin) endif endif - ifeq ($(USE_FREETYPE),1) - BASE_CFLAGS += $(FREETYPE_CFLAGS) - endif - BASE_CFLAGS += -D_THREAD_SAFE=1 ifeq ($(USE_LOCAL_HEADERS),1) @@ -584,7 +575,7 @@ ifeq ($(PLATFORM),mingw32) RENDERER_LIBS = -lgdi32 -lole32 -lopengl32 ifeq ($(USE_FREETYPE),1) - BASE_CFLAGS += -Ifreetype2 + FREETYPE_CFLAGS = -Ifreetype2 endif ifeq ($(USE_CURL),1) @@ -913,10 +904,6 @@ endif TARGETS = -ifeq ($(USE_FREETYPE),1) - BASE_CFLAGS += -DBUILD_FREETYPE -endif - ifndef FULLBINEXT FULLBINEXT=.$(ARCH)$(BINEXT) endif @@ -1048,7 +1035,11 @@ else endif ifeq ($(USE_FREETYPE),1) - RENDERER_LIBS += -lfreetype + FREETYPE_CFLAGS ?= $(shell pkg-config --silence-errors --cflags freetype2 || true) + FREETYPE_LIBS ?= $(shell pkg-config --silence-errors --libs freetype2 || echo -lfreetype) + + BASE_CFLAGS += -DBUILD_FREETYPE $(FREETYPE_CFLAGS) + RENDERER_LIBS += $(FREETYPE_LIBS) endif ifeq ("$(CC)", $(findstring "$(CC)", "clang" "clang++")) From b1da3556444ae4413e4c078b6226c25f0a6afe7d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 19 May 2013 20:57:04 +0100 Subject: [PATCH 3/8] Allow libcurl to be in a non-standard location on all platforms We didn't add CURL_CFLAGS to CLIENT_CFLAGS on all platforms, and didn't use CURL_LIBS at all, so if "pkg-config --libs" returned "-L... -lcurl" or even "/.../libcurl.a", it wouldn't work. --- Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 9d8d0f26..4f8ac039 100644 --- a/Makefile +++ b/Makefile @@ -271,6 +271,9 @@ ifneq ($(BUILD_CLIENT),0) OPENAL_LIBS=$(shell pkg-config --silence-errors --libs openal) SDL_CFLAGS=$(shell pkg-config --silence-errors --cflags sdl|sed 's/-Dmain=SDL_main//') SDL_LIBS=$(shell pkg-config --silence-errors --libs sdl) + else + # assume they're in the system default paths (no -I or -L needed) + CURL_LIBS=-lcurl endif # Use sdl-config if all else fails ifeq ($(SDL_CFLAGS),) @@ -375,8 +378,9 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu")) endif ifeq ($(USE_CURL),1) + CLIENT_CFLAGS += $(CURL_CFLAGS) ifneq ($(USE_CURL_DLOPEN),1) - CLIENT_LIBS += -lcurl + CLIENT_LIBS += $(CURL_LIBS) endif endif @@ -456,8 +460,9 @@ ifeq ($(PLATFORM),darwin) endif ifeq ($(USE_CURL),1) + CLIENT_CFLAGS += $(CURL_CFLAGS) ifneq ($(USE_CURL_DLOPEN),1) - CLIENT_LIBS += -lcurl + CLIENT_LIBS += $(CURL_LIBS) endif endif @@ -666,8 +671,9 @@ ifeq ($(PLATFORM),freebsd) endif ifeq ($(USE_CURL),1) + CLIENT_CFLAGS += $(CURL_CFLAGS) ifeq ($(USE_CURL_DLOPEN),1) - CLIENT_LIBS += -lcurl + CLIENT_LIBS += $(CURL_LIBS) endif endif @@ -760,7 +766,7 @@ ifeq ($(PLATFORM),openbsd) ifeq ($(USE_CURL),1) ifneq ($(USE_CURL_DLOPEN),1) - CLIENT_LIBS += -lcurl + CLIENT_LIBS += $(CURL_LIBS) endif endif else # ifeq openbsd From 2821aa41d781a7ff15b425ef5cc96b523a796d68 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 19 May 2013 21:06:16 +0100 Subject: [PATCH 4/8] Allow OpenAL to be in a non-standard location on all platforms Similar to libcurl, we didn't use OPENAL_LIBS and assumed it was always "-lopenal". --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4f8ac039..35c1fc96 100644 --- a/Makefile +++ b/Makefile @@ -274,6 +274,7 @@ ifneq ($(BUILD_CLIENT),0) else # assume they're in the system default paths (no -I or -L needed) CURL_LIBS=-lcurl + OPENAL_LIBS=-lopenal endif # Use sdl-config if all else fails ifeq ($(SDL_CFLAGS),) @@ -373,7 +374,7 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu")) ifeq ($(USE_OPENAL),1) ifneq ($(USE_OPENAL_DLOPEN),1) - CLIENT_LIBS += -lopenal + CLIENT_LIBS += $(OPENAL_LIBS) endif endif @@ -666,7 +667,7 @@ ifeq ($(PLATFORM),freebsd) # optional features/libraries ifeq ($(USE_OPENAL),1) ifeq ($(USE_OPENAL_DLOPEN),1) - CLIENT_LIBS += $(THREAD_LIBS) -lopenal + CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS) endif endif @@ -760,7 +761,7 @@ ifeq ($(PLATFORM),openbsd) ifeq ($(USE_OPENAL),1) ifneq ($(USE_OPENAL_DLOPEN),1) - CLIENT_LIBS += $(THREAD_LIBS) -lopenal + CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS) endif endif From 9ff2fc3324503a95f1220521b8d063fca15a5db3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 19 May 2013 20:58:42 +0100 Subject: [PATCH 5/8] Allow system libjpeg to be in a non-standard location It doesn't have pkg-config metadata (at least on Debian), so if the user doesn't override it, assume normal system paths. --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 35c1fc96..416d1f17 100644 --- a/Makefile +++ b/Makefile @@ -1038,7 +1038,13 @@ ifeq ($(USE_INTERNAL_JPEG),1) BASE_CFLAGS += -DUSE_INTERNAL_JPEG BASE_CFLAGS += -I$(JPDIR) else - RENDERER_LIBS += -ljpeg + # libjpeg doesn't have pkg-config yet, but let users override with + # "make JPEG_CFLAGS=-I/opt/jpeg/include JPEG_LIBS='-L/opt/jpeg/lib -ljpeg'" + # if they need to + JPEG_CFLAGS ?= + JPEG_LIBS ?= -ljpeg + BASE_CFLAGS += $(JPEG_CFLAGS) + RENDERER_LIBS += $(JPEG_LIBS) endif ifeq ($(USE_FREETYPE),1) From c817ab5ae0601a9bbdce6c36f7cdccff9fe7474b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 19 May 2013 21:31:12 +0100 Subject: [PATCH 6/8] Find system zlib via user override, pkg-config or in standard locations --- Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 416d1f17..1563d703 100644 --- a/Makefile +++ b/Makefile @@ -1028,11 +1028,13 @@ ifeq ($(USE_VOIP),1) endif ifeq ($(USE_INTERNAL_ZLIB),1) - BASE_CFLAGS += -DNO_GZIP - BASE_CFLAGS += -I$(ZDIR) + ZLIB_CFLAGS = -DNO_GZIP -I$(ZDIR) else - LIBS += -lz + ZLIB_CFLAGS ?= $(shell pkg-config --silence-errors --cflags zlib || true) + ZLIB_LIBS ?= $(shell pkg-config --silence-errors --libs zlib || echo -lz) endif +BASE_CFLAGS += $(ZLIB_CFLAGS) +LIBS += $(ZLIB_LIBS) ifeq ($(USE_INTERNAL_JPEG),1) BASE_CFLAGS += -DUSE_INTERNAL_JPEG From cff1fcd658fe1805791ed9658d2822ab356fffeb Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 19 May 2013 21:02:31 +0100 Subject: [PATCH 7/8] Look for system Vorbis, Opus and Ogg via pkg-config As usual, the order of precedence is: user override, pkg-config, or assume they're in standard locations. In particular, Opus isn't in the default search path on Debian. --- Makefile | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 1563d703..086048dc 100644 --- a/Makefile +++ b/Makefile @@ -982,31 +982,37 @@ ifeq ($(USE_CURL),1) endif ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_CFLAGS += -DUSE_CODEC_VORBIS - CLIENT_LIBS += -lvorbisfile -lvorbis + VORBIS_CFLAGS ?= $(shell pkg-config --silence-errors --cflags vorbisfile vorbis || true) + VORBIS_LIBS ?= $(shell pkg-config --silence-errors --libs vorbisfile vorbis || echo -lvorbisfile -lvorbis) + CLIENT_CFLAGS += -DUSE_CODEC_VORBIS $(VORBIS_CFLAGS) + CLIENT_LIBS += $(VORBIS_LIBS) NEED_OGG=1 endif ifeq ($(USE_CODEC_OPUS),1) CLIENT_CFLAGS += -DUSE_CODEC_OPUS ifeq ($(USE_INTERNAL_OPUS),1) - CLIENT_CFLAGS += -DOPUS_BUILD -DHAVE_LRINTF -DFLOATING_POINT -DUSE_ALLOCA \ + OPUS_CFLAGS = -DOPUS_BUILD -DHAVE_LRINTF -DFLOATING_POINT -DUSE_ALLOCA \ -I$(OPUSDIR)/include -I$(OPUSDIR)/celt -I$(OPUSDIR)/silk \ - -I$(OPUSDIR)/silk/float - - CLIENT_CFLAGS += -I$(OPUSFILEDIR)/include + -I$(OPUSDIR)/silk/float -I$(OPUSFILEDIR)/include else - CLIENT_LIBS += -lopusfile -lopus + OPUS_CFLAGS=$(shell pkg-config --silence-errors --cflags opusfile opus || true) + OPUS_LIBS=$(shell pkg-config --silence-errors --libs opusfile opus || echo -lopusfile -lopus) endif + CLIENT_CFLAGS += $(OPUS_CFLAGS) + CLIENT_LIBS += $(OPUS_LIBS) NEED_OGG=1 endif ifeq ($(NEED_OGG),1) ifeq ($(USE_INTERNAL_OGG),1) - CLIENT_CFLAGS += -I$(OGGDIR)/include + OGG_CFLAGS = -I$(OGGDIR)/include else - CLIENT_LIBS += -logg + OGG_CFLAGS ?= $(shell pkg-config --silence-errors --cflags ogg || true) + OGG_LIBS ?= $(shell pkg-config --silence-errors --libs ogg || echo -logg) endif + CLIENT_CFLAGS += $(OGG_CFLAGS) + CLIENT_LIBS += $(OGG_LIBS) endif ifeq ($(USE_RENDERER_DLOPEN),1) From 69999280c6645998a497dd80c87e9c3c0f0f83a4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 19 May 2013 21:19:36 +0100 Subject: [PATCH 8/8] Find Speex via user override, pkg-config or default search path --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 086048dc..6173dc74 100644 --- a/Makefile +++ b/Makefile @@ -1027,10 +1027,13 @@ ifeq ($(USE_VOIP),1) CLIENT_CFLAGS += -DUSE_VOIP SERVER_CFLAGS += -DUSE_VOIP ifeq ($(USE_INTERNAL_SPEEX),1) - CLIENT_CFLAGS += -DFLOATING_POINT -DUSE_ALLOCA -I$(SPEEXDIR)/include + SPEEX_CFLAGS += -DFLOATING_POINT -DUSE_ALLOCA -I$(SPEEXDIR)/include else - CLIENT_LIBS += -lspeex -lspeexdsp + SPEEX_CFLAGS ?= $(shell pkg-config --silence-errors --cflags speex speexdsp || true) + SPEEX_LIBS ?= $(shell pkg-config --silence-errors --libs speex speexdsp || echo -lspeex -lspeexdsp) endif + CLIENT_CFLAGS += $(SPEEX_CFLAGS) + CLIENT_LIBS += $(SPEEX_LIBS) endif ifeq ($(USE_INTERNAL_ZLIB),1)