mirror of
https://github.com/RPCS3/hidapi.git
synced 2024-11-26 19:40:35 +00:00
Add Autotools build system (automake, autconf)
This adds the familiar autotools build system and associated documentation for Linux, FreeBSD, Mac, MinGW, and Cygwin. The old Makefiles have been kept, and where appropriate have been renamed Makefile-manual. Thanks to Peter Stuge, Ludovic Rousseau, Xiaofan Chen, Alex Dupre, and Segher Boessenkool for providing testing, review, and suggestions, and to Ludovic Rousseau for providing patches which contributed to this commit.
This commit is contained in:
parent
567304bf2d
commit
6d50f8fa0f
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
# Autotools-added generated files
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
config.guess
|
||||
config.h.in
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
libusb/Makefile.in
|
||||
linux/Makefile.in
|
||||
ltmain.sh
|
||||
mac/Makefile.in
|
||||
missing
|
||||
testgui/Makefile.in
|
||||
windows/Makefile.in
|
||||
|
||||
Makefile
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
stamp-h1
|
||||
libtool
|
77
Makefile.am
Normal file
77
Makefile.am
Normal file
@ -0,0 +1,77 @@
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
if OS_FREEBSD
|
||||
pkgconfigdir=$(prefix)/libdata/pkgconfig
|
||||
else
|
||||
pkgconfigdir=$(libdir)/pkgconfig
|
||||
endif
|
||||
|
||||
if OS_LINUX
|
||||
pkgconfig_DATA=pc/hidapi-hidraw.pc pc/hidapi-libusb.pc
|
||||
else
|
||||
pkgconfig_DATA=pc/hidapi.pc
|
||||
endif
|
||||
|
||||
SUBDIRS=
|
||||
|
||||
if OS_LINUX
|
||||
SUBDIRS += linux libusb
|
||||
endif
|
||||
|
||||
if OS_DARWIN
|
||||
SUBDIRS += mac
|
||||
endif
|
||||
|
||||
if OS_FREEBSD
|
||||
SUBDIRS += libusb
|
||||
endif
|
||||
|
||||
if OS_WINDOWS
|
||||
SUBDIRS += windows
|
||||
endif
|
||||
|
||||
SUBDIRS += hidtest
|
||||
|
||||
if BUILD_TESTGUI
|
||||
SUBDIRS += testgui
|
||||
endif
|
||||
|
||||
EXTRA_DIST = udev doxygen
|
||||
|
||||
dist_doc_DATA = \
|
||||
README.txt \
|
||||
AUTHORS.txt \
|
||||
LICENSE-bsd.txt \
|
||||
LICENSE-gpl3.txt \
|
||||
LICENSE-orig.txt \
|
||||
LICENSE.txt
|
||||
|
||||
SCMCLEAN_TARGETS= \
|
||||
aclocal.m4 \
|
||||
config.guess \
|
||||
config.sub \
|
||||
configure \
|
||||
config.h.in \
|
||||
depcomp \
|
||||
install-sh \
|
||||
ltmain.sh \
|
||||
missing \
|
||||
mac/Makefile.in \
|
||||
testgui/Makefile.in \
|
||||
libusb/Makefile.in \
|
||||
Makefile.in \
|
||||
linux/Makefile.in \
|
||||
windows/Makefile.in \
|
||||
m4/libtool.m4 \
|
||||
m4/lt~obsolete.m4 \
|
||||
m4/ltoptions.m4 \
|
||||
m4/ltsugar.m4 \
|
||||
m4/ltversion.m4
|
||||
|
||||
SCMCLEAN_DIR_TARGETS = \
|
||||
autom4te.cache
|
||||
|
||||
scm-clean: distclean
|
||||
rm -f $(SCMCLEAN_TARGETS)
|
||||
rm -Rf $(SCMCLEAN_DIR_TARGETS)
|
261
README.txt
261
README.txt
@ -1,13 +1,14 @@
|
||||
HID API for Windows, Linux, FreeBSD and Mac OS X
|
||||
HIDAPI library for Windows, Linux, FreeBSD and Mac OS X
|
||||
=========================================================
|
||||
|
||||
About
|
||||
------
|
||||
======
|
||||
|
||||
HIDAPI is a multi-platform library which allows an application to interface
|
||||
with USB and Bluetooth HID-Class devices on Windows, Linux, FreeBSD, and Mac
|
||||
OS X. On Windows, a DLL is built. On other platforms (and optionally on
|
||||
Windows), the single source file can simply be dropped into a target
|
||||
application.
|
||||
OS X. HIDAPI can be either built as a shared library (.so or .dll) or
|
||||
can be embedded directly into a target application by adding a single source
|
||||
file (per platform) and a single header.
|
||||
|
||||
HIDAPI has four back-ends:
|
||||
* Windows (using hid.dll)
|
||||
@ -32,15 +33,18 @@ Linux/FreeBSD/libusb (libusb/hid-libusb.c):
|
||||
This back-end uses libusb-1.0 to communicate directly to a USB device. This
|
||||
back-end will of course not work with Bluetooth devices.
|
||||
|
||||
HIDAPI also comes with a Test GUI. The Test GUI is cross-platform and uses
|
||||
Fox Toolkit (http://www.fox-toolkit.org). It will build on every platform
|
||||
which HIDAPI supports. Since it relies on a 3rd party library, building it
|
||||
is optional but recommended because it is so useful when debugging hardware.
|
||||
|
||||
What Does the API Look Like?
|
||||
-----------------------------
|
||||
=============================
|
||||
The API provides the the most commonly used HID functions including sending
|
||||
and receiving of input, output, and feature reports. The sample program,
|
||||
which communicates with a heavily modified version the USB Generic HID
|
||||
sample which is part of the Microchip Application Library (in folder
|
||||
"Microchip Solutions\USB Device - HID - Custom Demos\Generic HID - Firmware"
|
||||
when the Microchip Application Framework is installed), looks like this
|
||||
(with error checking removed for simplicity):
|
||||
which communicates with a heavily hacked up version of the Microchip USB
|
||||
Generic HID sample looks like this (with error checking removed for
|
||||
simplicity):
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
@ -97,51 +101,172 @@ int main(int argc, char* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
If you have your own simple test programs which communicate with standard
|
||||
hardware development boards (such as those from Microchip, TI, Atmel,
|
||||
FreeScale and others), please consider sending me something like the above
|
||||
for inclusion into the HIDAPI source. This will help others who have the
|
||||
same hardware as you do.
|
||||
|
||||
License
|
||||
--------
|
||||
========
|
||||
HIDAPI may be used by one of three licenses as outlined in LICENSE.txt.
|
||||
|
||||
Download
|
||||
---------
|
||||
It can be downloaded from github
|
||||
=========
|
||||
HIDAPI can be downloaded from github
|
||||
git clone git://github.com/signal11/hidapi.git
|
||||
|
||||
Build Instructions
|
||||
-------------------
|
||||
To build the console test program:
|
||||
Windows:
|
||||
Build the .sln file in the windows/ directory.
|
||||
Linux:
|
||||
For the hidraw implementation, cd to the linux/ directory and run make.
|
||||
For the libusb implementation, cd to the libusb/ directory and run make.
|
||||
FreeBSD:
|
||||
cd to the libusb/ directory and run gmake.
|
||||
Mac OS X:
|
||||
cd to the mac/ directory and run make.
|
||||
===================
|
||||
|
||||
To build the Test GUI:
|
||||
The test GUI uses Fox toolkit, available from www.fox-toolkit.org.
|
||||
On Debian-based systems such as Ubuntu, install Fox using the following:
|
||||
sudo apt-get install libfox-1.6-dev
|
||||
On FreeBSD, install iconv and Fox as root:
|
||||
pkg_add -r gmake libiconv fox16
|
||||
On Mac OSX, install Fox from ports:
|
||||
sudo port install fox
|
||||
On Windows, download the hidapi-externals.zip file from the main download
|
||||
site and extract it just outside of hidapi, so that hidapi-externals and
|
||||
hidapi are on the same level, as shown:
|
||||
This section is long. Don't be put off by this. It's not long because it's
|
||||
complicated to build HIDAPI; it's quite the opposite. This section is long
|
||||
because of the flexibility of HIDAPI and the large number of ways in which
|
||||
it can be built and used. You will likely pick a single build method.
|
||||
|
||||
Parent_Folder
|
||||
|
|
||||
+hidapi
|
||||
+hidapi-externals
|
||||
HIDAPI can be built in several different ways. If you elect to build a
|
||||
shared library, you will need to build it from the HIDAPI source
|
||||
distribution. If you choose instead to embed HIDAPI directly into your
|
||||
application, you can skip the building and look at the provided platform
|
||||
Makefiles for guidance. These platform Makefiles are located in linux/
|
||||
libusb/ mac/ and windows/ and are called Makefile-manual. In addition,
|
||||
Visual Studio projects are provided. Even if you're going to embed HIDAPI
|
||||
into your project, it is still beneficial to build the example programs.
|
||||
|
||||
Then to build:
|
||||
On Windows, build the .sln file in the testgui/ directory.
|
||||
On Linux and Mac, run make from the testgui/ directory.
|
||||
On FreeBSD, run gmake from the testgui/ directory.
|
||||
|
||||
To build using the DDK (old method):
|
||||
Prerequisites:
|
||||
---------------
|
||||
|
||||
Linux:
|
||||
-------
|
||||
On Linux, you will need to install development packages for libudev,
|
||||
libusb and optionally Fox-toolkit (for the test GUI). On
|
||||
Debian/Ubuntu systems these can be installed by running:
|
||||
sudo apt-get install libudev-dev libusb-1.0-0-dev libfox-1.6-dev
|
||||
|
||||
If you downloaded the source directly from the git repository (using
|
||||
git clone), you'll need Autotools:
|
||||
sudo apt-get install autotools-dev
|
||||
|
||||
FreeBSD:
|
||||
---------
|
||||
On FreeBSD you will need to install GNU make, libiconv, and
|
||||
optionally Fox-Toolkit (for the test GUI). This is done by running
|
||||
the following:
|
||||
pkg_add -r gmake libiconv fox16
|
||||
|
||||
If you downloaded the source directly from the git repository (using
|
||||
git clone), you'll need Autotools:
|
||||
pkg_add -r autotools
|
||||
|
||||
Mac:
|
||||
-----
|
||||
On Mac, you will need to install Fox-Toolkit if you wish to build
|
||||
the Test GUI. There are two ways to do this, and each has a slight
|
||||
complication. Which method you use depends on your use case.
|
||||
|
||||
If you wish to build the Test GUI just for your own testing on your
|
||||
own computer, then the easiest method is to install Fox-Toolkit
|
||||
using ports:
|
||||
sudo port install fox
|
||||
|
||||
If you wish to build the TestGUI app bundle to redistribute to
|
||||
others, you will need to install Fox-toolkit from source. This is
|
||||
because the version of fox that gets installed using ports uses the
|
||||
ports X11 libraries which are not compatible with the Apple X11
|
||||
libraries. If you install Fox with ports and then try to distribute
|
||||
your built app bundle, it will simply fail to run on other systems.
|
||||
To install Fox-Toolkit manually, download the source package from
|
||||
http://www.fox-toolkit.org, extract it, and run the following from
|
||||
within the extracted source:
|
||||
./configure && make && make install
|
||||
|
||||
Windows:
|
||||
---------
|
||||
On Windows, if you want to build the test GUI, you will need to get
|
||||
the hidapi-externals.zip package from the download site. This
|
||||
contains pre-built binaries for Fox-toolkit. Extract
|
||||
hidapi-externals.zip just outside of hidapi, so that
|
||||
hidapi-externals and hidapi are on the same level, as shown:
|
||||
|
||||
Parent_Folder
|
||||
|
|
||||
+hidapi
|
||||
+hidapi-externals
|
||||
|
||||
Again, this step is not required if you do not wish to build the
|
||||
test GUI.
|
||||
|
||||
|
||||
Building HIDAPI into a shared library on Unix Platforms:
|
||||
---------------------------------------------------------
|
||||
|
||||
On Unix-like systems such as Linux, FreeBSD, Mac, and even Windows, using
|
||||
Mingw or Cygwin, the easiest way to build a standard system-installed shared
|
||||
library is to use the GNU Autotools build system. If you checked out the
|
||||
source from the git repository, run the following:
|
||||
|
||||
./bootstrap
|
||||
./configure
|
||||
make
|
||||
make install <----- as root, or using sudo
|
||||
|
||||
If you downloaded a source package (ie: if you did not run git clone), you
|
||||
can skip the ./bootstrap step.
|
||||
|
||||
./configure can take several arguments which control the build. The two most
|
||||
likely to be used are:
|
||||
--enable-testgui
|
||||
Enable build of the Test GUI. This requires Fox toolkit to
|
||||
be installed. Instructions for installing Fox-Toolkit on
|
||||
each platform are in the Prerequisites section above.
|
||||
|
||||
--prefix=/usr
|
||||
Specify where you want the output headers and libraries to
|
||||
be installed. The example above will put the headers in
|
||||
/usr/include and the binaries in /usr/lib. The default is to
|
||||
install into /usr/local which is fine on most systems.
|
||||
|
||||
Building the manual way on Unix platforms:
|
||||
-------------------------------------------
|
||||
|
||||
Manual Makefiles are provided mostly to give the user and idea what it takes
|
||||
to build a program which embeds HIDAPI directly inside of it. These should
|
||||
really be used as examples only. If you want to build a system-wide shared
|
||||
library, use the Autotools method described above.
|
||||
|
||||
To build HIDAPI using the manual makefiles, change to the directory
|
||||
of your platform and run make. For example, on Linux run:
|
||||
cd linux/
|
||||
make -f Makefile-manual
|
||||
|
||||
To build the Test GUI using the manual makefiles:
|
||||
cd testgui/
|
||||
make -f Makefile-manual
|
||||
|
||||
Building on Windows:
|
||||
---------------------
|
||||
|
||||
To build the HIDAPI DLL on Windows using Visual Studio, build the .sln file
|
||||
in the windows/ directory.
|
||||
|
||||
To build the Test GUI on windows using Visual Studio, build the .sln file in
|
||||
the testgui/ directory.
|
||||
|
||||
To build HIDAPI using MinGW or Cygwin using Autotools, use the instructions
|
||||
in the section titled "Building HIDAPI into a shared library on Unix
|
||||
Platforms" above. Note that building the Test GUI with MinGW or Cygwin will
|
||||
require the Windows procedure in the Prerequisites section above (ie:
|
||||
hidapi-externals.zip).
|
||||
|
||||
To build HIDAPI using MinGW using the Manual Makefiles, see the section
|
||||
"Building the manual way on Unix platforms" above.
|
||||
|
||||
HIDAPI can also be built using the Windows DDK (now also called the Windows
|
||||
Driver Kit or WDK). This method was originally required for the HIDAPI build
|
||||
but not anymore. However, some users still prefer this method. It is not as
|
||||
well supported anymore but should still work. Patches are welcome if it does
|
||||
not. To build using the DDK:
|
||||
|
||||
1. Install the Windows Driver Kit (WDK) from Microsoft.
|
||||
2. From the Start menu, in the Windows Driver Kits folder, select Build
|
||||
@ -154,9 +279,53 @@ To build using the DDK (old method):
|
||||
by the build system which is appropriate for your environment. On
|
||||
Windows XP, this directory is objfre_wxp_x86/i386.
|
||||
|
||||
--------------------------------
|
||||
Cross Compiling
|
||||
================
|
||||
|
||||
This section talks about cross compiling HIDAPI for Linux using autotools.
|
||||
This is useful for using HIDAPI on embedded Linux targets. These
|
||||
instructions assume the most raw kind of embedded Linux build, where all
|
||||
prerequisites will need to be built first. This process will of course vary
|
||||
based on your embedded Linux build system if you are using one, such as
|
||||
OpenEmbedded or Buildroot.
|
||||
|
||||
For the purpose of this section, it will be assumed that the following
|
||||
environment variables are exported.
|
||||
|
||||
$ export STAGING=$HOME/out
|
||||
$ export HOST=arm-linux
|
||||
|
||||
STAGING and HOST can be modified to suit your setup.
|
||||
|
||||
Prerequisites
|
||||
--------------
|
||||
|
||||
Note that the build of libudev is the very basic configuration.
|
||||
|
||||
Build Libusb. From the libusb source directory, run:
|
||||
./configure --host=$HOST --prefix=$STAGING
|
||||
make
|
||||
make install
|
||||
|
||||
Build libudev. From the libudev source directory, run:
|
||||
./configure --disable-gudev --disable-introspection --disable-hwdb \
|
||||
--host=arm-linux --prefix=$STAGING
|
||||
make
|
||||
make install
|
||||
|
||||
Building HIDAPI
|
||||
----------------
|
||||
|
||||
Build HIDAPI:
|
||||
|
||||
PKG_CONFIG_DIR= \
|
||||
PKG_CONFIG_LIBDIR=$STAGING/lib/pkgconfig:$STAGING/share/pkgconfig \
|
||||
PKG_CONFIG_SYSROOT_DIR=$STAGING \
|
||||
./configure --host=$HOST --prefix=$STAGING
|
||||
|
||||
|
||||
Signal 11 Software - 2010-04-11
|
||||
2010-07-28
|
||||
2011-09-10
|
||||
2012-05-01
|
||||
2012-07-03
|
||||
|
2
bootstrap
Executable file
2
bootstrap
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh -x
|
||||
autoreconf --install --verbose --force
|
224
configure.ac
Normal file
224
configure.ac
Normal file
@ -0,0 +1,224 @@
|
||||
AC_PREREQ(2.65)
|
||||
|
||||
# Version number. This is currently the only place.
|
||||
m4_define([HIDAPI_MAJOR], 0)
|
||||
m4_define([HIDAPI_MINOR], 7)
|
||||
m4_define([HIDAPI_RELEASE], 0)
|
||||
m4_define([HIDAPI_RC], +)
|
||||
m4_define([VERSION_STRING], HIDAPI_MAJOR[.]HIDAPI_MINOR[.]HIDAPI_RELEASE[]HIDAPI_RC)
|
||||
|
||||
AC_INIT([hidapi],[VERSION_STRING],[alan@signal11.us])
|
||||
|
||||
# Library soname version
|
||||
# Follow the following rules (particularly the ones in the second link):
|
||||
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
||||
# http://sourceware.org/autobook/autobook/autobook_91.html
|
||||
lt_current="0"
|
||||
lt_revision="0"
|
||||
lt_age="0"
|
||||
LTLDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age}"
|
||||
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
||||
LT_INIT
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_PROG_OBJC
|
||||
PKG_PROG_PKG_CONFIG
|
||||
|
||||
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
hidapi_lib_error() {
|
||||
echo ""
|
||||
echo " Library $1 was not found on this system."
|
||||
echo " Please install it and re-run ./configure"
|
||||
echo ""
|
||||
exit 1
|
||||
}
|
||||
|
||||
hidapi_prog_error() {
|
||||
echo ""
|
||||
echo " Program $1 was not found on this system."
|
||||
echo " This program is part of $2."
|
||||
echo " Please install it and re-run ./configure"
|
||||
echo ""
|
||||
exit 1
|
||||
}
|
||||
|
||||
AC_MSG_CHECKING([operating system])
|
||||
AC_MSG_RESULT($host)
|
||||
case $host in
|
||||
*-linux*)
|
||||
AC_MSG_RESULT([ (Linux back-end)])
|
||||
AC_DEFINE(OS_LINUX, 1, [Linux implementations])
|
||||
AC_SUBST(OS_LINUX)
|
||||
backend="linux"
|
||||
os="linux"
|
||||
threads="pthreads"
|
||||
|
||||
# HIDAPI/hidraw libs
|
||||
PKG_CHECK_MODULES([libudev], [libudev], true, [hidapi_lib_error libudev])
|
||||
LIBS_HIDRAW_PR+=" $libudev_LIBS"
|
||||
CFLAGS_HIDRAW+=" $libudev_CFLAGS"
|
||||
|
||||
# HIDAPI/libusb libs
|
||||
AC_CHECK_LIB([rt], [clock_gettime], [LIBS_LIBUSB_PRIVATE+=" -lrt"], [hidapi_lib_error librt])
|
||||
PKG_CHECK_MODULES([libusb], [libusb-1.0], true, [hidapi_lib_error libusb-1.0])
|
||||
LIBS_LIBUSB_PRIVATE+=" $libusb_LIBS"
|
||||
CFLAGS_LIBUSB+=" $libusb_CFLAGS"
|
||||
;;
|
||||
*-darwin*)
|
||||
AC_MSG_RESULT([ (Mac OS X back-end)])
|
||||
AC_DEFINE(OS_DARWIN, 1, [Mac implementation])
|
||||
AC_SUBST(OS_DARWIN)
|
||||
backend="mac"
|
||||
os="darwin"
|
||||
threads="pthreads"
|
||||
LIBS="${LIBS} -framework IOKit -framework CoreFoundation"
|
||||
;;
|
||||
*-freebsd*)
|
||||
AC_MSG_RESULT([ (FreeBSD back-end)])
|
||||
AC_DEFINE(OS_FREEBSD, 1, [FreeBSD implementation])
|
||||
AC_SUBST(OS_FREEBSD)
|
||||
backend="libusb"
|
||||
os="freebsd"
|
||||
threads="pthreads"
|
||||
|
||||
CFLAGS="$CFLAGS -I/usr/local/include"
|
||||
LDFLAGS="$LDFLAGS -L/usr/local/lib"
|
||||
LIBS="${LIBS}"
|
||||
AC_CHECK_LIB([usb], [libusb_init], [LIBS_LIBUSB_PRIVATE="${LIBS_LIBUSB_PRIVATE} -lusb"], [hidapi_lib_error libusb])
|
||||
AC_CHECK_LIB([iconv], [iconv_open], [LIBS_LIBUSB_PRIVATE="${LIBS_LIBUSB_PRIVATE} -liconv"], [hidapi_lib_error libiconv])
|
||||
echo libs_priv: $LIBS_LIBUSB_PRIVATE
|
||||
;;
|
||||
*-mingw*)
|
||||
AC_MSG_RESULT([ (Windows back-end, using MinGW)])
|
||||
backend="windows"
|
||||
os="windows"
|
||||
threads="windows"
|
||||
win_implementation="mingw"
|
||||
;;
|
||||
*-cygwin*)
|
||||
AC_MSG_RESULT([ (Windows back-end, using Cygwin)])
|
||||
backend="windows"
|
||||
os="windows"
|
||||
threads="windows"
|
||||
win_implementation="cygwin"
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([HIDAPI is not supported on your operating system yet])
|
||||
esac
|
||||
|
||||
LIBS_HIDRAW="${LIBS} ${LIBS_HIDRAW_PR}"
|
||||
LIBS_LIBUSB="${LIBS} ${LIBS_LIBUSB_PRIVATE}"
|
||||
AC_SUBST([LIBS_HIDRAW])
|
||||
AC_SUBST([LIBS_LIBUSB])
|
||||
AC_SUBST([CFLAGS_LIBUSB])
|
||||
AC_SUBST([CFLAGS_HIDRAW])
|
||||
|
||||
if test "x$os" = xwindows; then
|
||||
AC_DEFINE(OS_WINDOWS, 1, [Windows implementations])
|
||||
AC_SUBST(OS_WINDOWS)
|
||||
LDFLAGS="${LDFLAGS} -no-undefined"
|
||||
LIBS="${LIBS} -lsetupapi"
|
||||
fi
|
||||
|
||||
if test "x$threads" = xpthreads; then
|
||||
AX_PTHREAD([found_pthreads=yes], [found_pthreads=no])
|
||||
|
||||
if test "x$found_pthreads" = xyes; then
|
||||
if test "x$os" = xlinux; then
|
||||
# Only use pthreads for libusb implementation on Linux.
|
||||
LIBS_LIBUSB="$PTHREAD_LIBS $LIBS_LIBUSB"
|
||||
CFLAGS_LIBUSB="$CFLAGS_LIBUSB $PTHREAD_CFLAGS"
|
||||
# There's no separate CC on Linux for threading,
|
||||
# so it's ok that both implementations use $PTHREAD_CC
|
||||
CC="$PTHREAD_CC"
|
||||
else
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
CC="$PTHREAD_CC"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Test GUI
|
||||
AC_ARG_ENABLE([testgui],
|
||||
[AS_HELP_STRING([--enable-testgui],
|
||||
[enable building of test GUI (default n)])],
|
||||
[testgui_enabled=$enableval],
|
||||
[testgui_enabled='no'])
|
||||
AM_CONDITIONAL([BUILD_TESTGUI], [test "x$testgui_enabled" != "xno"])
|
||||
|
||||
# Configure the MacOS TestGUI app bundle
|
||||
rm -Rf testgui/TestGUI.app
|
||||
mkdir -p testgui/TestGUI.app
|
||||
cp -R ${srcdir}/testgui/TestGUI.app.in/* testgui/TestGUI.app
|
||||
chmod -R u+w testgui/TestGUI.app
|
||||
mkdir testgui/TestGUI.app/Contents/MacOS/
|
||||
|
||||
if test "x$testgui_enabled" != "xno"; then
|
||||
if test "x$os" = xdarwin; then
|
||||
# On Mac OS, don't use pkg-config.
|
||||
AC_CHECK_PROG([foxconfig], [fox-config], [fox-config], false)
|
||||
if test "x$foxconfig" = "xfalse"; then
|
||||
hidapi_prog_error fox-config "FOX Toolkit"
|
||||
fi
|
||||
LIBS_TESTGUI+=`$foxconfig --libs`
|
||||
LIBS_TESTGUI+=" -framework Cocoa -L/usr/X11R6/lib"
|
||||
CFLAGS_TESTGUI+=`$foxconfig --cflags`
|
||||
OBJCFLAGS+=" -x objective-c++"
|
||||
elif test "x$os" = xwindows; then
|
||||
# On Windows, just set the paths for Fox toolkit
|
||||
if test "x$win_implementation" = xmingw; then
|
||||
CFLAGS_TESTGUI="-I\$(srcdir)/../../hidapi-externals/fox/include -g -c"
|
||||
LIBS_TESTGUI=" -mwindows \$(srcdir)/../../hidapi-externals/fox/lib/libFOX-1.6.a -lgdi32 -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -lkernel32"
|
||||
else
|
||||
# Cygwin
|
||||
CFLAGS_TESTGUI="-DWIN32 -I\$(srcdir)/../../hidapi-externals/fox/include -g -c"
|
||||
LIBS_TESTGUI="\$(srcdir)/../../hidapi-externals/fox/lib/libFOX-cygwin-1.6.a -lgdi32 -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -lkernel32"
|
||||
fi
|
||||
else
|
||||
# On Linux and FreeBSD platforms, use pkg-config to find fox.
|
||||
PKG_CHECK_MODULES([fox], [fox])
|
||||
LIBS_TESTGUI="${LIBS_TESTGUI} $fox_LIBS"
|
||||
if test "x$os" = xfreebsd; then
|
||||
LIBS_TESTGUI="${LIBS_TESTGUI} -L/usr/local/lib"
|
||||
fi
|
||||
CFLAGS_TESTGUI="${CFLAGS_TESTGUI} $fox_CFLAGS"
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([LIBS_TESTGUI])
|
||||
AC_SUBST([CFLAGS_TESTGUI])
|
||||
AC_SUBST([backend])
|
||||
|
||||
# OS info for Automake
|
||||
AM_CONDITIONAL(OS_LINUX, test "x$os" = xlinux)
|
||||
AM_CONDITIONAL(OS_DARWIN, test "x$os" = xdarwin)
|
||||
AM_CONDITIONAL(OS_FREEBSD, test "x$os" = xfreebsd)
|
||||
AM_CONDITIONAL(OS_WINDOWS, test "x$os" = xwindows)
|
||||
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
if test "x$os" = "xlinux"; then
|
||||
AC_CONFIG_FILES([pc/hidapi-hidraw.pc])
|
||||
AC_CONFIG_FILES([pc/hidapi-libusb.pc])
|
||||
else
|
||||
AC_CONFIG_FILES([pc/hidapi.pc])
|
||||
fi
|
||||
|
||||
AC_SUBST(LTLDFLAGS)
|
||||
|
||||
AC_CONFIG_FILES([Makefile \
|
||||
hidtest/Makefile \
|
||||
libusb/Makefile \
|
||||
linux/Makefile \
|
||||
mac/Makefile \
|
||||
testgui/Makefile \
|
||||
windows/Makefile])
|
||||
AC_OUTPUT
|
5
hidtest/.gitignore
vendored
5
hidtest/.gitignore
vendored
@ -10,3 +10,8 @@ Release
|
||||
*.dll
|
||||
*.pdb
|
||||
*.o
|
||||
.deps/
|
||||
.libs/
|
||||
hidtest-hidraw
|
||||
hidtest-libusb
|
||||
hidtest
|
||||
|
20
hidtest/Makefile.am
Normal file
20
hidtest/Makefile.am
Normal file
@ -0,0 +1,20 @@
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/hidapi/
|
||||
|
||||
## Linux
|
||||
if OS_LINUX
|
||||
noinst_PROGRAMS = hidtest-libusb hidtest-hidraw
|
||||
|
||||
hidtest_hidraw_SOURCES = hidtest.cpp
|
||||
hidtest_hidraw_LDADD = $(top_builddir)/linux/libhidapi-hidraw.la
|
||||
|
||||
hidtest_libusb_SOURCES = hidtest.cpp
|
||||
hidtest_libusb_LDADD = $(top_builddir)/libusb/libhidapi-libusb.la
|
||||
else
|
||||
|
||||
# Other OS's
|
||||
noinst_PROGRAMS = hidtest
|
||||
|
||||
hidtest_SOURCES = hidtest.cpp
|
||||
hidtest_LDADD = $(top_builddir)/$(backend)/libhidapi.la
|
||||
|
||||
endif
|
6
libusb/.gitignore
vendored
6
libusb/.gitignore
vendored
@ -1,4 +1,8 @@
|
||||
*.o
|
||||
*.so
|
||||
hidtest
|
||||
*.la
|
||||
*.lo
|
||||
*.a
|
||||
.libs
|
||||
.deps
|
||||
hidtest-libusb
|
||||
|
20
libusb/Makefile.am
Normal file
20
libusb/Makefile.am
Normal file
@ -0,0 +1,20 @@
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/hidapi $(CFLAGS_LIBUSB)
|
||||
|
||||
if OS_LINUX
|
||||
lib_LTLIBRARIES = libhidapi-libusb.la
|
||||
libhidapi_libusb_la_SOURCES = hid.c
|
||||
libhidapi_libusb_la_LDFLAGS = $(LTLDFLAGS)
|
||||
libhidapi_libusb_la_LIBADD = $(LIBS_LIBUSB)
|
||||
endif
|
||||
|
||||
if OS_FREEBSD
|
||||
lib_LTLIBRARIES = libhidapi.la
|
||||
libhidapi_la_SOURCES = hid.c
|
||||
libhidapi_la_LDFLAGS = $(LTLDFLAGS)
|
||||
libhidapi_la_LIBADD = $(LIBS_LIBUSB)
|
||||
endif
|
||||
|
||||
hdrdir = $(includedir)/hidapi
|
||||
hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
|
||||
|
||||
EXTRA_DIST = Makefile-manual
|
5
linux/.gitignore
vendored
5
linux/.gitignore
vendored
@ -12,4 +12,7 @@ Release
|
||||
*.o
|
||||
*.so
|
||||
hidtest-hidraw
|
||||
hidtest-libusb
|
||||
.deps
|
||||
.libs
|
||||
*.lo
|
||||
*.la
|
||||
|
10
linux/Makefile.am
Normal file
10
linux/Makefile.am
Normal file
@ -0,0 +1,10 @@
|
||||
lib_LTLIBRARIES = libhidapi-hidraw.la
|
||||
libhidapi_hidraw_la_SOURCES = hid.c
|
||||
libhidapi_hidraw_la_LDFLAGS = $(LTLDFLAGS)
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/hidapi/ $(CFLAGS_HIDRAW)
|
||||
libhidapi_hidraw_la_LIBADD = $(LIBS_HIDRAW)
|
||||
|
||||
hdrdir = $(includedir)/hidapi
|
||||
hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
|
||||
|
||||
EXTRA_DIST = Makefile-manual
|
6
mac/.gitignore
vendored
6
mac/.gitignore
vendored
@ -10,4 +10,8 @@ Release
|
||||
*.dll
|
||||
*.pdb
|
||||
*.o
|
||||
hidtest
|
||||
hidapi-hidtest
|
||||
.deps
|
||||
.libs
|
||||
*.la
|
||||
*.lo
|
||||
|
9
mac/Makefile.am
Normal file
9
mac/Makefile.am
Normal file
@ -0,0 +1,9 @@
|
||||
lib_LTLIBRARIES = libhidapi.la
|
||||
libhidapi_la_SOURCES = hid.c
|
||||
libhidapi_la_LDFLAGS = $(LTLDFLAGS)
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/hidapi/
|
||||
|
||||
hdrdir = $(includedir)/hidapi
|
||||
hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
|
||||
|
||||
EXTRA_DIST = Makefile-manual
|
1
pc/.gitignore
vendored
Normal file
1
pc/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.pc
|
9
testgui/.gitignore
vendored
9
testgui/.gitignore
vendored
@ -10,4 +10,11 @@ Release
|
||||
*.dll
|
||||
*.pdb
|
||||
*.o
|
||||
testgui
|
||||
hidapi-testgui
|
||||
hidapi-hidraw-testgui
|
||||
hidapi-libusb-testgui
|
||||
.deps
|
||||
.libs
|
||||
*.la
|
||||
*.lo
|
||||
TestGUI.app
|
||||
|
43
testgui/Makefile.am
Normal file
43
testgui/Makefile.am
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/hidapi/ $(CFLAGS_TESTGUI)
|
||||
|
||||
if OS_LINUX
|
||||
## Linux
|
||||
bin_PROGRAMS = hidapi-hidraw-testgui hidapi-libusb-testgui
|
||||
|
||||
hidapi_hidraw_testgui_SOURCES = test.cpp
|
||||
hidapi_hidraw_testgui_LDADD = $(top_builddir)/linux/libhidapi-hidraw.la $(LIBS_TESTGUI)
|
||||
|
||||
hidapi_libusb_testgui_SOURCES = test.cpp
|
||||
hidapi_libusb_testgui_LDADD = $(top_builddir)/libusb/libhidapi-libusb.la $(LIBS_TESTGUI)
|
||||
else
|
||||
## Other OS's
|
||||
bin_PROGRAMS = hidapi-testgui
|
||||
|
||||
hidapi_testgui_SOURCES = test.cpp
|
||||
hidapi_testgui_LDADD = $(top_builddir)/$(backend)/libhidapi.la $(LIBS_TESTGUI)
|
||||
endif
|
||||
|
||||
if OS_DARWIN
|
||||
hidapi_testgui_SOURCES = test.cpp mac_support_cocoa.m
|
||||
# Rules for copying the binary and its dependencies into the app bundle.
|
||||
TestGUI.app/Contents/MacOS/hidapi-testgui$(EXEEXT): hidapi-testgui$(EXEEXT)
|
||||
$(srcdir)/copy_to_bundle.sh
|
||||
|
||||
all: all-am TestGUI.app/Contents/MacOS/hidapi-testgui$(EXEEXT)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
copy_to_bundle.sh \
|
||||
Makefile-manual \
|
||||
Makefile.freebsd \
|
||||
Makefile.linux \
|
||||
Makefile.mac \
|
||||
Makefile.mingw \
|
||||
TestGUI.app.in \
|
||||
testgui.sln \
|
||||
testgui.vcproj
|
||||
|
||||
distclean-local:
|
||||
rm -rf TestGUI.app
|
@ -6,7 +6,7 @@
|
||||
# 2010-07-03
|
||||
###########################################
|
||||
|
||||
all: testgui
|
||||
all: hidapi-testgui
|
||||
|
||||
CC=gcc
|
||||
CXX=g++
|
||||
@ -15,14 +15,15 @@ CPPOBJS=test.o
|
||||
OBJCOBJS=mac_support_cocoa.o
|
||||
OBJS=$(COBJS) $(CPPOBJS) $(OBJCOBJS)
|
||||
CFLAGS=-I../hidapi -Wall -g -c `fox-config --cflags`
|
||||
LDFLAGS=-L/usr/X11R6/lib
|
||||
LIBS=`fox-config --libs` -framework IOKit -framework CoreFoundation -framework Cocoa
|
||||
|
||||
|
||||
testgui: $(OBJS)
|
||||
g++ -Wall -g $^ $(LIBS) -o testgui
|
||||
hidapi-testgui: $(OBJS) TestGUI.app
|
||||
g++ -Wall -g $(OBJS) $(LIBS) $(LDFLAGS) -o hidapi-testgui
|
||||
./copy_to_bundle.sh
|
||||
#cp TestGUI.app/Contents/MacOS/testgui TestGUI.app/Contents/MacOS/tg
|
||||
#cp start.sh TestGUI.app/Contents/MacOS/testgui
|
||||
#cp TestGUI.app/Contents/MacOS/hidapi-testgui TestGUI.app/Contents/MacOS/tg
|
||||
#cp start.sh TestGUI.app/Contents/MacOS/hidapi-testgui
|
||||
|
||||
$(COBJS): %.o: %.c
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
@ -33,8 +34,13 @@ $(CPPOBJS): %.o: %.cpp
|
||||
$(OBJCOBJS): %.o: %.m
|
||||
$(CXX) $(CFLAGS) -x objective-c++ $< -o $@
|
||||
|
||||
TestGUI.app: TestGUI.app.in
|
||||
rm -Rf TestGUI.app
|
||||
mkdir -p TestGUI.app
|
||||
cp -R TestGUI.app.in/ TestGUI.app
|
||||
|
||||
clean:
|
||||
rm $(OBJS) testgui
|
||||
rm -f $(OBJS) hidapi-testgui
|
||||
rm -Rf TestGUI.app
|
||||
|
||||
.PHONY: clean
|
||||
|
@ -6,19 +6,19 @@
|
||||
# 2010-06-01
|
||||
###########################################
|
||||
|
||||
all: testgui
|
||||
all: hidapi-testgui
|
||||
|
||||
CC=gcc
|
||||
CXX=g++
|
||||
COBJS=
|
||||
CPPOBJS=../windows/hid.o test.o
|
||||
COBJS=../windows/hid.o
|
||||
CPPOBJS=test.o
|
||||
OBJS=$(COBJS) $(CPPOBJS)
|
||||
CFLAGS=-I../hidapi -I../../hidapi-externals/fox/include -g -c
|
||||
LIBS= -lsetupapi -L../../hidapi-externals/fox/lib -lFOX-1.6 -lgdi32 -Wl,--enable-auto-import -lkernel32
|
||||
LIBS= -mwindows -lsetupapi -L../../hidapi-externals/fox/lib -Wl,-Bstatic -lFOX-1.6 -Wl,-Bdynamic -lgdi32 -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -lkernel32
|
||||
|
||||
|
||||
testgui: $(OBJS)
|
||||
g++ -g $^ $(LIBS) -o testgui
|
||||
hidapi-testgui: $(OBJS)
|
||||
g++ -g $^ $(LIBS) -o hidapi-testgui
|
||||
|
||||
$(COBJS): %.o: %.c
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
@ -27,6 +27,6 @@ $(CPPOBJS): %.o: %.cpp
|
||||
$(CXX) $(CFLAGS) $< -o $@
|
||||
|
||||
clean:
|
||||
rm *.o testgui.exe
|
||||
rm -f *.o hidapi-testgui.exe
|
||||
|
||||
.PHONY: clean
|
||||
|
@ -7,7 +7,7 @@
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string></string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>TestGUI</string>
|
||||
<string>hidapi-testgui</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>Signal11.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
@ -3,9 +3,10 @@
|
||||
#### Configuration:
|
||||
# The name of the executable. It is assumed
|
||||
# that it is in the current working directory.
|
||||
EXE_NAME=testgui
|
||||
EXE_NAME=hidapi-testgui
|
||||
# Path to the executable directory inside the bundle.
|
||||
EXEPATH=./TestGUI.app/Contents/MacOS
|
||||
# This must be an absolute path, so use $PWD.
|
||||
EXEPATH=$PWD/TestGUI.app/Contents/MacOS
|
||||
# Libraries to explicitly bundle, even though they
|
||||
# may not be in /opt/local. One per line. These
|
||||
# are used with grep, so only a portion of the name
|
||||
@ -52,6 +53,7 @@ function copydeps {
|
||||
z=0
|
||||
else
|
||||
cp $i $EXEPATH
|
||||
chmod 755 $EXEPATH/$BASE
|
||||
fi
|
||||
|
||||
|
||||
@ -74,7 +76,22 @@ function copydeps {
|
||||
done
|
||||
}
|
||||
|
||||
rm $EXEPATH/*
|
||||
cp $EXE_NAME $EXEPATH
|
||||
copydeps $EXEPATH/$EXE_NAME
|
||||
rm -f $EXEPATH/*
|
||||
|
||||
# Copy the binary into the bundle. Use ../libtool to do this if it's
|
||||
# available beacuse if $EXE_NAME was built with autotools, it will be
|
||||
# necessary. If ../libtool not available, just use cp to do the copy, but
|
||||
# only if $EXE_NAME is a binary.
|
||||
if [ -x ../libtool ]; then
|
||||
../libtool --mode=install cp $EXE_NAME $EXEPATH
|
||||
else
|
||||
file -bI $EXE_NAME |grep binary
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "There is no ../libtool and $EXE_NAME is not a binary."
|
||||
echo "I'm not sure what to do."
|
||||
exit 1
|
||||
else
|
||||
cp $EXE_NAME $EXEPATH
|
||||
fi
|
||||
fi
|
||||
copydeps $EXEPATH/$EXE_NAME
|
||||
|
4
windows/.gitignore
vendored
4
windows/.gitignore
vendored
@ -9,3 +9,7 @@ Release
|
||||
*.suo
|
||||
*.dll
|
||||
*.pdb
|
||||
.deps
|
||||
.libs
|
||||
*.lo
|
||||
*.la
|
||||
|
16
windows/Makefile.am
Normal file
16
windows/Makefile.am
Normal file
@ -0,0 +1,16 @@
|
||||
lib_LTLIBRARIES = libhidapi.la
|
||||
libhidapi_la_SOURCES = hid.c
|
||||
libhidapi_la_LDFLAGS = $(LTLDFLAGS)
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/hidapi/
|
||||
libhidapi_la_LIBADD = $(LIBS)
|
||||
|
||||
hdrdir = $(includedir)/hidapi
|
||||
hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
ddk_build \
|
||||
hidapi.vcproj \
|
||||
hidtest.vcproj \
|
||||
Makefile-manual \
|
||||
Makefile.mingw \
|
||||
hidapi.sln
|
@ -6,7 +6,7 @@
|
||||
# 2010-06-01
|
||||
###########################################
|
||||
|
||||
all: hidtest
|
||||
all: hidtest libhidapi.dll
|
||||
|
||||
CC=gcc
|
||||
CXX=g++
|
||||
@ -15,11 +15,14 @@ CPPOBJS=../hidtest/hidtest.o
|
||||
OBJS=$(COBJS) $(CPPOBJS)
|
||||
CFLAGS=-I../hidapi -g -c
|
||||
LIBS= -lsetupapi
|
||||
|
||||
DLL_LDFLAGS = -mwindows -lsetupapi
|
||||
|
||||
hidtest: $(OBJS)
|
||||
g++ -g $^ $(LIBS) -o hidtest
|
||||
|
||||
libhidapi.dll: $(OBJS)
|
||||
$(CC) -g $^ $(DLL_LDFLAGS) -o libhidapi.dll
|
||||
|
||||
$(COBJS): %.o: %.c
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user