changeset 1991:5d0f5094fb66

package libffi: bugfix for build directory and add test program
author Tony Theodore <tonyt@logyst.com>
date Mon, 19 Sep 2011 19:32:19 +1000
parents a5e9e90cf187
children a8709467c874
files src/libffi-test.c src/libffi.mk
diffstat 2 files changed, 38 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libffi-test.c	Mon Sep 19 19:32:19 2011 +1000
@@ -0,0 +1,31 @@
+/* This file is part of mingw-cross-env.       */
+/* See doc/index.html for further information. */
+
+#include <stdio.h>
+#include <ffi.h>
+
+int main(int argc, char *argv[])
+{
+    ffi_cif cif;
+    ffi_type *args[1];
+    void *values[1];
+    char *s;
+    int rc;
+    
+    (void)argc;
+    (void)argv;
+
+    args[0] = &ffi_type_pointer;
+    values[0] = &s;
+
+    if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+    		       &ffi_type_uint, args) == FFI_OK)
+    {
+        s = "Hello World!";
+        ffi_call(&cif, FFI_FN(puts), &rc, values);
+        s = "Goodbye!";
+        ffi_call(&cif, FFI_FN(puts), &rc, values);
+    }
+
+    return 0;
+}
--- a/src/libffi.mk	Sun Sep 18 23:42:25 2011 +0200
+++ b/src/libffi.mk	Mon Sep 19 19:32:19 2011 +1000
@@ -24,6 +24,11 @@
         --host='$(TARGET)' \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared
-    $(MAKE) -C '$(1)' -j '$(JOBS)'
-    $(MAKE) -C '$(1)' -j 1 install
+    $(MAKE) -C '$(1)/$(TARGET)' -j '$(JOBS)'
+    $(MAKE) -C '$(1)/$(TARGET)' -j 1 install
+
+    '$(TARGET)-gcc' \
+        -W -Wall -Werror -std=c99 -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-libffi.exe' \
+        `'$(TARGET)-pkg-config' libffi --cflags --libs`
 endef