[cowdancer] 01/01: Rewrite build system to use autotools

James Clarke jrtc27-guest at moszumanska.debian.org
Wed Sep 28 14:44:36 UTC 2016


This is an automated email from the git hooks/post-receive script.

jrtc27-guest pushed a commit to branch autotools
in repository cowdancer.

commit c8092d3c4afd698f9b543b4fad2a3f58fd472a24
Author: James Clarke <jrtc27 at jrtc27.com>
Date:   Wed Sep 28 15:43:43 2016 +0100

    Rewrite build system to use autotools
---
 Makefile                                           | 122 ---------------------
 Makefile.am                                        |  75 +++++++++++++
 .../cowbuilder                                     |   0
 .../qemubuilder                                    |   0
 configure.ac                                       |  35 ++++++
 cow-shell.c                                        |   2 +-
 debian/control                                     |   1 +
 debian/rules                                       |   7 +-
 m4/.placeholder                                    |   0
 9 files changed, 118 insertions(+), 124 deletions(-)

diff --git a/Makefile b/Makefile
deleted file mode 100644
index aebc2f8..0000000
--- a/Makefile
+++ /dev/null
@@ -1,122 +0,0 @@
-SHELL=/bin/bash
-DEB_BUILD_ARCH_OS ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
-BINARY := libcowdancer.so cow-shell cowbuilder cowdancer-ilistcreate \
-	cowdancer-ilistdump
-ifeq ($(DEB_BUILD_ARCH_OS),linux)
-	BINARY := $(BINARY) qemubuilder
-endif
-INSTALL_DIR=install -d -o root -g root -m 755
-INSTALL_FILE=install -o root -g root -m 644
-INSTALL_PROGRAM=install -o root -g root -m 755
-DESTDIR=
-PREFIX=/usr
-LIBDIR=$(PREFIX)/lib
-CFLAGS := $(CFLAGS) -fno-strict-aliasing
-CFLAGS_LFS=$(CFLAGS) $(shell getconf LFS_CFLAGS)
-PWD=$(shell pwd)
-LDFLAGS += -lncurses
-
-export VERSION=$(shell sed -n '1s/.*(\(.*\)).*$$/\1/p' < debian/changelog )
-
-all: $(BINARY)
-
-install: $(BINARY)
-	$(INSTALL_DIR) $(DESTDIR)${PREFIX}/bin
-	$(INSTALL_DIR) $(DESTDIR)${PREFIX}/sbin
-	$(INSTALL_DIR) $(DESTDIR)${LIBDIR}/cowdancer
-	$(INSTALL_DIR) $(DESTDIR)${PREFIX}/share/man/man1
-	$(INSTALL_DIR) $(DESTDIR)${PREFIX}/share/man/man8
-	$(INSTALL_FILE)  cow-shell.1 $(DESTDIR)/usr/share/man/man1/cow-shell.1
-	$(INSTALL_FILE)  cowdancer-ilistcreate.1 $(DESTDIR)/usr/share/man/man1/cowdancer-ilistcreate.1
-	$(INSTALL_FILE)  cowdancer-ilistdump.1 $(DESTDIR)/usr/share/man/man1/cowdancer-ilistdump.1
-	$(INSTALL_FILE)  cowbuilder.8 $(DESTDIR)/usr/share/man/man8/cowbuilder.8
-ifeq ($(DEB_BUILD_ARCH_OS),linux)
-	$(INSTALL_FILE)  qemubuilder.8 $(DESTDIR)/usr/share/man/man8/qemubuilder.8
-endif
-	$(INSTALL_FILE)  libcowdancer.so $(DESTDIR)${LIBDIR}/cowdancer/libcowdancer.so
-	$(INSTALL_PROGRAM) cow-shell $(DESTDIR)/usr/bin/cow-shell
-	$(INSTALL_PROGRAM) cowbuilder $(DESTDIR)/usr/sbin/cowbuilder
-ifeq ($(DEB_BUILD_ARCH_OS),linux)
-	$(INSTALL_PROGRAM) qemubuilder $(DESTDIR)/usr/sbin/qemubuilder
-endif
-	$(INSTALL_PROGRAM) cowdancer-ilistcreate $(DESTDIR)/usr/bin/cowdancer-ilistcreate
-	$(INSTALL_PROGRAM) cowdancer-ilistdump $(DESTDIR)/usr/bin/cowdancer-ilistdump
-
-	$(INSTALL_DIR) $(DESTDIR)/usr/share/bash-completion/completions
-ifeq ($(DEB_BUILD_ARCH_OS),linux)
-	$(INSTALL_FILE) bash_completion.qemubuilder $(DESTDIR)/usr/share/bash-completion/completions/qemubuilder
-endif
-	$(INSTALL_FILE) bash_completion.cowbuilder $(DESTDIR)/usr/share/bash-completion/completions/cowbuilder
-
-libcowdancer.so: cowdancer.lo ilistcreate.lo log.lo
-	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -ldl
-
-cow-shell: cow-shell.o ilistcreate.o log.o
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
-
-cowdancer-ilistcreate: cowdancer-ilistcreate.o ilistcreate.o log.o
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
-
-cowdancer-ilistdump: cowdancer-ilistdump.o log.o
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
-
-cowbuilder: cowbuilder.o parameter.o forkexec.o ilistcreate.o main.o cowbuilder_util.o log.o
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
-
-qemubuilder: qemubuilder.lfso parameter.lfso forkexec.lfso qemuipsanitize.lfso qemuarch.lfso file.lfso main.lfso log.lfso
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
-
-%.lo: %.c
-	$(CC) $(CFLAGS) -fPIC $< -o $@ -c
-
-%.lfso: %.c
-	$(CC) $(CFLAGS_LFS) $< -o $@ -c
-
-%.o: %.c parameter.h
-	$(CC) $(CFLAGS) $< -o $@ -c -D LIBDIR="\"${LIBDIR}\""
-
-clean:
-	-rm -f *~ *.o *.lo *.lfso $(BINARY)
-	-make -C initrd clean
-
-upload-dist-all:
-	scp ../cowdancer_$(VERSION).tar.gz aegis.netfort.gr.jp:public_html/software/downloads
-
-tests/log:
-	mkdir -p $@
-
-fastcheck: tests/log
-	set -e; set -o pipefail; for A in ./test_*.c; do echo $$A; \
-		if [ "$(DEB_BUILD_ARCH_OS)" != "linux" ] && [ "$${A:0:11}" == "./test_qemu" ]; then \
-			echo "Skipping (qemubuilder is only supported on linux-any)"; \
-		else \
-			./tests/run_c.sh $$A 2>&1; \
-		fi | \
-		tee tests/log/$${A/*\//}.log; done
-
-ifeq ($(DEB_BUILD_ARCH_OS),linux)
-slowcheck: tests/log cowdancer-ilistdump qemubuilder cow-shell
-else
-slowcheck: tests/log cowdancer-ilistdump cow-shell
-endif
-	# FIXME: The tests are running installed cowdancer, not the just-built
-	set -e; set -o pipefail; for A in tests/[0-9][0-9][0-9]_*.sh; \
-	do echo $$A; \
-	if [ "$(DEB_BUILD_ARCH_OS)" != "linux" ] && [ "$${A:0:40}" == "tests/101_test_qemubuilder_dumpconfig.sh" ]; then \
-		echo "Skipping (qemubuilder is only supported on linux-any)"; \
-	else \
-		PATH="$(PWD):$(PWD)/tests:/usr/bin/:/bin" \
-		COWDANCER_SO=$(PWD)/libcowdancer.so \
-		bash $$A  2>&1 | \
-		sed -e's,/tmp/[^/]*,/tmp/XXXX,g' \
-			-e "s,^Current time:.*,Current time: TIME," \
-			-e "s,^pbuilder-time-stamp: .*,pbuilder-time-stamp: XXXX," \
-			-e "s,^Fetched .*B in .*s (.*B/s),Fetched XXXB in Xs (XXXXXB/s),"; \
-	fi | tee tests/log/$${A/*\//}.log; done
-
-check: fastcheck slowcheck
-
-check-syntax:
-	$(CC) -c $(CFLAGS) $(CHK_SOURCES)  -o/dev/null -D LIBDIR="\"${LIBDIR}\""
-
-.PHONY: clean check upload-dist-all check-syntax fastcheck slowcheck
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..b4b7024
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,75 @@
+AUTOMAKE_OPTIONS = foreign
+ACLOCAL_AMFLAGS = -I m4
+
+SHELL = /bin/bash
+bashcompletiondir = $(datadir)/bash-completion/completions
+
+pkglib_LTLIBRARIES = libcowdancer.la
+bin_PROGRAMS = cow-shell cowdancer-ilistcreate cowdancer-ilistdump
+sbin_PROGRAMS = cowbuilder
+man_MANS = cow-shell.1 cowdancer-ilistcreate.1 cowdancer-ilistdump.1 cowbuilder.8
+bashcompletion_DATA = bash-completion/cowbuilder
+
+if QEMUBUILDER
+QEMUBUILDER = yes
+sbin_PROGRAMS += qemubuilder
+man_MANS += qemubuilder.8
+bashcompletion_DATA += bash-completion/qemubuilder
+else
+QEMUBUILDER = no
+endif
+
+AM_CFLAGS = -fno-strict-aliasing -DCOWDANCER_SO="\"$(pkglibdir)/libcowdancer.so\""
+
+libcowdancer_la_SOURCES = cowdancer.c ilistcreate.c log.c
+## Effectively a no-op, but causes libcowdancer's object files to have a prefix
+## so they don't clash with the non-libtool versions.
+libcowdancer_la_CFLAGS = $(AM_CFLAGS)
+## This is an internal library, so disable versioning, and don't build a static
+## library
+libcowdancer_la_LDFLAGS = -avoid-version -shared
+cow_shell_SOURCES = cow-shell.c ilistcreate.c log.c
+cowdancer_ilistcreate_SOURCES = cowdancer-ilistcreate.c ilistcreate.c log.c
+cowdancer_ilistdump_SOURCES = cowdancer-ilistdump.c log.c
+cowbuilder_SOURCES = cowbuilder.c parameter.c forkexec.c ilistcreate.c main.c cowbuilder_util.c log.c
+qemubuilder_SOURCES = qemubuilder.c parameter.c forkexec.c qemuipsanitize.c qemuarch.c file.c main.c log.c
+qemubuilder_CFLAGS = $(shell getconf LFS_CFLAGS) $(AM_CFLAGS)
+
+export srcdir
+
+tests/log:
+	mkdir -p $@
+
+fastcheck: tests/log
+	set -e; set -o pipefail; for A in $(srcdir)/test_*.c; do \
+		echo $$A; \
+		if [ "x$(QEMUBUILDER)" = "xno" -a "x$${A:$${#srcdir}+1:9}" == "xtest_qemu" ]; then \
+			echo "Skipping (qemubuilder is only supported on linux-any)"; \
+		else \
+			$(srcdir)/tests/run_c.sh $$A 2>&1; \
+		fi | \
+		tee tests/log/$${A/*\//}.log; done
+
+if QEMUBUILDER
+slowcheck: tests/log cowdancer-ilistdump qemubuilder cow-shell
+else
+slowcheck: tests/log cowdancer-ilistdump cow-shell
+endif
+	## FIXME: The tests are running installed cowdancer, not the just-built
+	set -e; set -o pipefail; for A in $(srcdir)/tests/[0-9][0-9][0-9]_*.sh; do \
+		echo $$A; \
+		if [ "x$(QEMUBUILDER)" = "xno" -a "x$${A:$${#srcdir}+1:40}" == "xtests/101_test_qemubuilder_dumpconfig.sh" ]; then \
+			echo "Skipping (qemubuilder is only supported on linux-any)"; \
+		else \
+			PATH="$(abs_builddir):$(abs_builddir)/@objdir@:$(abs_srcdir)/tests:/usr/bin/:/bin" \
+			COWDANCER_SO=$(abs_builddir)/@objdir@/libcowdancer.so \
+			bash $$A  2>&1 | \
+			sed -e's,/tmp/[^/]*,/tmp/XXXX,g' \
+				-e "s,^Current time:.*,Current time: TIME," \
+				-e "s,^pbuilder-time-stamp: .*,pbuilder-time-stamp: XXXX," \
+				-e "s,^Fetched .*B in .*s (.*B/s),Fetched XXXB in Xs (XXXXXB/s),"; \
+		fi | tee tests/log/$${A/*\//}.log; done
+
+check-local: fastcheck slowcheck
+
+.PHONY: clean-local check-local fastcheck slowcheck
diff --git a/bash_completion.cowbuilder b/bash-completion/cowbuilder
similarity index 100%
rename from bash_completion.cowbuilder
rename to bash-completion/cowbuilder
diff --git a/bash_completion.qemubuilder b/bash-completion/qemubuilder
similarity index 100%
rename from bash_completion.qemubuilder
rename to bash-completion/qemubuilder
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..5f28305
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,35 @@
+AC_INIT([cowdancer], m4_esyscmd_s([dpkg-parsechangelog -S version]))
+AC_PREREQ([2.68])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([m4])
+AM_INIT_AUTOMAKE
+
+LT_INIT
+AM_MAINTAINER_MODE
+
+# Check this is the right directory
+AC_CONFIG_SRCDIR([cowdancer.c])
+
+AC_PROG_CC
+
+AC_CHECK_LIB([ncurses],
+             [setupterm],
+             [[LIBS="-lncurses${LIBS:+ $LIBS}"] AC_CHECK_HEADER([curses.h], [], AC_MSG_FAILURE([curses.h could not be found]))],
+             [AC_MSG_FAILURE([ncurses library could not be found])])
+
+AC_CANONICAL_HOST
+AC_MSG_CHECKING([whether qemubuilder is supported])
+case "$host_os" in
+    *linux*)
+        AC_MSG_RESULT([yes])
+        AM_CONDITIONAL([QEMUBUILDER], [true])
+        ;;
+    *)
+        AC_MSG_RESULT([no])
+        AM_CONDITIONAL([QEMUBUILDER], [false])
+        ;;
+esac
+
+AC_SUBST([objdir], [$objdir])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/cow-shell.c b/cow-shell.c
index 853befb..3f59aba 100755
--- a/cow-shell.c
+++ b/cow-shell.c
@@ -65,7 +65,7 @@ static void set_env_vars() {
   asprintf(&buf, "%s%s%s",
 	   getenv("LD_PRELOAD")?:"",
 	   getenv("LD_PRELOAD")?" ":"",
-	   getenv("COWDANCER_SO") ?: LIBDIR "/cowdancer/libcowdancer.so");
+	   getenv("COWDANCER_SO") ?: COWDANCER_SO);
   setenv("LD_PRELOAD", buf, 1);
   free(buf);
 }
diff --git a/debian/control b/debian/control
index 0998927..91cafdc 100644
--- a/debian/control
+++ b/debian/control
@@ -6,6 +6,7 @@ Section: utils
 Priority: optional
 Build-Depends: cpio,
                debhelper (>> 9),
+               dh-autoreconf,
                klibc-utils [linux-any],
                libklibc-dev [linux-any],
                libncurses-dev,
diff --git a/debian/rules b/debian/rules
index caaf4a1..a73b97e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -14,7 +14,12 @@ endif
 endif
 
 %:
-	dh $@ --parallel
+	dh $@ --with autoreconf --parallel
+
+# Multiarch is not supported (and irrelevant), since libcowdancer is the only
+# shared library and is internal
+override_dh_auto_configure:
+	dh_auto_configure -- --libdir='$${prefix}/lib' --libexecdir='$${prefix}/lib'
 
 override_dh_install:
 	dh_install --fail-missing
diff --git a/m4/.placeholder b/m4/.placeholder
new file mode 100644
index 0000000..e69de29

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pbuilder/cowdancer.git



More information about the Pbuilder-maint mailing list