[gcr] Makefile.am: Single Makefile mode and parallel-tests



commit 9019498dfef15efec4d12eee8becc55781062a30
Author: Stef Walter <stefw gnome org>
Date:   Sun Mar 2 16:43:19 2014 +0100

    Makefile.am: Single Makefile mode and parallel-tests
    
    gtk-doc doesn't work as an included Makefile so continue to
    use SUBDIRS with docs/reference/*
    
    Run the tests using TAP. Unfortunately the GTest --tap output
    mode doesn't behave well in the face of failures, and doesn't
    output a test plan. Use our own tap-driver and tap-compiler
    for these reasons.
    
    This also fixes several builddir != srcdir issues and testing hacks
    that were sneaking around in the code base.
    
    Move the tests into the same directories as the code that it
    is testing.

 Makefile.am                                        |  146 +++++-
 Makefile.decl                                      |   60 ---
 build/Makefile.am                                  |   33 +-
 build/tap-compiler                                 |  174 +++++++
 build/tap-driver                                   |  284 ++++++++++++
 configure.ac                                       |   15 +-
 docs/Makefile.am                                   |    2 -
 docs/reference/Makefile.am                         |    2 -
 docs/reference/gck/Makefile.am                     |    4 +-
 docs/reference/gcr/Makefile.am                     |    8 +-
 egg/Makefile.am                                    |  142 ++++--
 egg/egg-asn1x.c                                    |   10 +-
 egg/egg-timegm.c                                   |    2 -
 egg/egg-timegm.h                                   |    2 -
 egg/{tests/files => fixtures}/dh-params.pem        |    0
 egg/{tests/files => fixtures}/echo-script.sh       |    0
 egg/{tests/files => fixtures}/pem-rsa-enc.key      |    0
 .../files => fixtures}/test-certificate-1.der      |  Bin 813 -> 813 bytes
 .../files => fixtures}/test-personalname-1.der     |    0
 .../test-personalname-invalid.der                  |    0
 egg/{tests/files => fixtures}/test-pkcs12-1.der    |  Bin 2824 -> 2824 bytes
 egg/{tests/files => fixtures}/test-pkcs12-2.der    |  Bin 2142 -> 2142 bytes
 egg/{tests/files => fixtures}/test-pkcs7-1.der     |  Bin 1002 -> 1002 bytes
 egg/{tests/files => fixtures}/test-pkcs7-2.der     |  Bin 1002 -> 1002 bytes
 egg/{tests/files => fixtures}/test-pkcs8-1.der     |  Bin 335 -> 335 bytes
 egg/{tests/files => fixtures}/test-rsakey-1.der    |  Bin 609 -> 609 bytes
 egg/{tests => }/test-armor.c                       |    0
 egg/{tests => }/test-asn1.c                        |    2 +-
 egg/{tests => }/test-asn1x.c                       |   14 +-
 egg/{tests => }/test-decimal.c                     |    0
 egg/{tests => }/test-dh.c                          |    0
 egg/{tests => }/test-dn.c                          |    2 +-
 egg/{tests => }/test-hex.c                         |    0
 egg/{tests => }/test-hkdf.c                        |    0
 egg/{tests => }/test-oid.c                         |    0
 egg/{tests => }/test-openssl.c                     |    2 +-
 egg/{tests => }/test-padding.c                     |    0
 egg/{tests => }/test-secmem.c                      |    0
 egg/{tests => }/test-symkey.c                      |    0
 egg/{tests => }/test.asn                           |    0
 egg/{tests => }/test.asn.h                         |    0
 egg/tests/Makefile.am                              |   54 ---
 gck/Makefile.am                                    |  293 +++++++-----
 gck/gck-module.c                                   |    3 +-
 gck/gck-modules.c                                  |    3 +-
 gck/gck-session.c                                  |    3 +-
 gck/gck-uri.c                                      |    3 +-
 gck/{tests => }/mock-interaction.c                 |    0
 gck/{tests => }/mock-interaction.h                 |    0
 gck/{tests => }/mock-test-module.c                 |    0
 gck/{tests => }/test-gck-attributes.c              |    0
 gck/{tests => }/test-gck-crypto.c                  |    0
 gck/{tests => }/test-gck-enumerator.c              |    0
 gck/{tests => }/test-gck-module.c                  |    0
 gck/{tests => }/test-gck-modules.c                 |    0
 gck/{tests => }/test-gck-object.c                  |    0
 gck/{tests => }/test-gck-session.c                 |    0
 gck/{tests => }/test-gck-slot.c                    |    0
 gck/{tests => }/test-gck-uri.c                     |    0
 gck/tests/Makefile.am                              |   67 ---
 gcr/Makefile.am                                    |  488 ++++++++++++--------
 gcr/{tests => }/console-interaction.c              |    0
 gcr/{tests => }/console-interaction.h              |    0
 .../files => fixtures}/RSA_Root_Certificate_1.pem  |    0
 .../files => fixtures}/RSA_Security_1024_v3.pem    |    0
 .../files => fixtures}/RSA_Security_2048_v3.pem    |    0
 .../Thawte_Personal_Basic_CA.pem                   |    0
 .../Thawte_Personal_Freemail_CA.pem                |    0
 .../Thawte_Personal_Premium_CA.pem                 |    0
 .../Thawte_Premium_Server_CA.pem                   |    0
 gcr/{tests/files => fixtures}/Thawte_Server_CA.pem |    0
 .../files => fixtures}/Thawte_Time_Stamping_CA.pem |    0
 .../files => fixtures}/base64-rsa-2048.spkac       |    0
 gcr/{tests/files => fixtures}/ca-certificates.crt  |    0
 gcr/{tests/files => fixtures}/cacert.org.cer       |  Bin 1857 -> 1857 bytes
 gcr/{tests/files => fixtures}/cacert.org.pem       |    0
 gcr/{tests/files => fixtures}/client.crt           |  Bin 736 -> 736 bytes
 gcr/{tests/files => fixtures}/client.key           |    0
 gcr/{tests/files => fixtures}/client.pem           |    0
 gcr/{tests/files => fixtures}/client.spk           |  Bin 294 -> 294 bytes
 gcr/{tests/files => fixtures}/collabora-ca.cer     |  Bin 1536 -> 1536 bytes
 .../files => fixtures}/der-certificate-dsa.cer     |  Bin 1639 -> 1639 bytes
 gcr/{tests/files => fixtures}/der-certificate.crt  |  Bin 747 -> 747 bytes
 gcr/{tests/files => fixtures}/der-dsa-1024.key     |  Bin 447 -> 447 bytes
 .../files => fixtures}/der-key-PBE-MD5-DES.p8      |  Bin 677 -> 677 bytes
 .../files => fixtures}/der-key-PBE-SHA1-3DES.p8    |  Bin 678 -> 678 bytes
 .../files => fixtures}/der-key-PBE-SHA1-DES.p8     |  Bin 677 -> 677 bytes
 .../files => fixtures}/der-key-PBE-SHA1-RC2-40.p8  |  Bin 678 -> 678 bytes
 .../files => fixtures}/der-key-PBE-SHA1-RC4-128.p8 |  Bin 673 -> 673 bytes
 gcr/{tests/files => fixtures}/der-key-dsa.p8       |  Bin 335 -> 335 bytes
 .../files => fixtures}/der-key-encrypted-pkcs5.p8  |  Bin 677 -> 677 bytes
 gcr/{tests/files => fixtures}/der-key-v2-des.p8    |  Bin 711 -> 711 bytes
 gcr/{tests/files => fixtures}/der-key-v2-des3.p8   |  Bin 714 -> 714 bytes
 gcr/{tests/files => fixtures}/der-key.p8           |  Bin 635 -> 635 bytes
 gcr/{tests/files => fixtures}/der-rsa-1024.key     |  Bin 609 -> 609 bytes
 gcr/{tests/files => fixtures}/der-rsa-2048.p10     |  Bin 681 -> 681 bytes
 gcr/{tests/files => fixtures}/der-rsa-2048.spkac   |  Bin 592 -> 592 bytes
 .../files => fixtures}/dhansak-collabora.cer       |  Bin 1200 -> 1200 bytes
 gcr/{tests/files => fixtures}/email.p12            |  Bin 2488 -> 2488 bytes
 gcr/{tests/files => fixtures}/generic-dsa.crt      |  Bin 918 -> 918 bytes
 gcr/{tests/files => fixtures}/generic-dsa.key      |    0
 gcr/{tests/files => fixtures}/generic-dsa.pem      |    0
 gcr/{tests/files => fixtures}/generic-dsa.spk      |  Bin 443 -> 443 bytes
 .../files => fixtures}/gnupg-homedir/gpg.conf      |    1 -
 .../files => fixtures}/gnupg-homedir/pubring.gpg   |  Bin 21969 -> 21969 bytes
 .../files => fixtures}/gnupg-homedir/secring.gpg   |  Bin 4398 -> 4398 bytes
 .../files => fixtures}/gnupg-homedir/trustdb.gpg   |  Bin 1400 -> 1400 bytes
 .../gnupg-mock/mock-arguments-environ              |    0
 gcr/{tests/files => fixtures}/gnupg-mock/mock-echo |    0
 .../files => fixtures}/gnupg-mock/mock-fail-exit   |    0
 .../files => fixtures}/gnupg-mock/mock-fail-signal |    0
 .../gnupg-mock/mock-simple-error                   |    0
 .../gnupg-mock/mock-simple-output                  |    0
 .../gnupg-mock/mock-status-and-attribute           |    0
 .../gnupg-mock/mock-status-and-output              |    0
 .../gnupg-mock/mock-with-homedir                   |    0
 gcr/{tests/files => fixtures}/jabber-server.cer    |  Bin 2095 -> 2095 bytes
 gcr/{tests/files => fixtures}/openssh_keys.pub     |    0
 gcr/{tests/files => fixtures}/pem-dsa-1024.key     |    0
 gcr/{tests/files => fixtures}/pem-pkcs8.key        |    0
 gcr/{tests/files => fixtures}/pem-rsa-2048.req     |    0
 gcr/{tests/files => fixtures}/pem-rsa-enc.key      |    0
 .../files => fixtures}/pem-with-attributes.req     |    0
 gcr/{tests/files => fixtures}/personal.p12         |  Bin 3396 -> 3396 bytes
 .../prompt-tests/multiple.prompt                   |    0
 .../prompt-tests/password-choice.prompt            |    0
 gcr/{tests/files => fixtures}/pubring.gpg          |  Bin 21969 -> 21969 bytes
 gcr/{tests/files => fixtures}/secring.gpg          |  Bin 4398 -> 4398 bytes
 gcr/{tests/files => fixtures}/startcom-ca.cer      |  Bin 1997 -> 1997 bytes
 .../files => fixtures}/startcom-intermediate.cer   |  Bin 1592 -> 1592 bytes
 gcr/{tests/files => fixtures}/test-x509-swiss.p7b  |  Bin 1002 -> 1002 bytes
 gcr/{tests/files => fixtures}/unclient.p12         |  Bin 1476 -> 1476 bytes
 gcr/{tests/files => fixtures}/usr0052-firefox.p12  |  Bin 2142 -> 2142 bytes
 gcr/{tests/files => fixtures}/werner-koch.asc      |    0
 gcr/{tests => }/frob-certificate-request.c         |    0
 gcr/{tests => }/frob-openpgp.c                     |    0
 gcr/{tests => }/frob-parser.c                      |    0
 gcr/gcr-certificate-chain.c                        |    3 +-
 gcr/gcr-certificate-extensions.c                   |    3 +-
 gcr/gcr-certificate-request.c                      |    5 +-
 gcr/gcr-certificate.c                              |    3 +-
 gcr/gcr-fingerprint.c                              |    3 +-
 gcr/gcr-gnupg-process.c                            |    3 +-
 gcr/gcr-importer.c                                 |    3 +-
 gcr/gcr-parser.c                                   |    5 +-
 gcr/gcr-subject-public-key.c                       |    3 +-
 gcr/gcr-system-prompt.c                            |    3 +-
 gcr/gcr-system-prompter.c                          |    7 +-
 gcr/{tests => }/test-certificate-chain.c           |   12 +-
 gcr/{tests => }/test-certificate.c                 |    6 +-
 gcr/{tests => }/test-filter-collection.c           |    0
 gcr/{tests => }/test-fingerprint.c                 |    8 +-
 gcr/{tests => }/test-gnupg-collection.c            |   23 +-
 gcr/{tests => }/test-gnupg-key.c                   |    0
 gcr/{tests => }/test-gnupg-process.c               |    2 +-
 gcr/{tests => }/test-memory-icon.c                 |    0
 gcr/{tests => }/test-openpgp.c                     |    8 +-
 gcr/{tests => }/test-openssh.c                     |    0
 gcr/{tests => }/test-parser.c                      |   12 +-
 gcr/{tests => }/test-pkcs11-certificate.c          |    4 +-
 gcr/{tests => }/test-record.c                      |    0
 gcr/{tests => }/test-secret-exchange.c             |    0
 gcr/{tests => }/test-secure-memory.c               |    0
 gcr/{tests => }/test-simple-certificate.c          |    2 +-
 gcr/{tests => }/test-subject-public-key.c          |    6 +-
 gcr/{tests => }/test-system-prompt.c               |    0
 gcr/{tests => }/test-trust.c                       |    2 +-
 gcr/{tests => }/test-util.c                        |    0
 gcr/tests/Makefile.am                              |   71 ---
 schema/Makefile.am                                 |    8 +-
 testing/Makefile.am                                |    3 -
 ui/Makefile.am                                     |  377 ++++++++-------
 ui/{tests/files => fixtures}/ca-certificates.crt   |    0
 ui/{tests/files => fixtures}/der-certificate.crt   |  Bin 747 -> 747 bytes
 ui/{tests/files => fixtures}/der-rsa-2048.p10      |  Bin 681 -> 681 bytes
 ui/{tests/files => fixtures}/email.p12             |  Bin 2488 -> 2488 bytes
 ui/{tests/files => fixtures}/pem-dsa-1024.key      |    0
 ui/{tests => }/frob-certificate.c                  |    2 +-
 ui/{tests => }/frob-combo-selector.c               |    2 +-
 ui/{tests => }/frob-gnupg-selector.c               |    0
 ui/{tests => }/frob-import-button.c                |    2 +-
 ui/{tests => }/frob-key.c                          |    2 +-
 ui/{tests => }/frob-prompt.c                       |    0
 ui/{tests => }/frob-request.c                      |    2 +-
 ui/{tests => }/frob-system-prompt.c                |    0
 ui/{tests => }/frob-tree-selector.c                |    2 +-
 ui/{tests => }/frob-unlock-options.c               |    0
 ui/{tests => }/frob-unlock.c                       |    2 +-
 ui/gcr-collection-model.c                          |    3 +-
 ui/gcr-live-search.c                               |    4 +-
 ui/gcr-ui.h                                        |    2 +-
 ui/icons/Makefile.am                               |   22 +-
 ui/tests/Makefile.am                               |   42 --
 193 files changed, 1517 insertions(+), 974 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 8769a74..73b7f44 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,22 +1,10 @@
-include $(top_srcdir)/Makefile.decl
-
-if WITH_GTK
-UI_DIR = ui
-else
-UI_DIR =
-endif
+NULL =
 
 SUBDIRS = \
        . \
-       build \
-       egg \
-       gck \
-       gcr \
-       $(UI_DIR) \
-       schema \
-       testing \
        po \
-       docs
+       docs/reference/gck \
+       docs/reference/gcr
 
 ACLOCAL_AMFLAGS = -I build/m4 ${ACLOCAL_FLAGS}
 
@@ -29,7 +17,7 @@ EXTRA_DIST = \
 DISTCHECK_CONFIGURE_FLAGS = \
        --enable-gtk-doc \
        --enable-strict \
-       --disable-code-coverage \
+       --disable-coverage \
        --disable-update-mime \
        --disable-update-icon-cache \
        --with-gtk \
@@ -55,10 +43,132 @@ dist-hook:
        fi
 
 check-memory:
-       make -C egg check-memory
-       make -C gck check-memory
        make -C gcr check-memory
 
+check-local: check-gck-symbols check-gcr-symbols check-ui-symbols
+
 upload-release: $(DIST_ARCHIVES)
        scp $(DIST_ARCHIVES) master.gnome.org:
        ssh master.gnome.org ftpadmin install $(DIST_ARCHIVES)
+
+AM_CPPFLAGS = \
+       -I$(srcdir) \
+       -I$(builddir) \
+       -I$(srcdir)/build \
+       -DSRCDIR="\"@abs_srcdir \"" \
+       -DBUILDDIR="\"@abs_builddir \"" \
+       -DLOCALEDIR=\""$(datadir)/locale"\" \
+       $(GLIB_CFLAGS)
+
+LDADD = \
+       $(GLIB_LIBS)
+
+LOG_DRIVER = $(srcdir)/build/tap-driver
+LOG_COMPILER = $(srcdir)/build/tap-compiler
+
+BUILT_SOURCES =
+TESTS =
+
+check_PROGRAMS =
+check_LTLIBRARIES =
+lib_LTLIBRARIES =
+noinst_LTLIBRARIES =
+noinst_PROGRAMS = $(check_PROGRAMS)
+
+pkgconfig_DATA =
+pkgconfigdir = $(libdir)/pkgconfig
+
+CLEANFILES = \
+       $(pkgconfig_DATA)
+
+TEST_SUPPRESSIONS = $(top_builddir)/build/valgrind-suppressions
+
+V_SED = $(V_SED_$(V))
+V_SED_ = $(V_SED_$(AM_DEFAULT_VERBOSITY))
+V_SED_0 = @echo "  SED     " $@;
+
+SED_SUBST = sed \
+       -e 's,[ ]datadir[@],$(datadir),g' \
+       -e 's,[ ]libexecdir[@],$(libexecdir),g' \
+       -e 's,[ ]libdir[@],$(libdir),g' \
+       -e 's,[ ]includedir[@],$(includedir),g' \
+       -e 's,[ ]datarootdir[@],$(datarootdir),g' \
+       -e 's,[ ]sysconfdir[@],$(sysconfdir),g' \
+       -e 's,[ ]bindir[@],$(bindir),g' \
+       -e 's,[ ]exec_prefix[@],$(exec_prefix),g' \
+       -e 's,[ ]prefix[@],$(prefix),g' \
+       -e 's,[ ]PACKAGE[@],$(PACKAGE),g' \
+       -e 's,[ ]VERSION[@],$(VERSION),g' \
+       $(NULL)
+
+.desktop.in.in.desktop.in:
+       $(V_SED) $(SED_SUBST) $< > $@
+
+ INTLTOOL_DESKTOP_RULE@
+
+.service.in.service:
+       $(V_SED) $(SED_SUBST) $< > $@
+
+ENUM_TEMPLATE_C = $(top_srcdir)/build/enum-template.c
+ENUM_TEMPLATE_H = $(top_srcdir)/build/enum-template.h
+
+V_XSLTPROC = $(V_XSLTPROC_$(V))
+V_XSLTPROC_ = $(V_XSLTPROC_$(AM_DEFAULT_VERBOSITY))
+V_XSLTPROC_0 = @echo "  XSLTPROC" $@;
+
+FIX_GIR = $(top_srcdir)/build/g-ir-unbreak.xsl
+
+.broken.gir.gir:
+       $(V_XSLTPROC) xsltproc -o $@ $(FIX_GIR) $<
+.broken.typelib.typelib:
+       $(AM_V_GEN) cp $< $@
+
+SUFFIXES = .desktop.in .desktop.in.in .service .service.in .broken.typelib .broken.gir .gir
+
+if HAVE_INTROSPECTION
+
+include $(INTROSPECTION_MAKEFILE)
+
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = $(INTROSPECTION_FLAGS) --warn-all --add-include-path=.
+INTROSPECTION_COMPILER_ARGS = --includedir=.
+
+girdir = $(datadir)/gir-1.0
+gir_DATA =
+
+typelibsdir = $(libdir)/girepository-1.0
+typelibs_DATA = $(gir_DATA:.gir=.typelib)
+
+CLEANFILES += \
+       $(gir_DATA) \
+       $(typelibs_DATA) \
+       $(BUILT_SOURCES)
+
+if ENABLE_VAPIGEN
+
+include $(VAPIGEN_MAKEFILE)
+
+VAPIGEN_VAPIS =
+VAPI_DEPS = $(VAPIGEN_VAPIS:.vapi=.deps)
+
+vapidir = $(datadir)/vala/vapi
+vapi_DATA = $(VAPI_DEPS)
+
+CLEANFILES += \
+       $(VAPIGEN_VAPIS) \
+       $(VAPI_DEPS)
+
+endif
+
+endif
+
+include build/Makefile.am
+include egg/Makefile.am
+include gck/Makefile.am
+include gcr/Makefile.am
+include schema/Makefile.am
+
+if WITH_GTK
+include ui/Makefile.am
+include ui/icons/Makefile.am
+endif
diff --git a/build/Makefile.am b/build/Makefile.am
index 1b89dea..20cfa35 100644
--- a/build/Makefile.am
+++ b/build/Makefile.am
@@ -1,31 +1,34 @@
+# included in top-level Makefile.am
 
 VALGRIND_CONTRIB = \
-       valgrind/valgrind.h \
-       valgrind/memcheck.h
+       build/valgrind/valgrind.h \
+       build/valgrind/memcheck.h
 
 SUPPRESSIONS = \
-       gcr.supp \
-       gcrypt.supp \
-       glib.supp \
-       glibc.supp \
-       p11-kit.supp \
-       pixman.supp \
-       pthread.supp \
-       unknown.supp
+       build/gcr.supp \
+       build/gcrypt.supp \
+       build/glib.supp \
+       build/glibc.supp \
+       build/p11-kit.supp \
+       build/pixman.supp \
+       build/pthread.supp \
+       build/unknown.supp
 
 valgrind-suppressions: $(SUPPRESSIONS)
        $(AM_V_GEN) sh -c "cd $(srcdir) && cat $(SUPPRESSIONS)" > $@
 
-EXTRA_DIST = \
+EXTRA_DIST += \
        $(VALGRIND_CONTRIB) \
        $(SUPPRESSIONS) \
-       enum-template.c \
-       enum-template.h \
-       g-ir-unbreak.xsl
+       build/enum-template.c \
+       build/enum-template.h \
+       build/g-ir-unbreak.xsl \
+       build/tap-driver \
+       build/tap-compiler
 
 all-local: valgrind-suppressions
 
-CLEANFILES = \
+CLEANFILES += \
        coverage \
        coverage.info \
        valgrind-suppressions
diff --git a/build/tap-compiler b/build/tap-compiler
new file mode 100755
index 0000000..76b3171
--- /dev/null
+++ b/build/tap-compiler
@@ -0,0 +1,174 @@
+#!/usr/bin/python
+
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# Cockpit is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# Cockpit is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
+
+#
+# This is a test output compiler which produces TAP from GTest output
+# if GTest output is detected.
+#
+# Versions of glib later than 2.38.x output TAP natively when tests are
+# run with the --tap option. However we can't depend on such a recent
+# version of glib for our purposes.
+#
+# This implements the Test Anything Protocol (ie: TAP)
+# https://metacpan.org/pod/release/PETDANCE/Test-Harness-2.64/lib/Test/Harness/TAP.pod
+#
+
+import argparse
+import os
+import select
+import subprocess
+import sys
+
+class NullCompiler:
+    def __init__(self, command):
+        self.command = command
+
+    def input(self, line):
+        sys.stdout.write(line)
+
+    def process(self, proc):
+        while True:
+            line = proc.stdout.readline()
+            if not line:
+                break
+            self.input(line)
+        proc.wait()
+        return proc.returncode
+
+    def run(self, proc, line=None):
+        if line:
+            self.input(line)
+        return self.process(proc)
+
+
+class GTestCompiler(NullCompiler):
+    def __init__(self, filename):
+        NullCompiler.__init__(self, filename)
+        self.test_num = 0
+        self.test_name = None
+        self.test_remaining = []
+
+    def input(self, line):
+        line = line.strip()
+        if line.startswith("GTest: "):
+           (cmd, unused, data) = line[7:].partition(": ")
+           cmd = cmd.strip()
+           data = data.strip()
+           if cmd == "run":
+               self.test_name = data
+               assert self.test_name in self.test_remaining, "%s %s" % (self.test_name, 
repr(self.test_remaining))
+               self.test_remaining.remove(self.test_name)
+               self.test_num += 1
+           elif cmd == "result":
+               if data == "OK":
+                   print "ok %d %s" % (self.test_num, self.test_name)
+               if data == "FAIL":
+                   print "not ok %d %s", (self.test_num, self.test_name)
+               self.test_name = None
+           elif cmd == "skipping":
+               print "ok %d # skip -- %s" % (self.test_num, self.test_name)
+               self.test_name = None
+           elif data:
+               print "# %s: %s" % (cmd, data)
+           else:
+               print "# %s" % cmd
+        elif line.startswith("(MSG: "):
+            print "# %s" % line[6:-1]
+        elif line:
+            print "# %s" % line
+        sys.stdout.flush()
+
+    def run(self, proc, output=""):
+        # Complete retrieval of the list of tests
+        output += proc.stdout.read()
+        proc.wait()
+        if proc.returncode:
+            raise subprocess.CalledProcessError(proc.returncode, self.command)
+        self.test_remaining = []
+        for line in output.split("\n"):
+            if line.startswith("/"):
+                self.test_remaining.append(line.strip())
+        if not self.test_remaining:
+            print "Bail out! No tests found in GTest: %s" % self.command[0]
+            return 0
+
+        print "1..%d" % len(self.test_remaining)
+
+        # First try to run all the tests in a batch
+        proc = subprocess.Popen(self.command + ["--verbose" ], close_fds=True, stdout=subprocess.PIPE)
+        result = self.process(proc)
+        if result == 0:
+            return 0
+
+        # Now pick up any stragglers due to failures
+        while True:
+            # Assume that the last test failed
+            if self.test_name:
+                print "not ok %d %s" % (self.test_num, self.test_name)
+                self.test_name = None
+
+            # Run any tests which didn't get run
+            if not self.test_remaining:
+                break
+
+            proc = subprocess.Popen(self.command + ["--verbose", "-p", self.test_remaining[0]],
+                                    close_fds=True, stdout=subprocess.PIPE)
+            result = self.process(proc)
+
+            # The various exit codes and signals we continue for
+            if result not in [ 0, 1, -4, -5, -6, -7, -8, -11 ]:
+                break
+
+        return result
+
+def main(argv):
+    parser = argparse.ArgumentParser(description='Automake TAP compiler')
+    parser.add_argument('--format', metavar='FORMAT', choices=[ "auto", "GTest", "TAP" ],
+                        default="auto", help='The input format to compile')
+    parser.add_argument('--verbose', action='store_true',
+                        default=True, help='Verbose mode (ignored)')
+    parser.add_argument('command', nargs='+', help="A test command to run")
+    args = parser.parse_args(argv[1:])
+
+    output = None
+    format = args.format
+    cmd = args.command
+    proc = None
+
+    if format in ["auto", "GTest"]:
+        list_cmd = cmd + ["-l", "--verbose"]
+        proc = subprocess.Popen(list_cmd, close_fds=True, stdout=subprocess.PIPE)
+        output = proc.stdout.readline()
+        # Smell whether we're dealing with GTest list output from first line
+        if "random seed" in output or "GTest" in output or output.startswith("/"):
+            format = "GTest"
+        else:
+            format = "TAP"
+    else:
+        proc = subprocess.Popen(cmd, close_fds=True, stdout=subprocess.PIPE)
+
+    if format == "GTest":
+        compiler = GTestCompiler(cmd)
+    elif format == "TAP":
+        compiler = NullCompiler(cmd)
+    else:
+        assert False, "not reached"
+
+    return compiler.run(proc, output)
+
+if __name__ == "__main__":
+    sys.exit(main(sys.argv))
diff --git a/build/tap-driver b/build/tap-driver
new file mode 100755
index 0000000..eb22462
--- /dev/null
+++ b/build/tap-driver
@@ -0,0 +1,284 @@
+#!/usr/bin/python
+
+# Copyright (C) 2013 Red Hat, Inc.
+#
+# Cockpit is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# Cockpit is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
+
+#
+# This is a TAP driver for automake
+#
+# In particular it leaves stderr untouched, and is cleaner than the
+# one implemented in shell that is making the rounds.
+#
+# This implements the automake "Custom Test Driver" protocol:
+# https://www.gnu.org/software/automake/manual/html_node/Custom-Test-Drivers.html
+#
+# This consumes the Test Anything Protocol (ie: TAP)
+# https://metacpan.org/pod/release/PETDANCE/Test-Harness-2.64/lib/Test/Harness/TAP.pod
+#
+
+import argparse
+import os
+import select
+import subprocess
+import sys
+
+class Driver:
+    def __init__(self, command, args):
+        self.argv = command
+        self.output = ""
+        self.test_name = args.test_name
+        self.log = open(args.log_file, "w")
+        self.trs = open(args.trs_file, "w")
+        self.color_tests = args.color_tests
+        self.expect_failure = args.expect_failure
+        self.reported = { }
+        self.test_plan = None
+        self.late_plan = False
+        self.errored = False
+        self.bail_out = False
+
+    def report(self, code, num, *args):
+        CODES = {
+            "XPASS": '\x1b[0;31m', # red
+            "FAIL": '\x1b[0;31m', # red
+            "PASS": '\x1b[0;32m', # grn
+            "XFAIL": '\x1b[1;32m', # lgn
+            "SKIP": '\x1b[1;34m', # blu
+            "ERROR": '\x1b[0;35m', # mgn
+        }
+
+        # Print out to console
+        if self.color_tests:
+            if code in CODES:
+                sys.stdout.write(CODES[code])
+        sys.stdout.write(code)
+        if self.color_tests:
+            sys.stdout.write('\x1b[m')
+        sys.stdout.write(": ")
+        sys.stdout.write(self.test_name)
+        sys.stdout.write(" ")
+        if num:
+            sys.stdout.write(str(num))
+            sys.stdout.write(" ")
+        for arg in args:
+            sys.stdout.write(str(arg))
+        sys.stdout.write("\n")
+        sys.stdout.flush()
+
+        # Book keeping
+        if code in CODES:
+            if num != None:
+                self.reported[num] = code
+            self.trs.write(":test-result: %s\n" % code)
+        if code == "ERROR":
+            self.errored = True
+
+    def result_pass(self, num, description):
+        if self.expect_failure:
+            self.report("XPASS", num, description)
+        else:
+            self.report("PASS", num, description)
+
+    def result_fail(self, num, description):
+        if self.expect_failure:
+            self.report("XFAIL", num, description)
+        else:
+            self.report("FAIL", num, description)
+
+    def result_skip(self, num, description, ok):
+        if self.expect_failure:
+            self.report("XFAIL", num, description)
+        else:
+            self.report("SKIP", num, description)
+
+    def report_error(self, problem):
+        self.report("ERROR", None, problem)
+
+    def consume_test_line(self, ok, data):
+        # It's an error if the caller sends a test plan in the middle of tests
+        if self.late_plan:
+            self.report_error("Got tests after late TAP test plan")
+            self.late_plan = False
+
+        # Parse out a number and then description
+        (num, unused, description) = data.partition(" ")
+        try:
+            num = int(num)
+        except ValueError:
+            self.report_error("Invalid test number: %s" %  data)
+            return
+        description = description.lstrip()
+
+        # Special case if description starts with this, then skip
+        if description.lower().startswith("# skip"):
+            self.result_skip(num, description, ok)
+        elif ok:
+            self.result_pass(num, description)
+        else:
+            self.result_fail(num, description)
+
+    def consume_test_plan(self, first, last):
+        # Only one test plan is supported
+        if self.test_plan:
+            self.report_error("Get a second TAP test plan")
+            return
+
+        try:
+            first = int(first)
+            last = int(last)
+        except ValueError:
+            self.report_error("Invalid test plan: %s..%s" % (first, last))
+            return
+
+        self.test_plan = (first, last)
+        self.late_plan = self.reported and True or False
+
+    def consume_bail_out(self, line):
+        self.bail_out = True
+        self.report("SKIP", 0, line)
+
+    def drain(self):
+        (ready, unused, self.output) = self.output.rpartition("\n")
+        for line in ready.split("\n"):
+            self.log.write(line)
+            self.log.write("\n")
+
+            if line.startswith("ok "):
+                self.consume_test_line(True, line[3:])
+            elif line.startswith("not ok "):
+                self.consume_test_line(False, line[7:])
+            elif line and line[0].isdigit() and ".." in line:
+                (first, unused, last) = line.partition("..")
+                self.consume_test_plan(first, last)
+            elif line.lower().startswith("bail out!"):
+                self.consume_bail_out(line)
+
+    def execute(self):
+        try:
+            proc = subprocess.Popen(self.argv, close_fds=True,
+                                    stdout=subprocess.PIPE,
+                                    stderr=subprocess.PIPE)
+        except OSError, ex:
+            self.report_error("Couldn't run %s: %s" % (self.argv[0], str(ex)))
+            return
+
+        outf = proc.stdout.fileno()
+        errf = proc.stderr.fileno()
+        rset = [outf, errf]
+        while len(rset) > 0:
+            ret = select.select(rset, [], [], 10)
+            if outf in ret[0]:
+                data = os.read(outf, 1024)
+                if data == "":
+                    if self.output:
+                        self.output += "\n"
+                    rset.remove(outf)
+                else:
+                    self.output += data
+                self.drain()
+            if errf in ret[0]:
+                data = os.read(errf, 1024)
+                if data == "":
+                    rset.remove(errf)
+                self.log.write(data)
+                sys.stderr.write(data)
+
+        proc.wait()
+        self.returncode = proc.returncode
+
+    def run(self):
+        self.execute()
+
+        failed = False
+        skipped = True
+
+        # Basic collation of results
+        for (num, code) in self.reported.items():
+            if code == "ERROR":
+                self.errored = True
+            elif code == "FAIL" or code == "XPASS":
+                failed = True
+            if code != "SKIP":
+                skipped = False
+
+        # Check the plan
+        if not self.errored:
+            if not self.test_plan:
+                if not self.bail_out:
+                    self.report_error("Didn't receive a TAP test plan")
+            else:
+                for i in range(self.test_plan[0], self.test_plan[1] + 1):
+                    if i not in self.reported:
+                        if self.bail_out:
+                            self.report("SKIP", i, "- bailed out")
+                        else:
+                            self.report("ERROR", i, "- missing test")
+                            skipped = False
+                            self.errored = True
+
+        if self.errored:
+            self.trs.write(":global-test-result: ERROR\n")
+            self.trs.write(":test-global-result: ERROR\n")
+            self.trs.write(":recheck: no\n")
+        elif failed:
+            self.trs.write(":global-test-result: FAIL\n")
+            self.trs.write(":test-global-result: FAIL\n")
+            self.trs.write(":recheck: yes\n")
+        elif skipped:
+            self.trs.write(":global-test-result: SKIP\n")
+            self.trs.write(":test-global-result: SKIP\n")
+            self.trs.write(":recheck: no\n")
+        if self.errored or failed:
+            self.trs.write(":copy-in-global-log: yes\n")
+
+        # Process result code
+        return self.errored and 1 or 0
+
+class YesNoAction(argparse.Action):
+    def __init__(self, option_strings, dest, **kwargs):
+        argparse.Action.__init__(self, option_strings, dest, **kwargs)
+        self.metavar = "[yes|no]"
+    def __call__(self, parser, namespace, values, option_string=None):
+        if not values or "yes" in values:
+            setattr(namespace, self.dest, True)
+        else:
+            setattr(namespace, self.dest, False)
+
+def main(argv):
+    parser = argparse.ArgumentParser(description='Automake TAP driver')
+    parser.add_argument('--test-name', metavar='NAME',
+                        help='The name of the test')
+    parser.add_argument('--log-file', metavar='PATH.log', required=True,
+                        help='The .log file the driver creates')
+    parser.add_argument('--trs-file', metavar='PATH.trs', required=True,
+                        help='The .trs file the driver creates')
+    parser.add_argument('--color-tests', default=True, action=YesNoAction,
+                        help='Whether the console output should be colorized or not')
+    parser.add_argument('--expect-failure', default=False, action=YesNoAction,
+                        help="Whether the tested program is expected to fail")
+    parser.add_argument('--enable-hard-errors', default=False, action=YesNoAction,
+                        help="Whether hard errors in the tested program are treated differently")
+    parser.add_argument('command', nargs='+',
+                        help="A test command line to run")
+    args = parser.parse_args(argv[1:])
+
+    if not args.test_name:
+        args.test_name = os.path.basename(args.command[0])
+
+    driver = Driver(args.command, args)
+    return driver.run()
+
+if __name__ == "__main__":
+    sys.exit(main(sys.argv))
diff --git a/configure.ac b/configure.ac
index 2e48d29..23bce0a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,7 @@ GCR_AGE=0
 dnl ****************************************************************************
 
 AC_CONFIG_MACRO_DIR([build/m4])
+AC_CONFIG_AUX_DIR([build])
 AM_INIT_AUTOMAKE([1.11 tar-ustar foreign -Wno-portability])
 AM_SANITY_CHECK
 AC_CONFIG_HEADERS(config.h)
@@ -386,37 +387,23 @@ AC_SUBST(GCR_MICRO)
 
 AC_OUTPUT([
 Makefile
-build/Makefile
-docs/Makefile
-docs/reference/Makefile
 docs/reference/gck/Makefile
 docs/reference/gck/version.xml
 docs/reference/gcr/Makefile
 docs/reference/gcr/version.xml
-egg/Makefile
-egg/tests/Makefile
 gck/gck.pc
 gck/gck-version.h
-gck/Makefile
-gck/tests/Makefile
 gcr/gcr-base.pc
 gcr/gcr-version.h
-gcr/Makefile
-gcr/tests/Makefile
 po/Makefile.in
-schema/Makefile
-testing/Makefile
 ui/gcr.pc
 ui/gcr-ui.pc
-ui/icons/Makefile
 ui/icons/16x16/Makefile
 ui/icons/22x22/Makefile
 ui/icons/24x24/Makefile
 ui/icons/32x32/Makefile
 ui/icons/48x48/Makefile
 ui/icons/256x256/Makefile
-ui/Makefile
-ui/tests/Makefile
 ])
 
 # ------------------------------------------------------------------------------
diff --git a/docs/reference/gck/Makefile.am b/docs/reference/gck/Makefile.am
index d7351d4..5733c3d 100644
--- a/docs/reference/gck/Makefile.am
+++ b/docs/reference/gck/Makefile.am
@@ -17,7 +17,7 @@ DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
 # gtk-doc will search all .c & .h files beneath here for inline comments
 # documenting the functions and macros.
 # e.g. DOC_SOURCE_DIR=../../../gtk
-DOC_SOURCE_DIR=$(top_srcdir)/gck
+DOC_SOURCE_DIR=$(top_srcdir)/gck $(top_builddir)/gck
 
 # Extra options to pass to gtkdoc-scangobj. Not normally needed.
 SCANGOBJ_OPTIONS=
@@ -88,7 +88,7 @@ expand_content_files=
 GTKDOC_CFLAGS= -I$(top_srcdir) -I$(top_builddir) $(GLIB_CFLAGS) -Wno-error \
        -Wno-deprecated-declarations
 GTKDOC_LIBS= $(GLIB_LIBS) \
-       $(top_builddir)/$(DOC_MODULE)/lib$(DOC_MODULE)- GCK_MAJOR@.la
+       $(top_builddir)/lib$(DOC_MODULE)- GCK_MAJOR@.la
 
 # This includes the standard gtk-doc make rules, copied by gtkdocize.
 include $(top_srcdir)/gtk-doc.make
diff --git a/docs/reference/gcr/Makefile.am b/docs/reference/gcr/Makefile.am
index 37c1fc9..1c6a9ee 100644
--- a/docs/reference/gcr/Makefile.am
+++ b/docs/reference/gcr/Makefile.am
@@ -21,7 +21,7 @@ DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
 # gtk-doc will search all .c & .h files beneath here for inline comments
 # documenting the functions and macros.
 # e.g. DOC_SOURCE_DIR=../../../gtk
-DOC_SOURCE_DIR=$(top_srcdir)/$(DOC_MODULE) $(top_srcdir)/ui
+DOC_SOURCE_DIR=$(top_srcdir)/$(DOC_MODULE) $(top_srcdir)/ui $(top_builddir)/$(DOC_MODULE) $(top_builddir)/ui
 
 # Extra options to pass to gtkdoc-scangobj. Not normally needed.
 SCANGOBJ_OPTIONS=
@@ -121,9 +121,9 @@ expand_content_files=
 GTKDOC_CFLAGS= -I$(top_srcdir) -I$(top_builddir) $(GLIB_CFLAGS) -Wno-error \
        -Wno-deprecated-declarations
 GTKDOC_LIBS= $(GLIB_LIBS) \
-       $(top_builddir)/ui/libgcr-ui- GCR_MAJOR@.la \
-       $(top_builddir)/gcr/libgcr-base- GCR_MAJOR@.la \
-       $(top_builddir)/gck/libgck- GCK_MAJOR@.la
+       $(top_builddir)/libgcr-ui- GCR_MAJOR@.la \
+       $(top_builddir)/libgcr-base- GCR_MAJOR@.la \
+       $(top_builddir)/libgck- GCK_MAJOR@.la
 
 # This includes the standard gtk-doc make rules, copied by gtkdocize.
 include $(top_srcdir)/gtk-doc.make
diff --git a/egg/Makefile.am b/egg/Makefile.am
index e826a2c..9006b39 100644
--- a/egg/Makefile.am
+++ b/egg/Makefile.am
@@ -1,17 +1,12 @@
-include $(top_srcdir)/Makefile.decl
+# included in top-level Makefile.am
 
-noinst_LTLIBRARIES = \
+noinst_LTLIBRARIES += \
        libegg.la \
        libegg-asn1x.la \
        libegg-hex.la \
        libegg-secmem.la \
        libegg-test.la
 
-AM_CPPFLAGS = \
-       -I$(top_srcdir) \
-       -I$(top_builddir) \
-       -I$(top_srcdir)/build
-
 libegg_la_CFLAGS = \
        $(GLIB_CFLAGS) \
        $(LIBGCRYPT_CFLAGS)
@@ -21,44 +16,38 @@ libegg_la_LIBADD = \
        $(LIBGCRYPT_LIBS)
 
 libegg_la_SOURCES = \
-       egg-armor.c egg-armor.h \
-       egg-asn1x.c egg-asn1x.h \
-       egg-asn1-defs.c egg-asn1-defs.h \
-       egg-buffer.c egg-buffer.h \
-       egg-dh.c egg-dh.h \
-       egg-dn.c egg-dn.h \
-       egg-error.h \
-       egg-decimal.c egg-decimal.h \
-       egg-hex.c egg-hex.h \
-       egg-hkdf.c egg-hkdf.h \
-       egg-libgcrypt.c egg-libgcrypt.h \
-       egg-oid.c egg-oid.h \
-       egg-padding.c egg-padding.h \
-       egg-openssl.c egg-openssl.h \
-       egg-secure-memory.c egg-secure-memory.h \
-       egg-symkey.c egg-symkey.h \
-       egg-testing.c egg-testing.h \
-       egg-timegm.c egg-timegm.h \
-       pk.asn.h pkix.asn.h \
-       $(NULL)
-
-EXTRA_DIST = \
-       pk.asn \
-       pkix.asn \
+       egg/egg-armor.c egg/egg-armor.h \
+       egg/egg-asn1x.c egg/egg-asn1x.h \
+       egg/egg-asn1-defs.c egg/egg-asn1-defs.h \
+       egg/egg-buffer.c egg/egg-buffer.h \
+       egg/egg-dh.c egg/egg-dh.h \
+       egg/egg-dn.c egg/egg-dn.h \
+       egg/egg-error.h \
+       egg/egg-decimal.c egg/egg-decimal.h \
+       egg/egg-hex.c egg/egg-hex.h \
+       egg/egg-hkdf.c egg/egg-hkdf.h \
+       egg/egg-libgcrypt.c egg/egg-libgcrypt.h \
+       egg/egg-oid.c egg/egg-oid.h \
+       egg/egg-padding.c egg/egg-padding.h \
+       egg/egg-openssl.c egg/egg-openssl.h \
+       egg/egg-secure-memory.c egg/egg-secure-memory.h \
+       egg/egg-symkey.c egg/egg-symkey.h \
+       egg/egg-testing.c egg/egg-testing.h \
+       egg/egg-timegm.c egg/egg-timegm.h \
+       egg/pk.asn.h egg/pkix.asn.h \
        $(NULL)
 
 # --------------------------------------------------------------------
 # COMMON STUFF COMPILED INTO SMALLER COMPONENTS
 
 libegg_asn1x_la_SOURCES = \
-       egg-asn1x.c egg-asn1x.h \
-       $(BUILT_SOURCES)
+       egg/egg-asn1x.c egg/egg-asn1x.h
 
 libegg_asn1x_la_CFLAGS = \
        $(GLIB_CFLAGS)
 
 libegg_hex_la_SOURCES = \
-       egg-hex.c egg-hex.h
+       egg/egg-hex.c egg/egg-hex.h
 
 libegg_hex_la_CFLAGS = \
        $(GLIB_CFLAGS)
@@ -67,10 +56,10 @@ libegg_hex_la_LIBADD = \
        $(GLIB_LIBS)
 
 libegg_secmem_la_SOURCES = \
-       egg-secure-memory.c egg-secure-memory.h
+       egg/egg-secure-memory.c egg/egg-secure-memory.h
 
 libegg_test_la_SOURCES = \
-       egg-testing.c egg-testing.h
+       egg/egg-testing.c egg/egg-testing.h
 
 libegg_test_la_CFLAGS = \
        $(GLIB_CFLAGS)
@@ -80,12 +69,81 @@ libegg_test_la_LIBADD = \
 
 # -------------------------------------------------------------------
 
-SUBDIRS = . tests
+egg_LDADD =  \
+       libegg.la \
+       $(LIBGCRYPT_LIBS) \
+       $(GLIB_LIBS)
+
+egg_TESTS = \
+       test-asn1 \
+       test-asn1x \
+       test-dn \
+       test-decimal \
+       test-hex \
+       test-hkdf \
+       test-oid \
+       test-secmem \
+       test-padding \
+       test-symkey \
+       test-armor \
+       test-openssl \
+       test-dh
+
+test_armor_SOURCES = egg/test-armor.c
+test_armor_LDADD = $(egg_LDADD)
+
+test_asn1_SOURCES = egg/test-asn1.c egg/test.asn.h
+test_asn1_LDADD = $(egg_LDADD)
+
+test_asn1x_SOURCES = egg/test-asn1x.c
+test_asn1x_LDADD = $(egg_LDADD)
+
+test_decimal_SOURCES = egg/test-decimal.c
+test_decimal_LDADD = $(egg_LDADD)
+
+test_dh_SOURCES = egg/test-dh.c
+test_dh_LDADD = $(egg_LDADD)
 
-check-memory:
-       make -C tests check-memory
+test_dn_SOURCES = egg/test-dn.c
+test_dn_LDADD = $(egg_LDADD)
+
+test_hex_SOURCES = egg/test-hex.c
+test_hex_LDADD = $(egg_LDADD)
+
+test_hkdf_SOURCES = egg/test-hkdf.c
+test_hkdf_LDADD = $(egg_LDADD)
+
+test_oid_SOURCES = egg/test-oid.c
+test_oid_LDADD = $(egg_LDADD)
+
+test_openssl_SOURCES = egg/test-openssl.c
+test_openssl_LDADD = $(egg_LDADD)
+
+test_padding_SOURCES = egg/test-padding.c
+test_padding_LDADD = $(egg_LDADD)
+
+test_secmem_SOURCES = egg/test-secmem.c
+test_secmem_LDADD = $(egg_LDADD)
+
+test_symkey_SOURCES = egg/test-symkey.c
+test_symkey_LDADD = $(egg_LDADD)
+
+check_PROGRAMS += $(egg_TESTS)
+TESTS += $(egg_TESTS)
+
+ASN_SRCS = \
+       egg/pk.asn \
+       egg/pkix.asn \
+       egg/test.asn \
+       $(NULL)
 
 asn:
-       asn1Parser -o pk.asn.h pk.asn
-       asn1Parser -o pkix.asn.h pkix.asn
-       sed -i 's|#include.*|/* \0 */|' pk.asn.h pkix.asn.h
+       for asn in $(ASN_SRCS); do \
+               asn1Parser -o $(srcdir)/$$asn.h $$asn \
+               sed -i 's|#include.*|/* \0 */|' $$asn.h \
+       done
+
+EXTRA_DIST += \
+       egg/fixtures \
+       $(ASN_SRCS) \
+       $(NULL)
diff --git a/egg/egg-asn1x.c b/egg/egg-asn1x.c
index 7ea1685..0daf2ef 100644
--- a/egg/egg-asn1x.c
+++ b/egg/egg-asn1x.c
@@ -4513,7 +4513,7 @@ traverse_and_dump (GNode *node, gpointer unused)
 
        depth = g_node_depth (node);
        for (i = 0; i < depth - 1; ++i)
