netsurf/gtk/Makefile.target
Vincent Sanders 571af764a5 completely remove remaining GTK theme code
Removes the theme code from GTK by moving the small remaining parts to
being implementation details within the toolbar implementation.
2016-03-09 11:37:09 +00:00

226 lines
8.1 KiB
Makefile

#
# Makefile for NetSurf GTK target
#
# This file is part of NetSurf
#
# ----------------------------------------------------------------------------
# GTK flag setup (using pkg-config)
# ----------------------------------------------------------------------------
# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
NETSURF_FEATURE_RSVG_CFLAGS := -DWITH_RSVG
NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG
NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
NETSURF_FEATURE_JS_CFLAGS := -DWITH_JS -DJS_HAS_FILE_OBJECT=0
NETSURF_FEATURE_MOZJS_CFLAGS := -DWITH_MOZJS -DJS_HAS_FILE_OBJECT=0
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,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))
$(eval $(call pkg_config_find_and_add_enabled,NSSVG,libsvgtiny,SVG))
$(eval $(call pkg_config_find_and_add_enabled,ROSPRITE,librosprite,Sprite))
$(eval $(call pkg_config_find_and_add_enabled,MOZJS,mozjs185,JavaScript))
$(eval $(call pkg_config_find_and_add_enabled,JS,mozilla-js,JavaScript))
$(eval $(call pkg_config_find_and_add_enabled,VIDEO,gstreamer-0.10,Video))
# GTK and GLIB flags to disable depricated usage
GTKDEPFLAGS := -DG_DISABLE_SINGLE_INCLUDES \
-DG_DISABLE_DEPRECATED \
-DGTK_DISABLE_SINGLE_INCLUDES \
-DGTK_MULTIHEAD_SAFE \
-DPANGO_DISABLE_DEPRECATED
# later editions of gtk 2 deprecate interfaces we rely upon for cursors
# -DGDK_PIXBUF_DISABLE_DEPRECATED
# libsexy currently means we cannot enable this
# -DGDK_DISABLE_DEPRECATED
# gtk3 is depricating interfaces we use a lot
ifeq ($(NETSURF_GTK_MAJOR),2)
GTKDEPFLAGS += -DGTK_DISABLE_DEPRECATED
endif
GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk -g \
$(GTKDEPFLAGS) \
-D_BSD_SOURCE \
-D_DEFAULT_SOURCE \
-D_XOPEN_SOURCE=600 \
-D_POSIX_C_SOURCE=200809L \
-D_NETBSD_SOURCE \
-DGTK_RESPATH=\"$(NETSURF_GTK_RESOURCES)\"
# non optional pkg-configed libs
$(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))
CFLAGS += $(GTKCFLAGS)
LDFLAGS += -lm
# ---------------------------------------------------------------------------
# Target setup
# ---------------------------------------------------------------------------
# The gtk binary target
EXETARGET := nsgtk
# The filter and target for split messages
MESSAGES_FILTER=gtk
MESSAGES_TARGET=gtk/res
# ---------------------------------------------------------------------------
# Windows flag setup
# ---------------------------------------------------------------------------
ifeq ($(HOST),Windows_NT)
CFLAGS += -U__STRICT_ANSI__
endif
# ----------------------------------------------------------------------------
# Builtin resource handling
# ----------------------------------------------------------------------------
# builtin resource sources
S_RESOURCE :=
# Path to GTK resources
NSGTK_RESOURCES_DIR := gtk/res
# Glib prior to 2.32 does not have GResource handling.
#
# This uses pkg-config to check for the minimum required version for
# this feature in a way similar to the pkg_config_find_and_add_enabled
# macro. Note we check for gmodule-2.0 which is a specific part of
# glib we require.
#
# It would be nice if we could check for this functionality rather
# than "knowing" the version but there does not appear to be a simple
# way to implement that.
#
NETSURF_FEATURE_GRESOURCE_AVAILABLE := $(shell $(PKG_CONFIG) --atleast-version=2.32 gmodule-2.0 && echo yes)
ifneq (,$(filter $(NETSURF_USE_GRESOURCE),AUTO YES))
ifeq ($(NETSURF_FEATURE_GRESOURCE_AVAILABLE),yes)
# Gresource use has been enabled
NETSURF_FEATURE_GRESOURCE_ENABLED := yes
#resource compiler tool
GLIB_COMPILE_RESOURCES := glib-compile-resources
CFLAGS += -DWITH_GRESOURCE
NETSURF_GRESOURCE_XML := $(NSGTK_RESOURCES_DIR)/netsurf.gresource.xml
MESSAGES_GRESOURCE_XML := $(NSGTK_RESOURCES_DIR)/messages.gresource.xml
# generate the netsurf gresource source files
$(OBJROOT)/netsurf_gresource.c: $(NETSURF_GRESOURCE_XML) $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir $(NSGTK_RESOURCES_DIR) --generate-dependencies $(NETSURF_GRESOURCE_XML))
$(VQ)echo "GRESORCE: $<"
$(Q)$(GLIB_COMPILE_RESOURCES) --generate-source --sourcedir $(NSGTK_RESOURCES_DIR) --target=$@ $<
S_RESOURCE += $(OBJROOT)/netsurf_gresource.c
# generate the messages gresource source file
$(OBJROOT)/messages_gresource.c: $(MESSAGES_GRESOURCE_XML) $(addsuffix /Messages,$(addprefix $(MESSAGES_TARGET)/,$(MESSAGES_LANGUAGES)))
$(VQ)echo "GRESORCE: $<"
$(Q)$(GLIB_COMPILE_RESOURCES) --generate-source --sourcedir $(NSGTK_RESOURCES_DIR) --target=$@ $<
S_RESOURCE += $(OBJROOT)/messages_gresource.c
endif
endif
# Build pixbufs as inlines if enabled
ifneq (,$(filter $(NETSURF_USE_INLINE_PIXBUF),AUTO YES))
ifneq ($(NETSURF_FEATURE_GRESOURCE_ENABLED),yes)
CFLAGS += -DWITH_BUILTIN_PIXBUF
GTK_IMAGE_favicon := favicon.png
GTK_IMAGE_netsurf := netsurf.xpm
GTK_IMAGE_menu_cursor := menu_cursor.png
# 1: input file
# 2: output file
# 3: bitmap name
define convert_image
# add converted pixbuf to builtin resource sources
S_RESOURCE += $(2)
$(2): $(1)
$(VQ)echo " INLINE: ${3}"
$(Q)echo "#include <gdk-pixbuf/gdk-pixdata.h>" > $(2)
$(Q)gdk-pixbuf-csource --extern --raw --name=$(3) $(1) >> $(2) || \
( rm -f $(2) && false )
endef
$(eval $(foreach V,$(filter GTK_IMAGE_%,$(.VARIABLES)),$(call convert_image,$(addprefix $(NSGTK_RESOURCES_DIR)/,$($(V))),$(OBJROOT)/$(patsubst GTK_IMAGE_%,%,$(V)).c,$(patsubst GTK_IMAGE_%,%,$(V))_pixdata)))
endif
endif
# ----------------------------------------------------------------------------
# Source file setup
# ----------------------------------------------------------------------------
# S_GTK are sources purely for the GTK build
S_GTK := font_pango.c bitmap.c gui.c schedule.c plotters.c \
treeview.c scaffolding.c gdk.c completion.c login.c throbber.c \
selection.c history.c window.c fetch.c download.c menu.c \
print.c search.c tabs.c toolbar.c gettext.c \
compat.c cookies.c hotlist.c viewdata.c viewsource.c \
preferences.c about.c ssl_cert.c resources.c
S_GTK := $(addprefix gtk/,$(S_GTK))
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image
# are not yet available
SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_RESOURCE) $(S_GTK)
# ----------------------------------------------------------------------------
# Install target
# ----------------------------------------------------------------------------
GTK_RESOURCES_LIST := \
languages SearchEngines toolbarIndices ca-bundle.txt \
default.css adblock.css quirks.css internal.css \
credits.html licence.html welcome.html maps.html Messages \
default.ico favicon.png netsurf.png netsurf.xpm netsurf-16x16.xpm \
arrow_down_8x32.png
GTK_RESOURCES_LIST := \
$(addprefix gtk/res/, $(GTK_RESOURCES_LIST)) \
$(wildcard gtk/res/*.gtk$(NETSURF_GTK_MAJOR).ui)
# translations with more than just Messages files
GTK_TRANSLATIONS_HTML := de en fr it ja nl
install-gtk:
$(Q)mkdir -p $(DESTDIR)$(NETSURF_GTK_BIN)
$(Q)install nsgtk $(DESTDIR)$(NETSURF_GTK_BIN)netsurf
$(Q)mkdir -p $(DESTDIR)$(NETSURF_GTK_RESOURCES)icons
$(Q)install -m 0644 gtk/res/icons/*.png $(DESTDIR)$(NETSURF_GTK_RESOURCES)/icons
$(Q)mkdir -p $(DESTDIR)$(NETSURF_GTK_RESOURCES)throbber
$(Q)install -m 0644 gtk/res/throbber/*.png $(DESTDIR)$(NETSURF_GTK_RESOURCES)/throbber
$(Q)tar -c -h -C gtk/res -f - $(GTK_TRANSLATIONS_HTML) | tar -xv -C $(DESTDIR)$(NETSURF_GTK_RESOURCES) -f -
$(Q)install -m 0644 $(GTK_RESOURCES_LIST) $(DESTDIR)$(NETSURF_GTK_RESOURCES)
# ----------------------------------------------------------------------------
# Package target
# ----------------------------------------------------------------------------
package-gtk: