[API] Add version macros and functions
authorBehdad Esfahbod <behdad@behdad.org>
Fri, 6 May 2011 01:31:04 +0000 (21:31 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Fri, 6 May 2011 01:31:04 +0000 (21:31 -0400)
Step version up to 0.5.0.

Also, fix to pass "make distcheck"

configure.ac
src/Makefile.am
src/check-c-linkage-decls.sh
src/hb-common.cc
src/hb-version.h.in [new file with mode: 0644]
src/hb.h
test/Makefile.am

index 761a213..bb25950 100644 (file)
@@ -1,6 +1,6 @@
 AC_PREREQ([2.64])
 AC_INIT([harfbuzz],
-        [0.3],
+        [0.5.0],
         [http://bugs.freedesktop.org/enter_bug.cgi?product=harfbuzz],
         [harfbuzz],
         [http://freedesktop.org/wiki/Software/harfbuzz])
@@ -9,11 +9,8 @@ AC_CONFIG_SRCDIR([harfbuzz.pc.in])
 AC_CONFIG_HEADERS([config.h])
 
 AM_INIT_AUTOMAKE([1.11.1 gnu dist-bzip2 no-dist-gzip -Wall no-define])
-
 AM_SILENT_RULES([yes])
 
-AC_CANONICAL_HOST
-
 # Check for programs
 AC_PROG_CC
 AM_PROG_CC_C_O
@@ -23,11 +20,25 @@ AC_PROG_CXX
 LT_PREREQ([2.2])
 LT_INIT([disable-static])
 
+# Version
+m4_define(version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]]))
+HB_VERSION_MAJOR=m4_argn(1,version_triplet)
+HB_VERSION_MINOR=m4_argn(2,version_triplet)
+HB_VERSION_MICRO=m4_argn(3,version_triplet)
+HB_VERSION=AC_PACKAGE_VERSION
+
+AC_SUBST(HB_VERSION_MAJOR)
+AC_SUBST(HB_VERSION_MINOR)
+AC_SUBST(HB_VERSION_MICRO)
+AC_SUBST(HB_VERSION)
+
+
 # Functions and headers
 AC_CHECK_FUNCS(mprotect sysconf getpagesize)
 AC_CHECK_HEADERS(unistd.h sys/mman.h)
 
 # Compiler flags
+AC_CANONICAL_HOST
 if test "x$GCC" = "xyes"; then
 
        # Make sure we don't link to libstdc++
@@ -100,12 +111,13 @@ if $have_freetype; then
 fi
 AM_CONDITIONAL(HAVE_FREETYPE, $have_freetype)
 
-dnl ==========================================================================
+dnl ===========================================================================
 
 AC_CONFIG_FILES([
-harfbuzz.pc
 Makefile
+harfbuzz.pc
 src/Makefile
+src/hb-version.h
 test/Makefile
 ])
 
index 0a7edb3..73ac547 100644 (file)
@@ -2,6 +2,9 @@
 
 NULL =
 EXTRA_DIST =
+CLEANFILES =
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
 
 # The following warning options are useful for debugging: -Wpadded -Wcast-align
 #AM_CXXFLAGS =
@@ -35,6 +38,7 @@ HBHEADERS = \
        hb-font.h \
        hb-shape.h \
        hb-unicode.h \
+       hb-version.h \
        $(NULL)
 
 HBSOURCES += \
@@ -61,6 +65,10 @@ HBHEADERS += \
        hb-ot-tag.h \
        $(NULL)
 
+MAINTAINERCLEANFILES = \
+       $(srcdir)/hb-version.h \
+       $(NULL)
+
 if HAVE_GLIB
 HBCFLAGS += $(GLIB_CFLAGS)
 HBLIBS   += $(GLIB_LIBS)
@@ -99,6 +107,7 @@ libharfbuzz_la_SOURCES = $(HBSOURCES) $(HBHEADERS)
 libharfbuzz_la_CPPFLAGS = $(HBCFLAGS)
 libharfbuzz_la_LIBADD = $(HBLIBS)
 pkginclude_HEADERS = $(HBHEADERS)
+nodist_pkginclude_HEADERS = hb-version.h
 
 
 GENERATORS = \
index 711d089..ffdb9e3 100755 (executable)
@@ -8,7 +8,7 @@ stat=0
 
 cd "$srcdir"
 
-for x in hb-*.c hb-*.cc hb-*.h hb-*.hh ; do
+for x in hb-*.cc hb-*.h hb-*.hh ; do
        if ! grep -q HB_BEGIN_DECLS "$x" || ! grep -q HB_END_DECLS "$x"; then
                echo "Ouch, file $x does not HB_BEGIN_DECLS / HB_END_DECLS"
                stat=1
index b000340..49f3eb8 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "hb-private.hh"
 
+#include "hb-version.h"
+
 #include "hb-mutex-private.hh"
 #include "hb-object-private.hh"
 
@@ -308,4 +310,31 @@ hb_user_data_array_t::get (hb_user_data_key_t *key)
 }
 
 