-               g_printerr ("    ");
+               g_print ("    ");
 
        an = node->data;
        output = g_string_new ("");
@@ -4521,14 +4521,14 @@ traverse_and_dump (GNode *node, gpointer unused)
        dump_append_flags (output, anode_def_flags (node));
        string = g_utf8_casefold (output->str, output->len - 1);
        g_string_free (output, TRUE);
-       g_printerr ("+ %s: %s [%s]%s\n", anode_def_name (node), anode_def_value (node),
-                   string, an->parsed || an->value ? " *" : "");
+       g_print ("+ %s: %s [%s]%s\n", anode_def_name (node), anode_def_value (node),
+                string, an->parsed || an->value ? " *" : "");
        g_free (string);
 
        /* Print out all the options */
        for (l = an->opts; l; l = g_list_next (l)) {
                for (i = 0; i < depth; ++i)
-                       g_printerr ("    ");
+                       g_print ("    ");
 
                def = l->data;
                output = g_string_new ("");
@@ -4536,7 +4536,7 @@ traverse_and_dump (GNode *node, gpointer unused)
                dump_append_flags (output, def->type);
                string = g_utf8_casefold (output->str, output->len - 1);
                g_string_free (output, TRUE);
-               g_printerr ("- %s: %s [%s]\n", def->name, (const gchar*)def->value, string);
+               g_print ("- %s: %s [%s]\n", def->name, (const gchar*)def->value, string);
                g_free (string);
        }
 
