AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
-AC_LIB_HAVE_LINKFLAGS(usb,, [#include <usb.h>], [usb_init()])
-if test "$ac_cv_libusb" != yes; then
- AC_MSG_ERROR([libusb not found, please install usb.h and libusb.so])
-fi
-
AC_LIB_HAVE_LINKFLAGS(yubikey,, [#include <yubikey.h>],
[yubikey_modhex_decode(0,0,0)])
if test "$ac_cv_libyubikey" != yes; then
AC_MSG_ERROR([libyubikey not found, see http://code.google.com/p/yubico-c/])
fi
+AC_ARG_WITH([backend],
+ [AS_HELP_STRING([--with-backend=ARG],
+ [use specific backend; 'libusb' or 'osx'])])
+AC_MSG_CHECKING([for backend])
+if test x$with_backend != xosx && test x$with_backend != xlibusb; then
+ AC_CANONICAL_HOST
+ case "$host" in
+ *-darwin*) with_backend=osx ;;
+ *) with_backend=libusb ;;
+ esac
+fi
+AC_MSG_RESULT([$with_backend])
+AM_CONDITIONAL([BACKEND_LIBUSB], test x$with_backend = xlibusb)
+AM_CONDITIONAL([BACKEND_OSX], test x$with_backend = xosx)
+
+if test x$with_backend = libusb; then
+ AC_LIB_HAVE_LINKFLAGS(usb,, [#include <usb.h>], [usb_init()])
+ if test "$ac_cv_libusb" != yes; then
+ AC_MSG_ERROR([libusb not found, please install usb.h and libusb.so])
+ fi
+fi
+
AC_CONFIG_FILES([
Makefile
ykcore/Makefile
-# Copyright (c) 2008, Yubico AB
+# Copyright (c) 2008, 2009, Yubico AB
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
libykcore_la_SOURCES = ykdef.h ykcore.h ykcore_backend.h ykcore.c \
ykstatus.h ykstatus.c
libykcore_la_LIBADD = $(LTLIBYUBIKEY)
-EXTRA_DIST = ykcore_libusb.c ykcore_win32.c
+
+if BACKEND_LIBUSB
+libykcore_la_SOURCES += ykcore_libusb.c
+endif
+
+if BACKEND_OSX
+libykcore_la_SOURCES += ykcore_osx.c
+endif
#include "ykdef.h"
#include "ykcore_backend.h"
-/* Include platform-specific backends for the USB routines */
-#ifdef _WIN32
-# include "ykcore_win32.c"
-#elif defined(__APPLE__)
-# include "ykcore_osx.c"
-#else
-# include "ykcore_libusb.c"
-#endif
-
#include <yubikey.h>
+#ifndef _WIN32
+#define Sleep(x) usleep((x)*1000)
+#endif
+
int yk_init(void)
{
_ykusb_start();
/* -*- mode:C; c-file-style: "bsd" -*- */
/*
- * Copyright (c) 2008, Yubico AB
+ * Copyright (c) 2008, 2009, Yubico AB
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include <stdio.h>
#include <string.h>
+#include "ykcore.h"
+#include "ykdef.h"
#include "ykcore_backend.h"
-#ifndef _WIN32
-#define Sleep(x) usleep((x)*1000)
-#endif
-
#define HID_GET_REPORT 0x01
#define HID_SET_REPORT 0x09