From 059bfdbed84a2c3e8274ca9bc99a103171cdeca5 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 25 Mar 2015 10:30:27 +0100 Subject: Add an autotools-based build system This is based on util-cursor's build system and libxcb/configure.ac for finding xcb-proto's XML files. Signed-off-by: Uli Schlachter --- .gitignore | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- .gitmodules | 3 ++ Makefile | 27 ------------------ Makefile.am | 40 ++++++++++++++++++++++++++ autogen.sh | 27 ++++++++++++++++++ configure.ac | 29 +++++++++++++++++++ m4 | 1 + src/extensions.py | 2 +- tests/test.c | 2 +- xcb-errors.pc.in | 11 ++++++++ 10 files changed, 196 insertions(+), 30 deletions(-) create mode 100644 .gitmodules delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100755 autogen.sh create mode 100644 configure.ac create mode 160000 m4 create mode 100644 xcb-errors.pc.in diff --git a/.gitignore b/.gitignore index 9e4cdf3..0b5282f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,85 @@ -src/libxcb_errors.so +# +# X.Org module default exclusion patterns +# The next section if for module specific patterns +# +# Do not edit the following section +# GNU Build System (Autotools) +aclocal.m4 +autom4te.cache/ +autoscan.log +ChangeLog +compile +config.guess +config.h +config.h.in +config.log +config-ml.in +config.py +config.status +config.status.lineno +config.sub +configure +configure.scan +depcomp +.deps/ +INSTALL +install-sh +.libs/ +libtool +libtool.m4 +ltmain.sh +lt~obsolete.m4 +ltoptions.m4 +ltsugar.m4 +ltversion.m4 +Makefile +Makefile.in +mdate-sh +missing +mkinstalldirs +*.pc +py-compile +stamp-h? +symlink-tree +texinfo.tex +ylwrap + +# Do not edit the following section +# Edit Compile Debug Document Distribute +*~ +*.[0-9] +*.[0-9]x +*.bak +*.bin +core +*.dll +*.exe +*-ISO*.bdf +*-JIS*.bdf +*-KOI8*.bdf +*.kld +*.ko +*.ko.cmd +*.lai +*.l[oa] +*.[oa] +*.obj +*.patch +*.so +*.pcf.gz +*.pdb +*.tar.bz2 +*.tar.gz +# +# Add & Override patterns for xinit +# +# Edit the following section as needed +# For example, !report.pc overrides *.pc. See 'man gitignore' +# +.dirstamp src/extensions.c +test-driver +test-suite.log +test.log +test.trs tests/test diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..cff1b86 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "m4"] + path = m4 + url = git://anongit.freedesktop.org/xcb/util-common-m4.git diff --git a/Makefile b/Makefile deleted file mode 100644 index 0136815..0000000 --- a/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -FLAGS=-std=gnu89 -Wall -Wextra -ggdb3 -SHARED_FLAGS=$(FLAGS) -lxcb -fpic -shared -Wl,-no-undefined # -Wl,-export-symbols-regex,'^xcb_errors_' -TEST_FLAGS=$(FLAGS) -Isrc - -.PHONY: check - -all: src/libxcb-errors.so check - -check: tests/test - LD_LIBRARY_PATH=src tests/test - -src/libxcb-errors.so: $(wildcard src/*.c) $(wildcard *.h) src/extensions.c Makefile syms - gcc $(SHARED_FLAGS) -Wl,--retain-symbols-file=syms -o $@ $(wildcard src/*.c) - -src/extensions.c: src/extensions.py - PYTHONPATH=/home/psychon/projects/proto/ src/extensions.py $@ /home/psychon/projects/proto/src/*xml - -tests/test: tests/test.c src/libxcb-errors.so - gcc $(TEST_FLAGS) -lxcb -Lsrc -lxcb-errors -o $@ $< - -syms: - echo xcb_errors_context_new > $@ - echo xcb_errors_context_free > $@ - echo xcb_errors_get_name_for_major_code > $@ - echo xcb_errors_get_name_for_minor_code > $@ - echo xcb_errors_get_name_for_event > $@ - echo xcb_errors_get_name_for_error > $@ diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..4703f74 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,40 @@ +ACLOCAL_AMFLAGS = -I m4 + +MAINTAINERCLEANFILES = ChangeLog INSTALL Makefile.in + +.PHONY: ChangeLog INSTALL + +INSTALL: + $(INSTALL_CMD) + +ChangeLog: + $(CHANGELOG_CMD) + +dist-hook: ChangeLog INSTALL + +EXTRA_DIST = autogen.sh xcb-errors.pc.in src/errors.h src/extensions.py + +lib_LTLIBRARIES = libxcb-errors.la + +xcbinclude_HEADERS = src/xcb_errors.h + +AM_CFLAGS = $(CWARNFLAGS) + +libxcb_errors_la_SOURCES = src/xcb_errors.c src/extensions.c +libxcb_errors_la_CPPFLAGS = $(XCB_CFLAGS) $(XPROTO_CFLAGS) +libxcb_errors_la_LIBADD = $(XCB_LIBS) $(XPROTO_LIBS) +libxcb_errors_la_LDFLAGS = -version-info 0:0:0 -no-undefined -export-symbols-regex '^xcb_errors_' + +pkgconfig_DATA = xcb-errors.pc + +TESTS = tests/test +check_PROGRAMS = tests/test +tests_test_SOURCE = tests/test.c +tests_test_CPPFLAGS = -Isrc/ +tests_test_LDADD = libxcb-errors.la + +CLEANFILES = src/extensions.c + +src/extensions.c: src/extensions.py + $(AM_V_GEN)src/extensions.py $@.tmp ${XCBPROTO_XCBINCLUDEDIR}/*.xml && \ + mv $@.tmp $@ diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..afe5299 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,27 @@ +#! /bin/sh + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +ORIGDIR=`pwd` +cd $srcdir + +# If this is a git checkout, verify that the submodules are initialized, +# otherwise autotools will just fail with an unhelpful error message. +if [ -d ".git" ] && [ -r ".gitmodules" ] +then + # If git is not in PATH, this will not return 0, thus not keeping us + # from building. Since the message is worthless when git is not + # installed, this is what we want. + if git submodule status 2>/dev/null | grep -q '^-' + then + echo "You have uninitialized git submodules." >&2 + echo "Please run: git submodule update --init" >&2 + exit 1 + fi +fi + +autoreconf -v --install || exit 1 +cd $ORIGDIR || exit $? + +$srcdir/configure --enable-maintainer-mode "$@" diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..cc2e83e --- /dev/null +++ b/configure.ac @@ -0,0 +1,29 @@ +dnl XCB_UTIL_M4_WITH_INCLUDE_PATH requires Autoconf >= 2.62 +AC_PREREQ(2.62) +AC_INIT([xcb-util-errors],0.0,[xcb@lists.freedesktop.org]) +AC_CONFIG_SRCDIR([Makefile.am]) +AC_CONFIG_MACRO_DIR([m4]) + +# Set common system defines for POSIX extensions, such as _GNU_SOURCE +# Must be called before any macros that run the compiler (like AC_PROG_LIBTOOL) +# to avoid autoconf errors. +AC_USE_SYSTEM_EXTENSIONS + +AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects]) +AM_MAINTAINER_MODE + +AC_TYPE_SSIZE_T + +XCB_UTIL_M4_WITH_INCLUDE_PATH +XCB_UTIL_COMMON([1.4], [1.6]) + +# Checks for xcb-proto's XML files, inspired from libxcb's configure.ac +PKG_CHECK_MODULES(XCBPROTO, xcb-proto) +AC_MSG_CHECKING(XCBPROTO_XCBINCLUDEDIR) +XCBPROTO_XCBINCLUDEDIR=`$PKG_CONFIG --variable=xcbincludedir xcb-proto` +AC_MSG_RESULT($XCBPROTO_XCBINCLUDEDIR) +AC_SUBST(XCBPROTO_XCBINCLUDEDIR) + +AC_OUTPUT([Makefile + xcb-errors.pc + ]) diff --git a/m4 b/m4 new file mode 160000 index 0000000..f662e3a --- /dev/null +++ b/m4 @@ -0,0 +1 @@ +Subproject commit f662e3a93ebdec3d1c9374382dcc070093a42fed diff --git a/src/extensions.py b/src/extensions.py index c7a1afe..c776935 100755 --- a/src/extensions.py +++ b/src/extensions.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python import sys from xml.etree.cElementTree import parse diff --git a/tests/test.c b/tests/test.c index dcd96cc..964ce0a 100644 --- a/tests/test.c +++ b/tests/test.c @@ -122,7 +122,7 @@ static int test_valid_connection(void) return err; } -int main() +int main(void) { int err = 0; err |= test_error_connection(); diff --git a/xcb-errors.pc.in b/xcb-errors.pc.in new file mode 100644 index 0000000..f292712 --- /dev/null +++ b/xcb-errors.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: XCB errors library +Description: XCB errors utility library +Version: @PACKAGE_VERSION@ +Requires: xcb +Libs: -L${libdir} -lxcb-errors @LIBS@ +Cflags: -I${includedir} -- cgit v1.2.3