diff --git a/egg/egg-timegm.c b/egg/egg-timegm.c
index a075d25..24faa4c 100644
--- a/egg/egg-timegm.c
+++ b/egg/egg-timegm.c
@@ -15,8 +15,6 @@
    License along with the GNU C Library; see the file COPYING.LIB.  If not,
    see <http://www.gnu.org/licenses/>.  */
 
-/* Extracted from misc/mkdtemp.c and sysdeps/posix/tempname.c.  */
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
diff --git a/egg/egg-timegm.h b/egg/egg-timegm.h
index ad68d23..02bec8f 100644
--- a/egg/egg-timegm.h
+++ b/egg/egg-timegm.h
@@ -16,8 +16,6 @@
    License along with the GNU C Library; see the file COPYING.LIB.  If not,
    see <http://www.gnu.org/licenses/>.  */
 
-/* Extracted from misc/mkdtemp.c and sysdeps/posix/tempname.c.  */
-
 #ifndef EGG_TIMEGM_H_
 #define EGG_TIMEGM_H_
 
diff --git a/egg/tests/files/dh-params.pem b/egg/fixtures/dh-params.pem
similarity index 100%
rename from egg/tests/files/dh-params.pem
rename to egg/fixtures/dh-params.pem
diff --git a/egg/tests/files/echo-script.sh b/egg/fixtures/echo-script.sh
similarity index 100%
rename from egg/tests/files/echo-script.sh
rename to egg/fixtures/echo-script.sh
diff --git a/egg/tests/files/pem-rsa-enc.key b/egg/fixtures/pem-rsa-enc.key
similarity index 100%
rename from egg/tests/files/pem-rsa-enc.key
rename to egg/fixtures/pem-rsa-enc.key
diff --git a/egg/tests/files/test-personalname-1.der b/egg/fixtures/test-personalname-1.der
similarity index 100%
rename from egg/tests/files/test-personalname-1.der
rename to egg/fixtures/test-personalname-1.der
diff --git a/egg/tests/files/test-personalname-invalid.der b/egg/fixtures/test-personalname-invalid.der
similarity index 100%
rename from egg/tests/files/test-personalname-invalid.der
rename to egg/fixtures/test-personalname-invalid.der
diff --git a/egg/tests/test-armor.c b/egg/test-armor.c
similarity index 100%
rename from egg/tests/test-armor.c
rename to egg/test-armor.c
diff --git a/egg/tests/test-asn1.c b/egg/test-asn1.c
similarity index 99%
rename from egg/tests/test-asn1.c
rename to egg/test-asn1.c
index 36912f8..883c92b 100644
--- a/egg/tests/test-asn1.c
+++ b/egg/test-asn1.c
@@ -1745,7 +1745,7 @@ setup (Test *test, gconstpointer unused)
 {
        GBytes *bytes;
 
-       if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der",
+       if (!g_file_get_contents (SRCDIR "/egg/fixtures/test-certificate-1.der",
                                  (gchar**)&test->data, &test->n_data, NULL))
                g_assert_not_reached ();
 
diff --git a/egg/tests/test-asn1x.c b/egg/test-asn1x.c
similarity index 89%
rename from egg/tests/test-asn1x.c
rename to egg/test-asn1x.c
index f4d8e33..fec410e 100644
--- a/egg/tests/test-asn1x.c
+++ b/egg/test-asn1x.c
@@ -74,11 +74,11 @@ typedef struct {
 } Fixture;
 
 static const Fixture parse_test_fixtures[] = {
-       { pkix_asn1_tab, SRCDIR "/files/test-certificate-1.der", "Certificate" },
-       { pkix_asn1_tab, SRCDIR "/files/test-pkcs8-1.der", "pkcs-8-PrivateKeyInfo" },
-       { pk_asn1_tab, SRCDIR "/files/test-rsakey-1.der", "RSAPrivateKey" },
-       { pkix_asn1_tab, SRCDIR "/files/test-pkcs7-1.der", "pkcs-7-ContentInfo" },
-       { pkix_asn1_tab, SRCDIR "/files/test-pkcs7-2.der", "pkcs-7-ContentInfo" },
+       { pkix_asn1_tab, SRCDIR "/egg/fixtures/test-certificate-1.der", "Certificate" },
+       { pkix_asn1_tab, SRCDIR "/egg/fixtures/test-pkcs8-1.der", "pkcs-8-PrivateKeyInfo" },
+       { pk_asn1_tab, SRCDIR "/egg/fixtures/test-rsakey-1.der", "RSAPrivateKey" },
+       { pkix_asn1_tab, SRCDIR "/egg/fixtures/test-pkcs7-1.der", "pkcs-7-ContentInfo" },
+       { pkix_asn1_tab, SRCDIR "/egg/fixtures/test-pkcs7-2.der", "pkcs-7-ContentInfo" },
 };
 
 static void
@@ -191,9 +191,9 @@ main (int argc, char **argv)
                g_free (name);
        }
 
