Skip to content

Commit a36753a

Browse files
committed
fix: use offical libusb
1 parent e4d3f2d commit a36753a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+25306
-5090
lines changed

Makefile.am

Lines changed: 79 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,98 @@
1+
AUTOMAKE_OPTIONS = subdir-objects
2+
3+
AM_CFLAGS += -fvisibility=hidden $(THREAD_CFLAGS)
4+
AM_CXXFLAGS += -fvisibility=hidden $(THREAD_CFLAGS)
5+
16
lib_LTLIBRARIES = libusb-1.0.la
27

3-
LINUX_USBFS_SRC = os/linux_usbfs.c
4-
DARWIN_USB_SRC = os/darwin_usb.c
5-
OPENBSD_USB_SRC = os/openbsd_usb.c
6-
WINDOWS_USB_SRC = os/poll_windows.c os/windows_usb.c libusb-1.0.rc \
7-
libusb-1.0.def
8+
POSIX_PLATFORM_SRC = os/events_posix.h os/events_posix.c \
9+
os/threads_posix.h os/threads_posix.c
10+
WINDOWS_PLATFORM_SRC = os/events_windows.h os/events_windows.c \
11+
os/threads_windows.h os/threads_windows.c
12+
13+
if PLATFORM_POSIX
14+
PLATFORM_SRC = $(POSIX_PLATFORM_SRC)
15+
else
16+
PLATFORM_SRC = $(WINDOWS_PLATFORM_SRC)
17+
endif
18+
19+
OS_DARWIN_SRC = os/darwin_usb.h os/darwin_usb.c
20+
OS_HAIKU_SRC = os/haiku_usb.h os/haiku_usb_backend.cpp \
21+
os/haiku_pollfs.cpp os/haiku_usb_raw.h os/haiku_usb_raw.cpp
22+
OS_LINUX_SRC = os/linux_usbfs.h os/linux_usbfs.c
23+
OS_EMSCRIPTEN_SRC = os/emscripten_webusb.cpp
24+
OS_NETBSD_SRC = os/netbsd_usb.c
25+
OS_NULL_SRC = os/null_usb.c
26+
OS_OPENBSD_SRC = os/openbsd_usb.c
27+
OS_SUNOS_SRC = os/sunos_usb.h os/sunos_usb.c
28+
OS_WINDOWS_SRC = libusb-1.0.def libusb-1.0.rc \
29+
os/windows_common.h os/windows_common.c \
30+
os/windows_usbdk.h os/windows_usbdk.c \
31+
os/windows_winusb.h os/windows_winusb.c
832

9-
EXTRA_DIST = $(LINUX_USBFS_SRC) $(DARWIN_USB_SRC) $(OPENBSD_USB_SRC) \
10-
$(WINDOWS_USB_SRC) os/threads_posix.c os/threads_windows.c
33+
if OS_DARWIN
34+
OS_SRC = $(OS_DARWIN_SRC)
35+
endif
36+
37+
noinst_LTLIBRARIES =
38+
39+
if OS_HAIKU
40+
noinst_LTLIBRARIES += libusb_haiku.la
41+
libusb_haiku_la_SOURCES = $(OS_HAIKU_SRC)
42+
libusb_1_0_la_LIBADD = libusb_haiku.la
43+
endif
1144

1245
if OS_LINUX
13-
OS_SRC = $(LINUX_USBFS_SRC)
46+
OS_SRC = $(OS_LINUX_SRC)
47+
if USE_UDEV
48+
OS_SRC += os/linux_udev.c
49+
else
50+
OS_SRC += os/linux_netlink.c
51+
endif
1452
endif
1553

16-
if OS_DARWIN
17-
OS_SRC = $(DARWIN_USB_SRC)
18-
AM_CFLAGS_EXT = -no-cpp-precomp
54+
if OS_EMSCRIPTEN
55+
noinst_LTLIBRARIES += libusb_emscripten.la
56+
libusb_emscripten_la_SOURCES = $(OS_EMSCRIPTEN_SRC)
57+
AM_CXXFLAGS += -std=c++20
58+
libusb_1_0_la_LIBADD = libusb_emscripten.la
59+
endif
60+
61+
if OS_NETBSD
62+
OS_SRC = $(OS_NETBSD_SRC)
63+
endif
64+
65+
if OS_NULL
66+
OS_SRC = $(OS_NULL_SRC)
1967
endif
2068

