Skip to contentSkip to conversation

Convert build system to autotools

PATCH Superseded Qais Yousef 2 participants 9 messages Mar 23, 2015 – Mar 24, 2015

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover 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
Signature · 1 line
2.1.0
#1 lore raw

PATCH 2/6 add .gitignore file

---
 .gitignore | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 .gitignore
.gitignore new file +39 -0
new file mode 100644
index 000000000000..581b31038c8f
@@ -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
Signature · 1 line
2.1.0
#2 lore raw

PATCH 3/6 makefile.linux: delete as no longer necessary/used

In reply to Qais Yousef

Now autotools takes care of generating Makefiles.

---
 makefile.linux | 41 -----------------------------------------
 1 file changed, 41 deletions(-)
 delete mode 100644 makefile.linux
makefile.linux deleted +0 -41
deleted file mode 100644
index c4dab6d3b7d5..000000000000
@@ -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,[email protected] -o [email protected] ${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
Signature · 1 line
2.1.0
#3 lore raw

PATCH 4/6 Android.mk: Update to use the new location of source files

In reply to Qais Yousef
---
 Android.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Android.mk +3 -3
index 3cdd3d050c05..14878cccc805 100644
@@ -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
Signature · 1 line
2.1.0
#4 lore raw

PATCH 5/6 compress.c: fix check for errors from poll(), read() and write()

In reply to Qais Yousef

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(-)
src/lib/compress.c +12 -10
index 15dfdb74137e..84738d24ff45 100644
@@ -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;
Signature · 1 line
2.1.0
#5 lore raw

PATCH 6/6 src/lib/utils.c: remove this empty file

In reply to Qais Yousef

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
Android.mk +1 -1
index 14878cccc805..d201cfa1abff 100644
@@ -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
src/lib/Makefile.am +1 -1
index 01afb8a443a1..6f900ac98a27 100644
@@ -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
src/lib/utils.c deleted +0 -62

62 lines not on this page · raw message

Signature · 1 line
2.1.0
#6 lore raw
In reply to Qais Yousef

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.

Quoted 62 lines · Qais Yousef

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

#7 lore raw
In reply to Qais Yousef
Quoted 8 lines · Qais Yousef

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...

Signature · 1 line
~Vinod
Quoted 57 lines

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
Signature · 1 line
2.1.0
#8 lore raw
Quoted 6 lines · Vinod Koul
Quoted 5 lines · Qais Yousef

This series converts the build system to use autotools and splits the files into lib and utils.

Also patch 5 fixes error handling code.

Quoted 9 lines
Quoted 3 lines

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