[Spice-devel] [usbredir] Switch to autotools build system

Hans de Goede hdegoede at redhat.com
Fri Nov 25 09:26:02 PST 2011


Hi,

Thanks,

I've pushed this to my usbredir git tree, with 33 small changes:

     1) LIBUSBREDIRPARSER_SO_VERSION 1:0:0 should be 0:0:0, so that the soname
        does not change by going from Makefiles to autofoo
     2) Drop LIBGPOD_SO_VERSION from configure.ac
     3) Make libusb pkgconfig check require version >= 1.0.9

Regards,

Hans

On 11/23/2011 02:23 PM, Christophe Fergeau wrote:
> Replace the current build system with an autotools based one.
> ---
>   Make.rules                              |   28 ----------------
>   Makefile                                |   18 -----------
>   Makefile.am                             |    1 +
>   autogen.sh                              |    4 ++
>   configure.ac                            |   44 ++++++++++++++++++++++++++
>   usbredirhost/Makefile                   |   52 -------------------------------
>   usbredirhost/Makefile.am                |   15 +++++++++
>   usbredirhost/libusbredirhost.pc.in      |   10 ++++++
>   usbredirhost/usbredirhost.c             |    1 +
>   usbredirparser/Makefile                 |   44 --------------------------
>   usbredirparser/Makefile.am              |   12 +++++++
>   usbredirparser/libusbredirparser.pc.in  |    9 +++++
>   usbredirparser/usbredirparser.c         |    2 +
>   usbredirserver/Makefile                 |   20 ------------
>   usbredirserver/Makefile.am              |    8 +++++
>   usbredirserver/usbredirserver.c         |    7 +++-
>   usbredirtestclient/Makefile             |   13 --------
>   usbredirtestclient/Makefile.am          |    5 +++
>   usbredirtestclient/usbredirtestclient.c |    6 ++-
>   19 files changed, 120 insertions(+), 179 deletions(-)
>   delete mode 100644 Make.rules
>   delete mode 100644 Makefile
>   create mode 100644 Makefile.am
>   create mode 100755 autogen.sh
>   create mode 100644 configure.ac
>   delete mode 100644 usbredirhost/Makefile
>   create mode 100644 usbredirhost/Makefile.am
>   create mode 100644 usbredirhost/libusbredirhost.pc.in
>   delete mode 100644 usbredirparser/Makefile
>   create mode 100644 usbredirparser/Makefile.am
>   create mode 100644 usbredirparser/libusbredirparser.pc.in
>   delete mode 100644 usbredirserver/Makefile
>   create mode 100644 usbredirserver/Makefile.am
>   delete mode 100644 usbredirtestclient/Makefile
>   create mode 100644 usbredirtestclient/Makefile.am
>
> diff --git a/Make.rules b/Make.rules
> deleted file mode 100644
> index 4d4c4ea..0000000
> --- a/Make.rules
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -USBREDIR_VERSION=0.3.1
> -
> -# These ones can be overriden from the cmdline
> -CFLAGS  = -g -O2 -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Werror
> -PREFIX  = /usr/local
> -LIBDIR  = $(PREFIX)/lib
> -SBINDIR = $(PREFIX)/sbin
> -
> -# These ones should not be overriden from the cmdline
> -override CPPFLAGS += -I../usbredirparser -I../usbredirhost -DUSBREDIR_VERSION='"$(USBREDIR_VERSION)"'
> -override LDFLAGS += -L../usbredirparser -L../usbredirhost
> -
> -# And last various rules
> -%.o: %.c
> -	$(CC) -Wp,-MMD,"$*.d",-MQ,"$@",-MP -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
> -
> -%.o: %.cpp
> -	$(CXX) -Wp,-MMD,"$*.d",-MQ,"$@",-MP -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
> -
> -%.so:
> -	$(CC) -shared $(LDFLAGS) -Wl,-soname,$@.$(LIB_RELEASE) -o $@.$(LIB_RELEASE) $^ $(LIBS_$*)
> -	ln -f -s $@.$(LIB_RELEASE) $@
> -
> -%.a:
> -	$(AR) cqs $@ $^
> -
> -clean::
> -	rm -f core core.[0123456789]* *~ *.o *.d *.a *.so* DEADJOE *.orig *.rej $(TARGETS)
> diff --git a/Makefile b/Makefile
> deleted file mode 100644
> index 18600fb..0000000
> --- a/Makefile
> +++ /dev/null
> @@ -1,18 +0,0 @@
> -SUBDIRS = usbredirparser usbredirhost usbredirserver usbredirtestclient
> -
> -all install clean::
> -	for i in $(SUBDIRS); do \
> -		$(MAKE) -C $$i $@ || exit 1; \
> -	done
> -
> -tag:
> -	@git tag -a -m "Tag as usbredir-$(USBREDIR_VERSION)" usbredir-$(USBREDIR_VERSION)
> -	@echo "Tagged as usbredir-$(USBREDIR_VERSION)"
> -
> -archive-no-tag:
> -	@git archive --format=tar --prefix=usbredir-$(USBREDIR_VERSION)/ usbredir-$(USBREDIR_VERSION)>  usbredir-$(USBREDIR_VERSION).tar
> -	@bzip2 -f usbredir-$(USBREDIR_VERSION).tar
> -
> -archive: clean tag archive-no-tag
> -
> -include Make.rules
> diff --git a/Makefile.am b/Makefile.am
> new file mode 100644
> index 0000000..288463c
> --- /dev/null
> +++ b/Makefile.am
> @@ -0,0 +1 @@
> +SUBDIRS = usbredirparser usbredirhost usbredirserver usbredirtestclient
> diff --git a/autogen.sh b/autogen.sh
> new file mode 100755
> index 0000000..52083e5
> --- /dev/null
> +++ b/autogen.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +
> +autoreconf -fi
> +./configure $@
> diff --git a/configure.ac b/configure.ac
> new file mode 100644
> index 0000000..d617d0b
> --- /dev/null
> +++ b/configure.ac
> @@ -0,0 +1,44 @@
> +AC_PREREQ(2.63)
> +AC_INIT([usbredir], [0.3.1])
> +AC_CONFIG_SRCDIR([configure.ac])
> +
> +AM_CONFIG_HEADER([config.h])
> +
> +dnl libtool versioning
> +# +1 : 0 : +1  == adds new functions to the interface
> +# +1 : 0 : 0   == changes or removes functions (changes include both
> +#                 changes to the signature and the semantic)
> +#  ? :+1 : ?   == just internal changes
> +# CURRENT : REVISION : AGE
> +LIBUSBREDIRHOST_SO_VERSION=1:0:0
> +AC_SUBST(LIBUSBREDIRHOST_SO_VERSION)
> +
> +LIBUSBREDIRPARSER_SO_VERSION=1:0:0
> +AC_SUBST(LIBUSBREDIRPARSER_SO_VERSION)
> +
> +LIBGPOD_SO_VERSION=7:2:3
> +AC_SUBST(LIBGPOD_SO_VERSION)
> +
> +AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip])
> +m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
> +
> +AC_PROG_CC
> +AC_HEADER_STDC
> +AC_PROG_INSTALL
> +AC_PROG_LN_S
> +LT_INIT
> +dnl AC_DEFINE(_GNU_SOURCE, [1], [Enable GNU extensions])
> +
> +PKG_PROG_PKG_CONFIG
> +PKG_CHECK_MODULES(LIBUSB, [libusb-1.0])
> +
> +AC_CONFIG_FILES([
> +Makefile
> +usbredirhost/Makefile
> +usbredirhost/libusbredirhost.pc
> +usbredirparser/Makefile
> +usbredirparser/libusbredirparser.pc
> +usbredirserver/Makefile
> +usbredirtestclient/Makefile
> +])
> +AC_OUTPUT
> diff --git a/usbredirhost/Makefile b/usbredirhost/Makefile
> deleted file mode 100644
> index 1b5d62f..0000000
> --- a/usbredirhost/Makefile
> +++ /dev/null
> @@ -1,52 +0,0 @@
> -override CPPFLAGS    += $(shell pkg-config --cflags libusb-1.0)
> -
> -LIBS_libusbredirhost  = $(shell pkg-config --libs libusb-1.0)
> -
> -USBREDIRHOST_OBJS     = usbredirhost.o
> -USBREDIRHOST_DEPS     = $(USBREDIRHOST_OBJS)
> -TARGETS               = $(USBREDIRHOST_LIB) libusbredirhost.pc
> -INCLUDES              = usbredirhost.h
> -
> -ifeq ($(LINKTYPE),static)
> -USBREDIRHOST_LIB      = libusbredirhost.a
> -else
> -USBREDIRHOST_LIB      = libusbredirhost.so
> -USBREDIRHOST_DEPS    += ../usbredirparser/libusbredirparser.so
> -override CPPFLAGS    += -fPIC
> -endif
> -
> -LIB_RELEASE = 1
> -
> -all: $(TARGETS)
> -
> --include $(USBREDIRHOST_OBJS:.o=.d)
> -
> -$(USBREDIRHOST_LIB): $(USBREDIRHOST_DEPS)
> -
> -libusbredirhost.pc:
> -	@echo prefix=$(PREFIX)>  libusbredirhost.pc
> -	@echo libdir=$(LIBDIR)>>  libusbredirhost.pc
> -	@echo>>  libusbredirhost.pc
> -	@echo 'Name: libusbredirhost'>>  libusbredirhost.pc
> -	@echo 'Description: usbredirhost library'>>  libusbredirhost.pc
> -	@echo 'Version: '$(USBREDIR_VERSION)>>  libusbredirhost.pc
> -	@echo 'Requires.private: libusbredirparser'>>  libusbredirhost.pc
> -	@echo 'Libs: -L$${libdir} -lusbredirhost'>>  libusbredirhost.pc
> -	@echo 'Libs.private: -lusb-1.0'>>  libusbredirhost.pc
> -	@echo 'Cflags: -I$${prefix}/include'>>  libusbredirhost.pc
> -
> -install: all
> -	mkdir -p $(DESTDIR)$(PREFIX)/include
> -	install -p -m 644 $(INCLUDES) $(DESTDIR)$(PREFIX)/include
> -	mkdir -p $(DESTDIR)$(LIBDIR)
> -ifeq ($(LINKTYPE),static)
> -	install -m 644 $(USBREDIRHOST_LIB) $(DESTDIR)$(LIBDIR)
> -else
> -	install -m 755 $(USBREDIRHOST_LIB).$(LIB_RELEASE) $(DESTDIR)$(LIBDIR)
> -	cd $(DESTDIR)$(LIBDIR)&&  \
> -	  ln -f -s $(USBREDIRHOST_LIB).$(LIB_RELEASE) $(USBREDIRHOST_LIB)
> -endif
> -	mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig
> -	install -m 644 libusbredirhost.pc $(DESTDIR)$(LIBDIR)/pkgconfig
> -
> -include ../Make.rules
> diff --git a/usbredirhost/Makefile.am b/usbredirhost/Makefile.am
> new file mode 100644
> index 0000000..ecf91fc
> --- /dev/null
> +++ b/usbredirhost/Makefile.am
> @@ -0,0 +1,15 @@
> +lib_LTLIBRARIES = libusbredirhost.la
> +
> +libusbredirhost_la_SOURCES = usbredirhost.c
> +libusbredirhost_ladir = $(includedir)
> +libusbredirhost_la_HEADERS = usbredirhost.h
> +libusbredirhost_la_CFLAGS = $(LIBUSB_CFLAGS) -I$(top_srcdir)/usbredirparser
> +libusbredirhost_la_LIBADD = $(LIBUSB_LIBS) \
> +                            $(top_builddir)/usbredirparser/libusbredirparser.la
> +libusbredirhost_la_LDFLAGS = -version-info $(LIBUSBREDIRHOST_SO_VERSION) \
> +                             -no-undefined
> +
> +pkgconfigdir = $(libdir)/pkgconfig
> +pkgconfig_DATA = libusbredirhost.pc
> +
> +EXTRA_DIST = libusbredirhost.pc
> diff --git a/usbredirhost/libusbredirhost.pc.in b/usbredirhost/libusbredirhost.pc.in
> new file mode 100644
> index 0000000..c69d13b
> --- /dev/null
> +++ b/usbredirhost/libusbredirhost.pc.in
> @@ -0,0 +1,10 @@
> +prefix=@prefix@
> +libdir=@libdir@
> +includedir=@includedir@
> +
> +Name: libusbredirhost
> +Description: usbredirhost library
> +Version: @VERSION@
> +Libs: -L${libdir} -lusbredirhost
> +Requires.private: libusb-1.0 libusbredirparser
> +Cflags: -I${includedir}
> diff --git a/usbredirhost/usbredirhost.c b/usbredirhost/usbredirhost.c
> index f794ded..f55d55c 100644
> --- a/usbredirhost/usbredirhost.c
> +++ b/usbredirhost/usbredirhost.c
> @@ -18,6 +18,7 @@
>      You should have received a copy of the GNU Lesser General Public
>      License along with this library; if not, see<http://www.gnu.org/licenses/>.
>   */
> +#include "config.h"
>
>   #include<stdio.h>
>   #include<stdlib.h>
> diff --git a/usbredirparser/Makefile b/usbredirparser/Makefile
> deleted file mode 100644
> index c33d264..0000000
> --- a/usbredirparser/Makefile
> +++ /dev/null
> @@ -1,44 +0,0 @@
> -USBREDIRPARSER_OBJS = usbredirparser.o
> -TARGETS             = $(USBREDIRPARSER_LIB) libusbredirparser.pc
> -INCLUDES            = usbredirproto.h usbredirparser.h
> -
> -ifeq ($(LINKTYPE),static)
> -USBREDIRPARSER_LIB  = libusbredirparser.a
> -else
> -USBREDIRPARSER_LIB  = libusbredirparser.so
> -override CPPFLAGS  += -fPIC
> -endif
> -
> -LIB_RELEASE = 0
> -
> -all: $(TARGETS)
> -
> --include $(USBREDIRPARSER_OBJS:.o=.d)
> -
> -$(USBREDIRPARSER_LIB): $(USBREDIRPARSER_OBJS)
> -
> -libusbredirparser.pc:
> -	@echo prefix=$(PREFIX)>  libusbredirparser.pc
> -	@echo libdir=$(LIBDIR)>>  libusbredirparser.pc
> -	@echo>>  libusbredirparser.pc
> -	@echo 'Name: libusbredirparser'>>  libusbredirparser.pc
> -	@echo 'Description: usbredirparser library'>>  libusbredirparser.pc
> -	@echo 'Version: '$(USBREDIR_VERSION)>>  libusbredirparser.pc
> -	@echo 'Libs: -L$${libdir} -lusbredirparser'>>  libusbredirparser.pc
> -	@echo 'Cflags: -I$${prefix}/include'>>  libusbredirparser.pc
> -
> -install: all
> -	mkdir -p $(DESTDIR)$(PREFIX)/include
> -	install -p -m 644 $(INCLUDES) $(DESTDIR)$(PREFIX)/include
> -	mkdir -p $(DESTDIR)$(LIBDIR)
> -ifeq ($(LINKTYPE),static)
> -	install -m 644 $(USBREDIRPARSER_LIB) $(DESTDIR)$(LIBDIR)
> -else
> -	install -m 755 $(USBREDIRPARSER_LIB).$(LIB_RELEASE) $(DESTDIR)$(LIBDIR)
> -	cd $(DESTDIR)$(LIBDIR)&&  \
> -	  ln -f -s $(USBREDIRPARSER_LIB).$(LIB_RELEASE) $(USBREDIRPARSER_LIB)
> -endif
> -	mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig
> -	install -m 644 libusbredirparser.pc $(DESTDIR)$(LIBDIR)/pkgconfig
> -
> -include ../Make.rules
> diff --git a/usbredirparser/Makefile.am b/usbredirparser/Makefile.am
> new file mode 100644
> index 0000000..a47450c
> --- /dev/null
> +++ b/usbredirparser/Makefile.am
> @@ -0,0 +1,12 @@
> +lib_LTLIBRARIES = libusbredirparser.la
> +
> +libusbredirparser_la_SOURCES = usbredirparser.c
> +libusbredirparser_ladir = $(includedir)
> +libusbredirparser_la_HEADERS = usbredirparser.h  usbredirproto.h
> +libusbredirparser_la_LDFLAGS = -version-info $(LIBUSBREDIRPARSER_SO_VERSION) \
> +                               -no-undefined
> +
> +pkgconfigdir = $(libdir)/pkgconfig
> +pkgconfig_DATA = libusbredirparser.pc
> +
> +EXTRA_DIST = libusbredirparser.pc
> diff --git a/usbredirparser/libusbredirparser.pc.in b/usbredirparser/libusbredirparser.pc.in
> new file mode 100644
> index 0000000..6c9b286
> --- /dev/null
> +++ b/usbredirparser/libusbredirparser.pc.in
> @@ -0,0 +1,9 @@
> +prefix=@prefix@
> +libdir=@libdir@
> +includedir=@includedir@
> +
> +Name: libusbredirparser
> +Description: usbredirparser library
> +Version: @VERSION@
> +Libs: -L${libdir} -lusbredirparser
> +Cflags: -I${includedir}
> diff --git a/usbredirparser/usbredirparser.c b/usbredirparser/usbredirparser.c
> index 6237b3b..ae731e0 100644
> --- a/usbredirparser/usbredirparser.c
> +++ b/usbredirparser/usbredirparser.c
> @@ -18,6 +18,8 @@
>      You should have received a copy of the GNU Lesser General Public
>      License along with this library; if not, see<http://www.gnu.org/licenses/>.
>   */
> +#include "config.h"
> +
>   #include<stdio.h>
>   #include<stdlib.h>
>   #include<stdarg.h>
> diff --git a/usbredirserver/Makefile b/usbredirserver/Makefile
> deleted file mode 100644
> index 889b839..0000000
> --- a/usbredirserver/Makefile
> +++ /dev/null
> @@ -1,20 +0,0 @@
> -override CPPFLAGS    += $(shell pkg-config --cflags libusb-1.0)
> -LIBS                  = $(shell pkg-config --libs libusb-1.0)
> -
> -USBREDIRSERVER_OBJS   = usbredirserver.o
> -TARGETS               = usbredirserver
> -
> -all: $(TARGETS)
> -
> --include *.d
> -
> -usbredirserver: $(USBREDIRSERVER_OBJS)
> -# rpath-link so that usbredirparser (needed by usbredirhost) can be found
> -# when building without having a previous version installed
> -	$(CC) $(LDFLAGS) -Wl,-rpath-link,../usbredirparser -o $@ $^ $(LIBS) -lusbredirhost
> -
> -install: all
> -	mkdir -p $(DESTDIR)$(SBINDIR)
> -	install -m 755 usbredirserver $(DESTDIR)$(SBINDIR)
> -
> -include ../Make.rules
> diff --git a/usbredirserver/Makefile.am b/usbredirserver/Makefile.am
> new file mode 100644
> index 0000000..6d059f5
> --- /dev/null
> +++ b/usbredirserver/Makefile.am
> @@ -0,0 +1,8 @@
> +sbin_PROGRAMS = usbredirserver
> +
> +usbredirserver_SOURCES = usbredirserver.c
> +usbredirserver_LDADD = $(LIBUSB_LIBS) \
> +                       $(top_builddir)/usbredirhost/libusbredirhost.la
> +usbredirserver_CFLAGS = $(LIBUSB_CFLAGS) \
> +                        -I$(top_srcdir)/usbredirhost \
> +                        -I$(top_srcdir)/usbredirparser
> diff --git a/usbredirserver/usbredirserver.c b/usbredirserver/usbredirserver.c
> index 33fa231..5ba3e04 100644
> --- a/usbredirserver/usbredirserver.c
> +++ b/usbredirserver/usbredirserver.c
> @@ -19,6 +19,8 @@
>      along with this library; if not, see<http://www.gnu.org/licenses/>.
>   */
>
> +#include "config.h"
> +
>   #include<stdio.h>
>   #include<stdlib.h>
>   #include<stdarg.h>
> @@ -35,7 +37,8 @@
>   #include<netdb.h>
>   #include "usbredirhost.h"
>
> -#define VERSION "usbredirserver " USBREDIR_VERSION
> +
> +#define SERVER_VERSION "usbredirserver " PACKAGE_VERSION
>
>   static int verbose = usbredirparser_info;
>   static int client_fd, running = 1;
> @@ -350,7 +353,7 @@ int main(int argc, char *argv[])
>
>           host = usbredirhost_open(ctx, handle, usbredirserver_log,
>                                    usbredirserver_read, usbredirserver_write,
> -                                 NULL, VERSION, verbose, 0);
> +                                 NULL, SERVER_VERSION, verbose, 0);
>           if (!host)
>               exit(1);
>           run_main_loop();
> diff --git a/usbredirtestclient/Makefile b/usbredirtestclient/Makefile
> deleted file mode 100644
> index 6df1440..0000000
> --- a/usbredirtestclient/Makefile
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -USBREDIRTESTCLIENT_OBJS = usbredirtestclient.o
> -TARGETS                 = usbredirtestclient
> -
> -all: $(TARGETS)
> -
> --include *.d
> -
> -usbredirtestclient: $(USBREDIRTESTCLIENT_OBJS)
> -	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) -lusbredirparser
> -
> -install:
> -
> -include ../Make.rules
> diff --git a/usbredirtestclient/Makefile.am b/usbredirtestclient/Makefile.am
> new file mode 100644
> index 0000000..c054a4d
> --- /dev/null
> +++ b/usbredirtestclient/Makefile.am
> @@ -0,0 +1,5 @@
> +noinst_PROGRAMS = usbredirtestclient
> +
> +usbredirtestclient_SOURCES = usbredirtestclient.c
> +usbredirtestclient_LDADD = $(top_builddir)/usbredirparser/libusbredirparser.la
> +usbredirtestclient_CFLAGS = -I$(top_srcdir)/usbredirparser
> diff --git a/usbredirtestclient/usbredirtestclient.c b/usbredirtestclient/usbredirtestclient.c
> index bda23e2..7fbff8b 100644
> --- a/usbredirtestclient/usbredirtestclient.c
> +++ b/usbredirtestclient/usbredirtestclient.c
> @@ -19,6 +19,8 @@
>      along with this library; if not, see<http://www.gnu.org/licenses/>.
>   */
>
> +#include "config.h"
> +
>   #include<stdio.h>
>   #include<stdlib.h>
>   #include<stdarg.h>
> @@ -39,7 +41,7 @@
>   #define EP2I(ep_address) (((ep_address&  0x80)>>  3) | (ep_address&  0x0f))
>   #define I2EP(i) (((i&  0x10)<<  3) | (i&  0x0f))
>
> -#define VERSION "usbredirtestclient " USBREDIR_VERSION
> +#define TESTCLIENT_VERSION "usbredirtestclient " PACKAGE_VERSION
>
>   static void usbredirtestclient_device_connect(void *priv,
>       struct usb_redir_device_connect_header *device_connect);
> @@ -283,7 +285,7 @@ int main(int argc, char *argv[])
>       parser->bulk_packet_func = usbredirtestclient_bulk_packet;
>       parser->iso_packet_func = usbredirtestclient_iso_packet;
>       parser->interrupt_packet_func = usbredirtestclient_interrupt_packet;
> -    usbredirparser_init(parser, VERSION, NULL, 0, 0);
> +    usbredirparser_init(parser, TESTCLIENT_VERSION, NULL, 0, 0);
>
>       /* Queue a reset + set config the other test commands will be send in
>          response to the status packets of previous commands */


More information about the Spice-devel mailing list