From 4a5540a925e47923ed20b4ea68aabe550dac976d Mon Sep 17 00:00:00 2001 From: Chris Dickens Date: Wed, 25 Mar 2020 00:09:26 -0700 Subject: [PATCH] autotools: Fix a number of issues Change the name of the project to be what it actually is called everywhere: libusb-1.0. This allows the public libusb.h header file to be tracked by automake through pkginclude_HEADERS. Decouple the doc directory from automake. There aren't any targets that automake understands, so the build uselessly recurses into the directory. Update the makefile targets with the correct dependencies so that the docs aren't regenerated unnecessarily. Update the doxygen config file to include the version, exclude irrelevant source files and create the output into 'api-1.0' instead of 'html'. Also fix a deprecation tag for the libusb_get_port_path() function and add Solaris to the list of supported platforms. Fix the 'dist' target. Clean up the README file to remote the GitHub Markdown and remove the .gitattributes file from the msvc directory. Add doc/libusb.png to EXTRA_DIST. Enhance the {dist,doc}-upload targets to look at the SF_USER environment variable to get the SourceForge username. This allows maintainers (like me!) to have a local username that is different from their SourceForge username. Switch the docs-upload recipe to use rsync with --delete to clean up obsolete files. Fix the Windows shared library (DLL) targets. The dependencies for the RC file were incorrect, leading to cases of missed recompilation. The 'all' rule should not be overridden, so define an 'all-local' rule when necessary. Fix the rule for running dlltool on the just generated DLL so that it only fires when the correct dependencies change and do not bother to run the rule when not building a DLL. Signed-off-by: Chris Dickens --- .gitignore | 3 ++- Makefile.am | 44 +++++++++++++++++++++++++++---------- README.git | 6 +++--- README.md | 4 ++-- configure.ac | 7 ++++-- doc/Makefile.am | 9 -------- doc/Makefile.in | 22 +++++++++++++++++++ doc/doxygen.cfg.in | 60 +++++++++------------------------------------------ libusb/Makefile.am | 18 +++++++--------- libusb/core.c | 5 +++-- libusb/libusb.h | 6 +++--- libusb/libusbi.h | 3 +-- libusb/version_nano.h | 2 +- 13 files changed, 93 insertions(+), 96 deletions(-) delete mode 100644 doc/Makefile.am create mode 100644 doc/Makefile.in diff --git a/.gitignore b/.gitignore index d31074d..9a70cc7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .libs Makefile Makefile.in +!doc/Makefile.in *.la *.lo *.o @@ -39,7 +40,7 @@ examples/testlibusb tests/stress *.exe *.pc -doc/html +doc/api-1.0 *.plg *.ncb *.opt diff --git a/Makefile.am b/Makefile.am index 0155625..047be99 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,10 +1,8 @@ AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip ACLOCAL_AMFLAGS = -I m4 -DISTCLEANFILES = libusb-1.0.pc -EXTRA_DIST = TODO PORTING msvc libusb/libusb-1.0.def libusb/version_nano.h \ - examples/getopt/getopt.c examples/getopt/getopt1.c examples/getopt/getopt.h \ - android Xcode -SUBDIRS = libusb doc +EXTRA_DIST = INSTALL_WIN.txt PORTING doc/libusb.png \ + android msvc Xcode +SUBDIRS = libusb if BUILD_EXAMPLES SUBDIRS += examples @@ -14,15 +12,39 @@ if BUILD_TESTS SUBDIRS += tests endif -pkgconfigdir=$(libdir)/pkgconfig -pkgconfig_DATA=libusb-1.0.pc +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libusb-1.0.pc -.PHONY: dist-up +# The package name is libusb-1.0, but we want the distribution +# to be created as libusb-x.y.z instead of libusb-1.0-x.y.z +distdir = libusb-$(VERSION) -reldir = .release/$(distdir) -dist-up: dist +# Ensure any generated docs are cleaned out +# We need this here because make does not recurse into doc/ +clean-local: + rm -rf doc/$(DOXYGEN_HTMLDIR) + +# Use dist-hook to accomplish the following things for the dist recipe: +# 1) Remove the GitHub Markdown from the README file +# 2) Remove the .gitattributes file from the msvc directory +dist-hook: + chmod u+w $(distdir)/README $(distdir)/msvc + $(SED) -i.orig -e '/Build Status/d' $(distdir)/README + $(SED) -i.orig -e '/^$$/N;/^\n$$/D' $(distdir)/README + $(SED) -i.orig -e 's/\[\([A-Z]*\)\](\1)/\1/' $(distdir)/README + rm -f $(distdir)/README.orig + rm -f $(distdir)/msvc/.gitattributes + +.PHONY: dist-upload +dist-upload: reldir = .release/$(distdir) +dist-upload: sfurl = frs.sourceforge.net:/home/frs/project/libusb/libusb-1.0 +dist-upload: dist rm -rf $(reldir) mkdir -p $(reldir) cp $(distdir).tar.bz2 $(reldir) - rsync -rv $(reldir) frs.sourceforge.net:/home/frs/project/l/li/libusb/libusb-1.0/ + if [ -z "$$SF_USER" ]; then \ + rsync -rv $(reldir) $(sfurl); \ + else \ + rsync -rv $(reldir) $$SF_USER@$(sfurl); \ + fi rm -rf $(reldir) diff --git a/README.git b/README.git index eab938c..d67d374 100644 --- a/README.git +++ b/README.git @@ -33,9 +33,9 @@ public account on github, if you don't have one already, and then fork a new libusb repository under this account from https://github.com/libusb/libusb. Then you can create a git branch for your work, that we will be able to better -reference and test. +reference and test. We also suggest that, if you are planning to bring in a large development, you try to involve the libusb community early by letting the mailing list know, as -you may find that other people might be eager to help you out. -See http://mailing-list.libusb.info for details on how to join the mailing list. \ No newline at end of file +you may find that other people might be eager to help you out. +See http://mailing-list.libusb.info for details on how to join the mailing list. diff --git a/README.md b/README.md index 0e7228a..a47b4bd 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # libusb [![Build Status](https://travis-ci.org/libusb/libusb.svg?branch=master)](https://travis-ci.org/libusb/libusb) -[![Build status](https://ci.appveyor.com/api/projects/status/xvrfam94jii4a6lw?svg=true)](https://ci.appveyor.com/project/LudovicRousseau/libusb) +[![Build Status](https://ci.appveyor.com/api/projects/status/xvrfam94jii4a6lw?svg=true)](https://ci.appveyor.com/project/LudovicRousseau/libusb) [![Coverity Scan Build Status](https://scan.coverity.com/projects/2180/badge.svg)](https://scan.coverity.com/projects/libusb-libusb) libusb is a library for USB device access from Linux, macOS, -Windows, OpenBSD/NetBSD and Haiku userspace. +Windows, OpenBSD/NetBSD, Haiku and Solaris userspace. It is written in C (Haiku backend in C++) and licensed under the GNU Lesser General Public License version 2.1 or, at your option, any later version (see [COPYING](COPYING)). diff --git a/configure.ac b/configure.ac index a9eddba..e8c0023 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ LU_DEFINE_VERSION_ATOM([LIBUSB_MINOR]) LU_DEFINE_VERSION_ATOM([LIBUSB_MICRO]) LU_DEFINE_VERSION_RC_ATOM([LIBUSB_RC]) -AC_INIT([libusb],[LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC],[libusb-devel@lists.sourceforge.net],[libusb],[http://libusb.info]) +AC_INIT([libusb-1.0], [LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC], [libusb-devel@lists.sourceforge.net], [libusb-1.0], [http://libusb.info]) dnl Library versioning dnl These numbers should be tweaked on every release. Read carefully: @@ -103,7 +103,7 @@ case $host in backend=windows poll=windows threads=windows - create_import_lib=yes + test "x$enable_shared" = xyes && create_import_lib=yes AM_CFLAGS="${AM_CFLAGS} -fno-omit-frame-pointer" ;; *) @@ -363,6 +363,9 @@ AM_CFLAGS="${AM_CFLAGS} -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-impli AC_SUBST(AM_CFLAGS) AC_SUBST(LTLDFLAGS) +dnl set name of html output directory for doxygen +AC_SUBST(DOXYGEN_HTMLDIR, [api-1.0]) + AC_CONFIG_FILES([libusb-1.0.pc]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([libusb/Makefile]) diff --git a/doc/Makefile.am b/doc/Makefile.am deleted file mode 100644 index 45f43c6..0000000 --- a/doc/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -EXTRA_DIST = doxygen.cfg.in - -docs: doxygen.cfg - doxygen $^ - -docs-upload: docs - ln -s html api-1.0 - scp -r api-1.0 web.sourceforge.net:/home/project-web/libusb/htdocs - rm -f api-1.0 diff --git a/doc/Makefile.in b/doc/Makefile.in new file mode 100644 index 0000000..3d835c5 --- /dev/null +++ b/doc/Makefile.in @@ -0,0 +1,22 @@ +LIBUSB_SRC_DIR = @top_srcdir@/libusb +EXCLUDED_FILES = hotplug.h libusbi.h version.h version_nano.h +LIBUSB_SRC = $(wildcard $(LIBUSB_SRC_DIR)/*.c) $(wildcard $(LIBUSB_SRC_DIR)/*.h) +LIBUSB_DOC_SRC = $(filter-out $(addprefix $(LIBUSB_SRC_DIR)/,$(EXCLUDED_FILES)),$(LIBUSB_SRC)) + +docs: @DOXYGEN_HTMLDIR@ + +@DOXYGEN_HTMLDIR@: doxygen.cfg libusb.png $(LIBUSB_DOC_SRC) + doxygen $< + +docs-upload: sfurl = web.sourceforge.net:/home/project-web/libusb/htdocs +docs-upload: @DOXYGEN_HTMLDIR@ + if [ -z "$$SF_USER" ]; then \ + rsync -rv --delete $< $(sfurl); \ + else \ + rsync -rv --delete $< $$SF_USER@$(sfurl); \ + fi + +clean: + rm -rf @DOXYGEN_HTMLDIR@ + +.PHONY: clean docs docs-upload diff --git a/doc/doxygen.cfg.in b/doc/doxygen.cfg.in index 957e0f8..504d41c 100644 --- a/doc/doxygen.cfg.in +++ b/doc/doxygen.cfg.in @@ -38,7 +38,7 @@ PROJECT_NAME = libusb # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = @PACKAGE_VERSION@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -845,50 +845,7 @@ INPUT_ENCODING = UTF-8 # *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice. FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.idl \ - *.ddl \ - *.odl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.cs \ - *.d \ - *.php \ - *.php4 \ - *.php5 \ - *.phtml \ - *.inc \ - *.m \ - *.markdown \ - *.md \ - *.mm \ - *.dox \ - *.py \ - *.pyw \ - *.f90 \ - *.f95 \ - *.f03 \ - *.f08 \ - *.f \ - *.for \ - *.tcl \ - *.vhd \ - *.vhdl \ - *.ucf \ - *.qsf \ - *.ice + *.h # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -903,8 +860,11 @@ RECURSIVE = NO # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = @top_srcdir@/libusb/libusbi.h \ - @top_srcdir@/libusb/hotplug.h +EXCLUDE = @top_srcdir@/libusb/hotplug.h \ + @top_srcdir@/libusb/libusbi.h \ + @top_srcdir@/libusb/version.h \ + @top_srcdir@/libusb/version_nano.h \ + @top_srcdir@/libusb/os # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -1142,7 +1102,7 @@ GENERATE_HTML = YES # The default directory is: html. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_OUTPUT = html +HTML_OUTPUT = @DOXYGEN_HTMLDIR@ # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each # generated HTML page (for example: .htm, .php, .asp). @@ -2152,8 +2112,8 @@ INCLUDE_FILE_PATTERNS = # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. PREDEFINED = API_EXPORTED= \ - LIBUSB_CALL= \ - DEFAULT_VISIBILITY= + DEFAULT_VISIBILITY= \ + LIBUSB_CALL= # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/libusb/Makefile.am b/libusb/Makefile.am index 5adba7c..b8936a5 100644 --- a/libusb/Makefile.am +++ b/libusb/Makefile.am @@ -1,5 +1,3 @@ -all: libusb-1.0.la libusb-1.0.dll - AUTOMAKE_OPTIONS = subdir-objects lib_LTLIBRARIES = libusb-1.0.la @@ -87,22 +85,22 @@ if OS_WINDOWS OS_SRC = $(OS_WINDOWS_SRC) .rc.lo: - $(AM_V_GEN)$(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --tag=RC --mode=compile $(RC) $(RCFLAGS) -i $< -o $@ + $(AM_V_GEN)$(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) -i $< -o $@ -libusb-1.0.rc: version.h version_nano.h -endif +libusb-1.0.lo: libusb-1.0.rc version.h version_nano.h -libusb-1.0.dll: libusb-1.0.def libusb-1.0.la if CREATE_IMPORT_LIB +all-local: .libs/libusb-1.0.dll.a # Rebuild the import lib from the .def so that MS and MinGW DLLs can be interchanged - $(AM_V_GEN)$(DLLTOOL) $(DLLTOOLFLAGS) --kill-at --input-def $(srcdir)/libusb-1.0.def --dllname $@ --output-lib .libs/$@.a +.libs/libusb-1.0.dll.a: libusb-1.0.def libusb-1.0.la + $(AM_V_GEN)$(DLLTOOL) $(DLLTOOLFLAGS) --kill-at --input-def $(srcdir)/$< --dllname libusb-1.0.dll --output-lib $@ +endif endif libusb_1_0_la_CFLAGS = $(AM_CFLAGS) libusb_1_0_la_LDFLAGS = $(LTLDFLAGS) -libusb_1_0_la_SOURCES = libusbi.h libusb.h version.h version_nano.h \ +libusb_1_0_la_SOURCES = libusbi.h version.h version_nano.h \ core.c descriptor.c hotplug.h hotplug.c io.c strerror.c sync.c \ $(POLL_SRC) $(THREADS_SRC) $(OS_SRC) -hdrdir = $(includedir)/libusb-1.0 -hdr_HEADERS = libusb.h +pkginclude_HEADERS = libusb.h diff --git a/libusb/core.c b/libusb/core.c index e7f8d5e..5b87132 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -22,6 +22,7 @@ #include "libusbi.h" #include "hotplug.h" +#include "version.h" #ifdef __ANDROID__ #include @@ -943,7 +944,7 @@ int API_EXPORTED libusb_get_port_numbers(libusb_device *dev, } /** \ingroup libusb_dev - * Deprecated please use libusb_get_port_numbers instead. + * \deprecated Please use \ref libusb_get_port_numbers() instead. */ int API_EXPORTED libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t* port_numbers, uint8_t port_numbers_len) @@ -961,7 +962,7 @@ int API_EXPORTED libusb_get_port_path(libusb_context *ctx, libusb_device *dev, * function and make sure that you only access the parent before issuing * \ref libusb_free_device_list(). The reason is that libusb currently does * not maintain a permanent list of device instances, and therefore can - * only guarantee that parents are fully instantiated within a + * only guarantee that parents are fully instantiated within a * libusb_get_device_list() - libusb_free_device_list() block. */ DEFAULT_VISIBILITY diff --git a/libusb/libusb.h b/libusb/libusb.h index 2c4d589..4cd9149 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -898,7 +898,7 @@ struct libusb_version { const char *rc; /** For ABI compatibility only. */ - const char* describe; + const char *describe; }; /** \ingroup libusb_lib @@ -1359,9 +1359,9 @@ void LIBUSB_CALL libusb_free_container_id_descriptor( struct libusb_container_id_descriptor *container_id); uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev); uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev); -int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len); +int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t *port_numbers, int port_numbers_len); LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers) -int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t* path, uint8_t path_length); +int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *path, uint8_t path_length); libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev); uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev); int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev); diff --git a/libusb/libusbi.h b/libusb/libusbi.h index a9f904e..da8ec53 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -35,7 +35,6 @@ #endif #include "libusb.h" -#include "version.h" #define container_of(ptr, type, member) \ ((type *)((uintptr_t)(ptr) - (uintptr_t)offsetof(type, member))) @@ -209,7 +208,7 @@ static inline void *usbi_reallocf(void *ptr, size_t size) #define TIMESPEC_IS_SET(ts) ((ts)->tv_sec || (ts)->tv_nsec) #define TIMESPEC_CLEAR(ts) (ts)->tv_sec = (ts)->tv_nsec = 0 -#define TIMESPEC_CMP(a, b, CMP) \ +#define TIMESPEC_CMP(a, b, CMP) \ (((a)->tv_sec == (b)->tv_sec) \ ? ((a)->tv_nsec CMP (b)->tv_nsec) \ : ((a)->tv_sec CMP (b)->tv_sec)) diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 3c9623c..fb6345c 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11469 +#define LIBUSB_NANO 11470 -- 2.7.4