r8151: changes for asdf-install
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 11 Nov 2003 14:58:32 +0000 (14:58 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 11 Nov 2003 14:58:32 +0000 (14:58 +0000)
doc/uffi.pdf
tests/Makefile
tests/foreign-loader.lisp
tests/make.sh [new file with mode: 0644]
tests/uffi-c-test-lib.c [deleted file]
tests/uffi-c-test.c [new file with mode: 0644]
uffi-tests.asd

index b2b9b2c34ded8de057d2798772731df5b8defd4a..ae6e4249d8f800ce6138eeaf4ddcf2bcfef330bc 100644 (file)
Binary files a/doc/uffi.pdf and b/doc/uffi.pdf differ
index 09e6e396ecca354baed697be2baca658c00e70b6..cd1a5c5e741c9e5b62ce59635fea57932023dfd5 100644 (file)
 # as governed by the terms of the Lisp Lesser GNU Public License
 # (http://opensource.franz.com/preamble.html), also known as the LLGPL.
 
-SUBDIRS:=
+SUBDIRS=
 
 include ../Makefile.common
 
-.PHONY: distclean
-distclean: clean
-       rm -f $(base).dylib $(base).dylib $(base).so $(base).o
-
-base=uffi-c-test-lib
+base=uffi-c-test
 source=$(base).c
 object=$(base).o
 shared_lib=$(base).so
 
 .PHONY: all
-all: 
-       echo "you need to specify a platform"
+all: $(shared_lib)
 
-linux: $(source) Makefile
-       gcc -fPIC -DPIC -c $(source) -o $(object)
-       gcc -shared $(object) -o $(shared_lib)
-       #gcc -shared -Wl,-soname,uffi-c-test-lib $(object) -o $(shared_lib)
+$(shared_lib): $(source) Makefile
+       BASE=$(base) OBJECT=$(object) SOURCE=$(source) SHARED_LIB=$(shared_lib) sh make.sh
        rm $(object)
 
-mac:
-       cc -dynamic -c $(source) -o $(object)
-       ld -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress -o $(base).dylib $(object)
-       ld -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
-
-mac-alt:
-       gcc -bundle -c $(source) -o $(base).bundle
-       ld -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.bundle
-
-solaris:
-       cc -KPIC -c $(source) -o $(object)
-       cc -G $(object) -o $(shared_lib)
-
-aix-acl:
-       gcc -c -D_BSD -D_NO_PROTO -D_NONSTD_TYPES -D_MBI=void $(source)
-       make_shared -o $(shared_lib) $(object)
+.PHONY: distclean
+distclean: clean
+       rm -f $(base).dylib $(base).dylib $(base).so $(base).o
index a611f8831d687ea86fb57e00069e8f89f9e72c57..10307321d3a21e17c543ff90a14380914c90ada1 100644 (file)
   
 (unless (uffi:load-foreign-library 
         (uffi:find-foreign-library
-         "uffi-c-test-lib
+         "uffi-c-test" 
          (list (pathname-directory *load-truename*)
                "/usr/lib/uffi/"))
         :supporting-libraries '("c")
         :module "uffi_tests")
-  (warn "Unable to load uffi-c-test-lib library"))
+  (warn "Unable to load uffi-c-test library"))
 