2169
if OS_OPENBSD
22-
OS_SRC = $(OPENBSD_USB_SRC)
70+
OS_SRC = $(OS_OPENBSD_SRC)
71+
endif
72+
73+
if OS_SUNOS
74+
OS_SRC = $(OS_SUNOS_SRC)
2375
endif
2476

2577
if OS_WINDOWS
26-
OS_SRC = $(WINDOWS_USB_SRC)
78+
OS_SRC = $(OS_WINDOWS_SRC)
2779

28-
.rc.lo:
29-
$(AM_V_GEN)$(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --tag=RC --mode=compile $(RC) $(RCFLAGS) -i $< -o $@
80+
include Makefile.am.extra
3081

31-
libusb-1.0.rc: version.h
32-
endif
82+
# Dependencies for compiling libusb-1.0.lo from libusb-1.0.rc
83+
-include ./$(DEPDIR)/libusb-1.0.Plo
3384

34-
if THREADS_POSIX
35-
THREADS_SRC = os/threads_posix.h os/threads_posix.c
36-
else
37-
THREADS_SRC = os/threads_windows.h os/threads_windows.c
85+
if CREATE_IMPORT_LIB
86+
all-local: .libs/libusb-1.0.dll.a
87+
# Rebuild the import lib from the .def so that MS and MinGW DLLs can be interchanged
88+
.libs/libusb-1.0.dll.a: libusb-1.0.def libusb-1.0.la
89+
$(AM_V_DLLTOOL)$(DLLTOOL) $(DLLTOOLFLAGS) --kill-at --input-def $< --dllname libusb-1.0.dll --output-lib $@
90+
endif
3891
endif
3992

40-
libusb_1_0_la_CFLAGS = $(AM_CFLAGS) \
41-
-DLIBUSB_DESCRIBE=\"`git --git-dir "$(top_srcdir)/.git" describe --tags 2>/dev/null`\"
42-
libusb_1_0_la_LDFLAGS = $(LTLDFLAGS)
43-
libusb_1_0_la_SOURCES = libusbi.h core.c descriptor.c io.c sync.c $(OS_SRC) \
44-
os/linux_usbfs.h os/darwin_usb.h os/windows_usb.h \
45-
$(THREADS_SRC) \
46-
os/poll_posix.h os/poll_windows.h
93+
libusb_1_0_la_LDFLAGS = $(LT_LDFLAGS) $(EXTRA_LDFLAGS)
94+
libusb_1_0_la_SOURCES = libusbi.h version.h version_nano.h \
95+
core.c descriptor.c hotplug.c io.c strerror.c sync.c \
96+
$(PLATFORM_SRC) $(OS_SRC)
4797

48-
hdrdir = $(includedir)/libusb-1.0
49-
hdr_HEADERS = libusb.h
98+
pkginclude_HEADERS = libusb.h

Makefile.am.extra

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
AM_V_DLLTOOL = $(am__v_DLLTOOL_$(V))
2+
am__v_DLLTOOL_ = $(am__v_DLLTOOL_$(AM_DEFAULT_VERBOSITY))
3+
am__v_DLLTOOL_0 = @echo " DLLTOOL " $@;
4+
am__v_DLLTOOL_1 =
5+
6+
AM_V_RC = $(am__v_RC_$(V))
7+
am__v_RC_ = $(am__v_RC_$(AM_DEFAULT_VERBOSITY))
8+
am__v_RC_0 = @echo " RC " $@;
9+
am__v_RC_1 =
10+
11+
LTRC = $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) \
12+
$(LIBTOOLFLAGS) --mode=compile $(RC) $(AM_RCFLAGS) \
13+
$(RCFLAGS)
14+
15+
RCPPARGS = \
16+
--preprocessor-arg -MT \
17+
--preprocessor-arg $@ \
18+
--preprocessor-arg -MD \
19+
--preprocessor-arg -MP \
20+
--preprocessor-arg -MF \
21+
--preprocessor-arg $$depbase.Tpo
22+
23+
.rc.lo:
24+
$(AM_V_RC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
25+
$(LTRC) $(RCPPARGS) -i $< -o $@ &&\
26+
$(am__mv) $$depbase.Tpo $$depbase.Plo

0 commit comments

Comments
 (0)