-       g_test_add ("/asn1x/pkcs12-decode/1", Test, SRCDIR "/files/test-pkcs12-1.der",
+       g_test_add ("/asn1x/pkcs12-decode/1", Test, SRCDIR "/egg/fixtures/test-pkcs12-1.der",
                    setup, test_pkcs12_decode, teardown);
-       g_test_add ("/asn1x/pkcs5-personal-name/invalid", Test, SRCDIR "/files/test-personalname-invalid.der",
+       g_test_add ("/asn1x/pkcs5-personal-name/invalid", Test, SRCDIR 
"/egg/fixtures/test-personalname-invalid.der",
                    setup, test_personal_name_invalid, teardown);
 
        return g_test_run ();
diff --git a/egg/tests/test-decimal.c b/egg/test-decimal.c
similarity index 100%
rename from egg/tests/test-decimal.c
rename to egg/test-decimal.c
diff --git a/egg/tests/test-dh.c b/egg/test-dh.c
similarity index 100%
rename from egg/tests/test-dh.c
rename to egg/test-dh.c
diff --git a/egg/tests/test-dn.c b/egg/test-dn.c
similarity index 98%
rename from egg/tests/test-dn.c
rename to egg/test-dn.c
index 3cc0561..f209068 100644
--- a/egg/tests/test-dn.c
+++ b/egg/test-dn.c
@@ -46,7 +46,7 @@ setup (Test *test, gconstpointer unused)
 {
        GBytes *bytes;
 
-       if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der",
+       if (!g_file_get_contents (SRCDIR "/egg/fixtures/test-certificate-1.der",
                                  (gchar**)&test->data, &test->n_data, NULL))
                g_assert_not_reached ();
 
diff --git a/egg/tests/test-hex.c b/egg/test-hex.c
similarity index 100%
rename from egg/tests/test-hex.c
rename to egg/test-hex.c
diff --git a/egg/tests/test-hkdf.c b/egg/test-hkdf.c
similarity index 100%
rename from egg/tests/test-hkdf.c
rename to egg/test-hkdf.c
diff --git a/egg/tests/test-oid.c b/egg/test-oid.c
similarity index 100%
rename from egg/tests/test-oid.c
rename to egg/test-oid.c
diff --git a/egg/tests/test-openssl.c b/egg/test-openssl.c
similarity index 98%
rename from egg/tests/test-openssl.c
rename to egg/test-openssl.c
index cf3fd4c..b18565f 100644
--- a/egg/tests/test-openssl.c
+++ b/egg/test-openssl.c
@@ -53,7 +53,7 @@ setup (Test *test, gconstpointer unused)
        gchar *contents;
        gsize length;
 
-       if (!g_file_get_contents (SRCDIR "/files/pem-rsa-enc.key", &contents, &length, NULL))
+       if (!g_file_get_contents (SRCDIR "/egg/fixtures/pem-rsa-enc.key", &contents, &length, NULL))
                g_assert_not_reached ();
 
        test->input = g_bytes_new_take (contents, length);
diff --git a/egg/tests/test-padding.c b/egg/test-padding.c
similarity index 100%
rename from egg/tests/test-padding.c
rename to egg/test-padding.c
diff --git a/egg/tests/test-secmem.c b/egg/test-secmem.c
similarity index 100%
rename from egg/tests/test-secmem.c
rename to egg/test-secmem.c
diff --git a/egg/tests/test-symkey.c b/egg/test-symkey.c
similarity index 100%
rename from egg/tests/test-symkey.c
rename to egg/test-symkey.c
diff --git a/egg/tests/test.asn b/egg/test.asn
similarity index 100%
rename from egg/tests/test.asn
rename to egg/test.asn
diff --git a/egg/tests/test.asn.h b/egg/test.asn.h
similarity index 100%
rename from egg/tests/test.asn.h
rename to egg/test.asn.h
diff --git a/gck/Makefile.am b/gck/Makefile.am
index 4779c37..8c4951c 100644
--- a/gck/Makefile.am
+++ b/gck/Makefile.am
@@ -1,116 +1,113 @@
-include $(top_srcdir)/Makefile.decl
+# included in top-level Makefile.am
+
+gck_incdir = $(includedir)/gck- GCK_MAJOR@/gck
+
+gck_HEADER_FILES = \
+       gck/gck.h \
+       gck/gck-deprecated.h
+
+gck_inc_HEADERS = \
+       $(gck_HEADER_FILES) \
+       gck/gck-enum-types.h \
+       gck/gck-version.h \
+       gck/pkcs11.h \
+       gck/pkcs11n.h \
+       gck/pkcs11x.h
+
+gck_BUILT_SOURCES = \
+       gck/gck-marshal.c gck/gck-marshal.h \
+       gck/gck-enum-types.c gck/gck-enum-types.h
+
+BUILT_SOURCES += $(gck_BUILT_SOURCES)
+
+lib_LTLIBRARIES += libgck- GCK_MAJOR@.la
+
+gck_PUBLIC_FILES = \
+       gck/gck.h \
+       gck/gck-enum-types.h \
+       gck/gck-attributes.c \
+       gck/gck-dump.c \
+       gck/gck-enumerator.c \
+       gck/gck-misc.c \
+       gck/gck-module.c \
+       gck/gck-modules.c \
+       gck/gck-object.c \
+       gck/gck-object-cache.c \
+       gck/gck-password.c \
+       gck/gck-session.c \
+       gck/gck-slot.c \
+       gck/gck-uri.c \
+       gck/gck-version.h
+
+gck_INTERNAL_FILES = \
+       gck/gck-call.c \
+       gck/gck-debug.c gck/gck-debug.h \
+       gck/gck-deprecated.h \
+       gck/gck-interaction.c \
+       gck/gck-private.h \
+       gck/pkcs11.h
 
-SUBDIRS = . tests
-
-incdir = $(includedir)/gck- GCK_MAJOR@/gck
-
-HEADER_FILES = \
-       gck.h \
-       gck-deprecated.h
+libgck_ GCK_MAJOR@_la_SOURCES = \
+       $(gck_PUBLIC_FILES) \
+       $(gck_INTERNAL_FILES)
 
-inc_HEADERS = \
-       $(HEADER_FILES) \
-       gck-enum-types.h \
-       gck-version.h \
-       pkcs11.h \
-       pkcs11n.h \
-       pkcs11x.h
+nodist_libgck_ GCK_MAJOR@_la_SOURCES = \
+       $(gck_BUILT_SOURCES)
 
-AM_CPPFLAGS = \
-       -I$(top_builddir) \
-       -I$(top_srcdir)/gcr \
-       -I$(top_srcdir) \
+libgck_ GCK_MAJOR@_la_CFLAGS = \
        $(P11_KIT_CFLAGS) \
-       $(GTHREAD_CFLAGS) \
-       $(GLIB_CFLAGS) \
        -DG_LOG_DOMAIN=\"Gck\" \
        -DGCK_API_SUBJECT_TO_CHANGE \
        -DP11_KIT_API_SUBJECT_TO_CHANGE \
        -DPKCS11_REGISTRY_DIR=\"$(libdir)/pkcs11\"
 
-BUILT_SOURCES = \
-       gck-marshal.c gck-marshal.h \
-       gck-enum-types.c gck-enum-types.h
-
-lib_LTLIBRARIES = libgck- GCK_MAJOR@.la
-
-PUBLIC_FILES = \
-       gck.h \
-       gck-enum-types.h \
-       gck-attributes.c \
-       gck-dump.c \
-       gck-enumerator.c \
-       gck-misc.c \
-       gck-module.c \
-       gck-modules.c \
-       gck-object.c \
-       gck-object-cache.c \
-       gck-password.c \
-       gck-session.c \
-       gck-slot.c \
-       gck-uri.c \
-       gck-version.h
-
-INTERNAL_FILES = \
-       gck-call.c \
-       gck-debug.c gck-debug.h \
-       gck-deprecated.h \
-       gck-interaction.c \
-       gck-private.h \
-       pkcs11.h
-
-libgck_ GCK_MAJOR@_la_SOURCES = \
-       $(PUBLIC_FILES) \
-       $(INTERNAL_FILES)
-
-nodist_libgck_ GCK_MAJOR@_la_SOURCES = \
-       $(BUILT_SOURCES)
-
 libgck_ GCK_MAJOR@_la_LDFLAGS = \
        -version-info $(GCK_LT_RELEASE) \
        -no-undefined \
        -export-symbols-regex '^gck_.*|^SECMEM_.*'
 
 libgck_ GCK_MAJOR@_la_LIBADD = \
-       $(top_builddir)/egg/libegg-hex.la \
-       $(top_builddir)/egg/libegg-secmem.la \
+       libegg-hex.la \
+       libegg-secmem.la \
        $(P11_KIT_LIBS) \
-       $(GTHREAD_LIBS) \
        $(GIO_LIBS) \
        $(GLIB_LIBS)
 
-noinst_LTLIBRARIES = libgck-testable.la
+noinst_LTLIBRARIES += libgck-testable.la
 libgck_testable_la_SOURCES = \
-       gck-mock.c \
-       gck-mock.h \
-       gck-test.c \
-       gck-test.h
-libgck_testable_la_LIBADD = $(libgck_ GCK_MAJOR@_la_OBJECTS) \
+       gck/gck-mock.c gck/gck-mock.h \
+       gck/gck-test.c gck/gck-test.h
+
+libgck_testable_la_CFLAGS = \
+       $(libgck_ GCK_MAJOR@_la_CFLAGS)
+
+libgck_testable_la_LIBADD = \
+       $(libgck_ GCK_MAJOR@_la_OBJECTS) \
        $(libgck_ GCK_MAJOR@_la_LIBADD)
 libgck_testable_la_DEPENDENCIES = $(libgck_ GCK_MAJOR@_la_OBJECTS)
 
-gck-marshal.h: gck-marshal.list $(GLIB_GENMARSHAL)
+gck/gck-marshal.h: gck/gck-marshal.list $(GLIB_GENMARSHAL)
        $(AM_V_GEN) $(GLIB_GENMARSHAL) $< --header --prefix=_gck_marshal > $@
 
-gck-marshal.c: gck-marshal.list $(GLIB_GENMARSHAL)
-       $(AM_V_GEN) echo "#include \"gck-marshal.h\"" > $@ && \
+gck/gck-marshal.c: gck/gck-marshal.list $(GLIB_GENMARSHAL)
+       $(AM_V_GEN) echo "#include \"gck/gck-marshal.h\"" > $@ && \
                $(GLIB_GENMARSHAL) $< --body --prefix=_gck_marshal >> $@
 
-gck-enum-types.h: $(ENUM_TEMPLATE_H) $(HEADER_FILES)
+gck/gck-enum-types.h: $(ENUM_TEMPLATE_H) $(gck_HEADER_FILES)
        $(AM_V_GEN) $(GLIB_MKENUMS) --template $^ > $@
 
-gck-enum-types.c: $(ENUM_TEMPLATE_C) $(HEADER_FILES)
+gck/gck-enum-types.c: $(ENUM_TEMPLATE_C) $(gck_HEADER_FILES)
        $(AM_V_GEN) $(GLIB_MKENUMS) --template $^ > $@
 
-EXTRA_DIST = \
-       gck.pc.in \
-       gck-marshal.list \
-       gck-version.h \
-       gck.symbols \
-       pkcs11-trust-assertions.h \
-       pkcs11i.h
+EXTRA_DIST += \
+       gck/gck.pc.in \
+       gck/gck-marshal.list \
+       gck/gck-version.h \
+       gck/gck.symbols \
+       gck/pkcs11-trust-assertions.h \
+       gck/pkcs11i.h
 
-CLEANFILES = \
+CLEANFILES += \
        gck-$(GCK_MAJOR).pc \
        $(gir_DATA) \
        $(typelibs_DATA) \
@@ -123,11 +120,7 @@ CLEANFILES = \
 
 if HAVE_INTROSPECTION
 
-include $(INTROSPECTION_MAKEFILE)
-
-INTROSPECTION_GIRS = Gck- GCK_MAJOR@.gir
-INTROSPECTION_SCANNER_ARGS = $(INTROSPECTION_FLAGS) --warn-all --add-include-path=$(srcdir) 
--add-include-path=.
-INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) --includedir=.
+INTROSPECTION_GIRS += Gck- GCK_MAJOR@.gir
 
 Gck- GCK_MAJOR@.gir: libgck- GCK_MAJOR@.la
 
@@ -135,45 +128,30 @@ Gck_ GCK_MAJOR@_gir_PACKAGES = gobject-2.0 gio-2.0 p11-kit-1
 Gck_ GCK_MAJOR@_gir_EXPORT_PACKAGES = gck- GCK_MAJOR@
 Gck_ GCK_MAJOR@_gir_INCLUDES = GObject-2.0 Gio-2.0
 Gck_ GCK_MAJOR@_gir_LIBS = libgck- GCK_MAJOR@.la
-Gck_ GCK_MAJOR@_gir_CFLAGS = -I$(top_srcdir) -I$(top_builddir) -DGCK_COMPILATION -DGCK_API_SUBJECT_TO_CHANGE
-Gck_ GCK_MAJOR@_gir_FILES = $(PUBLIC_FILES)
-Gck_ GCK_MAJOR@_gir_SCANNERFLAGS = --c-include "gck/gck.h"
+Gck_ GCK_MAJOR@_gir_CFLAGS = -I$(srcdir) -I$(builddir) -DGCK_COMPILATION -DGCK_API_SUBJECT_TO_CHANGE
+Gck_ GCK_MAJOR@_gir_FILES = $(gck_PUBLIC_FILES)
+Gck_ GCK_MAJOR@_gir_SCANNERFLAGS = --add-include-path=$(srcdir)/gck --c-include "gck/gck.h"
 
-girdir = $(datadir)/gir-1.0
-gir_DATA = $(INTROSPECTION_GIRS)
-
-typelibsdir = $(libdir)/girepository-1.0
-typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+gir_DATA += Gck- GCK_MAJOR@.gir
 
 if ENABLE_VAPIGEN
-include $(VAPIGEN_MAKEFILE)
 
-gck- GCK_MAJOR@.vapi: Gck- GCK_MAJOR@.gir Gck- GCK_MAJOR@.metadata gck- GCK_MAJOR@.deps
+gck- GCK_MAJOR@.vapi: Gck- GCK_MAJOR@.gir gck/Gck- GCK_MAJOR@.metadata gck- GCK_MAJOR@.deps
 
-VAPIGEN_VAPIS = gck- GCK_MAJOR@.vapi
+VAPIGEN_VAPIS += gck- GCK_MAJOR@.vapi
 
 gck_ GCK_MAJOR@_vapi_DEPS = glib-2.0 gio-2.0
 gck_ GCK_MAJOR@_vapi_METADATADIRS = $(srcdir)
 gck_ GCK_MAJOR@_vapi_FILES = Gck- GCK_MAJOR@.gir
 
-VAPI_DEPS = $(VAPIGEN_VAPIS:.vapi=.deps)
-
 gck-$(GCK_MAJOR).deps: Makefile.am
        $(AM_V_GEN) echo $(gck_ GCK_MAJOR@_vapi_DEPS) | tr ' ' '\n' > $@
 
-vapidir = $(datadir)/vala/vapi
-vapi_DATA = \
-       pkcs11.vapi \
-       $(VAPIGEN_VAPIS) \
-       $(VAPI_DEPS)
+vapi_DATA += gck/pkcs11.vapi
 
 EXTRA_DIST += \
-       Gck- GCK_MAJOR@.metadata \
-       pkcs11.vapi
-
-CLEANFILES += \
-       $(VAPIGEN_VAPIS) \
-       $(VAPI_DEPS)
+       gck/Gck- GCK_MAJOR@.metadata \
+       gck/pkcs11.vapi
 
 endif # ENABLE_VAPIGEN
 
@@ -181,24 +159,103 @@ endif
 
 # ----------------------------------------------------------------
 
-pkgconfig_DATA = gck-$(GCK_MAJOR).pc
+pkgconfig_DATA += gck-$(GCK_MAJOR).pc
 
-gck-$(GCK_MAJOR).pc: gck.pc
-       $(AM_V_GEN) cp gck.pc gck-$(GCK_MAJOR).pc
+gck-$(GCK_MAJOR).pc: gck/gck.pc
+       $(AM_V_GEN) cp gck/gck.pc gck-$(GCK_MAJOR).pc
 
-gck-expected.abi: gck.symbols
+gck-expected.abi: gck/gck.symbols
        $(AM_V_GEN) cpp -P $< | sort > $@
 
 gck-actual.abi: $(builddir)/.libs/libgck- GCK_MAJOR@.so
        $(AM_V_GEN)  $(NM) -D -g --defined-only $< | \
                cut -d ' ' -f 3 | grep -Ev '^(__bss_start|_edata|_end)' | sort > $@
 
-check-symbols: gck-expected.abi gck-actual.abi
+check-gck-symbols: gck-expected.abi gck-actual.abi
        $(AM_V_GEN) diff -U0 --ignore-blank-lines gck-expected.abi gck-actual.abi || \
                (echo "check-symbols: Symbols have CHANGED. Fix gck.symbols"; exit 1)
 
-check-local: check-symbols
+gck_CFLAGS = \
+       -I$(top_builddir) \
+       -I$(top_srcdir) \
+       -DGCK_API_SUBJECT_TO_CHANGE \
+       -DG_LOG_DOMAIN=\"Gck\" \
+       $(P11_KIT_CFLAGS) \
+       $(GLIB_CFLAGS)
+
+gck_LIBS =  \
+       libgck-testable.la \
+       libegg-test.la \
+       libegg-hex.la \
+       $(GLIB_LIBS) \
+       $(P11_KIT_LIBS) \
+       $(GIO_LIBS)
+
+gck_TESTS = \
+       test-gck-attributes \
+       test-gck-module \
+       test-gck-slot \
+       test-gck-session \
+       test-gck-object \
+       test-gck-crypto \
+       test-gck-uri \
+       test-gck-enumerator \
+       test-gck-modules
+
+test_gck_attributes_SOURCES = gck/test-gck-attributes.c
+test_gck_attributes_CFLAGS = $(gck_CFLAGS)
+test_gck_attributes_LDADD = $(gck_LIBS)
+
+test_gck_crypto_SOURCES = gck/test-gck-crypto.c
+test_gck_crypto_CFLAGS = $(gck_CFLAGS)
+test_gck_crypto_LDADD = $(gck_LIBS)
+
+test_gck_enumerator_SOURCES = \
+       gck/test-gck-enumerator.c \
+       gck/mock-interaction.c gck/mock-interaction.h
+test_gck_enumerator_CFLAGS = $(gck_CFLAGS)
+test_gck_enumerator_LDADD = $(gck_LIBS)
+
+test_gck_object_SOURCES = gck/test-gck-object.c
+test_gck_object_CFLAGS = $(gck_CFLAGS)
+test_gck_object_LDADD = $(gck_LIBS)
+
+test_gck_module_SOURCES = gck/test-gck-module.c
+test_gck_module_CFLAGS = $(gck_CFLAGS)
+test_gck_module_LDADD = $(gck_LIBS)
+
+test_gck_modules_SOURCES = gck/test-gck-modules.c
+test_gck_modules_CFLAGS = $(gck_CFLAGS)
+test_gck_modules_LDADD = $(gck_LIBS)
+
+test_gck_session_SOURCES = \
+       gck/test-gck-session.c \
+       gck/mock-interaction.c gck/mock-interaction.h
+test_gck_session_CFLAGS = $(gck_CFLAGS)
+test_gck_session_LDADD = $(gck_LIBS)
+
+test_gck_slot_SOURCES = gck/test-gck-slot.c
+test_gck_slot_CFLAGS = $(gck_CFLAGS)
+test_gck_slot_LDADD = $(gck_LIBS)
+
+test_gck_uri_SOURCES = gck/test-gck-uri.c
+test_gck_uri_CFLAGS = $(gck_CFLAGS)
+test_gck_uri_LDADD = $(gck_LIBS)
+
+check_PROGRAMS += $(gck_TESTS)
+TESTS += $(gck_TESTS)
+
+check_LTLIBRARIES += libmock-test-module.la
+
+libmock_test_module_la_LDFLAGS = \
+       -module -avoid-version -shared -rpath $(abs_builddir)
+
+libmock_test_module_la_CFLAGS = \
+       -DGCK_API_SUBJECT_TO_CHANGE \
+       $(gck_CFLAGS)
 
-check-memory:
-       make -C tests check-memory
+libmock_test_module_la_SOURCES = \
+       gck/mock-test-module.c
 
+libmock_test_module_la_LIBADD = \
+       libgck-testable.la
diff --git a/gck/gck-module.c b/gck/gck-module.c
index 257e88b..71c2832 100644
--- a/gck/gck-module.c
+++ b/gck/gck-module.c
@@ -24,7 +24,8 @@
 
 #include "gck.h"
 #include "gck-private.h"
-#include "gck-marshal.h"
+
+#include "gck/gck-marshal.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/gck/gck-modules.c b/gck/gck-modules.c
index 64ee63d..9b59ba8 100644
--- a/gck/gck-modules.c
+++ b/gck/gck-modules.c
@@ -24,7 +24,8 @@
 
 #include "gck.h"
 #include "gck-private.h"
-#include "gck-marshal.h"
+
+#include "gck/gck-marshal.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/gck/gck-session.c b/gck/gck-session.c
index 5df0020..7e635c3 100644
--- a/gck/gck-session.c
+++ b/gck/gck-session.c
@@ -25,9 +25,10 @@
 #include "gck.h"
 #define DEBUG_FLAG GCK_DEBUG_SESSION
 #include "gck-debug.h"
-#include "gck-marshal.h"
 #include "gck-private.h"
 
+#include "gck/gck-marshal.h"
+
 #include <string.h>
 
 #include <glib/gi18n-lib.h>
diff --git a/gck/gck-uri.c b/gck/gck-uri.c
index 6ab71b7..29caeba 100644
--- a/gck/gck-uri.c
+++ b/gck/gck-uri.c
@@ -24,7 +24,8 @@
 
 #include "gck.h"
 #include "gck-private.h"
-#include "gck-marshal.h"
+
+#include "gck/gck-marshal.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/gck/tests/mock-interaction.c b/gck/mock-interaction.c
similarity index 100%
rename from gck/tests/mock-interaction.c
rename to gck/mock-interaction.c
diff --git a/gck/tests/mock-interaction.h b/gck/mock-interaction.h
similarity index 100%
rename from gck/tests/mock-interaction.h
rename to gck/mock-interaction.h
diff --git a/gck/tests/mock-test-module.c b/gck/mock-test-module.c
similarity index 100%
rename from gck/tests/mock-test-module.c
rename to gck/mock-test-module.c
diff --git a/gck/tests/test-gck-attributes.c b/gck/test-gck-attributes.c
similarity index 100%
rename from gck/tests/test-gck-attributes.c
rename to gck/test-gck-attributes.c
diff --git a/gck/tests/test-gck-crypto.c b/gck/test-gck-crypto.c
similarity index 100%
rename from gck/tests/test-gck-crypto.c
rename to gck/test-gck-crypto.c
diff --git a/gck/tests/test-gck-enumerator.c b/gck/test-gck-enumerator.c
similarity index 100%
rename from gck/tests/test-gck-enumerator.c
rename to gck/test-gck-enumerator.c
diff --git a/gck/tests/test-gck-module.c b/gck/test-gck-module.c
similarity index 100%
rename from gck/tests/test-gck-module.c
rename to gck/test-gck-module.c
diff --git a/gck/tests/test-gck-modules.c b/gck/test-gck-modules.c
similarity index 100%
rename from gck/tests/test-gck-modules.c
rename to gck/test-gck-modules.c
diff --git a/gck/tests/test-gck-object.c b/gck/test-gck-object.c
similarity index 100%
rename from gck/tests/test-gck-object.c
rename to gck/test-gck-object.c
diff --git a/gck/tests/test-gck-session.c b/gck/test-gck-session.c
similarity index 100%
rename from gck/tests/test-gck-session.c
rename to gck/test-gck-session.c
diff --git a/gck/tests/test-gck-slot.c b/gck/test-gck-slot.c
similarity index 100%
rename from gck/tests/test-gck-slot.c
rename to gck/test-gck-slot.c
diff --git a/gck/tests/test-gck-uri.c b/gck/test-gck-uri.c
similarity index 100%
rename from gck/tests/test-gck-uri.c
rename to gck/test-gck-uri.c
diff --git a/gcr/Makefile.am b/gcr/Makefile.am
index e88f8ec..d3469d7 100644
--- a/gcr/Makefile.am
+++ b/gcr/Makefile.am
@@ -1,140 +1,128 @@
-include $(top_srcdir)/Makefile.decl
-
-SUBDIRS = . tests
-
-incdir = $(includedir)/gcr- GCR_MAJOR@/gcr
-
-AM_CPPFLAGS = \
-       -I$(top_builddir) \
-       -I$(top_srcdir) \
-       $(GLIB_CFLAGS) \
-       $(LIBGCRYPT_CFLAGS) \
-       $(P11_KIT_CFLAGS) \
-       -DG_LOG_DOMAIN=\"Gcr\" \
-       -DGCR_API_SUBJECT_TO_CHANGE \
-       -DLOCALEDIR=\""$(datadir)/locale"\"
-
-check-local: check-symbols
-
-check-memory:
-       make -C tests check-memory
-
-HEADER_FILES = \
-       gcr-base.h \
-       gcr-certificate.h \
-       gcr-certificate-chain.h \
-       gcr-certificate-request.h \
-       gcr-collection.h \
-       gcr-column.h \
-       gcr-comparable.h \
-       gcr-deprecated-base.h \
-       gcr-fingerprint.h \
-       gcr-filter-collection.h \
-       gcr-icons.h \
-       gcr-importer.h \
-       gcr-import-interaction.h \
-       gcr-library.h \
-       gcr-mock-prompter.h \
-       gcr-parser.h \
-       gcr-pkcs11-certificate.h \
-       gcr-prompt.h \
-       gcr-secret-exchange.h \
-       gcr-secure-memory.h \
-       gcr-simple-certificate.h \
-       gcr-simple-collection.h \
-       gcr-system-prompt.h \
-       gcr-system-prompter.h \
-       gcr-trust.h \
-       gcr-types.h \
-       gcr-union-collection.h \
-       gcr-unlock-options.h \
-       gcr-version.h
-
-inc_HEADERS = \
-       $(HEADER_FILES) \
-       gcr-enum-types-base.h
+# included in top-level Makefile.am
+
+gcr_incdir = $(includedir)/gcr- GCR_MAJOR@/gcr
+
+gcr_HEADER_FILES = \
+       gcr/gcr-base.h \
+       gcr/gcr-certificate.h \
+       gcr/gcr-certificate-chain.h \
+       gcr/gcr-certificate-request.h \
+       gcr/gcr-collection.h \
+       gcr/gcr-column.h \
+       gcr/gcr-comparable.h \
+       gcr/gcr-deprecated-base.h \
+       gcr/gcr-fingerprint.h \
+       gcr/gcr-filter-collection.h \
+       gcr/gcr-icons.h \
+       gcr/gcr-importer.h \
+       gcr/gcr-import-interaction.h \
+       gcr/gcr-library.h \
+       gcr/gcr-mock-prompter.h \
+       gcr/gcr-parser.h \
+       gcr/gcr-pkcs11-certificate.h \
+       gcr/gcr-prompt.h \
+       gcr/gcr-secret-exchange.h \
+       gcr/gcr-secure-memory.h \
+       gcr/gcr-simple-certificate.h \
+       gcr/gcr-simple-collection.h \
+       gcr/gcr-system-prompt.h \
+       gcr/gcr-system-prompter.h \
+       gcr/gcr-trust.h \
+       gcr/gcr-types.h \
+       gcr/gcr-union-collection.h \
+       gcr/gcr-unlock-options.h \
+       gcr/gcr-version.h
+
+gcr_inc_HEADERS = \
+       $(gcr/HEADER_FILES) \
+       gcr/gcr-enum-types-base.h
 
 if WITH_GTK
-inc_HEADERS += gcr.h
+gcr_inc_HEADERS += gcr/gcr.h
 endif
 
-lib_LTLIBRARIES = \
+lib_LTLIBRARIES += \
        libgcr-base- GCR_MAJOR@.la
 
-BUILT_SOURCES = \
-       gcr-marshal.c gcr-marshal.h \
-       gcr-enum-types-base.c gcr-enum-types-base.h \
-       gcr-oids.c gcr-oids.h \
-       gcr-dbus-generated.c gcr-dbus-generated.h
-
-PUBLIC_FILES = \
-       gcr-base.h \
-       gcr-certificate.c gcr-certificate.h \
-       gcr-certificate-chain.c gcr-certificate-chain.h \
-       gcr-certificate-request.c gcr-certificate-request.h \
-       gcr-collection.c gcr-collection.h \
-       gcr-column.h \
-       gcr-comparable.c gcr-comparable.h \
-       gcr-filter-collection.c gcr-filter-collection.h \
-       gcr-fingerprint.c gcr-fingerprint.h \
-       gcr-icons.c gcr-icons.h \
-       gcr-importer.c gcr-importer.h \
-       gcr-import-interaction.c gcr-import-interaction.h \
-       gcr-library.c gcr-library.h \
-       gcr-mock-prompter.c gcr-mock-prompter.h \
-       gcr-parser.c gcr-parser.h \
-       gcr-pkcs11-certificate.c gcr-pkcs11-certificate.h \
-       gcr-prompt.c gcr-prompt.h \
-       gcr-secret-exchange.c gcr-secret-exchange.h \
-       gcr-secure-memory.c gcr-secure-memory.h \
-       gcr-simple-certificate.c gcr-simple-certificate.h \
-       gcr-simple-collection.c gcr-simple-collection.h \
-       gcr-system-prompt.c gcr-system-prompt.h \
-       gcr-system-prompter.c gcr-system-prompter.h \
-       gcr-types.h \
-       gcr-union-collection.c gcr-union-collection.h \
-       gcr-unlock-options.h \
-       gcr-version.h \
+gcr_BUILT_SOURCES = \
+       gcr/gcr-marshal.c gcr/gcr-marshal.h \
+       gcr/gcr-enum-types-base.c gcr/gcr-enum-types-base.h \
+       gcr/gcr-oids.c gcr/gcr-oids.h \
+       gcr/gcr-dbus-generated.c gcr/gcr-dbus-generated.h
+
+BUILT_SOURCES += $(gcr_BUILT_SOURCES)
+
+gcr_PUBLIC_FILES = \
+       gcr/gcr-base.h \
+       gcr/gcr-certificate.c gcr/gcr-certificate.h \
+       gcr/gcr-certificate-chain.c gcr/gcr-certificate-chain.h \
+       gcr/gcr-certificate-request.c gcr/gcr-certificate-request.h \
+       gcr/gcr-collection.c gcr/gcr-collection.h \
+       gcr/gcr-column.h \
+       gcr/gcr-comparable.c gcr/gcr-comparable.h \
+       gcr/gcr-filter-collection.c gcr/gcr-filter-collection.h \
+       gcr/gcr-fingerprint.c gcr/gcr-fingerprint.h \
+       gcr/gcr-icons.c gcr/gcr-icons.h \
+       gcr/gcr-importer.c gcr/gcr-importer.h \
+       gcr/gcr-import-interaction.c gcr/gcr-import-interaction.h \
+       gcr/gcr-library.c gcr/gcr-library.h \
+       gcr/gcr-mock-prompter.c gcr/gcr-mock-prompter.h \
+       gcr/gcr-parser.c gcr/gcr-parser.h \
+       gcr/gcr-pkcs11-certificate.c gcr/gcr-pkcs11-certificate.h \
+       gcr/gcr-prompt.c gcr/gcr-prompt.h \
+       gcr/gcr-secret-exchange.c gcr/gcr-secret-exchange.h \
+       gcr/gcr-secure-memory.c gcr/gcr-secure-memory.h \
+       gcr/gcr-simple-certificate.c gcr/gcr-simple-certificate.h \
+       gcr/gcr-simple-collection.c gcr/gcr-simple-collection.h \
+       gcr/gcr-system-prompt.c gcr/gcr-system-prompt.h \
+       gcr/gcr-system-prompter.c gcr/gcr-system-prompter.h \
+       gcr/gcr-types.h \
+       gcr/gcr-union-collection.c gcr/gcr-union-collection.h \
+       gcr/gcr-unlock-options.h \
+       gcr/gcr-version.h \
        $(NULL)
 
-PRIVATE_FILES = \
-       gcr-callback-output-stream.c gcr-callback-output-stream.h \
-       gcr-certificate-extensions.c gcr-certificate-extensions.h \
-       gcr-column.c \
-       gcr-dbus-constants.h \
-       gcr-debug.c gcr-debug.h \
-       gcr-deprecated-base.h \
-       gcr-gnupg-collection.c gcr-gnupg-collection.h \
-       gcr-gnupg-importer.c gcr-gnupg-importer.h \
-       gcr-gnupg-key.c gcr-gnupg-key.h \
-       gcr-gnupg-process.c gcr-gnupg-process.h \
-       gcr-gnupg-records.c gcr-gnupg-records.h \
-       gcr-gnupg-util.c gcr-gnupg-util.h \
-       gcr-internal.h \
-       gcr-key-mechanisms.h gcr-key-mechanisms.c \
-       gcr-memory-icon.c gcr-memory-icon.h \
-       gcr-openpgp.c gcr-openpgp.h \
-       gcr-openssh.c gcr-openssh.h \
-       gcr-pkcs11-importer.c gcr-pkcs11-importer.h \
-       gcr-record.c gcr-record.h \
-       gcr-single-collection.c gcr-single-collection.h \
-       gcr-subject-public-key.c gcr-subject-public-key.h \
-       gcr-trust.c gcr-trust.h \
-       gcr-util.c gcr-util.h \
+gcr_PRIVATE_FILES = \
+       gcr/gcr-callback-output-stream.c gcr/gcr-callback-output-stream.h \
+       gcr/gcr-certificate-extensions.c gcr/gcr-certificate-extensions.h \
+       gcr/gcr-column.c \
+       gcr/gcr-dbus-constants.h \
+       gcr/gcr-debug.c gcr/gcr-debug.h \
+       gcr/gcr-deprecated-base.h \
+       gcr/gcr-gnupg-collection.c gcr/gcr-gnupg-collection.h \
+       gcr/gcr-gnupg-importer.c gcr/gcr-gnupg-importer.h \
+       gcr/gcr-gnupg-key.c gcr/gcr-gnupg-key.h \
+       gcr/gcr-gnupg-process.c gcr/gcr-gnupg-process.h \
+       gcr/gcr-gnupg-records.c gcr/gcr-gnupg-records.h \
+       gcr/gcr-gnupg-util.c gcr/gcr-gnupg-util.h \
+       gcr/gcr-internal.h \
+       gcr/gcr-key-mechanisms.h gcr/gcr-key-mechanisms.c \
+       gcr/gcr-memory-icon.c gcr/gcr-memory-icon.h \
+       gcr/gcr-openpgp.c gcr/gcr-openpgp.h \
+       gcr/gcr-openssh.c gcr/gcr-openssh.h \
+       gcr/gcr-pkcs11-importer.c gcr/gcr-pkcs11-importer.h \
+       gcr/gcr-record.c gcr/gcr-record.h \
+       gcr/gcr-single-collection.c gcr/gcr-single-collection.h \
+       gcr/gcr-subject-public-key.c gcr/gcr-subject-public-key.h \
+       gcr/gcr-trust.c gcr/gcr-trust.h \
+       gcr/gcr-util.c gcr/gcr-util.h \
        $(NULL)
 
 libgcr_base_ GCR_MAJOR@_la_SOURCES = \
-       $(PUBLIC_FILES) \
-       $(PRIVATE_FILES) \
+       $(gcr_PUBLIC_FILES) \
+       $(gcr_PRIVATE_FILES) \
        $(NULL)
 
 nodist_libgcr_base_ GCR_MAJOR@_la_SOURCES = \
-       $(BUILT_SOURCES)
+       $(gcr_BUILT_SOURCES)
 
 libgcr_base_ GCR_MAJOR@_la_CFLAGS = \
+       $(LIBGCRYPT_CFLAGS) \
+       $(P11_KIT_CFLAGS) \
        -DGCK_API_SUBJECT_TO_CHANGE \
        -DP11_KIT_API_SUBJECT_TO_CHANGE \
-       -DGCR_COMPILATION
+       -DGCR_COMPILATION \
+       -DG_LOG_DOMAIN=\"Gcr\"
 
 libgcr_base_ GCR_MAJOR@_la_LDFLAGS = \
        -version-info $(GCR_LT_RELEASE) \
@@ -142,86 +130,70 @@ libgcr_base_ GCR_MAJOR@_la_LDFLAGS = \
        -export-symbols-regex '^_gcr_.*|^gcr_.*|^SECMEM_.*'
 
 libgcr_base_ GCR_MAJOR@_la_LIBADD = \
-       $(top_builddir)/egg/libegg.la \
-       $(top_builddir)/gck/libgck- GCK_MAJOR@.la \
+       libegg.la \
+       libgck- GCK_MAJOR@.la \
        $(GLIB_LIBS) \
        $(LIBGCRYPT_LIBS) \
        $(P11_KIT_LIBS)
 
-gcr-marshal.h: gcr-marshal.list $(GLIB_GENMARSHAL)
+gcr/gcr-marshal.h: gcr/gcr-marshal.list $(GLIB_GENMARSHAL)
        $(AM_V_GEN) $(GLIB_GENMARSHAL) $< --header --prefix=_gcr_marshal > $@
 
-gcr-marshal.c: gcr-marshal.list $(GLIB_GENMARSHAL)
-       $(AM_V_GEN) ( echo "#include \"gcr-marshal.h\"" > $@ && \
+gcr/gcr-marshal.c: gcr/gcr-marshal.list $(GLIB_GENMARSHAL)
+       $(AM_V_GEN) ( echo "#include \"gcr/gcr-marshal.h\"" > $@ && \
                $(GLIB_GENMARSHAL) $< --body --prefix=_gcr_marshal >> $@ )
 
-gcr-enum-types-base.h: $(ENUM_TEMPLATE_H) $(HEADER_FILES)
+gcr/gcr-enum-types-base.h: $(ENUM_TEMPLATE_H) $(gcr_HEADER_FILES)
        $(AM_V_GEN) $(GLIB_MKENUMS) --template $^ > $@
-gcr-enum-types-base.c: $(ENUM_TEMPLATE_C) $(HEADER_FILES)
+gcr/gcr-enum-types-base.c: $(ENUM_TEMPLATE_C) $(gcr_HEADER_FILES)
        $(AM_V_GEN) $(GLIB_MKENUMS) --template $^ > $@
 
-# $(AM_V_GEN) 
-
-gcr-oids.c: gcr-oids.list gcr-mkoids
-       $(AM_V_GEN) sh $(srcdir)/gcr-mkoids -p GCR -c gcr-oids.c -h gcr-oids.h $(srcdir)/gcr-oids.list
+gcr/gcr-oids.c: gcr/gcr-oids.list gcr/gcr-mkoids
+       $(AM_V_GEN) sh $(srcdir)/gcr/gcr-mkoids -p GCR -c gcr/gcr-oids.c -h gcr/gcr-oids.h 
$(srcdir)/gcr/gcr-oids.list
 
-gcr-oids.h: gcr-oids.c
+gcr/gcr-oids.h: gcr/gcr-oids.c
 
 DBUS_XML_DEFINITIONS = \
-       org.gnome.keyring.Prompter.xml
+       gcr/org.gnome.keyring.Prompter.xml
 
-gcr-dbus-generated.c: $(DBUS_XML_DEFINITIONS)
+gcr/gcr-dbus-generated.c: $(DBUS_XML_DEFINITIONS)
        $(AM_V_GEN) gdbus-codegen --interface-prefix org.gnome.keyring.internal. \
-               --generate-c-code gcr-dbus-generated --c-namespace GcrDBus $^
-       $(AM_V_GEN) sed -i -e 's/gcr_dbus/_gcr_dbus/g' gcr-dbus-generated.[ch]
+               --generate-c-code gcr/gcr-dbus-generated --c-namespace GcrDBus $^
+       $(AM_V_GEN) sed -i -e 's/gcr_dbus/_gcr_dbus/g' gcr/gcr-dbus-generated.[ch]
 
-gcr-dbus-generated.h: gcr-dbus-generated.c
+gcr/gcr-dbus-generated.h: gcr/gcr-dbus-generated.c
 
-pkgconfig_DATA = \
+pkgconfig_DATA += \
        gcr-base-$(GCR_MAJOR).pc
 
-gcr-base-$(GCR_MAJOR).pc: gcr-base.pc
-       $(AM_V_GEN) cp gcr-base.pc gcr-base-$(GCR_MAJOR).pc
+gcr-base-$(GCR_MAJOR).pc: gcr/gcr-base.pc
+       $(AM_V_GEN) cp gcr/gcr-base.pc gcr-base-$(GCR_MAJOR).pc
 
 service_in_files = \
-       org.gnome.keyring.SystemPrompter.service.in \
-       org.gnome.keyring.PrivatePrompter.service.in
+       gcr/org.gnome.keyring.SystemPrompter.service.in \
+       gcr/org.gnome.keyring.PrivatePrompter.service.in
 servicedir       = $(DBUS_SERVICES_DIR)
 service_DATA     = $(service_in_files:.service.in=.service)
 
-EXTRA_DIST = \
-       gcr-base.pc.in \
-       gcr-marshal.list \
-       gcr-oids.list \
-       gcr-mkoids \
+EXTRA_DIST += \
+       gcr/gcr-base.pc.in \
+       gcr/gcr-marshal.list \
+       gcr/gcr-oids.list \
+       gcr/gcr-mkoids \
        $(DBUS_XML_DEFINITIONS) \
-       gcr-base.symbols \
+       gcr/gcr-base.symbols \
        $(service_in_files) \
-       gcr-version.h.in
+       gcr/gcr-version.h.in
 
-CLEANFILES = \
-       $(BUILT_SOURCES) \
-       $(pkgconfig_DATA) \
+CLEANFILES += \
        $(service_DATA) \
-       $(desktop_in_files) \
-       $(gir_DATA) \
-       $(typelibs_DATA) \
        gcr-base-actual.abi \
-       gcr-base-expected.abi
+       gcr-base-expected.abi \
+       Gcr-3.broken.gir
 
 if HAVE_INTROSPECTION
 
-include $(INTROSPECTION_MAKEFILE)
-
-INTROSPECTION_GIRS = Gcr- GCR_MAJOR@.broken.gir
-INTROSPECTION_SCANNER_ARGS = \
-       $(INTROSPECTION_FLAGS) \
-       --warn-all \
-       --add-include-path=$(top_builddir)/gck  \
-       --include-uninstalled=$(top_builddir)/gck/Gck- GCK_MAJOR@.gir
-INTROSPECTION_COMPILER_ARGS = \
-       --includedir=$(srcdir) \
-       --includedir=$(top_builddir)/gck
+INTROSPECTION_GIRS += Gcr- GCR_MAJOR@.broken.gir
 
 Gcr- GCR_MAJOR@.gir: Gcr- GCR_MAJOR@.broken.gir $(FIX_GIR)
 
@@ -233,23 +205,20 @@ Gcr_ GCR_MAJOR@_broken_gir_INCLUDES = GLib-2.0 GObject-2.0
 Gcr_ GCR_MAJOR@_broken_gir_LIBS = libgcr-base- GCR_MAJOR@.la
 Gcr_ GCR_MAJOR@_broken_gir_CFLAGS = -I$(top_srcdir) -I$(top_builddir) \
        -DGCR_COMPILATION -DGCR_API_SUBJECT_TO_CHANGE
-Gcr_ GCR_MAJOR@_broken_gir_FILES = $(PUBLIC_FILES)
-Gcr_ GCR_MAJOR@_broken_gir_SCANNERFLAGS = --c-include "gcr/gcr-base.h" \
+Gcr_ GCR_MAJOR@_broken_gir_FILES = $(gcr_PUBLIC_FILES)
+Gcr_ GCR_MAJOR@_broken_gir_SCANNERFLAGS = \
+       --add-include-path=$(top_builddir)/gck \
+       --include-uninstalled=$(builddir)/Gck- GCK_MAJOR@.gir \
+       --c-include "gcr/gcr-base.h" \
        --identifier-prefix Gcr
 
-girdir = $(datadir)/gir-1.0
-gir_DATA = Gcr- GCR_MAJOR@.gir
-
-typelibsdir = $(libdir)/girepository-1.0
-typelibs_DATA = $(gir_DATA:.gir=.typelib)
+gir_DATA += Gcr- GCR_MAJOR@.gir
 
 if ENABLE_VAPIGEN
 
-include $(VAPIGEN_MAKEFILE)
-
-gcr- GCR_MAJOR@.vapi: Gcr- GCR_MAJOR@.gir Gcr- GCR_MAJOR@.metadata gcr- GCR_MAJOR@.deps
+gcr- GCR_MAJOR@.vapi: Gcr- GCR_MAJOR@.gir gcr/Gcr- GCR_MAJOR@.metadata gcr- GCR_MAJOR@.deps
 
-VAPIGEN_VAPIS = gcr- GCR_MAJOR@.vapi
+VAPIGEN_VAPIS += gcr- GCR_MAJOR@.vapi
 
 gcr_ GCR_MAJOR@_vapi_DEPS = glib-2.0 gio-2.0 gck- GCK_MAJOR@
 gcr_ GCR_MAJOR@_vapi_METADATADIRS = $(srcdir)
@@ -257,22 +226,11 @@ gcr_ GCR_MAJOR@_vapi_VAPIDIRS = $(builddir)/../gck
 gcr_ GCR_MAJOR@_vapi_GIRDIRS = $(builddir)/../gck
 gcr_ GCR_MAJOR@_vapi_FILES = Gcr- GCR_MAJOR@.gir
 
-VAPI_DEPS = $(VAPIGEN_VAPIS:.vapi=.deps)
-
 gcr-$(GCR_MAJOR).deps: Makefile.am
        $(AM_V_GEN) echo $(gcr_ GCR_MAJOR@_vapi_DEPS) | tr ' ' '\n' > $@
 
-vapidir = $(datadir)/vala/vapi
-vapi_DATA = \
-       $(VAPIGEN_VAPIS) \
-       $(VAPI_DEPS)
-
 EXTRA_DIST += \
-       Gcr- GCR_MAJOR@.metadata
-
-CLEANFILES += \
-       $(VAPIGEN_VAPIS) \
-       $(VAPI_DEPS)
+       gcr/Gcr- GCR_MAJOR@.metadata
 
 endif # ENABLE_VAPIGEN
 
@@ -280,13 +238,161 @@ endif # HAVE_INTROSPECTON
 
 # ----------------------------------------------------------------
 
-gcr-base-expected.abi: gcr-base.symbols
+gcr-base-expected.abi: gcr/gcr-base.symbols
        $(AM_V_GEN) cpp -P $< | sort > $@
 
 gcr-base-actual.abi: $(builddir)/.libs/libgcr-base- GCR_MAJOR@.so
        $(AM_V_GEN)  $(NM) -D -g --defined-only $< | \
                cut -d ' ' -f 3 | grep -Ev '^(__bss_start|_edata|_end|_gcr_)' | sort > $@
 
-check-symbols: gcr-base-expected.abi gcr-base-actual.abi
+check-gcr-symbols: gcr-base-expected.abi gcr-base-actual.abi
        $(AM_V_GEN) diff -U0 --ignore-blank-lines gcr-base-expected.abi gcr-base-actual.abi || \
                (echo "check-symbols: Symbols have CHANGED. Fix gcr-base.symbols"; exit 1)
+
+gcr_CFLAGS = \
+       -I$(top_builddir) \
+       -I$(top_srcdir) \
+       -DSRCDIR="\"@abs_srcdir \"" \
+       -DGCR_API_SUBJECT_TO_CHANGE \
+       -DGCK_API_SUBJECT_TO_CHANGE \
+       -DGCR_COMPILATION \
+       $(GLIB_CFLAGS) \
+       $(LIBGCRYPT_CFLAGS) \
+       $(P11_KIT_CFLAGS)
+
+gcr_LIBS = \
+       libgcr-base- GCR_MAJOR@.la \
+       libegg.la \
+       libgck-testable.la \
+       $(GLIB_LIBS) \
+       $(LIBGCRYPT_LIBS) \
+       $(P11_KIT_LIBS)
+
+gcr_TESTS = \
+       test-util \
+       test-filter-collection \
+       test-secret-exchange \
+       test-simple-certificate \
+       test-certificate \
+       test-certificate-chain \
+       test-subject-public-key \
+       test-fingerprint \
+       test-pkcs11-certificate \
+       test-openpgp \
+       test-openssh \
+       test-secure-memory \
+       test-trust \
+       test-parser \
+       test-record \
+       test-memory-icon \
+       test-gnupg-key \
+       test-gnupg-collection \
+       test-gnupg-process \
+       test-system-prompt
+
+test_certificate_SOURCES = gcr/test-certificate.c
+test_certificate_CFLAGS = $(gcr_CFLAGS)
+test_certificate_LDADD = $(gcr_LIBS)
+
+test_certificate_chain_SOURCES = gcr/test-certificate-chain.c
+test_certificate_chain_CFLAGS = $(gcr_CFLAGS)
+test_certificate_chain_LDADD = $(gcr_LIBS)
+
+test_filter_collection_SOURCES = gcr/test-filter-collection.c
+test_filter_collection_CFLAGS = $(gcr_CFLAGS)
+test_filter_collection_LDADD = $(gcr_LIBS)
+
+test_fingerprint_SOURCES = gcr/test-fingerprint.c
+test_fingerprint_CFLAGS = $(gcr_CFLAGS)
+test_fingerprint_LDADD = $(gcr_LIBS)
+
+test_gnupg_collection_SOURCES = gcr/test-gnupg-collection.c
+test_gnupg_collection_CFLAGS = $(gcr_CFLAGS)
+test_gnupg_collection_LDADD = $(gcr_LIBS)
+
+test_gnupg_key_SOURCES = gcr/test-gnupg-key.c
+test_gnupg_key_CFLAGS = $(gcr_CFLAGS)
+test_gnupg_key_LDADD = $(gcr_LIBS)
+
+test_gnupg_process_SOURCES = gcr/test-gnupg-process.c
+test_gnupg_process_CFLAGS = $(gcr_CFLAGS)
+test_gnupg_process_LDADD = $(gcr_LIBS)
+
+test_memory_icon_SOURCES = gcr/test-memory-icon.c
+test_memory_icon_CFLAGS = $(gcr_CFLAGS)
+test_memory_icon_LDADD = $(gcr_LIBS)
+
+test_openpgp_SOURCES = gcr/test-openpgp.c
+test_openpgp_CFLAGS = $(gcr_CFLAGS)
+test_openpgp_LDADD = $(gcr_LIBS)
+
+test_openssh_SOURCES = gcr/test-openssh.c
+test_openssh_CFLAGS = $(gcr_CFLAGS)
+test_openssh_LDADD = $(gcr_LIBS)
+
+test_parser_SOURCES = gcr/test-parser.c
+test_parser_CFLAGS = $(gcr_CFLAGS)
+test_parser_LDADD = $(gcr_LIBS)
+
+test_pkcs11_certificate_SOURCES = gcr/test-pkcs11-certificate.c
+test_pkcs11_certificate_CFLAGS = $(gcr_CFLAGS)
+test_pkcs11_certificate_LDADD = $(gcr_LIBS)
+
+test_record_SOURCES = gcr/test-record.c
+test_record_CFLAGS = $(gcr_CFLAGS)
+test_record_LDADD = $(gcr_LIBS)
+
+test_secret_exchange_SOURCES = gcr/test-secret-exchange.c
+test_secret_exchange_CFLAGS = $(gcr_CFLAGS)
+test_secret_exchange_LDADD = $(gcr_LIBS)
+
+test_secure_memory_SOURCES = gcr/test-secure-memory.c
+test_secure_memory_CFLAGS = $(gcr_CFLAGS)
+test_secure_memory_LDADD = $(gcr_LIBS)
+
+test_simple_certificate_SOURCES = gcr/test-simple-certificate.c
+test_simple_certificate_CFLAGS = $(gcr_CFLAGS)
+test_simple_certificate_LDADD = $(gcr_LIBS)
+
+test_subject_public_key_SOURCES = gcr/test-subject-public-key.c
+test_subject_public_key_CFLAGS = $(gcr_CFLAGS)
+test_subject_public_key_LDADD = $(gcr_LIBS)
+
+test_system_prompt_SOURCES = gcr/test-system-prompt.c
+test_system_prompt_CFLAGS = $(gcr_CFLAGS)
+test_system_prompt_LDADD = $(gcr_LIBS)
+
+test_trust_SOURCES = gcr/test-trust.c
+test_trust_CFLAGS = $(gcr_CFLAGS)
+test_trust_LDADD = $(gcr_LIBS)
+
+test_util_SOURCES = gcr/test-util.c
+test_util_CFLAGS = $(gcr_CFLAGS)
+test_util_LDADD = $(gcr_LIBS)
+
+check_PROGRAMS += $(gcr_TESTS)
+TESTS += $(gcr_TESTS)
+
+EXTRA_DIST += \
+       gcr/fixtures
+
+# ------------------------------------------------------------------
+
+noinst_PROGRAMS += \
+       frob-openpgp \
+       frob-certificate-request \
+       frob-parser
+
+frob_certificate_request_SOURCES = \
+       gcr/frob-certificate-request.c \
+       gcr/console-interaction.c gcr/console-interaction.h
+frob_certificate_request_CFLAGS = $(gcr_CFLAGS)
+frob_certificate_request_LDADD = $(gcr_LIBS)
+
+frob_openpgp_SOURCES = gcr/frob-openpgp.c
+frob_openpgp_CFLAGS = $(gcr_CFLAGS)
+frob_openpgp_LDADD = $(gcr_LIBS)
+
+frob_parser_SOURCES = gcr/frob-parser.c
+frob_parser_CFLAGS = $(gcr_CFLAGS)
+frob_parser_LDADD = $(gcr_LIBS)
diff --git a/gcr/tests/console-interaction.c b/gcr/console-interaction.c
similarity index 100%
rename from gcr/tests/console-interaction.c
rename to gcr/console-interaction.c
diff --git a/gcr/tests/console-interaction.h b/gcr/console-interaction.h
similarity index 100%
rename from gcr/tests/console-interaction.h
rename to gcr/console-interaction.h
diff --git a/gcr/tests/files/RSA_Root_Certificate_1.pem b/gcr/fixtures/RSA_Root_Certificate_1.pem
similarity index 100%
rename from gcr/tests/files/RSA_Root_Certificate_1.pem
rename to gcr/fixtures/RSA_Root_Certificate_1.pem
diff --git a/gcr/tests/files/RSA_Security_1024_v3.pem b/gcr/fixtures/RSA_Security_1024_v3.pem
similarity index 100%
rename from gcr/tests/files/RSA_Security_1024_v3.pem
rename to gcr/fixtures/RSA_Security_1024_v3.pem
diff --git a/gcr/tests/files/RSA_Security_2048_v3.pem b/gcr/fixtures/RSA_Security_2048_v3.pem
similarity index 100%
rename from gcr/tests/files/RSA_Security_2048_v3.pem
rename to gcr/fixtures/RSA_Security_2048_v3.pem
diff --git a/gcr/tests/files/Thawte_Personal_Basic_CA.pem b/gcr/fixtures/Thawte_Personal_Basic_CA.pem
similarity index 100%
rename from gcr/tests/files/Thawte_Personal_Basic_CA.pem
rename to gcr/fixtures/Thawte_Personal_Basic_CA.pem
diff --git a/gcr/tests/files/Thawte_Personal_Freemail_CA.pem b/gcr/fixtures/Thawte_Personal_Freemail_CA.pem
similarity index 100%
rename from gcr/tests/files/Thawte_Personal_Freemail_CA.pem
rename to gcr/fixtures/Thawte_Personal_Freemail_CA.pem
diff --git a/gcr/tests/files/Thawte_Personal_Premium_CA.pem b/gcr/fixtures/Thawte_Personal_Premium_CA.pem
similarity index 100%
rename from gcr/tests/files/Thawte_Personal_Premium_CA.pem
rename to gcr/fixtures/Thawte_Personal_Premium_CA.pem
diff --git a/gcr/tests/files/Thawte_Premium_Server_CA.pem b/gcr/fixtures/Thawte_Premium_Server_CA.pem
similarity index 100%
rename from gcr/tests/files/Thawte_Premium_Server_CA.pem
rename to gcr/fixtures/Thawte_Premium_Server_CA.pem
diff --git a/gcr/tests/files/Thawte_Server_CA.pem b/gcr/fixtures/Thawte_Server_CA.pem
similarity index 100%
rename from gcr/tests/files/Thawte_Server_CA.pem
rename to gcr/fixtures/Thawte_Server_CA.pem
diff --git a/gcr/tests/files/Thawte_Time_Stamping_CA.pem b/gcr/fixtures/Thawte_Time_Stamping_CA.pem
similarity index 100%
rename from gcr/tests/files/Thawte_Time_Stamping_CA.pem
rename to gcr/fixtures/Thawte_Time_Stamping_CA.pem
diff --git a/gcr/tests/files/base64-rsa-2048.spkac b/gcr/fixtures/base64-rsa-2048.spkac
similarity index 100%
rename from gcr/tests/files/base64-rsa-2048.spkac
rename to gcr/fixtures/base64-rsa-2048.spkac
diff --git a/gcr/tests/files/ca-certificates.crt b/gcr/fixtures/ca-certificates.crt
similarity index 100%
rename from gcr/tests/files/ca-certificates.crt
rename to gcr/fixtures/ca-certificates.crt
diff --git a/gcr/tests/files/cacert.org.pem b/gcr/fixtures/cacert.org.pem
similarity index 100%
rename from gcr/tests/files/cacert.org.pem
rename to gcr/fixtures/cacert.org.pem
diff --git a/gcr/tests/files/client.key b/gcr/fixtures/client.key
similarity index 100%
rename from gcr/tests/files/client.key
rename to gcr/fixtures/client.key
diff --git a/gcr/tests/files/client.pem b/gcr/fixtures/client.pem
similarity index 100%
rename from gcr/tests/files/client.pem
rename to gcr/fixtures/client.pem
diff --git a/gcr/tests/files/generic-dsa.key b/gcr/fixtures/generic-dsa.key
similarity index 100%
rename from gcr/tests/files/generic-dsa.key
rename to gcr/fixtures/generic-dsa.key
diff --git a/gcr/tests/files/generic-dsa.pem b/gcr/fixtures/generic-dsa.pem
similarity index 100%
rename from gcr/tests/files/generic-dsa.pem
rename to gcr/fixtures/generic-dsa.pem
diff --git a/gcr/tests/files/gnupg-homedir/gpg.conf b/gcr/fixtures/gnupg-homedir/gpg.conf
similarity index 95%
rename from gcr/tests/files/gnupg-homedir/gpg.conf
rename to gcr/fixtures/gnupg-homedir/gpg.conf
index 4a536a8..e1479ae 100644
--- a/gcr/tests/files/gnupg-homedir/gpg.conf
+++ b/gcr/fixtures/gnupg-homedir/gpg.conf
@@ -1,2 +1 @@
 no-auto-check-trustdb
-
diff --git a/gcr/tests/files/gnupg-mock/mock-arguments-environ 
b/gcr/fixtures/gnupg-mock/mock-arguments-environ
similarity index 100%
rename from gcr/tests/files/gnupg-mock/mock-arguments-environ
rename to gcr/fixtures/gnupg-mock/mock-arguments-environ
diff --git a/gcr/tests/files/gnupg-mock/mock-echo b/gcr/fixtures/gnupg-mock/mock-echo
similarity index 100%
rename from gcr/tests/files/gnupg-mock/mock-echo
rename to gcr/fixtures/gnupg-mock/mock-echo
diff --git a/gcr/tests/files/gnupg-mock/mock-fail-exit b/gcr/fixtures/gnupg-mock/mock-fail-exit
similarity index 100%
rename from gcr/tests/files/gnupg-mock/mock-fail-exit
rename to gcr/fixtures/gnupg-mock/mock-fail-exit
diff --git a/gcr/tests/files/gnupg-mock/mock-fail-signal b/gcr/fixtures/gnupg-mock/mock-fail-signal
similarity index 100%
rename from gcr/tests/files/gnupg-mock/mock-fail-signal
rename to gcr/fixtures/gnupg-mock/mock-fail-signal
diff --git a/gcr/tests/files/gnupg-mock/mock-simple-error b/gcr/fixtures/gnupg-mock/mock-simple-error
similarity index 100%
rename from gcr/tests/files/gnupg-mock/mock-simple-error
rename to gcr/fixtures/gnupg-mock/mock-simple-error
diff --git a/gcr/tests/files/gnupg-mock/mock-simple-output b/gcr/fixtures/gnupg-mock/mock-simple-output
similarity index 100%
rename from gcr/tests/files/gnupg-mock/mock-simple-output
rename to gcr/fixtures/gnupg-mock/mock-simple-output
diff --git a/gcr/tests/files/gnupg-mock/mock-status-and-attribute 
b/gcr/fixtures/gnupg-mock/mock-status-and-attribute
similarity index 100%
rename from gcr/tests/files/gnupg-mock/mock-status-and-attribute
rename to gcr/fixtures/gnupg-mock/mock-status-and-attribute
diff --git a/gcr/tests/files/gnupg-mock/mock-status-and-output 
b/gcr/fixtures/gnupg-mock/mock-status-and-output
similarity index 100%
rename from gcr/tests/files/gnupg-mock/mock-status-and-output
rename to gcr/fixtures/gnupg-mock/mock-status-and-output
diff --git a/gcr/tests/files/gnupg-mock/mock-with-homedir b/gcr/fixtures/gnupg-mock/mock-with-homedir
similarity index 100%
rename from gcr/tests/files/gnupg-mock/mock-with-homedir
rename to gcr/fixtures/gnupg-mock/mock-with-homedir
diff --git a/gcr/tests/files/openssh_keys.pub b/gcr/fixtures/openssh_keys.pub
similarity index 100%
rename from gcr/tests/files/openssh_keys.pub
rename to gcr/fixtures/openssh_keys.pub
diff --git a/gcr/tests/files/pem-dsa-1024.key b/gcr/fixtures/pem-dsa-1024.key
similarity index 100%
rename from gcr/tests/files/pem-dsa-1024.key
rename to gcr/fixtures/pem-dsa-1024.key
diff --git a/gcr/tests/files/pem-pkcs8.key b/gcr/fixtures/pem-pkcs8.key
similarity index 100%
rename from gcr/tests/files/pem-pkcs8.key
rename to gcr/fixtures/pem-pkcs8.key
diff --git a/gcr/tests/files/pem-rsa-2048.req b/gcr/fixtures/pem-rsa-2048.req
similarity index 100%
rename from gcr/tests/files/pem-rsa-2048.req
rename to gcr/fixtures/pem-rsa-2048.req
diff --git a/gcr/tests/files/pem-rsa-enc.key b/gcr/fixtures/pem-rsa-enc.key
similarity index 100%
rename from gcr/tests/files/pem-rsa-enc.key
rename to gcr/fixtures/pem-rsa-enc.key
diff --git a/gcr/tests/files/pem-with-attributes.req b/gcr/fixtures/pem-with-attributes.req
similarity index 100%
rename from gcr/tests/files/pem-with-attributes.req
rename to gcr/fixtures/pem-with-attributes.req
diff --git a/gcr/tests/files/prompt-tests/multiple.prompt b/gcr/fixtures/prompt-tests/multiple.prompt
similarity index 100%
rename from gcr/tests/files/prompt-tests/multiple.prompt
rename to gcr/fixtures/prompt-tests/multiple.prompt
diff --git a/gcr/tests/files/prompt-tests/password-choice.prompt 
b/gcr/fixtures/prompt-tests/password-choice.prompt
similarity index 100%
rename from gcr/tests/files/prompt-tests/password-choice.prompt
rename to gcr/fixtures/prompt-tests/password-choice.prompt
diff --git a/gcr/tests/files/werner-koch.asc b/gcr/fixtures/werner-koch.asc
similarity index 100%
rename from gcr/tests/files/werner-koch.asc
rename to gcr/fixtures/werner-koch.asc
diff --git a/gcr/tests/frob-certificate-request.c b/gcr/frob-certificate-request.c
similarity index 100%
rename from gcr/tests/frob-certificate-request.c
rename to gcr/frob-certificate-request.c
diff --git a/gcr/tests/frob-openpgp.c b/gcr/frob-openpgp.c
similarity index 100%
rename from gcr/tests/frob-openpgp.c
rename to gcr/frob-openpgp.c
diff --git a/gcr/tests/frob-parser.c b/gcr/frob-parser.c
similarity index 100%
rename from gcr/tests/frob-parser.c
rename to gcr/frob-parser.c
diff --git a/gcr/gcr-certificate-chain.c b/gcr/gcr-certificate-chain.c
index 42a83f0..c50615c 100644
--- a/gcr/gcr-certificate-chain.c
+++ b/gcr/gcr-certificate-chain.c
@@ -26,11 +26,12 @@
 #include "gcr-certificate.h"
 #define DEBUG_FLAG GCR_DEBUG_CERTIFICATE_CHAIN
 #include "gcr-debug.h"
-#include "gcr-enum-types-base.h"
 #include "gcr-pkcs11-certificate.h"
 #include "gcr-simple-certificate.h"
 #include "gcr-trust.h"
 
+#include "gcr/gcr-enum-types-base.h"
+
 #include "egg/egg-error.h"
 
 /**
diff --git a/gcr/gcr-certificate-extensions.c b/gcr/gcr-certificate-extensions.c
index 63d1eda..393b3a6 100644
--- a/gcr/gcr-certificate-extensions.c
+++ b/gcr/gcr-certificate-extensions.c
@@ -21,7 +21,8 @@
 #include "config.h"
 
 #include "gcr-certificate-extensions.h"
-#include "gcr-oids.h"
+
+#include "gcr/gcr-oids.h"
 
 #include "egg/egg-asn1x.h"
 #include "egg/egg-asn1-defs.h"
diff --git a/gcr/gcr-certificate-request.c b/gcr/gcr-certificate-request.c
index 5e946aa..1128f30 100644
--- a/gcr/gcr-certificate-request.c
+++ b/gcr/gcr-certificate-request.c
@@ -21,10 +21,11 @@
 
 #include "gcr-certificate-request.h"
 #include "gcr-key-mechanisms.h"
-#include "gcr-enum-types-base.h"
-#include "gcr-oids.h"
 #include "gcr-subject-public-key.h"
 
+#include "gcr/gcr-enum-types-base.h"
+#include "gcr/gcr-oids.h"
+
 #include <egg/egg-armor.h>
 #include <egg/egg-asn1x.h>
 #include <egg/egg-asn1-defs.h>
diff --git a/gcr/gcr-certificate.c b/gcr/gcr-certificate.c
index 0b7d58a..ef3270d 100644
--- a/gcr/gcr-certificate.c
+++ b/gcr/gcr-certificate.c
@@ -24,9 +24,10 @@
 #include "gcr-comparable.h"
 #include "gcr-icons.h"
 #include "gcr-internal.h"
-#include "gcr-oids.h"
 #include "gcr-subject-public-key.h"
 
+#include "gcr/gcr-oids.h"
+
 #include "egg/egg-asn1x.h"
 #include "egg/egg-asn1-defs.h"
 #include "egg/egg-dn.h"
diff --git a/gcr/gcr-fingerprint.c b/gcr/gcr-fingerprint.c
index fc024d1..445f88a 100644
--- a/gcr/gcr-fingerprint.c
+++ b/gcr/gcr-fingerprint.c
@@ -22,9 +22,10 @@
 #include "config.h"
 
 #include "gcr-fingerprint.h"
-#include "gcr-oids.h"
 #include "gcr-subject-public-key.h"
 
+#include "gcr/gcr-oids.h"
+
 #include "egg/egg-asn1x.h"
 #include "egg/egg-asn1-defs.h"
 
diff --git a/gcr/gcr-gnupg-process.c b/gcr/gcr-gnupg-process.c
index 3435bce..63fab11 100644
--- a/gcr/gcr-gnupg-process.c
+++ b/gcr/gcr-gnupg-process.c
@@ -24,9 +24,10 @@
 #define DEBUG_FLAG GCR_DEBUG_GNUPG
 #include "gcr-debug.h"
 #include "gcr-gnupg-process.h"
-#include "gcr-marshal.h"
 #include "gcr-util.h"
 
+#include "gcr/gcr-marshal.h"
+
 #include <glib/gi18n-lib.h>
 
 #include <sys/wait.h>
diff --git a/gcr/gcr-importer.c b/gcr/gcr-importer.c
index bad45e9..528d06b 100644
--- a/gcr/gcr-importer.c
+++ b/gcr/gcr-importer.c
@@ -26,11 +26,12 @@
 #include "gcr-deprecated-base.h"
 #include "gcr-importer.h"
 #include "gcr-internal.h"
-#include "gcr-marshal.h"
 #include "gcr-gnupg-importer.h"
 #include "gcr-parser.h"
 #include "gcr-pkcs11-importer.h"
 
+#include "gcr/gcr-marshal.h"
+
 #include <glib/gi18n-lib.h>
 
 /**
diff --git a/gcr/gcr-parser.c b/gcr/gcr-parser.c
index d64758e..4c39a1a 100644
--- a/gcr/gcr-parser.c
+++ b/gcr/gcr-parser.c
@@ -22,14 +22,15 @@
 #include "gck/gck.h"
 
 #include "gcr-internal.h"
-#include "gcr-marshal.h"
-#include "gcr-oids.h"
 #include "gcr-openpgp.h"
 #include "gcr-openssh.h"
 #include "gcr-parser.h"
 #include "gcr-record.h"
 #include "gcr-types.h"
 
+#include "gcr/gcr-marshal.h"
+#include "gcr/gcr-oids.h"
+
 #include "egg/egg-armor.h"
 #include "egg/egg-asn1x.h"
 #include "egg/egg-asn1-defs.h"
diff --git a/gcr/gcr-subject-public-key.c b/gcr/gcr-subject-public-key.c
index 8ac4f59..5b7dc28 100644
--- a/gcr/gcr-subject-public-key.c
+++ b/gcr/gcr-subject-public-key.c
@@ -22,10 +22,11 @@
 
 #define DEBUG_FLAG GCR_DEBUG_KEY
 #include "gcr-debug.h"
-#include "gcr-oids.h"
 #include "gcr-subject-public-key.h"
 #include "gcr-types.h"
 
+#include "gcr/gcr-oids.h"
+
 #include "egg/egg-asn1x.h"
 #include "egg/egg-asn1-defs.h"
 #include "egg/egg-error.h"
diff --git a/gcr/gcr-system-prompt.c b/gcr/gcr-system-prompt.c
index a6d8f95..7874ad1 100644
--- a/gcr/gcr-system-prompt.c
+++ b/gcr/gcr-system-prompt.c
@@ -22,7 +22,6 @@
 #include "config.h"
 
 #include "gcr-dbus-constants.h"
-#include "gcr-dbus-generated.h"
 #define DEBUG_FLAG GCR_DEBUG_PROMPT
 #include "gcr-debug.h"
 #include "gcr-internal.h"
@@ -31,6 +30,8 @@
 #include "gcr-secret-exchange.h"
 #include "gcr-system-prompt.h"
 
+#include "gcr/gcr-dbus-generated.h"
+
 #include "egg/egg-error.h"
 
 #include <glib/gi18n.h>
diff --git a/gcr/gcr-system-prompter.c b/gcr/gcr-system-prompter.c
index 8727ca1..654c686 100644
--- a/gcr/gcr-system-prompter.c
+++ b/gcr/gcr-system-prompter.c
@@ -22,18 +22,19 @@
 #include "config.h"
 
 #include "gcr-dbus-constants.h"
-#include "gcr-dbus-generated.h"
 #define DEBUG_FLAG GCR_DEBUG_PROMPT
 #include "gcr-debug.h"
-#include "gcr-enum-types-base.h"
 #include "gcr-internal.h"
 #include "gcr-library.h"
-#include "gcr-marshal.h"
 #include "gcr-prompt.h"
 #include "gcr-secret-exchange.h"
 #include "gcr-system-prompter.h"
 #include "gcr-system-prompt.h"
 
+#include "gcr/gcr-dbus-generated.h"
+#include "gcr/gcr-enum-types-base.h"
+#include "gcr/gcr-marshal.h"
+
 #include "egg/egg-error.h"
 
 #include <string.h>
diff --git a/gcr/tests/test-certificate-chain.c b/gcr/test-certificate-chain.c
similarity index 97%
rename from gcr/tests/test-certificate-chain.c
rename to gcr/test-certificate-chain.c
index 45c929a..ac2f734 100644
--- a/gcr/tests/test-certificate-chain.c
+++ b/gcr/test-certificate-chain.c
@@ -165,37 +165,37 @@ setup (Test *test, gconstpointer unused)
        gck_list_unref_free (modules);
 
        /* A self-signed certificate */
-       if (!g_file_get_contents (SRCDIR "/files/der-certificate.crt", &contents, &n_contents, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/der-certificate.crt", &contents, &n_contents, NULL))
                g_assert_not_reached ();
        test->cert_self = gcr_simple_certificate_new ((const guchar *)contents, n_contents);
        g_free (contents);
 
        /* A signed certificate */
-       if (!g_file_get_contents (SRCDIR "/files/dhansak-collabora.cer", &contents, &n_contents, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/dhansak-collabora.cer", &contents, &n_contents, NULL))
                g_assert_not_reached ();
        test->cert_signed = mock_certificate_new (contents, n_contents);
        g_free (contents);
 
        /* The signer for the above certificate */
-       if (!g_file_get_contents (SRCDIR "/files/collabora-ca.cer", &contents, &n_contents, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/collabora-ca.cer", &contents, &n_contents, NULL))
                g_assert_not_reached ();
        test->cert_ca = mock_certificate_new (contents, n_contents);
        g_free (contents);
 
        /* A root CA */
-       if (!g_file_get_contents (SRCDIR "/files/startcom-ca.cer", &contents, &n_contents, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/startcom-ca.cer", &contents, &n_contents, NULL))
                g_assert_not_reached ();
        test->cert_root = mock_certificate_new (contents, n_contents);
        g_free (contents);
 
        /* An intermediate */
-       if (!g_file_get_contents (SRCDIR "/files/startcom-intermediate.cer", &contents, &n_contents, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/startcom-intermediate.cer", &contents, &n_contents, 
NULL))
                g_assert_not_reached ();
        test->cert_inter = mock_certificate_new (contents, n_contents);
        g_free (contents);
 
        /* Signed by above intermediate */
-       if (!g_file_get_contents (SRCDIR "/files/jabber-server.cer", &contents, &n_contents, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/jabber-server.cer", &contents, &n_contents, NULL))
                g_assert_not_reached ();
        test->cert_host = mock_certificate_new (contents, n_contents);
        g_free (contents);
diff --git a/gcr/tests/test-certificate.c b/gcr/test-certificate.c
similarity index 96%
rename from gcr/tests/test-certificate.c
rename to gcr/test-certificate.c
index 71f43ba..8d77e88 100644
--- a/gcr/tests/test-certificate.c
+++ b/gcr/test-certificate.c
@@ -43,19 +43,19 @@ setup (Test *test, gconstpointer unused)
        gchar *contents;
        gsize n_contents;
 
-       if (!g_file_get_contents (SRCDIR "/files/der-certificate.crt", &contents, &n_contents, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/der-certificate.crt", &contents, &n_contents, NULL))
                g_assert_not_reached ();
        test->certificate = gcr_simple_certificate_new ((const guchar *)contents, n_contents);
        g_assert (test->certificate);
        g_free (contents);
 
-       if (!g_file_get_contents (SRCDIR "/files/der-certificate-dsa.cer", &contents, &n_contents, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/der-certificate-dsa.cer", &contents, &n_contents, 
NULL))
                g_assert_not_reached ();
        test->dsa_cert = gcr_simple_certificate_new ((const guchar *)contents, n_contents);
        g_assert (test->dsa_cert);
        g_free (contents);
 
-       if (!g_file_get_contents (SRCDIR "/files/dhansak-collabora.cer", &contents, &n_contents, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/dhansak-collabora.cer", &contents, &n_contents, NULL))
                g_assert_not_reached ();
        test->dhansak_cert = gcr_simple_certificate_new ((const guchar *)contents, n_contents);
        g_assert (test->certificate);
diff --git a/gcr/tests/test-filter-collection.c b/gcr/test-filter-collection.c
similarity index 100%
rename from gcr/tests/test-filter-collection.c
rename to gcr/test-filter-collection.c
diff --git a/gcr/tests/test-fingerprint.c b/gcr/test-fingerprint.c
similarity index 94%
rename from gcr/tests/test-fingerprint.c
rename to gcr/test-fingerprint.c
index 4bbdfe3..6c5e07b 100644
--- a/gcr/tests/test-fingerprint.c
+++ b/gcr/test-fingerprint.c
@@ -51,19 +51,19 @@ setup (Test *test, gconstpointer unused)
        gchar *contents;
        gsize length;
 
-       g_file_get_contents (SRCDIR "/files/client.crt", &contents, &length, &error);
+       g_file_get_contents (SRCDIR "/gcr/fixtures/client.crt", &contents, &length, &error);
        g_assert_no_error (error);
        test->cert_rsa = g_bytes_new_take (contents, length);
 
-       g_file_get_contents (SRCDIR "/files/client.key", &contents, &length, &error);
+       g_file_get_contents (SRCDIR "/gcr/fixtures/client.key", &contents, &length, &error);
        g_assert_no_error (error);
        test->key_rsa = g_bytes_new_take (contents, length);
 
-       g_file_get_contents (SRCDIR "/files/generic-dsa.crt", &contents, &length, &error);
+       g_file_get_contents (SRCDIR "/gcr/fixtures/generic-dsa.crt", &contents, &length, &error);
        g_assert_no_error (error);
        test->cert_dsa = g_bytes_new_take (contents, length);
 
-       g_file_get_contents (SRCDIR "/files/generic-dsa.key", &contents, &length, &error);
+       g_file_get_contents (SRCDIR "/gcr/fixtures/generic-dsa.key", &contents, &length, &error);
        g_assert_no_error (error);
        test->key_dsa = g_bytes_new_take (contents, length);
 }
diff --git a/gcr/tests/test-gnupg-collection.c b/gcr/test-gnupg-collection.c
similarity index 90%
rename from gcr/tests/test-gnupg-collection.c
rename to gcr/test-gnupg-collection.c
index 9a721ef..d10661f 100644
--- a/gcr/tests/test-gnupg-collection.c
+++ b/gcr/test-gnupg-collection.c
@@ -29,8 +29,10 @@
 #include "egg/egg-testing.h"
 
 #include <glib.h>
+#include <glib/gstdio.h>
 
 #include <errno.h>
+#include <stdlib.h>
 #include <string.h>
 
 typedef struct {
@@ -81,8 +83,16 @@ static void
 setup (Test *test, gconstpointer unused)
 {
        GcrCollection *collection;
+       GError *error = NULL;
+       gchar *cmd;
+
+       test->directory = g_build_filename ("/tmp/gcr-tests.XXXXXX", NULL);
+       g_assert (g_mkdtemp_full (test->directory, 0700) != NULL);
 
-       test->directory = g_build_filename (SRCDIR, "files", "gnupg-homedir", NULL);
+       cmd = g_strdup_printf ("cp -p " SRCDIR "/gcr/fixtures/gnupg-homedir/* %s", test->directory);
+       g_spawn_check_exit_status (system (cmd), &error);
+       g_assert_no_error (error);
+       g_free (cmd);
 
        collection = _gcr_gnupg_collection_new (test->directory);
        test->collection = GCR_GNUPG_COLLECTION (collection);
@@ -95,12 +105,23 @@ setup (Test *test, gconstpointer unused)
 static void
 teardown (Test *test, gconstpointer unused)
 {
+       GError *error = NULL;
+       gchar *cmd;
+
        g_hash_table_destroy (test->keys);
 
        if (test->result)
                g_object_unref (test->result);
 
        g_object_unref (test->collection);
+
+       cmd = g_strdup_printf ("rm %s/*", test->directory);
+       g_spawn_check_exit_status (system (cmd), &error);
+       g_assert_no_error (error);
+       g_free (cmd);
+
+       if (g_rmdir (test->directory) < 0)
+               g_critical ("couldn't remove %s: %s", test->directory, g_strerror (errno));
        g_free (test->directory);
 }
 
diff --git a/gcr/tests/test-gnupg-key.c b/gcr/test-gnupg-key.c
similarity index 100%
rename from gcr/tests/test-gnupg-key.c
rename to gcr/test-gnupg-key.c
diff --git a/gcr/tests/test-gnupg-process.c b/gcr/test-gnupg-process.c
similarity index 99%
rename from gcr/tests/test-gnupg-process.c
rename to gcr/test-gnupg-process.c
index b7dcb12..7051700 100644
--- a/gcr/tests/test-gnupg-process.c
+++ b/gcr/test-gnupg-process.c
@@ -115,7 +115,7 @@ build_script_path (const gchar *name)
 {
        gchar *path;
 
-       path = g_build_filename (SRCDIR, "files", "gnupg-mock", name, NULL);
+       path = g_build_filename (SRCDIR, "gcr", "fixtures", "gnupg-mock", name, NULL);
 
        return path;
 }
diff --git a/gcr/tests/test-memory-icon.c b/gcr/test-memory-icon.c
similarity index 100%
rename from gcr/tests/test-memory-icon.c
rename to gcr/test-memory-icon.c
diff --git a/gcr/tests/test-openpgp.c b/gcr/test-openpgp.c
similarity index 98%
rename from gcr/tests/test-openpgp.c
rename to gcr/test-openpgp.c
index f33da5e..21226e6 100644
--- a/gcr/tests/test-openpgp.c
+++ b/gcr/test-openpgp.c
@@ -166,28 +166,28 @@ static Fixture fixtures[] = {
        {
          "werner_koch",
          werner_koch_records,
-         SRCDIR "/files/werner-koch.asc",
+         SRCDIR "/gcr/fixtures/werner-koch.asc",
          "GnuPG v1.4.11 (GNU/Linux)",
          GCR_OPENPGP_PARSE_KEYS
        },
        {
          "werner_koch_with_sigs",
          werner_sig_records,
-         SRCDIR "/files/werner-koch.asc",
+         SRCDIR "/gcr/fixtures/werner-koch.asc",
          "GnuPG v1.4.11 (GNU/Linux)",
          GCR_OPENPGP_PARSE_KEYS | GCR_OPENPGP_PARSE_SIGNATURES
        },
        {
          "pubring",
          pubring_records,
-         SRCDIR "/files/pubring.gpg",
+         SRCDIR "/gcr/fixtures/pubring.gpg",
          NULL,
          GCR_OPENPGP_PARSE_KEYS
        },
        {
          "secring",
          secring_records,
-         SRCDIR "/files/secring.gpg",
+         SRCDIR "/gcr/fixtures/secring.gpg",
          NULL,
          GCR_OPENPGP_PARSE_KEYS
        }
diff --git a/gcr/tests/test-openssh.c b/gcr/test-openssh.c
similarity index 100%
rename from gcr/tests/test-openssh.c
rename to gcr/test-openssh.c
diff --git a/gcr/tests/test-parser.c b/gcr/test-parser.c
similarity index 95%
rename from gcr/tests/test-parser.c
rename to gcr/test-parser.c
index a2e6aac..a8dced7 100644
--- a/gcr/tests/test-parser.c
+++ b/gcr/test-parser.c
@@ -209,7 +209,7 @@ test_parsed_bytes (void)
        GBytes *bytes;
        gsize len;
 
-       if (!g_file_get_contents (SRCDIR "/files/cacert.org.cer", &contents, &len, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/cacert.org.cer", &contents, &len, NULL))
                g_assert_not_reached ();
 
        bytes = g_bytes_new_take (contents, len);
@@ -264,11 +264,11 @@ test_parse_stream (void)
        gsize len;
        GBytes *bytes;
 
-       file = g_file_new_for_path (SRCDIR "/files/cacert.org.cer");
+       file = g_file_new_for_path (SRCDIR "/gcr/fixtures/cacert.org.cer");
        fis = g_file_read (file, NULL, &error);
        g_assert_no_error (error);
 
-       if (!g_file_get_contents (SRCDIR "/files/cacert.org.cer", &contents, &len, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/cacert.org.cer", &contents, &len, NULL))
                g_assert_not_reached ();
        bytes = g_bytes_new_take (contents, len);
        g_signal_connect (parser, "parsed", G_CALLBACK (on_parsed_compare_bytes), bytes);
@@ -304,7 +304,7 @@ test_parse_filename (void)
        gsize len;
        GBytes *bytes;
 
-       if (!g_file_get_contents (SRCDIR "/files/cacert.org.cer", &contents, &len, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/cacert.org.cer", &contents, &len, NULL))
                g_assert_not_reached ();
 
        bytes = g_bytes_new_take (contents, len);
@@ -343,7 +343,7 @@ main (int argc, char **argv)
        g_set_prgname ("test-parser");
 
        strings = g_ptr_array_new_with_free_func (g_free);
-       dir = g_dir_open (SRCDIR "/files", 0, &error);
+       dir = g_dir_open (SRCDIR "/gcr/fixtures", 0, &error);
        g_assert_no_error (error);
 
        for (;;) {
@@ -353,7 +353,7 @@ main (int argc, char **argv)
                if (filename[0] == '.')
                        continue;
 
-               path = g_build_filename (SRCDIR "/files", filename, NULL);
+               path = g_build_filename (SRCDIR "/gcr/fixtures", filename, NULL);
 
                if (g_file_test (path, G_FILE_TEST_IS_DIR)) {
                        g_free (path);
diff --git a/gcr/tests/test-pkcs11-certificate.c b/gcr/test-pkcs11-certificate.c
similarity index 97%
rename from gcr/tests/test-pkcs11-certificate.c
rename to gcr/test-pkcs11-certificate.c
index ad70542..c3ac8a4 100644
--- a/gcr/tests/test-pkcs11-certificate.c
+++ b/gcr/test-pkcs11-certificate.c
@@ -57,12 +57,12 @@ setup (Test *test, gconstpointer unused)
        GNode *asn, *node;
        CK_RV rv;
 
-       if (!g_file_get_contents (SRCDIR "/files/der-certificate.crt", (gchar**)&test->cert_data,
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/der-certificate.crt", (gchar**)&test->cert_data,
                                  &test->n_cert_data, NULL))
                g_assert_not_reached ();
        g_assert (test->cert_data);
 
-       if (!g_file_get_contents (SRCDIR "/files/der-certificate-dsa.cer", (gchar**)&test->cert2_data,
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/der-certificate-dsa.cer", (gchar**)&test->cert2_data,
                                  &test->n_cert2_data, NULL))
                g_assert_not_reached ();
        g_assert (test->cert2_data);
diff --git a/gcr/tests/test-record.c b/gcr/test-record.c
similarity index 100%
rename from gcr/tests/test-record.c
rename to gcr/test-record.c
diff --git a/gcr/tests/test-secret-exchange.c b/gcr/test-secret-exchange.c
similarity index 100%
rename from gcr/tests/test-secret-exchange.c
rename to gcr/test-secret-exchange.c
diff --git a/gcr/tests/test-secure-memory.c b/gcr/test-secure-memory.c
similarity index 100%
rename from gcr/tests/test-secure-memory.c
rename to gcr/test-secure-memory.c
diff --git a/gcr/tests/test-simple-certificate.c b/gcr/test-simple-certificate.c
similarity index 96%
rename from gcr/tests/test-simple-certificate.c
rename to gcr/test-simple-certificate.c
index 48a509a..38287b1 100644
--- a/gcr/tests/test-simple-certificate.c
+++ b/gcr/test-simple-certificate.c
@@ -40,7 +40,7 @@ typedef struct {
 static void
 setup (Test *test, gconstpointer unused)
 {
-       if (!g_file_get_contents (SRCDIR "/files/der-certificate.crt", (gchar**)&test->cert_data,
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/der-certificate.crt", (gchar**)&test->cert_data,
                                  &test->n_cert_data, NULL))
                g_assert_not_reached ();
        g_assert (test->cert_data);
diff --git a/gcr/tests/test-subject-public-key.c b/gcr/test-subject-public-key.c
similarity index 98%
rename from gcr/tests/test-subject-public-key.c
rename to gcr/test-subject-public-key.c
index 90ff36a..3f84df6 100644
--- a/gcr/tests/test-subject-public-key.c
+++ b/gcr/test-subject-public-key.c
@@ -89,7 +89,7 @@ setup_attributes (TestAttributes *test,
        gsize length;
        gulong klass;
 
-       filename = g_strdup_printf (SRCDIR "/files/%s.crt", fixture->basename);
+       filename = g_strdup_printf (SRCDIR "/gcr/fixtures/%s.crt", fixture->basename);
        g_file_get_contents (filename, &contents, &length, &error);
        g_assert_no_error (error);
        test->crt_data = g_bytes_new_take (contents, length);
@@ -98,7 +98,7 @@ setup_attributes (TestAttributes *test,
        gck_assert_cmpulong (klass, ==, CKO_CERTIFICATE);
        g_free (filename);
 
-       filename = g_strdup_printf (SRCDIR "/files/%s.key", fixture->basename);
+       filename = g_strdup_printf (SRCDIR "/gcr/fixtures/%s.key", fixture->basename);
        g_file_get_contents (filename, &contents, &length, &error);
        g_assert_no_error (error);
        test->key_data = g_bytes_new_take (contents, length);
@@ -107,7 +107,7 @@ setup_attributes (TestAttributes *test,
        gck_assert_cmpulong (klass, ==, CKO_PRIVATE_KEY);
        g_free (filename);
 
-       filename = g_strdup_printf (SRCDIR "/files/%s.spk", fixture->basename);
+       filename = g_strdup_printf (SRCDIR "/gcr/fixtures/%s.spk", fixture->basename);
        g_file_get_contents (filename, &contents, &length, &error);
        g_assert_no_error (error);
        test->spk_data = g_bytes_new_take (contents, length);
diff --git a/gcr/tests/test-system-prompt.c b/gcr/test-system-prompt.c
similarity index 100%
rename from gcr/tests/test-system-prompt.c
rename to gcr/test-system-prompt.c
diff --git a/gcr/tests/test-trust.c b/gcr/test-trust.c
similarity index 99%
rename from gcr/tests/test-trust.c
rename to gcr/test-trust.c
index d24d011..eef8bdf 100644
--- a/gcr/tests/test-trust.c
+++ b/gcr/test-trust.c
@@ -52,7 +52,7 @@ setup (Test *test, gconstpointer unused)
        gsize len;
        CK_RV rv;
 
-       if (!g_file_get_contents (SRCDIR "/files/der-certificate.crt", &contents, &len, NULL))
+       if (!g_file_get_contents (SRCDIR "/gcr/fixtures/der-certificate.crt", &contents, &len, NULL))
                g_assert_not_reached ();
        g_assert (contents);
 
diff --git a/gcr/tests/test-util.c b/gcr/test-util.c
similarity index 100%
rename from gcr/tests/test-util.c
rename to gcr/test-util.c
diff --git a/schema/Makefile.am b/schema/Makefile.am
index d9e6b47..5d4c4d5 100644
--- a/schema/Makefile.am
+++ b/schema/Makefile.am
@@ -1,16 +1,16 @@
 
 gsettings_SCHEMAS = \
-       org.gnome.crypto.pgp.gschema.xml
+       schema/org.gnome.crypto.pgp.gschema.xml
 
 @GSETTINGS_RULES@
 
 convert_DATA = \
-       org.gnome.crypto.pgp.convert \
-       org.gnome.crypto.pgp_keyservers.convert
+       schema/org.gnome.crypto.pgp.convert \
+       schema/org.gnome.crypto.pgp_keyservers.convert
 
 convertdir = \
        $(datarootdir)/GConf/gsettings
 
-EXTRA_DIST = \
+EXTRA_DIST += \
        $(convert_DATA) \
        $(gsettings_SCHEMAS)
\ No newline at end of file
diff --git a/ui/Makefile.am b/ui/Makefile.am
index 67ecea9..2ae500a 100644
--- a/ui/Makefile.am
+++ b/ui/Makefile.am
@@ -1,40 +1,25 @@
-include $(top_srcdir)/Makefile.decl
 
-SUBDIRS = . icons tests
+ui_incdir = $(includedir)/gcr- GCR_MAJOR@/ui
 
-incdir = $(includedir)/gcr- GCR_MAJOR@/ui
-
-EXTRA_DIST = 
-CLEANFILES =
-
-AM_CPPFLAGS = \
-       -I$(top_builddir) \
-       -I$(top_srcdir) \
-       $(GLIB_CFLAGS) \
-       $(LIBGCRYPT_CFLAGS) \
-       $(P11_KIT_CFLAGS) \
-       -DG_LOG_DOMAIN=\"Gcr\" \
-       -DGCR_API_SUBJECT_TO_CHANGE \
-       -DLOCALEDIR=\""$(datadir)/locale"\"
-
-check-local: check-symbols
-
-check-memory:
-       make -C tests check-memory
-
-check-symbols: gcr-ui-expected.abi gcr-ui-actual.abi
+check-ui-symbols: gcr-ui-expected.abi gcr-ui-actual.abi
        $(AM_V_GEN) diff -U0 --ignore-blank-lines gcr-ui-expected.abi gcr-ui-actual.abi || \
                (echo "check-symbols: Symbols have CHANGED. Fix gcr-ui.symbols"; exit 1)
 
-BUILT_SOURCES = \
-       gcr-enum-types.c gcr-enum-types.h
+ui_BUILT_SOURCES = \
+       ui/gcr-enum-types.c ui/gcr-enum-types.h
+
+BUILT_SOURCES += \
+       $(ui_BUILT_SOURCES)
 
 libgcr_ui_ GCR_MAJOR@_la_CFLAGS = \
        -DGCK_API_SUBJECT_TO_CHANGE \
+       -DGCR_API_SUBJECT_TO_CHANGE \
        -DP11_KIT_API_SUBJECT_TO_CHANGE \
+       -DG_LOG_DOMAIN=\"Gcr\" \
        -DGCR_COMPILATION \
-       $(GTK_CFLAGS) \
-       -DUIDIR=\""$(uidir)"\"
+       -DUIDIR=\""$(uidir)"\" \
+       $(P11_KIT_CFLAGS) \
+       $(GTK_CFLAGS)
 
 libgcr_ui_ GCR_MAJOR@_la_LDFLAGS = \
        -version-info $(GCR_LT_RELEASE) \
@@ -42,9 +27,9 @@ libgcr_ui_ GCR_MAJOR@_la_LDFLAGS = \
        -export-symbols-regex '^_gcr_.*|^gcr_.*|^SECMEM_.*'
 
 libgcr_ui_ GCR_MAJOR@_la_LIBADD = \
-       $(top_builddir)/egg/libegg.la \
-       $(top_builddir)/gcr/libgcr-base-$(GCR_MAJOR).la \
-       $(top_builddir)/gck/libgck- GCK_MAJOR@.la \
+       libegg.la \
+       libgcr-base-$(GCR_MAJOR).la \
+       libgck- GCK_MAJOR@.la \
        $(GLIB_LIBS) \
        $(LIBGCRYPT_LIBS) \
        $(P11_KIT_LIBS) \
@@ -60,141 +45,124 @@ install-exec-hook:
 uidir = $(datadir)/gcr- GCR_MAJOR@/ui/
 
 ui_DATA = \
-       gcr-pkcs11-import-dialog.ui \
-       gcr-unlock-options-widget.ui
+       ui/gcr-pkcs11-import-dialog.ui \
+       ui/gcr-unlock-options-widget.ui
 
-lib_LTLIBRARIES = \
+lib_LTLIBRARIES += \
        libgcr-ui- GCR_MAJOR@.la
 
-HEADER_FILES = \
-       gcr-ui.h \
-       gcr-certificate-basics-widget.h \
-       gcr-certificate-details-widget.h \
-       gcr-certificate-renderer.h \
-       gcr-certificate-widget.h \
-       gcr-collection-model.h \
-       gcr-combo-selector.h \
-       gcr-deprecated.h \
-       gcr-failure-renderer.h \
-       gcr-key-renderer.h \
-       gcr-key-widget.h \
-       gcr-import-button.h \
-       gcr-list-selector.h \
-       gcr-prompt-dialog.h \
-       gcr-renderer.h \
-       gcr-secure-entry-buffer.h \
-       gcr-tree-selector.h \
-       gcr-unlock-options-widget.h \
-       gcr-viewer.h \
-       gcr-viewer-widget.h
-
-inc_HEADERS = \
-       $(HEADER_FILES) \
-       gcr-enum-types.h
-
-PUBLIC_FILES = \
-       gcr-certificate-renderer.c gcr-certificate-renderer.h \
-       gcr-certificate-widget.c gcr-certificate-widget.h \
-       gcr-collection-model.c gcr-collection-model.h \
-       gcr-combo-selector.c gcr-combo-selector.h \
-       gcr-failure-renderer.c gcr-failure-renderer.h \
-       gcr-key-renderer.c gcr-key-renderer.h \
-       gcr-key-widget.c gcr-key-widget.h \
-       gcr-import-button.c  gcr-import-button.h \
-       gcr-list-selector.c gcr-list-selector.h \
-       gcr-prompt-dialog.c gcr-prompt-dialog.h \
-       gcr-renderer.c gcr-renderer.h \
-       gcr-secure-entry-buffer.c gcr-secure-entry-buffer.h \
-       gcr-tree-selector.c gcr-tree-selector.h \
-       gcr-unlock-options-widget.c gcr-unlock-options-widget.h \
-       gcr-viewer.c gcr-viewer.h \
-       gcr-viewer-widget.c gcr-viewer-widget.h \
-       gcr-ui.h \
+ui_HEADER_FILES = \
+       ui/gcr-ui.h \
+       ui/gcr-certificate-basics-widget.h \
+       ui/gcr-certificate-details-widget.h \
+       ui/gcr-certificate-renderer.h \
+       ui/gcr-certificate-widget.h \
+       ui/gcr-collection-model.h \
+       ui/gcr-combo-selector.h \
+       ui/gcr-deprecated.h \
+       ui/gcr-failure-renderer.h \
+       ui/gcr-key-renderer.h \
+       ui/gcr-key-widget.h \
+       ui/gcr-import-button.h \
+       ui/gcr-list-selector.h \
+       ui/gcr-prompt-dialog.h \
+       ui/gcr-renderer.h \
+       ui/gcr-secure-entry-buffer.h \
+       ui/gcr-tree-selector.h \
+       ui/gcr-unlock-options-widget.h \
+       ui/gcr-viewer.h \
+       ui/gcr-viewer-widget.h
+
+ui_inc_HEADERS = \
+       $(ui_HEADER_FILES) \
+       ui/gcr-enum-types.h
+
+ui_PUBLIC_FILES = \
+       ui/gcr-certificate-renderer.c ui/gcr-certificate-renderer.h \
+       ui/gcr-certificate-widget.c ui/gcr-certificate-widget.h \
+       ui/gcr-collection-model.c ui/gcr-collection-model.h \
+       ui/gcr-combo-selector.c ui/gcr-combo-selector.h \
+       ui/gcr-failure-renderer.c ui/gcr-failure-renderer.h \
+       ui/gcr-key-renderer.c ui/gcr-key-renderer.h \
+       ui/gcr-key-widget.c ui/gcr-key-widget.h \
+       ui/gcr-import-button.c  ui/gcr-import-button.h \
+       ui/gcr-list-selector.c ui/gcr-list-selector.h \
+       ui/gcr-prompt-dialog.c ui/gcr-prompt-dialog.h \
+       ui/gcr-renderer.c ui/gcr-renderer.h \
+       ui/gcr-secure-entry-buffer.c ui/gcr-secure-entry-buffer.h \
+       ui/gcr-tree-selector.c ui/gcr-tree-selector.h \
+       ui/gcr-unlock-options-widget.c ui/gcr-unlock-options-widget.h \
+       ui/gcr-viewer.c ui/gcr-viewer.h \
+       ui/gcr-viewer-widget.c ui/gcr-viewer-widget.h \
+       ui/gcr-ui.h \
        $(NULL)
 
-PRIVATE_FILES = \
-       eggimagemenuitem.c eggimagemenuitem.h \
-       gcr-certificate-basics-widget.c gcr-certificate-basics-widget.h \
-       gcr-certificate-details-widget.c gcr-certificate-details-widget.h \
-       gcr-certificate-exporter.c gcr-certificate-exporter.h \
-       gcr-certificate-renderer-private.h \
-       gcr-certificate-request-renderer.c gcr-certificate-request-renderer.h \
-       gcr-deprecated.h \
-       gcr-dialog-util.c gcr-dialog-util.h \
-       gcr-display-scrolled.c gcr-display-scrolled.h \
-       gcr-display-view.c gcr-display-view.h \
-       gcr-gnupg-renderer.c gcr-gnupg-renderer.h \
-       gcr-list-selector-private.h \
-       gcr-live-search.c gcr-live-search.h \
-       gcr-pkcs11-import-dialog.c gcr-pkcs11-import-dialog.h \
-       gcr-pkcs11-import-interaction.c gcr-pkcs11-import-interaction.h \
-       gcr-unlock-renderer.c gcr-unlock-renderer.h \
-       gcr-viewer-window.c gcr-viewer-window.h \
+ui_PRIVATE_FILES = \
+       ui/eggimagemenuitem.c ui/eggimagemenuitem.h \
+       ui/gcr-certificate-basics-widget.c ui/gcr-certificate-basics-widget.h \
+       ui/gcr-certificate-details-widget.c ui/gcr-certificate-details-widget.h \
+       ui/gcr-certificate-exporter.c ui/gcr-certificate-exporter.h \
+       ui/gcr-certificate-renderer-private.h \
+       ui/gcr-certificate-request-renderer.c ui/gcr-certificate-request-renderer.h \
+       ui/gcr-deprecated.h \
+       ui/gcr-dialog-util.c ui/gcr-dialog-util.h \
+       ui/gcr-display-scrolled.c ui/gcr-display-scrolled.h \
+       ui/gcr-display-view.c ui/gcr-display-view.h \
+       ui/gcr-gnupg-renderer.c ui/gcr-gnupg-renderer.h \
+       ui/gcr-list-selector-private.h \
+       ui/gcr-live-search.c ui/gcr-live-search.h \
+       ui/gcr-pkcs11-import-dialog.c ui/gcr-pkcs11-import-dialog.h \
+       ui/gcr-pkcs11-import-interaction.c ui/gcr-pkcs11-import-interaction.h \
+       ui/gcr-unlock-renderer.c ui/gcr-unlock-renderer.h \
+       ui/gcr-viewer-window.c ui/gcr-viewer-window.h \
        $(NULL)
 
 libgcr_ui_ GCR_MAJOR@_la_SOURCES = \
-       $(PUBLIC_FILES) \
-       $(PRIVATE_FILES) \
+       $(ui_PUBLIC_FILES) \
+       $(ui_PRIVATE_FILES) \
        $(NULL)
 
 nodist_libgcr_ui_ GCR_MAJOR@_la_SOURCES = \
-       $(BUILT_SOURCES)
+       $(ui_BUILT_SOURCES)
 
-gcr-enum-types.h: $(ENUM_TEMPLATE_H) $(HEADER_FILES)
+ui/gcr-enum-types.h: $(ENUM_TEMPLATE_H) $(ui_HEADER_FILES)
        $(AM_V_GEN) $(GLIB_MKENUMS) --template $^ > $@
 
-gcr-enum-types.c: $(ENUM_TEMPLATE_C) $(HEADER_FILES)
+ui/gcr-enum-types.c: $(ENUM_TEMPLATE_C) $(ui_HEADER_FILES)
        $(AM_V_GEN) $(GLIB_MKENUMS) --template $^ > $@
 
-gcr-ui-$(GCR_MAJOR).pc: gcr-ui.pc
-       $(AM_V_GEN) cp gcr-ui.pc gcr-ui-$(GCR_MAJOR).pc
-gcr-$(GCR_MAJOR).pc: gcr.pc
-       $(AM_V_GEN) cp gcr.pc gcr-$(GCR_MAJOR).pc
+gcr-ui-$(GCR_MAJOR).pc: ui/gcr-ui.pc
+       $(AM_V_GEN) cp ui/gcr-ui.pc gcr-ui-$(GCR_MAJOR).pc
+gcr-$(GCR_MAJOR).pc: ui/gcr.pc
+       $(AM_V_GEN) cp ui/gcr.pc gcr-$(GCR_MAJOR).pc
 
 if HAVE_INTROSPECTION
 
-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS += GcrUi- GCR_MAJOR@.gir
 
-INTROSPECTION_GIRS = GcrUi- GCR_MAJOR@.gir
-INTROSPECTION_SCANNER_ARGS = \
-       $(INTROSPECTION_FLAGS) \
-       --warn-all \
-       --add-include-path=$(top_builddir)/gck \
-       --add-include-path=$(top_builddir)/gcr \
-       --include-uninstalled=$(top_builddir)/gck/Gck- GCK_MAJOR@.gir \
-       --include-uninstalled=$(top_builddir)/gcr/Gcr- GCR_MAJOR@.gir \
-       $(NULL)
-
-INTROSPECTION_COMPILER_ARGS = \
-       --includedir=$(srcdir) \
-       --includedir=$(top_builddir)/gck \
-       --includedir=$(top_builddir)/gcr \
-       $(NULL)
-
-GcrUi- GCR_MAJOR@.gir: $(builddir)/libgcr-ui- GCR_MAJOR@.la $(top_builddir)/gcr/Gcr- GCR_MAJOR@.gir
+GcrUi- GCR_MAJOR@.gir: libgcr-ui- GCR_MAJOR@.la Gcr- GCR_MAJOR@.gir
 
 GcrUi_ GCR_MAJOR@_gir_PACKAGES = gtk+-3.0 p11-kit-1
 GcrUi_ GCR_MAJOR@_gir_EXPORT_PACKAGES = gcr-ui- GCR_MAJOR@
 GcrUi_ GCR_MAJOR@_gir_INCLUDES = GLib-2.0 GObject-2.0 Gtk-3.0
-GcrUi_ GCR_MAJOR@_gir_LIBS = $(top_builddir)/gcr/libgcr-base- GCR_MAJOR@.la libgcr-ui- GCR_MAJOR@.la
-GcrUi_ GCR_MAJOR@_gir_CFLAGS = -I$(top_srcdir) -I$(top_builddir) -DGCR_COMPILATION 
-DGCR_API_SUBJECT_TO_CHANGE
-GcrUi_ GCR_MAJOR@_gir_FILES = $(PUBLIC_FILES)
-GcrUi_ GCR_MAJOR@_gir_SCANNERFLAGS = --c-include "ui/gcr-ui.h" \
-       --identifier-prefix Gcr --symbol-prefix gcr \
-       --include-uninstalled=$(top_builddir)/gcr/Gcr- GCR_MAJOR@.gir
-
-girdir = $(datadir)/gir-1.0
-gir_DATA = $(INTROSPECTION_GIRS)
-
-typelibsdir = $(libdir)/girepository-1.0
-typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+GcrUi_ GCR_MAJOR@_gir_LIBS = libgcr-base- GCR_MAJOR@.la libgcr-ui- GCR_MAJOR@.la
+GcrUi_ GCR_MAJOR@_gir_CFLAGS = -I$(srcdir) -I$(builddir) -DGCR_COMPILATION -DGCR_API_SUBJECT_TO_CHANGE
+GcrUi_ GCR_MAJOR@_gir_FILES = $(ui_PUBLIC_FILES)
+GcrUi_ GCR_MAJOR@_gir_SCANNERFLAGS = \
+       --add-include-path=$(builddir)/gck \
+       --add-include-path=$(builddir)/gcr \
+       --include-uninstalled=Gck- GCK_MAJOR@.gir \
+       --include-uninstalled=Gcr- GCR_MAJOR@.gir \
+       --c-include "ui/gcr-ui.h" \
+       --identifier-prefix Gcr --symbol-prefix gcr
+
+gir_DATA += GcrUi- GCR_MAJOR@.gir
 
 if ENABLE_VAPIGEN
-include $(VAPIGEN_MAKEFILE)
 
-gcr-ui- GCR_MAJOR@.vapi: GcrUi- GCR_MAJOR@.gir GcrUi- GCR_MAJOR@.metadata gcr-ui- GCR_MAJOR@.deps
+gcr-ui- GCR_MAJOR@.vapi: GcrUi- GCR_MAJOR@.gir ui/GcrUi- GCR_MAJOR@.metadata gcr-ui- GCR_MAJOR@.deps
 
-VAPIGEN_VAPIS = gcr-ui- GCR_MAJOR@.vapi
+VAPIGEN_VAPIS += gcr-ui- GCR_MAJOR@.vapi
 
 gcr_ui_ GCR_MAJOR@_vapi_DEPS = glib-2.0 gio-2.0 gck- GCK_MAJOR@ gcr- GCR_MAJOR@ gtk+-3.0
 gcr_ui_ GCR_MAJOR@_vapi_METADATADIRS = $(srcdir)
@@ -202,92 +170,80 @@ gcr_ui_ GCR_MAJOR@_vapi_VAPIDIRS = $(builddir) $(builddir)/../gck $(builddir)/..
 gcr_ui_ GCR_MAJOR@_vapi_GIRDIRS = $(builddir) $(builddir)/../gck $(builddir)/../gcr
 gcr_ui_ GCR_MAJOR@_vapi_FILES = GcrUi- GCR_MAJOR@.gir
 
-VAPI_DEPS = $(VAPIGEN_VAPIS:.vapi=.deps)
-
 gcr-ui-$(GCR_MAJOR).deps: Makefile.am
        $(AM_V_GEN) echo $(gcr_ui_ GCR_MAJOR@_vapi_DEPS) | tr ' ' '\n' > $@
 
-vapidir = $(datadir)/vala/vapi
-vapi_DATA = \
-       $(VAPIGEN_VAPIS) \
-       $(VAPI_DEPS)
-
 EXTRA_DIST += \
-       GcrUi- GCR_MAJOR@.metadata
-
-CLEANFILES += \
-       $(VAPIGEN_VAPIS) \
-       $(VAPI_DEPS)
+       ui/GcrUi- GCR_MAJOR@.metadata
 
 endif # ENABLE_VAPIGEN
 
 endif # HAVE_INTROSPECTION
 
-pkgconfig_DATA = \
+pkgconfig_DATA += \
        gcr-$(GCR_MAJOR).pc \
        gcr-ui-$(GCR_MAJOR).pc
 
-gcr-ui-expected.abi: gcr-ui.symbols
+gcr-ui-expected.abi: ui/gcr-ui.symbols
        $(AM_V_GEN) cpp -P $< | sort > $@
 
 desktopdir = $(datadir)/applications
-desktop_in_in_files = gcr-viewer.desktop.in.in gcr-prompter.desktop.in.in
+desktop_in_in_files = ui/gcr-viewer.desktop.in.in ui/gcr-prompter.desktop.in.in
 desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 
 bin_PROGRAMS = gcr-viewer
 
 gcr_viewer_SOURCES = \
-       gcr-viewer-tool.c
+       ui/gcr-viewer-tool.c
 
 gcr_viewer_CFLAGS = \
-       $(GLIB_CFLAGS) \
+       $(P11_KIT_CFLAGS) \
        $(GTK_CFLAGS) \
-       -DLOCALEDIR=\""$(datadir)/locale"\" \
        -DGCR_API_SUBJECT_TO_CHANGE
 
 gcr_viewer_LDADD = \
-       $(builddir)/libgcr-ui-$(GCR_MAJOR).la \
-       $(top_builddir)/gcr/libgcr-base-$(GCR_MAJOR).la \
-       $(top_builddir)/gck/libgck- GCK_MAJOR@.la \
+       libgcr-ui-$(GCR_MAJOR).la \
+       libgcr-base-$(GCR_MAJOR).la \
+       libgck- GCK_MAJOR@.la \
        $(GLIB_LIBS) \
        $(GTK_LIBS)
 
 libexec_PROGRAMS = gcr-prompter
 
 gcr_prompter_SOURCES = \
-       gcr-prompter-tool.c
+       ui/gcr-prompter-tool.c
 
 gcr_prompter_CFLAGS = \
+       -DGCR_API_SUBJECT_TO_CHANGE \
+       $(P11_KIT_CFLAGS) \
        $(GTK_CFLAGS)
 
 gcr_prompter_LDADD = \
-       $(builddir)/libgcr-ui-$(GCR_MAJOR).la \
-       $(top_builddir)/gcr/libgcr-base-$(GCR_MAJOR).la \
-       $(top_builddir)/gck/libgck- GCK_MAJOR@.la \
+       libgcr-ui-$(GCR_MAJOR).la \
+       libgcr-base-$(GCR_MAJOR).la \
+       libgck- GCK_MAJOR@.la \
        $(GTK_LIBS)
 
 EXTRA_DIST += \
-       gcr.pc.in \
-       gcr-ui.pc.in \
+       ui/gcr.pc.in \
+       ui/gcr-ui.pc.in \
        $(ui_DATA) \
-       gcr-ui.symbols \
+       ui/gcr-ui.symbols \
        $(desktop_in_in_files) \
-       $(mime_DATA)
+       $(mime_DATA) \
+       ui/fixtures
 
 CLEANFILES += \
        $(desktop_DATA) \
        gcr-ui-actual.abi \
        gcr-ui-expected.abi \
-       $(BUILT_SOURCES) \
-       $(pkgconfig_DATA) \
-       $(gir_DATA) \
-       $(typelibs_DATA) \
+       $(desktop_in_files) \
        $(NULL)
 
 # The new mime system
 mimedir = $(datadir)/mime/packages
-mime_DATA = gcr-crypto-types.xml
+mime_DATA = ui/gcr-crypto-types.xml
 
 if WITH_UPDATE_MIME
 
@@ -307,6 +263,83 @@ update_mime_database:
 
 endif # WITH_UPDATE_MIME
 
-gcr-ui-actual.abi: $(builddir)/.libs/libgcr-ui- GCR_MAJOR@.so
+gcr-ui-actual.abi: .libs/libgcr-ui- GCR_MAJOR@.so
        $(AM_V_GEN)  $(NM) -D -g --defined-only $< | \
                cut -d ' ' -f 3 | grep -Ev '^(__bss_start|_edata|_end|_gcr_)' | sort > $@
+
+ui_CFLAGS = \
+       -DGCR_API_SUBJECT_TO_CHANGE \
+       -DGCK_API_SUBJECT_TO_CHANGE \
+       -DGCR_COMPILATION \
+       $(LIBGCRYPT_CFLAGS) \
+       $(P11_KIT_CFLAGS) \
+       $(GTK_CFLAGS)
+
+ui_LIBS = \
+       libgcr-ui- GCR_MAJOR@.la \
+       libgcr-base- GCR_MAJOR@.la \
+       libegg.la \
+       libgck-testable.la \
+       $(LIBGCRYPT_LIBS) \
+       $(P11_KIT_LIBS) \
+       $(GTK_LIBS)
+
+# ------------------------------------------------------------------
+
+noinst_PROGRAMS += \
+       frob-certificate \
+       frob-combo-selector \
+       frob-gnupg-selector \
+       frob-import-button \
+       frob-key \
+       frob-tree-selector \
+       frob-prompt \
+       frob-request \
+       frob-system-prompt \
+       frob-unlock \
+       frob-unlock-options
+
+frob_certificate_SOURCES = ui/frob-certificate.c
+frob_certificate_CFLAGS = $(ui_CFLAGS)
+frob_certificate_LDADD = $(ui_LIBS)
+
+frob_combo_selector_SOURCES = ui/frob-combo-selector.c
+frob_combo_selector_CFLAGS = $(ui_CFLAGS)
+frob_combo_selector_LDADD = $(ui_LIBS)
+
+frob_gnupg_selector_SOURCES = ui/frob-gnupg-selector.c
+frob_gnupg_selector_CFLAGS = $(ui_CFLAGS)
+frob_gnupg_selector_LDADD = $(ui_LIBS)
+
+frob_import_button_SOURCES = ui/frob-import-button.c
+frob_import_button_CFLAGS = $(ui_CFLAGS)
+frob_import_button_LDADD = $(ui_LIBS)
+
+frob_key_SOURCES = ui/frob-key.c
+frob_key_CFLAGS = $(ui_CFLAGS)
+frob_key_LDADD = $(ui_LIBS)
+
+frob_prompt_SOURCES = ui/frob-prompt.c
+frob_prompt_CFLAGS = $(ui_CFLAGS)
+frob_prompt_LDADD = $(ui_LIBS)
+
+frob_request_SOURCES = ui/frob-request.c
+frob_request_CFLAGS = $(ui_CFLAGS)
+frob_request_LDADD = $(ui_LIBS)
+
+frob_system_prompt_SOURCES = ui/frob-system-prompt.c
+frob_system_prompt_CFLAGS = $(ui_CFLAGS)
+frob_system_prompt_LDADD = $(ui_LIBS)
+
+frob_tree_selector_SOURCES = ui/frob-tree-selector.c
+frob_tree_selector_CFLAGS = $(ui_CFLAGS)
+frob_tree_selector_LDADD = $(ui_LIBS)
+
+frob_unlock_SOURCES = \
+       ui/frob-unlock.c ui/gcr-viewer-window.c
+frob_unlock_CFLAGS = $(ui_CFLAGS)
+frob_unlock_LDADD = $(ui_LIBS)
+
+frob_unlock_options_SOURCES = ui/frob-unlock-options.c
+frob_unlock_options_CFLAGS = $(ui_CFLAGS)
+frob_unlock_options_LDADD = $(ui_LIBS)
diff --git a/ui/tests/files/ca-certificates.crt b/ui/fixtures/ca-certificates.crt
similarity index 100%
rename from ui/tests/files/ca-certificates.crt
rename to ui/fixtures/ca-certificates.crt
diff --git a/ui/tests/files/pem-dsa-1024.key b/ui/fixtures/pem-dsa-1024.key
similarity index 100%
rename from ui/tests/files/pem-dsa-1024.key
rename to ui/fixtures/pem-dsa-1024.key
diff --git a/ui/tests/frob-certificate.c b/ui/frob-certificate.c
similarity index 97%
rename from ui/tests/frob-certificate.c
rename to ui/frob-certificate.c
index df4495b..f9cc259 100644
--- a/ui/tests/frob-certificate.c
+++ b/ui/frob-certificate.c
@@ -106,7 +106,7 @@ main(int argc, char *argv[])
        if (argc > 1)
                test_certificate (argv[1]);
        else
-               test_certificate (SRCDIR "/files/der-certificate.crt");
+               test_certificate (SRCDIR "/ui/fixtures/der-certificate.crt");
 
        return 0;
 }
diff --git a/ui/tests/frob-combo-selector.c b/ui/frob-combo-selector.c
similarity index 96%
rename from ui/tests/frob-combo-selector.c
rename to ui/frob-combo-selector.c
index 856d09a..8263b94 100644
--- a/ui/tests/frob-combo-selector.c
+++ b/ui/frob-combo-selector.c
@@ -70,7 +70,7 @@ main (int argc, char *argv[])
        g_signal_connect (parser, "parsed", G_CALLBACK (on_parser_parsed), collection);
 
        if (argc == 1) {
-               add_to_selector (parser, SRCDIR "/files/ca-certificates.crt");
+               add_to_selector (parser, SRCDIR "/ui/fixtures/ca-certificates.crt");
        } else {
                for (i = 1; i < argc; ++i)
                        add_to_selector (parser, argv[i]);
diff --git a/ui/tests/frob-gnupg-selector.c b/ui/frob-gnupg-selector.c
similarity index 100%
rename from ui/tests/frob-gnupg-selector.c
rename to ui/frob-gnupg-selector.c
diff --git a/ui/tests/frob-import-button.c b/ui/frob-import-button.c
similarity index 98%
rename from ui/tests/frob-import-button.c
rename to ui/frob-import-button.c
index d3ca560..6a9a88e 100644
--- a/ui/tests/frob-import-button.c
+++ b/ui/frob-import-button.c
@@ -234,7 +234,7 @@ main (int argc, char *argv[])
        g_signal_connect (parser, "parsed", G_CALLBACK (on_parser_parsed), button);
 
        if (argc == 1) {
-               parse_file (parser, SRCDIR "/files/ca-certificates.crt");
+               parse_file (parser, SRCDIR "/ui/fixtures/ca-certificates.crt");
        } else {
                for (i = 1; i < argc; ++i)
                        parse_file (parser, argv[i]);
diff --git a/ui/tests/frob-key.c b/ui/frob-key.c
similarity index 97%
rename from ui/tests/frob-key.c
rename to ui/frob-key.c
index 7b62f11..97d216b 100644
--- a/ui/tests/frob-key.c
+++ b/ui/frob-key.c
@@ -81,7 +81,7 @@ main(int argc, char *argv[])
        if (argc > 1)
                test_key (argv[1]);
        else
-               test_key (SRCDIR "/files/pem-dsa-1024.key");
+               test_key (SRCDIR "/ui/fixtures/pem-dsa-1024.key");
 
        return 0;
 }
diff --git a/ui/tests/frob-prompt.c b/ui/frob-prompt.c
similarity index 100%
rename from ui/tests/frob-prompt.c
rename to ui/frob-prompt.c
diff --git a/ui/tests/frob-request.c b/ui/frob-request.c
similarity index 97%
rename from ui/tests/frob-request.c
rename to ui/frob-request.c
index c4b8d53..1d2f946 100644
--- a/ui/tests/frob-request.c
+++ b/ui/frob-request.c
@@ -91,7 +91,7 @@ main(int argc, char *argv[])
        if (argc > 1)
                test_request (argv[1]);
        else
-               test_request (SRCDIR "/files/der-rsa-2048.p10");
+               test_request (SRCDIR "/ui/fixtures/der-rsa-2048.p10");
 
        return 0;
 }
diff --git a/ui/tests/frob-system-prompt.c b/ui/frob-system-prompt.c
similarity index 100%
rename from ui/tests/frob-system-prompt.c
rename to ui/frob-system-prompt.c
diff --git a/ui/tests/frob-tree-selector.c b/ui/frob-tree-selector.c
similarity index 98%
rename from ui/tests/frob-tree-selector.c
rename to ui/frob-tree-selector.c
index ecf87d3..f3b3187 100644
--- a/ui/tests/frob-tree-selector.c
+++ b/ui/frob-tree-selector.c
@@ -183,7 +183,7 @@ main (int argc, char *argv[])
        g_signal_connect (parser, "parsed", G_CALLBACK (on_parser_parsed), collection);
 
        if (argc == 1) {
-               add_to_selector (parser, SRCDIR "/files/ca-certificates.crt");
+               add_to_selector (parser, SRCDIR "/ui/fixtures/ca-certificates.crt");
        } else {
                for (i = 1; i < argc; ++i)
                        add_to_selector (parser, argv[i]);
diff --git a/ui/tests/frob-unlock-options.c b/ui/frob-unlock-options.c
similarity index 100%
rename from ui/tests/frob-unlock-options.c
rename to ui/frob-unlock-options.c
diff --git a/ui/tests/frob-unlock.c b/ui/frob-unlock.c
similarity index 98%
rename from ui/tests/frob-unlock.c
rename to ui/frob-unlock.c
index 567b0b2..4919765 100644
--- a/ui/tests/frob-unlock.c
+++ b/ui/frob-unlock.c
@@ -116,7 +116,7 @@ main(int argc, char *argv[])
        if (argc > 1) {
                test_key (argv[1]);
        } else {
-               test_key (SRCDIR "/files/email.p12");
+               test_key (SRCDIR "/ui/fixtures/email.p12");
        }
 
        return 0;
diff --git a/ui/gcr-collection-model.c b/ui/gcr-collection-model.c
index 6e8db6c..d4f7c10 100644
--- a/ui/gcr-collection-model.c
+++ b/ui/gcr-collection-model.c
@@ -23,7 +23,8 @@
 #include "config.h"
 
 #include "gcr-collection-model.h"
-#include "gcr-enum-types.h"
+
+#include "ui/gcr-enum-types.h"
 
 #include <gtk/gtk.h>
 
diff --git a/ui/gcr-live-search.c b/ui/gcr-live-search.c
index fe8c371..f8483bf 100644
--- a/ui/gcr-live-search.c
+++ b/ui/gcr-live-search.c
@@ -27,10 +27,10 @@
 
 #include "config.h"
 
-#include "gcr/gcr-marshal.h"
-
 #include "gcr-live-search.h"
 
+#include "gcr/gcr-marshal.h"
+
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 
diff --git a/ui/gcr-ui.h b/ui/gcr-ui.h
index 193398a..cbec5b3 100644
--- a/ui/gcr-ui.h
+++ b/ui/gcr-ui.h
@@ -37,9 +37,9 @@
 #include <ui/gcr-collection-model.h>
 #include <ui/gcr-combo-selector.h>
 #include <ui/gcr-deprecated.h>
+#include <ui/gcr-enum-types.h>
 #include <ui/gcr-key-renderer.h>
 #include <ui/gcr-key-widget.h>
-#include <ui/gcr-enum-types.h>
 #include <ui/gcr-failure-renderer.h>
 #include <ui/gcr-key-renderer.h>
 #include <ui/gcr-key-widget.h>
diff --git a/ui/icons/Makefile.am b/ui/icons/Makefile.am
index 65da739..ef5c81e 100644
--- a/ui/icons/Makefile.am
+++ b/ui/icons/Makefile.am
@@ -1,15 +1,15 @@
 
-SUBDIRS = \
-       16x16 \
-       22x22 \
-       24x24 \
-       32x32 \
-       48x48 \
-       256x256
+SUBDIRS += \
+       ui/icons/16x16 \
+       ui/icons/22x22 \
+       ui/icons/24x24 \
+       ui/icons/32x32 \
+       ui/icons/48x48 \
+       ui/icons/256x256
 
-EXTRA_DIST = \
-       src \
-       render-icons.py
+EXTRA_DIST += \
+       ui/icons/src \
+       ui/icons/render-icons.py
 
 if WITH_UPDATE_ICON_CACHE
 
@@ -26,4 +26,4 @@ install-data-hook:
 endif
 
 render:
-       python render-icons.py
+       python ui/icons/render-icons.py


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]