+/* hb_version */
+
+void
+hb_version (unsigned int *major,
+           unsigned int *minor,
+           unsigned int *micro)
+{
+  *major = HB_VERSION_MAJOR;
+  *minor = HB_VERSION_MINOR;
+  *micro = HB_VERSION_MICRO;
+}
+
+const char *
+hb_version_string (void)
+{
+  return HB_VERSION_STRING;
+}
+
+hb_bool_t
+hb_version_check (unsigned int major,
+                 unsigned int minor,
+                 unsigned int micro)
+{
+  return HB_VERSION_CHECK (major, minor, micro);
+}
+
+
 HB_END_DECLS
diff --git a/src/hb-version.h.in b/src/hb-version.h.in
new file mode 100644 (file)
index 0000000..47a9b30
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2011  Google, Inc.
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#ifndef HB_VERSION_H
+#define HB_VERSION_H
+
+#include "hb-common.h"
+
+HB_BEGIN_DECLS
+
+
+#define HB_VERSION_MAJOR @HB_VERSION_MAJOR@
+#define HB_VERSION_MINOR @HB_VERSION_MINOR@
+#define HB_VERSION_MICRO @HB_VERSION_MICRO@
+
+#define HB_VERSION_STRING "@HB_VERSION@"
+
+#define HB_VERSION_CHECK(major,minor,micro) \
+       ((major)*10000+(minor)*100+(micro) >= \
+        HB_VERSION_MAJOR*10000+HB_VERSION_MINOR*100+HB_VERSION_MICRO)
+
+
+void
+hb_version (unsigned int *major,
+           unsigned int *minor,
+           unsigned int *micro);
+
+const char *
+hb_version_string (void);
+
+hb_bool_t
+hb_version_check (unsigned int major,
+                 unsigned int minor,
+                 unsigned int micro);
+
+
+HB_END_DECLS
+
+#endif /* HB_VERSION_H */
index b75998e..0a2ebd9 100644 (file)
--- a/src/hb.h
+++ b/src/hb.h
@@ -33,6 +33,7 @@
 #include "hb-font.h"
 #include "hb-shape.h"
 #include "hb-unicode.h"
+#include "hb-version.h"
 
 HB_BEGIN_DECLS
 HB_END_DECLS
index 56d6118..c744795 100644 (file)
@@ -6,6 +6,8 @@ if HAVE_GLIB
 AM_CPPFLAGS = -I$(top_srcdir)/src/ $(GLIB_CFLAGS)
 LDADD = $(top_builddir)/src/libharfbuzz.la $(GLIB_LIBS)
 
+EXTRA_DIST += hb-test.h
+
 check_PROGRAMS = $(TEST_PROGS)
 noinst_PROGRAMS = $(TEST_PROGS)