diff --git a/tests/make.sh b/tests/make.sh
new file mode 100644 (file)
index 0000000..f239372
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+UNAME=`uname -a`
+LINUX=`expr "$UNAME" : '.*Linux.*'`
+DARWIN=`expr "$UNAME" : '.*Darwin.*'`
+SOLARIS=`expr "$UNAME" : '.*sun4u.*'`
+AIX=`expr "$UNAME" : '.*aix.*'`
+
+
+if [ $LINUX -ne 0 ]; then
+    gcc -fPIC -DPIC -c $SOURCE -o $OBJECT
+    gcc -shared $OBJECT -o $SHARED_LIB
+    #gcc -shared -Wl,-soname,uffi-c-test-lib $OBJECT -o $SHARED_LIB
+elif [ $DARWIN -ne 0 ]; then
+    cc -dynamic -c $SOURCE -o $OBJECT
+    ld -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress -o $BASE.dylib $OBJECT
+    ld -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
+elif [ $SOLARIS -ne 0 ]; then
+    cc -KPIC -c $SOURCE -o $OBJECT
+    cc -G $OBJECT -o $SHARED_LIB
+elif [ $AIX -ne 0 ]; then
+    gcc -c -D_BSD -D_NO_PROTO -D_NONSTD_TYPES -D_MBI=void $SOURCE
+    make_shared -o $SHARED_LIB $OBJECT
+fi
+
+
diff --git a/tests/uffi-c-test-lib.c b/tests/uffi-c-test-lib.c
deleted file mode 100644 (file)
index ee1ab3a..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/***************************************************************************
- * FILE IDENTIFICATION
- *  
- *  Name:         c-test-fns.c
- *  Purpose:      Test functions in C for UFFI library
- *  Programer:    Kevin M. Rosenberg
- *  Date Started: Mar 2002
- *
- *  CVS Id:   $Id$
- *
- * This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
- *
- * UFFI users are granted the rights to distribute and use this software
- * as governed by the terms of the Lisp Lesser GNU Public License
- * (http://opensource.franz.com/preamble.html), also known as the LLGPL.
-
- * These variables are correct for GCC
- * you'll need to modify these for other compilers
- ***************************************************************************/
-
-#ifdef WIN32
-#include <windows.h>
-
-BOOL WINAPI DllEntryPoint(HINSTANCE hinstdll,
-                          DWORD fdwReason,
-                          LPVOID lpvReserved)
-{
-        return 1;
-}
-       
-#define DLLEXPORT __declspec(dllexport)
-
-#else
-#define DLLEXPORT 
-#endif
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <math.h>
-
-
-DLLEXPORT unsigned char uchar_13 = 13;
-DLLEXPORT signed char schar_neg_120 = -120;
-DLLEXPORT unsigned short uword_257 = 257;
-DLLEXPORT signed short sword_neg_321 = -321;
-DLLEXPORT unsigned int uint_1234567 = 1234567;
-DLLEXPORT signed int sint_neg_123456 = -123456;
-DLLEXPORT double double_3_1 = 3.1;
-DLLEXPORT float float_neg_4_5 = -4.5;
-
-/* Test of constant input string */
-DLLEXPORT
-int
-cs_count_upper (char* psz)
-{
-  int count = 0;
-
-  if (psz) {
-    while (*psz) {
-      if (isupper (*psz))
-       ++count;
-      ++psz;
-    }
-    return count;
-  } else 
-    return -1;
-}
-
-/* Test of input and output of a string */
-DLLEXPORT
-void
-cs_to_upper (char* psz)
-{
-  if (psz) {
-    while (*psz) {
-      *psz = toupper (*psz);
-      ++psz;
-    }
-  }
-}
-
-/* Test of an output only string */
-DLLEXPORT
-void
-cs_make_random (int size, char* buffer)
-{
-  int i;
-  for (i = 0; i < size; i++)
-    buffer[i] = 'A' + (rand() % 26);
-}
-
-    
-/* Test of input/output vector */
-DLLEXPORT
-void
-half_double_vector (int size, double* vec)
-{
-  int i;
-  for (i = 0; i < size; i++)
-    vec[i] /= 2.;
-}
-
-    
-
-DLLEXPORT
-void *
-cast_test_int () {
-  int *x = (int *) malloc(sizeof(int));
-  *x = 23;
-  return x;
-}
-
-DLLEXPORT
-void *
-cast_test_float ()
-{
-  double *y = (double *) malloc(sizeof(double));
-  *y = 3.21;
-  return y;
-}
-
-DLLEXPORT int fvar_addend = 3;
-
-typedef struct {
-  int i;
-  double d;
-} fvar_struct_type;
-
-fvar_struct_type fvar_struct = {42, 3.2};
-
-DLLEXPORT
-int fvar_struct_int () {
-  return (fvar_addend + fvar_struct.i);
-}
-
-DLLEXPORT
-double fvar_struct_double () {
-  return fvar_struct.d;
-}
-
-     
diff --git a/tests/uffi-c-test.c b/tests/uffi-c-test.c
new file mode 100644 (file)
index 0000000..ee1ab3a
--- /dev/null
@@ -0,0 +1,141 @@
+/***************************************************************************
+ * FILE IDENTIFICATION
+ *  
+ *  Name:         c-test-fns.c
+ *  Purpose:      Test functions in C for UFFI library
+ *  Programer:    Kevin M. Rosenberg
+ *  Date Started: Mar 2002
+ *
+ *  CVS Id:   $Id$
+ *
+ * This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
+ *
+ * UFFI users are granted the rights to distribute and use this software
+ * as governed by the terms of the Lisp Lesser GNU Public License
+ * (http://opensource.franz.com/preamble.html), also known as the LLGPL.
+
+ * These variables are correct for GCC
+ * you'll need to modify these for other compilers
+ ***************************************************************************/
+
+#ifdef WIN32
+#include <windows.h>
+
+BOOL WINAPI DllEntryPoint(HINSTANCE hinstdll,
+                          DWORD fdwReason,
+                          LPVOID lpvReserved)
+{
+        return 1;
+}
+       
+#define DLLEXPORT __declspec(dllexport)
+
+#else
+#define DLLEXPORT 
+#endif
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+DLLEXPORT unsigned char uchar_13 = 13;
+DLLEXPORT signed char schar_neg_120 = -120;
+DLLEXPORT unsigned short uword_257 = 257;
+DLLEXPORT signed short sword_neg_321 = -321;
+DLLEXPORT unsigned int uint_1234567 = 1234567;
+DLLEXPORT signed int sint_neg_123456 = -123456;
+DLLEXPORT double double_3_1 = 3.1;
+DLLEXPORT float float_neg_4_5 = -4.5;
+
+/* Test of constant input string */
+DLLEXPORT
+int
+cs_count_upper (char* psz)
+{
+  int count = 0;
+
+  if (psz) {
+    while (*psz) {
+      if (isupper (*psz))
+       ++count;
+      ++psz;
+    }
+    return count;
+  } else 
+    return -1;
+}
+
+/* Test of input and output of a string */
+DLLEXPORT
+void
+cs_to_upper (char* psz)
+{
+  if (psz) {
+    while (*psz) {
+      *psz = toupper (*psz);
+      ++psz;
+    }
+  }
+}
+
+/* Test of an output only string */
+DLLEXPORT
+void
+cs_make_random (int size, char* buffer)
+{
+  int i;
+  for (i = 0; i < size; i++)
+    buffer[i] = 'A' + (rand() % 26);
+}
+
+    
+/* Test of input/output vector */
+DLLEXPORT
+void
+half_double_vector (int size, double* vec)
+{
+  int i;
+  for (i = 0; i < size; i++)
+    vec[i] /= 2.;
+}
+
+    
+
+DLLEXPORT
+void *
+cast_test_int () {
+  int *x = (int *) malloc(sizeof(int));
+  *x = 23;
+  return x;
+}
+
+DLLEXPORT
+void *
+cast_test_float ()
+{
+  double *y = (double *) malloc(sizeof(double));
+  *y = 3.21;
+  return y;
+}
+
+DLLEXPORT int fvar_addend = 3;
+
+typedef struct {
+  int i;
+  double d;
+} fvar_struct_type;
+
+fvar_struct_type fvar_struct = {42, 3.2};
+
+DLLEXPORT
+int fvar_struct_int () {
+  return (fvar_addend + fvar_struct.i);
+}
+
+DLLEXPORT
+double fvar_struct_double () {
+  return fvar_struct.d;
+}
+
+     
index 4b8417b6df6900064b4980fa1bc0acd178eaa911..6f2c4bfc7c129149caaaf776c756afc6f6d583cb 100644 (file)
   (:use #:asdf #:cl))
 (in-package #:uffi-tests-system)
 
+(defvar *asd-file-dir* (pathname-directory *load-truename*))
+
+(defclass uffi-test-source-file (c-source-file)
+  ())
+
+(defmethod output-files ((o compile-op) (c uffi-test-source-file))
+  (let ((searched (or
+                  (probe-file #p"/usr/lib/uffi/uffi-c-test.so")
+                  (probe-file (make-pathname
+                               :directory *asd-file-dir*
+                               :name "uffi-c-test"
+                               :type "so")))))
+    (if searched
+       (list searched)
+       (list (merge-pathnames
+              (make-pathname :name (component-name c)
+                             :type "so"
+                             :directory '(:relative "tests"))
+              (make-pathname :directory *asd-file-dir*))))))
+
+(defmethod perform ((o load-op) (c uffi-test-source-file))
+  (dolist (f (asdf::input-files o c))
+    (funcall (intern (symbol-name '#:load-foreign-library)
+                    (symbol-name '#:uffi))
+            f :module "uffi_tests")))
+
+(defmethod perform ((o compile-op) (c uffi-test-source-file))
+  (unless (zerop (run-shell-command "cd ~A; make"
+                                   (namestring (merge-pathnames
+                                                (make-pathname
+                                                 :name nil
+                                                 :type nil
+                                                 :directory '(:relative "tests"))
+                                                (make-pathname
+                                                 :directory *asd-file-dir*)))))
+    (error 'operation-error :component c :operation o)))
+
+
 (defsystem uffi-tests
     :depends-on (:uffi)
     :components
     ((:module tests
              :components
              ((:file "rt")
+              (:uffi-test-source-file "uffi-c-test")
               (:file "package" :depends-on ("rt"))
               (:file "strtol" :depends-on ("package"))
               (:file "atoifl" :depends-on ("package"))
@@ -30,7 +69,7 @@
               (:file "structs" :depends-on ("package"))
               (:file "pointers" :depends-on ("package"))
               (:file "time" :depends-on ("package"))
-              (:file "foreign-loader" :depends-on ("package"))
+              (:file "foreign-loader" :depends-on ("package" "uffi-c-test"))
               (:file "uffi-c-test-lib" :depends-on ("foreign-loader"))
               (:file "compress" :depends-on ("foreign-loader"))
               (:file "casts" :depends-on ("foreign-loader"))