summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile25
-rw-r--r--gtk/Makefile.target25
2 files changed, 39 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index d8ce8a657..91f3aac08 100644
--- a/Makefile
+++ b/Makefile
@@ -318,6 +318,31 @@ 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)
# 2: pkg-config required modules for feature
# 3: Human-readable name for the feature
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index 3da4346a1..f9b5436af 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -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