[alsa-devel] [TINYCOMPRESS][PATCH 0/6] Convert build system to autotools
This series converts the build system to use autotools and splits the files into lib and utils.
Also patch 5 fixes error handling code.
I can't test Android builds but both cross and native compiling worked for me.
I left AUTHORS, ChangeLog and NEWS files empty. I used the license header to fill COPYING.
Qais Yousef (6): Convert the build system to autotools add .gitignore file makefile.linux: delete as no longer necessary/used Android.mk: Update to use the new location of source files compress.c: fix check for errors from poll(), read() and write() src/lib/utils.c: remove this empty file
.gitignore | 39 ++++ AUTHORS | 0 Android.mk | 6 +- COPYING | 51 ++++ ChangeLog | 0 INSTALL | 365 +++++++++++++++++++++++++++++ Makefile.am | 3 + NEWS | 0 autogen.sh | 6 + compress.c | 632 ------------------------------------------------- configure.ac | 31 +++ cplay.c | 330 -------------------------- crec.c | 489 -------------------------------------- m4/.place_holder | 0 makefile.linux | 41 ---- src/Makefile.am | 1 + src/lib/Makefile.am | 5 + src/lib/compress.c | 634 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/utils/Makefile.am | 11 + src/utils/cplay.c | 330 ++++++++++++++++++++++++++ src/utils/crec.c | 489 ++++++++++++++++++++++++++++++++++++++ utils.c | 62 ----- 22 files changed, 1968 insertions(+), 1557 deletions(-) create mode 100644 .gitignore create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 Makefile.am create mode 100644 NEWS create mode 100755 autogen.sh delete mode 100644 compress.c create mode 100644 configure.ac delete mode 100644 cplay.c delete mode 100644 crec.c create mode 100644 m4/.place_holder delete mode 100644 makefile.linux create mode 100644 src/Makefile.am create mode 100644 src/lib/Makefile.am create mode 100644 src/lib/compress.c create mode 100644 src/utils/Makefile.am create mode 100644 src/utils/cplay.c create mode 100644 src/utils/crec.c delete mode 100644 utils.c
--- .gitignore | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..581b31038c8f --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +.* +*.o +*.so +*.la +*.lo +*~ +configure +config.log +config.cache +config.status +config.guess +config.sub +config.h +config.h.in +Makefile +Makefile.in +libtool +depcomp +ltmain.sh +aclocal.m4 +autom4te.cache +compile +install-sh +missing +stamp-h1 +m4/libtool.m4 +m4/ltoptions.m4 +m4/ltsugar.m4 +m4/ltversion.m4 +m4/lt~obsolete.m4 + +# binary ignores +cplay +crecord + +# other ignores +*.patch +cscope.* +tags
Now autotools takes care of generating Makefiles. --- makefile.linux | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 makefile.linux
diff --git a/makefile.linux b/makefile.linux deleted file mode 100644 index c4dab6d3b7d5..000000000000 --- a/makefile.linux +++ /dev/null @@ -1,41 +0,0 @@ -LIB = libtinycompress -VER = 0.1 -LIBSRC = compress.c -PLAYBIN = cplay -RECBIN = crec -PLAYSRC = cplay.c utils.c -RECSRC = crec.c utils.c -LIBOBJ = ${LIBSRC:.c=.o} -PLAYOBJ = ${PLAYSRC:.c=.o} -RECOBJ = ${RECSRC:.c=.o} - -CROSS_COMPILE ?= -CC ?= ${CROSS_COMPILE}gcc - -CFLAGS += -std=c99 -Wall -Wextra -Wunused -DVERSION="${VER}" -I./include -LDFLAGS += -L. -ltinycompress -LIBLDFLAGS = -lasound - -all: libtinycompress cplay crec - -$(LIB): ${LIBOBJ} - @echo " LD "$@ - @${CC} ${CFLAGS} -shared -Wl,-soname,$@.so -o $@.so ${LIBOBJ} ${LIBLDFLAGS} - -$(PLAYBIN): ${PLAYOBJ} ${LIB} - @echo " LD "$@ - @${CC} ${CFLAGS} -o $@ ${PLAYOBJ} ${LDFLAGS} - -$(RECBIN): ${RECOBJ} ${LIB} - @echo " LD "$@ - @${CC} ${CFLAGS} -o $@ ${RECOBJ} ${LDFLAGS} - -%.o: %.c - @echo " CC "$< - @${CC} ${CFLAGS} -c -fPIC -o $@ $< - -clean: - @rm -rf ${BIN} ${PLAYOBJ} ${RECOBJ} ${LIB}.so ${LIBOBJ} - - -.PHONY: all clean
--- Android.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Android.mk b/Android.mk index 3cdd3d050c05..14878cccc805 100644 --- a/Android.mk +++ b/Android.mk @@ -2,7 +2,7 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS) LOCAL_C_INCLUDES:= $(LOCAL_PATH)/include -LOCAL_SRC_FILES:= compress.c utils.c +LOCAL_SRC_FILES:= src/lib/compress.c src/lib/utils.c LOCAL_MODULE := libtinycompress LOCAL_SHARED_LIBRARIES:= libcutils libutils LOCAL_MODULE_TAGS := optional @@ -13,7 +13,7 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS)
LOCAL_C_INCLUDES:= $(LOCAL_PATH)/include -LOCAL_SRC_FILES:= cplay.c +LOCAL_SRC_FILES:= src/utils/cplay.c LOCAL_MODULE := cplay LOCAL_SHARED_LIBRARIES:= libcutils libutils libtinycompress LOCAL_MODULE_TAGS := optional @@ -23,7 +23,7 @@ include $(BUILD_EXECUTABLE) include $(CLEAR_VARS)
LOCAL_C_INCLUDES:= $(LOCAL_PATH)/include -LOCAL_SRC_FILES:= crec.c +LOCAL_SRC_FILES:= src/utils/crec.c LOCAL_MODULE := crec LOCAL_SHARED_LIBRARIES:= libcutils libutils libtinycompress LOCAL_MODULE_TAGS := optional
When these functions fail they return -1 and set errno. Fix error checks accordingly. --- src/lib/compress.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/lib/compress.c b/src/lib/compress.c index 15dfdb74137e..84738d24ff45 100644 --- a/src/lib/compress.c +++ b/src/lib/compress.c @@ -383,7 +383,7 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size } /* A pause will cause -EBADFD or zero. * This is not an error, just stop writing */ - if ((ret == 0) || (ret == -EBADFD)) + if ((ret == 0) || (ret < 0 && errno == EBADFD)) break; if (ret < 0) return oops(compress, errno, "poll error"); @@ -397,11 +397,12 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size else to_write = size; written = write(compress->fd, cbuf, to_write); - /* If play was paused the write returns -EBADFD */ - if (written == -EBADFD) - break; - if (written < 0) + if (written < 0) { + /* If play was paused the write returns -EBADFD */ + if (errno == EBADFD) + break; return oops(compress, errno, "write failed!"); + }
size -= written; cbuf += written; @@ -443,7 +444,7 @@ int compress_read(struct compress *compress, void *buf, unsigned int size) } /* A pause will cause -EBADFD or zero. * This is not an error, just stop reading */ - if ((ret == 0) || (ret == -EBADFD)) + if ((ret == 0) || (ret < 0 && errno == EBADFD)) break; if (ret < 0) return oops(compress, errno, "poll error"); @@ -457,11 +458,12 @@ int compress_read(struct compress *compress, void *buf, unsigned int size) else to_read = size; num_read = read(compress->fd, cbuf, to_read); - /* If play was paused the read returns -EBADFD */ - if (num_read == -EBADFD) - break; - if (num_read < 0) + if (num_read < 0) { + /* If play was paused the read returns -EBADFD */ + if (errno == EBADFD) + break; return oops(compress, errno, "read failed!"); + }
size -= num_read; cbuf += num_read;
utils.c isn't implementing anything so delete it --- Android.mk | 2 +- src/lib/Makefile.am | 2 +- src/lib/utils.c | 62 ----------------------------------------------------- 3 files changed, 2 insertions(+), 64 deletions(-) delete mode 100644 src/lib/utils.c
diff --git a/Android.mk b/Android.mk index 14878cccc805..d201cfa1abff 100644 --- a/Android.mk +++ b/Android.mk @@ -2,7 +2,7 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS) LOCAL_C_INCLUDES:= $(LOCAL_PATH)/include -LOCAL_SRC_FILES:= src/lib/compress.c src/lib/utils.c +LOCAL_SRC_FILES:= src/lib/compress.c LOCAL_MODULE := libtinycompress LOCAL_SHARED_LIBRARIES:= libcutils libutils LOCAL_MODULE_TAGS := optional diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 01afb8a443a1..6f900ac98a27 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -1,5 +1,5 @@ tinycompressdir = $(libdir)
tinycompress_LTLIBRARIES = libtinycompress.la -libtinycompress_la_SOURCES = compress.c utils.c +libtinycompress_la_SOURCES = compress.c libtinycompress_la_CFLAGS = -I $(top_builddir)/include diff --git a/src/lib/utils.c b/src/lib/utils.c deleted file mode 100644 index 9a0f86a3160a..000000000000 --- a/src/lib/utils.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * BSD LICENSE - * - * tinycompress utility functions - * Copyright (c) 2011-2013, Intel Corporation - * All rights reserved. - * - * Author: Vinod Koul vinod.koul@intel.com - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of Intel Corporation nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - * LGPL LICENSE - * - * tinycompress utility functions - * Copyright (c) 2011-2013, Intel Corporation - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU Lesser General Public License, - * version 2.1, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to - * the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - */ -#include <stdio.h> -#include <stdlib.h> -#include <stdbool.h> -#include <linux/types.h> -#include <sys/time.h> -#define __force -#define __bitwise -#define __user -#include "tinycompress/tinycompress.h" -
I just realised I'm not setting the Makefile.am in include directory which wouldn't let the tinycompress.h header to be exported correctly. I'll wait for this series to be reviewed and then either send v2 with the fix or send a separate patch on top of this.
On 03/23/2015 01:08 PM, Qais Yousef wrote:
This series converts the build system to use autotools and splits the files into lib and utils.
Also patch 5 fixes error handling code.
I can't test Android builds but both cross and native compiling worked for me.
I left AUTHORS, ChangeLog and NEWS files empty. I used the license header to fill COPYING.
Qais Yousef (6): Convert the build system to autotools add .gitignore file makefile.linux: delete as no longer necessary/used Android.mk: Update to use the new location of source files compress.c: fix check for errors from poll(), read() and write() src/lib/utils.c: remove this empty file
.gitignore | 39 ++++ AUTHORS | 0 Android.mk | 6 +- COPYING | 51 ++++ ChangeLog | 0 INSTALL | 365 +++++++++++++++++++++++++++++ Makefile.am | 3 + NEWS | 0 autogen.sh | 6 + compress.c | 632 ------------------------------------------------- configure.ac | 31 +++ cplay.c | 330 -------------------------- crec.c | 489 -------------------------------------- m4/.place_holder | 0 makefile.linux | 41 ---- src/Makefile.am | 1 + src/lib/Makefile.am | 5 + src/lib/compress.c | 634 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/utils/Makefile.am | 11 + src/utils/cplay.c | 330 ++++++++++++++++++++++++++ src/utils/crec.c | 489 ++++++++++++++++++++++++++++++++++++++ utils.c | 62 ----- 22 files changed, 1968 insertions(+), 1557 deletions(-) create mode 100644 .gitignore create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 Makefile.am create mode 100644 NEWS create mode 100755 autogen.sh delete mode 100644 compress.c create mode 100644 configure.ac delete mode 100644 cplay.c delete mode 100644 crec.c create mode 100644 m4/.place_holder delete mode 100644 makefile.linux create mode 100644 src/Makefile.am create mode 100644 src/lib/Makefile.am create mode 100644 src/lib/compress.c create mode 100644 src/utils/Makefile.am create mode 100644 src/utils/cplay.c create mode 100644 src/utils/crec.c delete mode 100644 utils.c
On Mon, Mar 23, 2015 at 01:08:59PM +0000, Qais Yousef wrote:
This series converts the build system to use autotools and splits the files into lib and utils.
Also patch 5 fixes error handling code.
I can't test Android builds but both cross and native compiling worked for me.
I left AUTHORS, ChangeLog and NEWS files empty. I used the license header to fill COPYING.
Thanks :)
I was planning to do this after my current SKL work but this is welcome too. Just one advise, pls generate patches using -M option, that shows code moves nicely...
On 03/23/2015 04:40 PM, Vinod Koul wrote:
On Mon, Mar 23, 2015 at 01:08:59PM +0000, Qais Yousef wrote:
This series converts the build system to use autotools and splits the files into lib and utils.
Also patch 5 fixes error handling code.
I can't test Android builds but both cross and native compiling worked for me.
I left AUTHORS, ChangeLog and NEWS files empty. I used the license header to fill COPYING.
Thanks :)
I was planning to do this after my current SKL work but this is welcome too. Just one advise, pls generate patches using -M option, that shows code moves nicely...
Oh sorry I forgot about this option. I'll send v2 with this change and a couple of other fixes.
Thanks, Qais
participants (2)
-
Qais Yousef
-
Vinod Koul