Permalink
Browse files

Markdown: Fix Autotools to support bundled peg-markdown

Default is to try and use system's Discount library and if not
available or configured with --enable-peg-markdown, use the
bundled peg-markdown library.
  • Loading branch information...
1 parent e244ea5 commit be48f09750c1ec2282405d9f70e8f77799e82cbd @b4n b4n committed with codebrainz Mar 1, 2013
View
@@ -1,6 +1,50 @@
+dnl _CHECK_LIBMARKDOWN([action-if-found], [action-if-not-found])
+dnl Searches for libmarkdown and define HAVE_MKDIO_H, LIBMARKDOWN_LIBS and
+dnl LIBMARKDOWN_CFLAGS
+AC_DEFUN([_CHECK_LIBMARKDOWN],
+[
+ old_LIBS=$LIBS
+ LIBS=
+ LIBMARKDOWN_LIBS=
+ LIBMARKDOWN_CFLAGS=
+ AC_SEARCH_LIBS([mkd_compile], [markdown],
+ [AC_CHECK_HEADERS([mkdio.h],
+ [LIBMARKDOWN_LIBS=$LIBS
+ LIBMARKDOWN_CFLAGS=
+ $1],
+ [$2])],
+ [$2])
+ AC_SUBST([LIBMARKDOWN_CFLAGS])
+ AC_SUBST([LIBMARKDOWN_LIBS])
+ LIBS=$old_LIBS
+])
+
AC_DEFUN([GP_CHECK_MARKDOWN],
[
GP_ARG_DISABLE([markdown], [auto])
+ AC_ARG_ENABLE([peg-markdown],
+ [AS_HELP_STRING([--enable-peg-markdown],
+ [Whether to use Peg-Markdown library [[default=auto]]])],
+ [enable_peg_markdown=$enableval],
+ [enable_peg_markdown=auto])
+
+ dnl check which markdown library to use
+ AS_IF([test "x$enable_markdown" != xno &&
+ test "x$enable_peg_markdown" != xyes],
+ [_CHECK_LIBMARKDOWN([enable_peg_markdown=no],
+ [AS_IF([test "x$enable_peg_markdown" != xno],
+ [enable_peg_markdown=yes],
+ [test "x$enable_markdown" = xyes],
+ [AC_MSG_ERROR([libmarkdown not found])],
+ [enable_markdown=no
+ AC_MSG_WARN([libmarkdown not found, disabling Markdown plugin])])])])
+ AM_CONDITIONAL([MARKDOWN_PEG_MARKDOWN],
+ [test "x$enable_peg_markdown" = xyes])
+ dnl fancy status
+ AS_IF([test "x$enable_peg_markdown" = xyes],
+ [markdown_library=peg-markdown],
+ [markdown_library=libmarkdown])
+ GP_STATUS_FEATURE_ADD([Markdown library], [$markdown_library])
GTK_VERSION=2.16
WEBKIT_VERSION=1.1.13
@@ -14,7 +58,6 @@ AC_DEFUN([GP_CHECK_MARKDOWN],
AC_CONFIG_FILES([
markdown/Makefile
- markdown/discount/Makefile
markdown/src/Makefile
markdown/docs/Makefile
markdown/peg-markdown/Makefile
@@ -1,5 +1,11 @@
include $(top_srcdir)/build/vars.auxfiles.mk
-SUBDIRS = peg-markdown src docs
+SUBDIRS =
+
+if MARKDOWN_PEG_MARKDOWN
+SUBDIRS += peg-markdown
+endif
+
+SUBDIRS += src docs
plugin = markdown
@@ -17,3 +17,5 @@ LEG = peg-0.1.9/leg
markdown_parser.c: markdown_parser.leg $(LEG)
$(AM_V_GEN)$(LEG) -o $@ $<
+
+EXTRA_DIST = markdown_parser.leg
@@ -7,5 +7,4 @@ leg_SOURCES = \
tree.h \
version.h
-EXTRA_DIST = \
- leg.leg
+EXTRA_DIST = leg.leg
@@ -18,11 +18,17 @@ markdown_la_CFLAGS = \
$(MARKDOWN_CFLAGS) \
-DMARKDOWN_DATA_DIR=\"$(pkgdatadir)/markdown\" \
-DMARKDOWN_DOC_DIR=\"$(docdir)/markdown\" \
- -DMARKDOWN_HELP_FILE=\"$(docdir)/markdown/html/help.html\" \
- -I$(top_srcdir)/markdown/peg-markdown
+ -DMARKDOWN_HELP_FILE=\"$(docdir)/markdown/html/help.html\"
markdown_la_LIBADD = \
- $(MARKDOWN_LIBS) \
- $(top_builddir)/markdown/peg-markdown/libpegmarkdown.la
+ $(MARKDOWN_LIBS)
+
+if MARKDOWN_PEG_MARKDOWN
+markdown_la_CFLAGS += -DFULL_PRICE -I$(top_srcdir)/markdown/peg-markdown
+markdown_la_LIBADD += $(top_builddir)/markdown/peg-markdown/libpegmarkdown.la
+else
+markdown_la_CFLAGS += $(LIBMARKDOWN_CFLAGS)
+markdown_la_LIBADD += $(LIBMARKDOWN_LIBS)
+endif
include $(top_srcdir)/build/cppcheck.mk
@@ -19,6 +19,7 @@
* MA 02110-1301, USA.
*/
+#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include <webkit/webkitwebview.h>

0 comments on commit be48f09

Please sign in to comment.