changeset 2442:3a37e58eab36

package libgcrypt: add test program and prefixed libgcrypt-config
author Tony Theodore <tonyt@logyst.com>
date Mon, 23 Apr 2012 00:36:06 +1000
parents 17669944fd2f
children dd839ef15f57
files src/libgcrypt-test.c src/libgcrypt.mk
diffstat 2 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libgcrypt-test.c	Mon Apr 23 00:36:06 2012 +1000
@@ -0,0 +1,32 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <stdio.h>
+#include <gcrypt.h>
+
+int main(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+
+    if (!gcry_check_version (GCRYPT_VERSION)) {
+        fputs ("libgcrypt version mismatch\n", stderr);
+        exit (2);
+    }
+
+    gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
+    gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
+    gcry_control (GCRYCTL_RESUME_SECMEM_WARN);
+    gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
+
+    if (!gcry_control (GCRYCTL_INITIALIZATION_FINISHED_P)) {
+       fputs ("libgcrypt has not been initialized\n", stderr);
+       abort ();
+    }
+
+    printf("gcrypt version: %s", GCRYPT_VERSION );
+
+    return 0;
+}
--- a/src/libgcrypt.mk	Sun Apr 22 08:51:06 2012 +0200
+++ b/src/libgcrypt.mk	Mon Apr 23 00:36:06 2012 +1000
@@ -24,4 +24,10 @@
         --prefix='$(PREFIX)/$(TARGET)' \
         --with-gpg-error-prefix='$(PREFIX)/$(TARGET)'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+    ln -sf '$(PREFIX)/$(TARGET)/bin/libgcrypt-config' '$(PREFIX)/bin/$(TARGET)-libgcrypt-config'
+
+    '$(TARGET)-gcc' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-libgcrypt.exe' \
+        `$(TARGET)-libgcrypt-config --cflags --libs`
 endef