Merge "Add support for building libusb." am: 24970bd1df am: f99006eca4 am: bcf9655ab9
am: 4d2434da44

Change-Id: Iba4f5b1862297c85064b35a40d9dcb12bea9fcfe
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..266b50d
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,85 @@
+cc_library {
+    name: "libusb",
+    host_supported: true,
+
+    srcs: [
+        "libusb/core.c",
+        "libusb/descriptor.c",
+        "libusb/hotplug.c",
+        "libusb/io.c",
+        "libusb/sync.c",
+        "libusb/strerror.c",
+    ],
+
+    local_include_dirs: [
+        "libusb",
+        "libusb/os",
+    ],
+
+    target: {
+        android: {
+            srcs: [
+                "libusb/os/linux_usbfs.c",
+                "libusb/os/poll_posix.c",
+                "libusb/os/threads_posix.c",
+                "libusb/os/linux_netlink.c",
+            ],
+
+            local_include_dirs: [
+                "android",
+            ],
+        },
+
+        darwin: {
+            srcs: [
+                "libusb/os/darwin_usb.c",
+                "libusb/os/poll_posix.c",
+                "libusb/os/threads_posix.c",
+            ],
+
+            local_include_dirs: [
+                "darwin",
+            ],
+
+            host_ldlibs: [
+                "-framework CoreFoundation",
+                "-framework IOKit",
+                "-lobjc"
+            ],
+        },
+
+        linux: {
+            srcs: [
+                "libusb/os/linux_usbfs.c",
+                "libusb/os/poll_posix.c",
+                "libusb/os/threads_posix.c",
+                "libusb/os/linux_netlink.c",
+            ],
+
+            local_include_dirs: [
+                "linux",
+            ],
+        },
+
+        windows: {
+            srcs: [
+                "libusb/os/poll_windows.c",
+                "libusb/os/threads_windows.c",
+                "libusb/os/windows_nt_common.c",
+                "libusb/os/windows_usbdk.c",
+                "libusb/os/windows_winusb.c",
+            ],
+
+            local_include_dirs: [
+                "windows",
+            ],
+
+            // Not working yet.
+            enabled: false,
+        },
+    },
+
+    shared_libs: ["liblog"],
+    export_include_dirs: ["include"],
+}
+
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..d500f98
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1 @@
+# Empty Android.mk to keep the build system from using the one in upstream's android/jni.
diff --git a/README.version b/README.version
new file mode 100644
index 0000000..795b386
--- /dev/null
+++ b/README.version
@@ -0,0 +1,4 @@
+URL: https://github.com/libusb/libusb
+Version: Rolling from upstream
+BugComponent: 1352
+Owners: jmgao, adb-bugs
diff --git a/darwin/config.h b/darwin/config.h
new file mode 100644
index 0000000..bd8a0f9
--- /dev/null
+++ b/darwin/config.h
@@ -0,0 +1,158 @@
+/* config.h.  Generated from config.h.in by configure.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Default visibility */
+#define DEFAULT_VISIBILITY __attribute__((visibility("default")))
+
+/* Start with debug message logging enabled */
+/* #undef ENABLE_DEBUG_LOGGING */
+
+/* Message logging */
+#define ENABLE_LOGGING 1
+
+/* Define to 1 if you have the <asm/types.h> header file. */
+/* #undef HAVE_ASM_TYPES_H */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `udev' library (-ludev). */
+/* #undef HAVE_LIBUDEV */
+
+/* Define to 1 if you have the <libudev.h> header file. */
+/* #undef HAVE_LIBUDEV_H */
+
+/* Define to 1 if you have the <linux/netlink.h> header file. */
+/* #undef HAVE_LINUX_NETLINK_H */
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <poll.h> header file. */
+#define HAVE_POLL_H 1
+
+/* Define to 1 if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if the system has the type `struct timespec'. */
+#define HAVE_STRUCT_TIMESPEC 1
+
+/* syslog() function available */
+#define HAVE_SYSLOG_FUNC 1
+
+/* Define to 1 if you have the <syslog.h> header file. */
+#define HAVE_SYSLOG_H 1
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+/* #undef HAVE_SYS_SOCKET_H */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
+/* Darwin backend */
+#define OS_DARWIN 1
+
+/* Haiku backend */
+/* #undef OS_HAIKU */
+
+/* Linux backend */
+/* #undef OS_LINUX */
+
+/* NetBSD backend */
+/* #undef OS_NETBSD */
+
+/* OpenBSD backend */
+/* #undef OS_OPENBSD */
+
+/* SunOS backend */
+/* #undef OS_SUNOS */
+
+/* Windows backend */
+/* #undef OS_WINDOWS */
+
+/* Name of package */
+#define PACKAGE "libusb"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "libusb-devel@lists.sourceforge.net"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "libusb"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "libusb 1.0.21-rc5"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libusb"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "http://libusb.info"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.0.21-rc5"
+
+/* type of second poll() argument */
+#define POLL_NFDS_TYPE nfds_t
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Use POSIX Threads */
+#define THREADS_POSIX 1
+
+/* timerfd headers available */
+/* #undef USBI_TIMERFD_AVAILABLE */
+
+/* Enable output to system log */
+/* #undef USE_SYSTEM_LOGGING_FACILITY */
+
+/* Use udev for device enumeration/hotplug */
+/* #undef USE_UDEV */
+
+/* Use UsbDk Windows backend */
+/* #undef USE_USBDK */
+
+/* Version number of package */
+#define VERSION "1.0.21-rc5"
+
+/* Oldest Windows version supported */
+/* #undef WINVER */
+
+/* Use GNU extensions */
+#define _GNU_SOURCE 1
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
diff --git a/include/libusb/hotplug.h b/include/libusb/hotplug.h
new file mode 120000
index 0000000..1f6670a
--- /dev/null
+++ b/include/libusb/hotplug.h
@@ -0,0 +1 @@
+../../libusb/hotplug.h
\ No newline at end of file
diff --git a/include/libusb/libusb.h b/include/libusb/libusb.h
new file mode 120000
index 0000000..04954bd
--- /dev/null
+++ b/include/libusb/libusb.h
@@ -0,0 +1 @@
+../../libusb/libusb.h
\ No newline at end of file
diff --git a/include/libusb/libusbi.h b/include/libusb/libusbi.h
new file mode 120000
index 0000000..335b54c
--- /dev/null
+++ b/include/libusb/libusbi.h
@@ -0,0 +1 @@
+../../libusb/libusbi.h
\ No newline at end of file
diff --git a/include/libusb/version.h b/include/libusb/version.h
new file mode 120000
index 0000000..28b7fe4
--- /dev/null
+++ b/include/libusb/version.h
@@ -0,0 +1 @@
+../../libusb/version.h
\ No newline at end of file
diff --git a/include/libusb/version_nano.h b/include/libusb/version_nano.h
new file mode 120000
index 0000000..3380ebd
--- /dev/null
+++ b/include/libusb/version_nano.h
@@ -0,0 +1 @@
+../../libusb/version_nano.h
\ No newline at end of file
diff --git a/linux/config.h b/linux/config.h
new file mode 100644
index 0000000..f50f5ab
--- /dev/null
+++ b/linux/config.h
@@ -0,0 +1,159 @@
+/* config.h.  Generated from config.h.in by configure.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Default visibility */
+#define DEFAULT_VISIBILITY __attribute__((visibility("default")))
+
+/* Start with debug message logging enabled */
+/* #undef ENABLE_DEBUG_LOGGING */
+
+/* Message logging */
+#define ENABLE_LOGGING 1
+
+/* Define to 1 if you have the <asm/types.h> header file. */
+#define HAVE_ASM_TYPES_H 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `udev' library (-ludev). */
+/* #undef HAVE_LIBUDEV */
+
+/* Define to 1 if you have the <libudev.h> header file. */
+/* #undef HAVE_LIBUDEV_H */
+
+/* Define to 1 if you have the <linux/netlink.h> header file. */
+#define HAVE_LINUX_NETLINK_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <poll.h> header file. */
+#define HAVE_POLL_H 1
+
+/* Define to 1 if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if the system has the type `struct timespec'. */
+#define HAVE_STRUCT_TIMESPEC 1
+
+/* syslog() function available */
+#define HAVE_SYSLOG_FUNC 1
+
+/* Define to 1 if you have the <syslog.h> header file. */
+#define HAVE_SYSLOG_H 1
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#define HAVE_SYS_SOCKET_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#define LT_OBJDIR ".libs/"
+
+/* Darwin backend */
+/* #undef OS_DARWIN */
+
+/* Haiku backend */
+/* #undef OS_HAIKU */
+
+/* Linux backend */
+#define OS_LINUX 1
+
+/* NetBSD backend */
+/* #undef OS_NETBSD */
+
+/* OpenBSD backend */
+/* #undef OS_OPENBSD */
+
+/* SunOS backend */
+/* #undef OS_SUNOS */
+
+/* Windows backend */
+/* #undef OS_WINDOWS */
+
+/* Name of package */
+#define PACKAGE "libusb"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "libusb-devel@lists.sourceforge.net"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "libusb"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "libusb 1.0.21-rc5"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libusb"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "http://libusb.info"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.0.21-rc5"
+
+/* type of second poll() argument */
+#define POLL_NFDS_TYPE nfds_t
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Use POSIX Threads */
+#define THREADS_POSIX 1
+
+/* timerfd headers available */
+#define USBI_TIMERFD_AVAILABLE 1
+
+/* Enable output to system log */
+/* #undef USE_SYSTEM_LOGGING_FACILITY */
+
+/* Use udev for device enumeration/hotplug */
+/* #undef USE_UDEV */
+
+/* Use UsbDk Windows backend */
+/* #undef USE_USBDK */
+
+/* Version number of package */
+#define VERSION "1.0.21-rc5"
+
+/* Oldest Windows version supported */
+/* #undef WINVER */
+
+/* Use GNU extensions */
+#define _GNU_SOURCE 1
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
diff --git a/windows/config.h b/windows/config.h
new file mode 100644
index 0000000..4ef90a0
--- /dev/null
+++ b/windows/config.h
@@ -0,0 +1,159 @@
+/* config.h.  Generated from config.h.in by configure.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Default visibility */
+#define DEFAULT_VISIBILITY __attribute__((visibility("default")))
+
+/* Start with debug message logging enabled */
+/* #undef ENABLE_DEBUG_LOGGING */
+
+/* Message logging */
+#define ENABLE_LOGGING 1
+
+/* Define to 1 if you have the <asm/types.h> header file. */
+/* #undef HAVE_ASM_TYPES_H */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `udev' library (-ludev). */
+/* #undef HAVE_LIBUDEV */
+
+/* Define to 1 if you have the <libudev.h> header file. */
+/* #define HAVE_LIBUDEV_H */
+
+/* Define to 1 if you have the <linux/netlink.h> header file. */
+/* #undef HAVE_LINUX_NETLINK_H */
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <poll.h> header file. */
+/* #undef HAVE_POLL_H */
+
+/* Define to 1 if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if the system has the type `struct timespec'. */
+#define HAVE_STRUCT_TIMESPEC 1
+
+/* syslog() function available */
+/* #undef HAVE_SYSLOG_FUNC */
+
+/* Define to 1 if you have the <syslog.h> header file. */
+/* #undef HAVE_SYSLOG_H */
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+/* #undef HAVE_SYS_SOCKET_H */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#define LT_OBJDIR ".libs/"
+
+/* Darwin backend */
+/* #undef OS_DARWIN */
+
+/* Haiku backend */
+/* #undef OS_HAIKU */
+
+/* Linux backend */
+/* #define OS_LINUX 1 */
+
+/* NetBSD backend */
+/* #undef OS_NETBSD */
+
+/* OpenBSD backend */
+/* #undef OS_OPENBSD */
+
+/* SunOS backend */
+/* #undef OS_SUNOS */
+
+/* Windows backend */
+#define OS_WINDOWS 1
+
+/* Name of package */
+#define PACKAGE "libusb"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "libusb-devel@lists.sourceforge.net"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "libusb"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "libusb 1.0.21-rc5"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libusb"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "http://libusb.info"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.0.21-rc5"
+
+/* type of second poll() argument */
+#define POLL_NFDS_TYPE unsigned int
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Use POSIX Threads */
+/* #undef THREADS_POSIX */
+
+/* timerfd headers available */
+/* #undef USBI_TIMERFD_AVAILABLE */
+
+/* Enable output to system log */
+/* #undef USE_SYSTEM_LOGGING_FACILITY */
+
+/* Use udev for device enumeration/hotplug */
+/* #undef USE_UDEV */
+
+/* Use UsbDk Windows backend */
+#define USE_USBDK 1
+
+/* Version number of package */
+#define VERSION "1.0.21-rc5"
+
+/* Oldest Windows version supported */
+/* #undef WINVER */
+
+/* Use GNU extensions */
+/* #undef _GNU_SOURCE */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+/* #undef inline */
+#endif