diff options
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | ChangeLog | 0 | ||||
-rw-r--r-- | Makefile.am | 10 | ||||
-rw-r--r-- | NEWS | 1 | ||||
-rwxr-xr-x | autogen.sh | 31 | ||||
-rw-r--r-- | configure.ac | 108 | ||||
-rw-r--r-- | m4/Makefile.am | 2 | ||||
-rw-r--r-- | m4/as-compiler-flag.m4 | 33 | ||||
-rw-r--r-- | m4/tp-compiler-flag.m4 | 36 | ||||
-rw-r--r-- | m4/tp-compiler-warnings.m4 | 40 | ||||
-rw-r--r-- | tools/Makefile.am | 5 | ||||
-rw-r--r-- | tools/check-c-style.sh | 56 | ||||
-rw-r--r-- | tools/check-coding-style.mk | 17 | ||||
-rw-r--r-- | tools/check-misc.sh | 13 | ||||
-rw-r--r-- | tools/check-whitespace.sh | 17 | ||||
-rw-r--r-- | wocky/Makefile.am | 78 |
16 files changed, 448 insertions, 0 deletions
@@ -0,0 +1 @@ +Sjoerd Simons <sjoerd.simons@collabora.co.uk> diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ChangeLog diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..19e838d --- /dev/null +++ b/Makefile.am @@ -0,0 +1,10 @@ +ACLOCAL_AMFLAGS = -I m4 + +SUBDIRS = wocky tools m4 + +dist-hook: + chmod u+w ${distdir}/ChangeLog + if test -d ${top_srcdir}/.git; then \ + git log --stat > ${distdir}/ChangeLog || \ + git log > ${distdir}/ChangeLog; \ + fi @@ -0,0 +1 @@ +No news is good news diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..7f08e9b --- /dev/null +++ b/autogen.sh @@ -0,0 +1,31 @@ +#!/bin/sh +set -e + +if test -n "$AUTOMAKE"; then + : # don't override an explicit user request +elif automake-1.9 --version >/dev/null 2>/dev/null && \ + aclocal-1.9 --version >/dev/null 2>/dev/null; then + # If we have automake-1.9, use it. This helps to ensure that our build + # system doesn't accidentally grow automake-1.10 dependencies. + AUTOMAKE=automake-1.9 + export AUTOMAKE + ACLOCAL=aclocal-1.9 + export ACLOCAL +fi + +autoreconf -i -f + +run_configure=true +for arg in $*; do + case $arg in + --no-configure) + run_configure=false + ;; + *) + ;; + esac +done + +if test $run_configure = true; then + ./configure "$@" +fi diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..7ae22c7 --- /dev/null +++ b/configure.ac @@ -0,0 +1,108 @@ +AC_PREREQ([2.59]) + +# Making releases: +# set the new version number: +# odd minor -> development series +# even minor -> stable series +# increment micro for each release within a series +# set wockynano_version to 0. + +m4_define([wocky_major_version], [0]) +m4_define([wocky_minor_version], [0]) +m4_define([wocky_micro_version], [0]) +m4_define([wocky_nano_version], [0]) + +# Some magic +m4_define([wockybase_version], + [wockymajor_version.wockyminor_version.wockymicro_version]) +m4_define([wockyversion], + [m4_if(wockynano_version, 0, [wockybase_version], [wockybase_version].[wockynano_version])])dnl + +AC_INIT([Wocky], [wockyversion]) + +AC_CONFIG_MACRO_DIR([m4]) + +AM_INIT_AUTOMAKE([1.9 -Wno-portability tar-ustar]) +AM_PROG_LIBTOOL +AM_CONFIG_HEADER(config.h) + +dnl check for tools +AC_PROG_CC +AC_PROG_CC_STDC +AM_PROG_AS +AM_PROG_MKDIR_P + +dnl decide error flags +ifelse(wockynano_version, 0, + [ official_release=yes ], + [ official_release=no ]) + +TP_COMPILER_WARNINGS([ERROR_CFLAGS], [test "x$official_release" = xno], + [all \ + extra \ + declaration-after-statement \ + shadow \ + strict-prototypes \ + missing-prototypes \ + sign-compare \ + nested-externs \ + pointer-arith \ + format-security \ + init-self], + [missing-field-initializers \ + unused-parameter]) +AC_SUBST([ERROR_CFLAGS]) + +ifelse(wockynano_version, 0, + [ # Wocky is version x.y.z - disable coding style checks by default +AC_ARG_ENABLE(coding-style-checks, + AC_HELP_STRING([--enable-coding-style-checks], + [check coding style using grep]), + [ENABLE_CODING_STYLE_CHECKS=$enableval], [ENABLE_CODING_STYLE_CHECKS=no] ) + ], + [ # Wocky is version x.y.z.1 - enable coding style checks by default +AC_ARG_ENABLE(coding-style-checks, + AC_HELP_STRING([--disable-coding-style-checks], + [don't check coding style using grep]), + [ENABLE_CODING_STYLE_CHECKS=$enableval], [ENABLE_CODING_STYLE_CHECKS=yes]) + ]) + +if test x$enable_debug = xyes; then + AC_DEFINE(ENABLE_DEBUG, [], [Enable debug code]) +fi + +AC_SUBST([ENABLE_CODING_STYLE_CHECKS]) + +dnl Check for code generation tools +AC_HEADER_STDC([]) +AC_C_INLINE + +dnl Check endianness (Needed for the sha1 implementation) +AC_C_BIGENDIAN + +dnl GTK docs +GTK_DOC_CHECK + +dnl Check for Glib +PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.16, gobject-2.0 >= 2.16, gthread-2.0 >= +2.4, gnio]) + +AC_SUBST(GLIB_CFLAGS) +AC_SUBST(GLIB_LIBS) + +GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` +AC_SUBST(GLIB_GENMARSHAL) + +dnl Check for libxml2 +PKG_CHECK_MODULES(LIBXML2, [libxml-2.0]) + +AC_SUBST(LIBXML2_CFLAGS) +AC_SUBST(LIBXML2_LIBS) + +AC_SUBST(PACKAGE_STRING) + +AC_OUTPUT( Makefile \ + wocky/Makefile \ + m4/Makefile \ + tools/Makefile \ +) diff --git a/m4/Makefile.am b/m4/Makefile.am new file mode 100644 index 0000000..5e1bb50 --- /dev/null +++ b/m4/Makefile.am @@ -0,0 +1,2 @@ +EXTRA_DIST = \ +as-compiler-flag.m4 diff --git a/m4/as-compiler-flag.m4 b/m4/as-compiler-flag.m4 new file mode 100644 index 0000000..605708a --- /dev/null +++ b/m4/as-compiler-flag.m4 @@ -0,0 +1,33 @@ +dnl as-compiler-flag.m4 0.1.0 + +dnl autostars m4 macro for detection of compiler flags + +dnl David Schleef <ds@schleef.org> + +dnl $Id: as-compiler-flag.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $ + +dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED]) +dnl Tries to compile with the given CFLAGS. +dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags, +dnl and ACTION-IF-NOT-ACCEPTED otherwise. + +AC_DEFUN([AS_COMPILER_FLAG], +[ + AC_MSG_CHECKING([to see if compiler understands $1]) + + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $1" + + AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) + CFLAGS="$save_CFLAGS" + + if test "X$flag_ok" = Xyes ; then + $2 + true + else + $3 + true + fi + AC_MSG_RESULT([$flag_ok]) +]) + diff --git a/m4/tp-compiler-flag.m4 b/m4/tp-compiler-flag.m4 new file mode 100644 index 0000000..fc05e9e --- /dev/null +++ b/m4/tp-compiler-flag.m4 @@ -0,0 +1,36 @@ +dnl A version of AS_COMPILER_FLAG that supports both C and C++. +dnl Based on: + +dnl as-compiler-flag.m4 0.1.0 +dnl autostars m4 macro for detection of compiler flags +dnl David Schleef <ds@schleef.org> +dnl $Id: as-compiler-flag.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $ + +dnl TP_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED]) +dnl Tries to compile with the given CFLAGS and CXXFLAGS. +dnl +dnl Runs ACTION-IF-ACCEPTED if the compiler for the currently selected +dnl AC_LANG can compile with the flags, and ACTION-IF-NOT-ACCEPTED otherwise. + +AC_DEFUN([TP_COMPILER_FLAG], +[ + AC_MSG_CHECKING([to see if compiler understands $1]) + + save_CFLAGS="$CFLAGS" + save_CXXFLAGS="$CXXFLAGS" + CFLAGS="$CFLAGS $1" + CXXFLAGS="$CXXFLAGS $1" + + AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) + CFLAGS="$save_CFLAGS" + CXXFLAGS="$save_CXXFLAGS" + + if test "X$flag_ok" = Xyes ; then + $2 + true + else + $3 + true + fi + AC_MSG_RESULT([$flag_ok]) +]) diff --git a/m4/tp-compiler-warnings.m4 b/m4/tp-compiler-warnings.m4 new file mode 100644 index 0000000..fab5dc8 --- /dev/null +++ b/m4/tp-compiler-warnings.m4 @@ -0,0 +1,40 @@ +dnl TP_COMPILER_WARNINGS(VARIABLE, WERROR_BY_DEFAULT, DESIRABLE, UNDESIRABLE) +dnl $1 (VARIABLE): the variable to put flags into +dnl $2 (WERROR_BY_DEFAULT): a command returning true if -Werror should be the +dnl default +dnl $3 (DESIRABLE): warning flags we want (e.g. all extra shadow) +dnl $4 (UNDESIRABLE): warning flags we don't want (e.g. +dnl missing-field-initializers unused-parameter) +AC_DEFUN([TP_COMPILER_WARNINGS], +[ + AC_REQUIRE([AC_ARG_ENABLE])dnl + AC_REQUIRE([AC_HELP_STRING])dnl + AC_REQUIRE([TP_COMPILER_FLAG])dnl + + tp_warnings="" + for tp_flag in $3; do + TP_COMPILER_FLAG([-W$tp_flag], [tp_warnings="$tp_warnings -W$tp_flag"]) + done + + tp_error_flags="-Werror" + TP_COMPILER_FLAG([-Werror], [tp_werror=yes], [tp_werror=no]) + + for tp_flag in $4; do + TP_COMPILER_FLAG([-Wno-$tp_flag], + [tp_warnings="$tp_warnings -Wno-$tp_flag"]) + TP_COMPILER_FLAG([-Wno-error=$tp_flag], + [tp_error_flags="$tp_error_flags -Wno-error=$tp_flag"], [tp_werror=no]) + done + + AC_ARG_ENABLE([Werror], + AC_HELP_STRING([--disable-Werror], + [compile without -Werror (normally enabled in development builds)]), + tp_werror=$enableval, :) + + if test "x$tp_werror" = xyes && $2; then + $1="$tp_warnings $tp_error_flags" + else + $1="$tp_warnings" + fi + +]) diff --git a/tools/Makefile.am b/tools/Makefile.am new file mode 100644 index 0000000..7188449 --- /dev/null +++ b/tools/Makefile.am @@ -0,0 +1,5 @@ +EXTRA_DIST = \ + check-coding-style.mk \ + check-c-style.sh \ + check-misc.sh \ + check-whitespace.sh diff --git a/tools/check-c-style.sh b/tools/check-c-style.sh new file mode 100644 index 0000000..dd62fb7 --- /dev/null +++ b/tools/check-c-style.sh @@ -0,0 +1,56 @@ +#!/bin/sh +fail=0 + +( . "${tools_dir}"/check-misc.sh ) || fail=$? + +if grep -n '^ *GError *\*[[:alpha:]_][[:alnum:]_]* *;' "$@" +then + echo "^^^ The above files contain uninitialized GError*s - they should be" + echo " initialized to NULL" + fail=1 +fi + +# The first regex finds function calls like foo() (as opposed to foo ()). +# It attempts to ignore string constants (may cause false negatives). +# The second and third ignore block comments (gtkdoc uses foo() as markup). +# The fourth ignores cpp so you can +# #define foo(bar) (_real_foo (__FUNC__, bar)) (cpp insists on foo() style). +if grep -n '^[^"]*[[:lower:]](' "$@" \ + | grep -v '^[-[:alnum:]_./]*:[[:digit:]]*: *\*' \ + | grep -v '^[-[:alnum:]_./]*:[[:digit:]]*: */\*' \ + | grep -v '^[-[:alnum:]_./]*:[[:digit:]]*: *#' +then + echo "^^^ Our coding style is to use function calls like foo (), not foo()" + fail=1 +fi + +if grep -En '[(][[:alnum:]_]+ ?\*[)][(]?[[:alpha:]_]' "$@"; then + echo "^^^ Our coding style is to have a space between a cast and the " + echo " thing being cast" + fail=1 +fi + +# this only spots casts +if grep -En '[(][[:alnum:]_]+\*+[)]' "$@"; then + echo "^^^ Our coding style is to have a space before the * of pointer types" + echo " (regex 1)" + fail=1 +fi +# ... and this only spots variable declarations and function return types +if grep -En '^ *(static |const |)* *[[:alnum:]_]+\*+([[:alnum:]_]|;|$)' \ + "$@"; then + echo "^^^ Our coding style is to have a space before the * of pointer types" + echo " (regex 2)" + fail=1 +fi + +if test -n "$CHECK_FOR_LONG_LINES" +then + if egrep -n '.{80,}' "$@" + then + echo "^^^ The above files contain long lines" + fail=1 + fi +fi + +exit $fail diff --git a/tools/check-coding-style.mk b/tools/check-coding-style.mk new file mode 100644 index 0000000..3fc92fc --- /dev/null +++ b/tools/check-coding-style.mk @@ -0,0 +1,17 @@ +check-coding-style: + @fail=0; \ + if test -n "$(check_misc_sources)"; then \ + tools_dir=$(top_srcdir)/tools \ + sh $(top_srcdir)/tools/check-misc.sh \ + $(check_misc_sources) || fail=1; \ + fi; \ + if test -n "$(check_c_sources)"; then \ + tools_dir=$(top_srcdir)/tools \ + sh $(top_srcdir)/tools/check-c-style.sh \ + $(check_c_sources) || fail=1; \ + fi;\ + if test yes = "$(ENABLE_CODING_STYLE_CHECKS)"; then \ + exit "$$fail";\ + else \ + exit 0;\ + fi diff --git a/tools/check-misc.sh b/tools/check-misc.sh new file mode 100644 index 0000000..89e8e87 --- /dev/null +++ b/tools/check-misc.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +fail=0 + +( . "${tools_dir}"/check-whitespace.sh ) || fail=$? + +if egrep '(Free\s*Software\s*Foundation.*02139|02111-1307)' "$@" +then + echo "^^^ The above files contain the FSF's old address in GPL headers" + fail=1 +fi + +exit $fail diff --git a/tools/check-whitespace.sh b/tools/check-whitespace.sh new file mode 100644 index 0000000..5348331 --- /dev/null +++ b/tools/check-whitespace.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +fail=0 + +if grep -n ' $' "$@" +then + echo "^^^ The above files contain unwanted trailing spaces" + fail=1 +fi + +if grep -n ' ' "$@" +then + echo "^^^ The above files contain tabs" + fail=1 +fi + +exit $fail diff --git a/wocky/Makefile.am b/wocky/Makefile.am new file mode 100644 index 0000000..f4e7aa1 --- /dev/null +++ b/wocky/Makefile.am @@ -0,0 +1,78 @@ +noinst_LTLIBRARIES = libwocky.la + +BUILT_SOURCES = \ + wocky-signals-marshal.list \ + wocky-signals-marshal.h \ + wocky-signals-marshal.c + +HANDWRITTEN_SOURCES = \ + wocky-xmpp-connection.c \ + wocky-xmpp-connection.h \ + wocky-debug.c \ + wocky-debug.h \ + wocky-xmpp-node.c \ + wocky-xmpp-node.h \ + wocky-xmpp-reader.c \ + wocky-xmpp-reader.h \ + wocky-xmpp-stanza.c \ + wocky-xmpp-stanza.h \ + wocky-xmpp-writer.c \ + wocky-xmpp-writer.h + +libwocky_la_SOURCES = $(HANDWRITTEN_SOURCES) $(BUILT_SOURCES) + +# Coding style checks +check_c_sources = \ + $(HANDWRITTEN_SOURCES) + +include $(top_srcdir)/tools/check-coding-style.mk +check-local: check-coding-style + +CLEANFILES=$(BUILT_SOURCES) +dist-hook: + $(shell for x in $(BUILT_SOURCES); do rm -f $(distdir)/$$x ; done) + +wocky-signals-marshal.list: $(HANDWRITTEN_SOURCES) Makefile.am + ( cd $(srcdir) && \ + sed -n -e 's/.*_wocky_signals_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \ + $(HANDWRITTEN_SOURCES) ) \ + | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp + if cmp -s $@.tmp $@; then \ + rm $@.tmp; \ + touch $@; \ + else \ + mv $@.tmp $@; \ + fi + +%-signals-marshal.h: %-signals-marshal.list Makefile.am + glib-genmarshal --header --prefix=_$(subst -,_,$*)_signals_marshal $< > $@ + +%-signals-marshal.c: %-signals-marshal.list Makefile.am + { echo '#include "$*-signals-marshal.h"' && \ + glib-genmarshal --body --prefix=_$(subst -,_,$*)_signals_marshal $< ; \ + } > $@ + + +AM_CFLAGS = $(ERROR_CFLAGS) $(GCOV_CFLAGS) @GLIB_CFLAGS@ @LIBXML2_CFLAGS@ + +AM_LDFLAGS = $(GCOV_LIBS) @GLIB_LIBS@ @LIBXML2_LIBS@ + +# rules for making the glib enum objects +%-enumtypes.h: %.h Makefile.in + glib-mkenums \ + --fhead "#ifndef __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__\n#define __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \ + --fprod "/* enumerations from \"@filename@\" */\n" \ + --vhead "GType @enum_name@_get_type (void);\n#define $(shell echo $* | tr [:lower:]- [:upper:]_ | sed 's/_.*//')_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \ + --ftail "G_END_DECLS\n\n#endif /* __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__ */" \ + $< > $@ + +%-enumtypes.c: %.h Makefile.in + glib-mkenums \ + --fhead "#include <$*.h>\n#include <$*-enumtypes.h>" \ + --fprod "\n/* enumerations from \"@filename@\" */" \ + --vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \ + --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@VALUENAME@\" }," \ + --vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \ + $< > $@ + + |