add pkg-config macro for libraries which are not controled by configuration

This commit is contained in:
Vincent Sanders 2012-12-13 17:23:47 +00:00
parent 45906b9dc2
commit 16d67095a6
2 changed files with 39 additions and 11 deletions

View File

@ -316,6 +316,31 @@ define feature_enabled
endif
endef
# Extend flags with appropriate values from pkg-config for enabled features
#
# 1: pkg-config required modules for feature
# 2: Human-readable name for the feature
define pkg_config_find_and_add
ifeq ($$(PKG_CONFIG),)
$$(error pkg-config is required to auto-detect feature availability)
endif
PKG_CONFIG_$(1)_EXISTS := $$(shell $$(PKG_CONFIG) --exists $(1) && echo yes)
ifeq ($$(PKG_CONFIG_$(1)_EXISTS),yes)
CFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(1))
LDFLAGS += $$(shell $$(PKG_CONFIG) --libs $(1))
ifneq ($(MAKECMDGOALS),clean)
$$(info PKG.CNFG: $(2) ($(1)) enabled)
endif
else
ifneq ($(MAKECMDGOALS),clean)
$$(info PKG.CNFG: $(2) ($(1)) failed)
$$(error Unable to find library for: $(2) ($(1)))
endif
endif
endef
# Extend flags with appropriate values from pkg-config for enabled features
#
# 1: Feature name (ie, NETSURF_USE_RSVG -> RSVG)

View File

@ -7,9 +7,6 @@
# GTK flag setup (using pkg-config)
# ----------------------------------------------------------------------------
LDFLAGS += $(shell $(PKG_CONFIG) --libs libcurl libdom libcss)
LDFLAGS += $(shell $(PKG_CONFIG) --libs openssl)
# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
NETSURF_FEATURE_RSVG_CFLAGS := -DWITH_RSVG
NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG
@ -24,7 +21,7 @@ NETSURF_FEATURE_VIDEO_CFLAGS := -DWITH_VIDEO
# add a line similar to below for each optional lib here
# note: webp lacks pkg-config file
$(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG ))
$(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG))
$(eval $(call pkg_config_find_and_add_enabled,BMP,libnsbmp,BMP))
$(eval $(call pkg_config_find_and_add_enabled,GIF,libnsgif,GIF))
$(eval $(call pkg_config_find_and_add_enabled,RSVG,librsvg-2.0,SVG))
@ -54,16 +51,22 @@ GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk \
-D_POSIX_C_SOURCE=200112L \
-D_NETBSD_SOURCE \
-DGTK_RESPATH=\"$(NETSURF_GTK_RESOURCES)\" \
$(WARNFLAGS) -I. -g \
$(shell $(PKG_CONFIG) --cflags gtk+-$(NETSURF_GTK_MAJOR).0) \
$(shell $(PKG_CONFIG) --cflags libhubbub libcurl) \
$(shell $(PKG_CONFIG) --cflags openssl) \
$(shell xml2-config --cflags)
$(WARNFLAGS) -I. -g
# non optional pkg-configed libs
$(eval $(call pkg_config_find_and_add,libcss,CSS))
$(eval $(call pkg_config_find_and_add,libdom,DOM))
$(eval $(call pkg_config_find_and_add,libhubbub,Hubbub))
$(eval $(call pkg_config_find_and_add,openssl,OpenSSL))
$(eval $(call pkg_config_find_and_add,libcurl,Curl ))
$(eval $(call pkg_config_find_and_add,gtk+-$(NETSURF_GTK_MAJOR).0,GTK-$(NETSURF_GTK_MAJOR)))
$(eval $(call pkg_config_find_and_add,gthread-2.0,GThread2))
$(eval $(call pkg_config_find_and_add,gmodule-2.0,GModule2))
$(eval $(call pkg_config_find_and_add,lcms,lcms))
GTKLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs gtk+-$(NETSURF_GTK_MAJOR).0 gthread-2.0 gmodule-2.0 lcms)
CFLAGS += $(GTKCFLAGS)
LDFLAGS += -lm $(GTKLDFLAGS)
LDFLAGS += -lm
# ---------------------------------------------------------------------------
# Windows flag setup