summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile61
-rw-r--r--Makefile.config21
-rw-r--r--desktop/print.c3
-rw-r--r--gtk/gtk_print.c6
-rw-r--r--gtk/gtk_scaffolding.c17
-rw-r--r--pdf/font_haru.c8
-rw-r--r--pdf/pdf_plotters.c5
-rw-r--r--utils/config.h5
8 files changed, 107 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 630c4b769..c389c416e 100644
--- a/Makefile
+++ b/Makefile
@@ -34,7 +34,7 @@ all: all-program
# In both cases HOST make variable is empty and we recover from that by
# assuming we're building on RISC OS.
# In case you don't see anything printed (including the warning), you
-# have an update to date RISC OS build sytem. ;-)
+# have an update to date RISC OS build system. ;-)
HOST := $(shell uname -s)
ifeq ($(HOST),)
HOST := riscos
@@ -138,6 +138,8 @@ endif
OBJROOT := build-$(HOST)-$(TARGET)$(SUBTARGET)
+include Makefile.config
+
ifeq ($(HOST),riscos)
LDFLAGS := -Xlinker -symbols=$(OBJROOT)/sym -lxml2 -lz -lm -lcurl -lssl -lcrypto -lmng -ljpeg \
-lcares
@@ -151,29 +153,68 @@ else
LDFLAGS := $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl openssl)
endif
# Common libraries without pkgconfig support:
-LDFLAGS += -lz -lm -lmng -ljpeg -lhpdf -lpng
+LDFLAGS += -lz -lm -lmng -ljpeg -lpng
+ifeq ($(NETSURF_USE_HARU_PDF),YES)
+LDFLAGS += -lhpdf
+CFLAGS += -DWITH_PDF_EXPORT
+endif
endif
ifeq ($(TARGET),gtk)
# Building for GTK, we need the GTK flags
+FEATURE_CFLAGS :=
+FEATURE_LDFLAGS :=
+
+# 1: Feature name (ie, NETSURF_USE_RSVG -> RSVG)
+# 2: pkg-config required modules for feature
+# 3: Human-readable name for the feature
+define pkg_config_find_and_add
+
+ ifneq ($$(NETSURF_USE_$(1)),NO)
+ NETSURF_FEATURE_$(1)_AVAILABLE := $$(shell pkg-config --exists $(2) && echo yes)
+ ifeq ($$(NETSURF_USE_$(1)),AUTO)
+ ifeq ($$(NETSURF_FEATURE_$(1)_AVAILABLE),yes)
+ NETSURF_USE_$(1) := YES
+ endif
+ endif
+ ifeq ($$(NETSURF_USE_$(1)),YES)
+ ifeq ($$(NETSURF_FEATURE_$(1)_AVAILABLE),yes)
+ FEATURE_CFLAGS += $$(shell pkg-config --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
+ FEATURE_LDFLAGS += $$(shell pkg-config --libs $(2)) $$(NETSURF_FEATURE_$(1)_LDFLAGS)
+ $$(info Auto-configuration enabled $(3) ($(2)).)
+ else
+ $$(error Unable to find library for: $$(3) ($(2))
+ endif
+ endif
+ endif
+
+endef
+
+# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
+NETSURF_FEATURE_RSVG_CFLAGS := -DWITH_RSVG
+NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
+
+# add a line similar to below for each optional pkg-configed lib here
+$(eval $(call pkg_config_find_and_add,RSVG,librsvg-2.0,SVG rendering))
+$(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,RISC OS sprite rendering))
+
GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk \
-DGTK_DISABLE_DEPRECATED \
-D_BSD_SOURCE \
-D_XOPEN_SOURCE=600 \
-D_POSIX_C_SOURCE=200112L \
-D_NETBSD_SOURCE \
- $(WARNFLAGS) -I. -I../../libsprite/trunk/ -g $(OPT2FLAGS) \
- $(shell $(PKG_CONFIG) --cflags libglade-2.0 gtk+-2.0 librsvg-2.0) \
- $(shell $(PKG_CONFIG) --cflags librosprite) \
+ $(WARNFLAGS) -I. -g $(OPT2FLAGS) \
+ $(shell $(PKG_CONFIG) --cflags libglade-2.0 gtk+-2.0) \
$(shell xml2-config --cflags)
+GTKCFLAGS += $(FEATURE_CFLAGS)
+
+GTKLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs libglade-2.0 gtk+-2.0 gthread-2.0 gmodule-2.0 lcms)
+GTKLDFLAGS += $(FEATURE_LDFLAGS)
-#GTKLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs libglade-2.0 gtk+-2.0 gthread-2.0 gmodule-2.0 librosprite)
-GTKLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs libglade-2.0 gtk+-2.0 gthread-2.0 gmodule-2.0 librsvg-2.0 librosprite)
-#CFLAGS += $(GTKCFLAGS) -g
-#LDFLAGS += $(GTKLDFLAGS) $(shell $(PKG_CONFIG) --libs lcms) -lsvgtiny
CFLAGS += $(GTKCFLAGS)
-LDFLAGS += $(GTKLDFLAGS) $(shell $(PKG_CONFIG) --libs lcms)
+LDFLAGS += $(GTKLDFLAGS)
ifeq ($(HOST),Windows_NT)
CFLAGS += -U__STRICT_ANSI__
diff --git a/Makefile.config b/Makefile.config
new file mode 100644
index 000000000..d89aa9520
--- /dev/null
+++ b/Makefile.config
@@ -0,0 +1,21 @@
+#
+# NetSurf build configuration
+#
+# Some of these options support an 'AUTO' option, as well as YES and NO. If
+# AUTO is set, the Makefile will attempt to detect if that feature is available
+
+# Use libharu to enable PDF export and GTK printing support. There is no
+# auto-detection available for this, as it does not have a pkg-config file.
+NETSURF_USE_HARU_PDF=YES
+
+# The following options are GTK-specific
+ifeq ($(TARGET),gtk)
+
+# Use librsvg in conjunction with Cairo to render SVG images
+NETSURF_USE_RSVG=AUTO
+
+# Use James Shaw's librosprite for rendering RISC OS Sprites
+NETSURF_USE_ROSPRITE=AUTO
+
+endif
+
diff --git a/desktop/print.c b/desktop/print.c
index 0852fa34c..0b96c852c 100644
--- a/desktop/print.c
+++ b/desktop/print.c
@@ -20,6 +20,7 @@
* Output-in-pages implementation
*/
+#ifdef WITH_PDF_EXPORT
#include "desktop/print.h"
#include "desktop/printer.h"
@@ -278,3 +279,5 @@ struct print_settings *print_make_settings(print_configuration configuration)
return settings;
}
+
+#endif /* WITH_PDF_EXPORT */
diff --git a/gtk/gtk_print.c b/gtk/gtk_print.c
index 6056eec61..f32fcc64e 100644
--- a/gtk/gtk_print.c
+++ b/gtk/gtk_print.c
@@ -23,7 +23,9 @@
* plotters, printer) are here.
* Most of the plotters have been copied from the gtk_plotters.c file.
*/
-
+
+#include "utils/config.h"
+#ifdef WITH_PDF_EXPORT
#include <math.h>
#include <gdk/gdk.h>
@@ -571,3 +573,5 @@ void gtk_print_signal_end_print(GtkPrintOperation *operation,
LOG(("End print"));
print_cleanup(content_to_print, &gtk_printer);
}
+
+#endif /* WITH_PDF_EXPORT */
diff --git a/gtk/gtk_scaffolding.c b/gtk/gtk_scaffolding.c
index 1165d785a..4580c9341 100644
--- a/gtk/gtk_scaffolding.c
+++ b/gtk/gtk_scaffolding.c
@@ -189,9 +189,11 @@ static struct menu_events menu_events[] = {
MENUEVENT(new_window),
MENUEVENT(open_location),
MENUEVENT(open_file),
+#ifdef WITH_PDF_EXPORT
MENUEVENT(export_pdf),
MENUEVENT(print),
MENUEVENT(print_preview),
+#endif
MENUEVENT(close_window),
MENUEVENT(quit),
@@ -478,6 +480,8 @@ MENUHANDLER(open_file)
return TRUE;
}
+#ifdef WITH_PDF_EXPORT
+
MENUHANDLER(export_pdf){
GtkWidget *save_dialog;
@@ -558,6 +562,8 @@ MENUHANDLER(print_preview){
return TRUE;
}
+#endif /* WITH_PDF_EXPORT */
+
MENUHANDLER(close_window)
{
struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
@@ -1129,8 +1135,15 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
/* hides redundant popup menu items */
GList *widgets = glade_xml_get_widget_prefix (g->popup_xml, "menupopup");
for (; widgets != NULL; widgets = widgets->next)
- gtk_widget_hide (GTK_WIDGET(widgets->data));
-
+ gtk_widget_hide(GTK_WIDGET(widgets->data));
+
+ /* disable PDF-requiring menu items */
+#ifndef WITH_PDF_EXPORT
+ gtk_widget_set_sensitive(GET_WIDGET("export_pdf"), FALSE);
+ gtk_widget_set_sensitive(GET_WIDGET("print"), FALSE);
+ gtk_widget_set_sensitive(GET_WIDGET("print_preview"), FALSE);
+#endif
+
/* finally, show the window. */
gtk_widget_show(GTK_WIDGET(g->window));
diff --git a/pdf/font_haru.c b/pdf/font_haru.c
index 045d481a2..555570ef0 100644
--- a/pdf/font_haru.c
+++ b/pdf/font_haru.c
@@ -22,7 +22,10 @@
* The functions were written to implement the same interface as the Pango ones
* so that the usage of the latter wouldn't have to be modified.
*/
-
+
+#include "utils/config.h"
+#ifdef WITH_PDF_EXPORT
+
#define FONT_HARU_DEBUG
#include <assert.h>
@@ -371,3 +374,6 @@ bool haru_nsfont_apply_style(const struct css_style *style,
return true;
}
+
+#endif /* WITH_PDF_EXPORT */
+
diff --git a/pdf/pdf_plotters.c b/pdf/pdf_plotters.c
index 50d7067eb..c641eef8f 100644
--- a/pdf/pdf_plotters.c
+++ b/pdf/pdf_plotters.c
@@ -22,6 +22,9 @@
* boundaries a 'fuzzy' bottom margin.
*/
+#include "utils/config.h"
+#ifdef WITH_PDF_EXPORT
+
#include <stdlib.h>
#include <string.h>
#include "hpdf.h"
@@ -771,4 +774,6 @@ void pdf_page_apply_notext_clip()
#endif
}
+#endif /* WITH_PDF_EXPORT */
+
diff --git a/utils/config.h b/utils/config.h
index 4bf3598b3..91eadb6fa 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -75,16 +75,11 @@ char *strndup(const char *s, size_t n);
#else
/* We're likely to have a working mmap() */
#define WITH_MMAP
- #if !defined(DEBUG_BUILD)
- /* Use librsvg and Cairo for rendering SVG */
- #define WITH_RSVG
- #endif
#endif
#if defined(riscos) || defined(DEBUG_BUILD)
/* Export modules */
#define WITH_SAVE_COMPLETE
#define WITH_DRAW_EXPORT
- #define WITH_PDF_EXPORT
#endif
/* Configuration sanity checks: */