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.
This commit is contained in:
Simon McVittie 2013-05-19 20:52:23 +01:00
parent 1fe4e0c239
commit 608347c84d
1 changed files with 6 additions and 15 deletions

View File

@ -271,7 +271,6 @@ ifneq ($(BUILD_CLIENT),0)
OPENAL_LIBS=$(shell pkg-config --silence-errors --libs openal) OPENAL_LIBS=$(shell pkg-config --silence-errors --libs openal)
SDL_CFLAGS=$(shell pkg-config --silence-errors --cflags sdl|sed 's/-Dmain=SDL_main//') SDL_CFLAGS=$(shell pkg-config --silence-errors --cflags sdl|sed 's/-Dmain=SDL_main//')
SDL_LIBS=$(shell pkg-config --silence-errors --libs sdl) SDL_LIBS=$(shell pkg-config --silence-errors --libs sdl)
FREETYPE_CFLAGS=$(shell pkg-config --silence-errors --cflags freetype2)
endif endif
# Use sdl-config if all else fails # Use sdl-config if all else fails
ifeq ($(SDL_CFLAGS),) ifeq ($(SDL_CFLAGS),)
@ -385,10 +384,6 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu"))
CLIENT_LIBS += -lrt CLIENT_LIBS += -lrt
endif endif
ifeq ($(USE_FREETYPE),1)
BASE_CFLAGS += $(FREETYPE_CFLAGS)
endif
ifeq ($(ARCH),x86) ifeq ($(ARCH),x86)
# linux32 make ... # linux32 make ...
BASE_CFLAGS += -m32 BASE_CFLAGS += -m32
@ -466,10 +461,6 @@ ifeq ($(PLATFORM),darwin)
endif endif
endif endif
ifeq ($(USE_FREETYPE),1)
BASE_CFLAGS += $(FREETYPE_CFLAGS)
endif
BASE_CFLAGS += -D_THREAD_SAFE=1 BASE_CFLAGS += -D_THREAD_SAFE=1
ifeq ($(USE_LOCAL_HEADERS),1) ifeq ($(USE_LOCAL_HEADERS),1)
@ -584,7 +575,7 @@ ifeq ($(PLATFORM),mingw32)
RENDERER_LIBS = -lgdi32 -lole32 -lopengl32 RENDERER_LIBS = -lgdi32 -lole32 -lopengl32
ifeq ($(USE_FREETYPE),1) ifeq ($(USE_FREETYPE),1)
BASE_CFLAGS += -Ifreetype2 FREETYPE_CFLAGS = -Ifreetype2
endif endif
ifeq ($(USE_CURL),1) ifeq ($(USE_CURL),1)
@ -913,10 +904,6 @@ endif
TARGETS = TARGETS =
ifeq ($(USE_FREETYPE),1)
BASE_CFLAGS += -DBUILD_FREETYPE
endif
ifndef FULLBINEXT ifndef FULLBINEXT
FULLBINEXT=.$(ARCH)$(BINEXT) FULLBINEXT=.$(ARCH)$(BINEXT)
endif endif
@ -1048,7 +1035,11 @@ else
endif endif
ifeq ($(USE_FREETYPE),1) 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 endif
ifeq ("$(CC)", $(findstring "$(CC)", "clang" "clang++")) ifeq ("$(CC)", $(findstring "$(CC)", "clang" "clang++"))