summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2017-08-19 11:57:01 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2017-08-19 14:15:58 (GMT)
commit511f9c9765eb2a9992ea4470703ebcd96faca52b (patch) (side-by-side diff)
treee0414383c4bc9cc9a95f5f32aae6fd2e8557e204
parentead370a83f981ccf3d288dbe222fd362ec801f79 (diff)
downloadruncap-511f9c9765eb2a9992ea4470703ebcd96faca52b.tar.gz
runcap-511f9c9765eb2a9992ea4470703ebcd96faca52b.tar.bz2
Switch to autotools
* .gitignore: Update. * Makefile: Remove. * Make.am: New file. * install.am: New file. * shared.am: New file. * static.am: New file. * configure.ac: New file. * runcap.m4: New file. * t/Makefile: Remove. * t/Makefile.am: New file. * t/testsuite: Don't use relative directory addressing.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--.gitignore21
-rw-r--r--Make.am41
-rw-r--r--Makefile103
-rw-r--r--configure.ac15
-rw-r--r--install.am7
-rw-r--r--runcap.34
-rw-r--r--runcap.m439
-rw-r--r--shared.am6
-rw-r--r--static.am6
-rw-r--r--t/Makefile.am (renamed from t/Makefile)27
-rwxr-xr-xt/testsuite16
11 files changed, 153 insertions, 132 deletions
diff --git a/.gitignore b/.gitignore
index a712fcb..fcda02c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,24 @@ core
.gdbinit
tmp
*.tar.gz
+.deps
+Makefile
+Makefile.in
+.deps
+.libs/
+aclocal.m4
+autom4te.cache/
+compile
+config.guess
+config.log
+config.status
+config.sub
+configure
+depcomp
+*.lo
+install-sh
+*.in
+*.la
+libtool
+ltmain.sh
+missing
diff --git a/Make.am b/Make.am
new file mode 100644
index 0000000..fe56d41
--- a/dev/null
+++ b/Make.am
@@ -0,0 +1,41 @@
+# Main Makefile.am source for runcap
+# Copyright (C) 2017 Sergey Poznyakoff
+#
+# Runcap is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# Runcap is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Runcap. If not, see <http://www.gnu.org/licenses/>.
+
+# The runcap library can be built in three distinct flavours:
+# 1. as a standalone library
+# 2. as a shared convenience library
+# 3. as a static convenience library
+# Due to various Automake/libtools subtleties, the three builds cannot be
+# defined in a single Makefile.am. Therefore, three distinct Automake sources
+# are provided for each of the above types. Each of them contains the rules
+# and variables for its particular build flavour, and obtains common rules and
+# and variables by including Make.am. The actual build flavour is determined by
+# the second argument to the RUNCAP_SETUP macro invocation (see runcap.m4).
+# The files and the corresponding 2nd argument for each build type are:
+# 1. install.am install
+# 2. shared.am shared
+# 3. static.am static
+
+RUNCAP_SRC = \
+ getc.c\
+ getl.c\
+ runcap.c\
+ seek.c\
+ tell.c
+EXTRA_DIST = Make.am installed.am shared.am static.am
+check:
+ $(MAKE) -C t check
+SUBDIRS = . t
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 47bcf17..0000000
--- a/Makefile
+++ b/dev/null
@@ -1,103 +0,0 @@
-# runcap - run program and capture its output
-# Copyright (C) 2017 Sergey Poznyakoff
-#
-# Runcap is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 3 of the License, or (at your
-# option) any later version.
-#
-# Runcap is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with Runcap. If not, see <http://www.gnu.org/licenses/>.
-
-PREFIX = /usr
-BINDIR = $(PREFIX)/bin
-MANDIR = $(PREFIX)/share/man
-
-MAN3DIR = $(MANDIR)/man3
-MAN3FILES = runcap.3
-
-# The install program. Use cp(1) if not available.
-INSTALL = install
-# Program to make directory hierarchy.
-MKHIER = install -d
-
-# Compiler options
-O = -ggdb -Wall
-
-PROJECT = libruncap
-VERSION = 1.0
-
-SOURCES = runcap.c getc.c getl.c seek.c tell.c
-OBJECTS = $(SOURCES:.c=.o)
-HEADERS = runcap.h
-
-CFLAGS = $(O)
-LDFLAGS =
-ARFLAGS = cru
-
-.c.o:
- $(CC) -c -o$@ $(CPPFLAGS) $(CFLAGS) $<
-
-all: libruncap.a
-
-$(OBJECTS): $(HEADERS)
-
-libruncap.a: $(OBJECTS)
- ar $(ARFLAGS) libruncap.a $(OBJECTS)
- ranlib libruncap.a
-
-clean: subdirs-clean
- rm -f libruncap.a $(OBJECTS)
-
-subdirs-clean:
- @$(MAKE) -C t clean
-
-install: install-lib install-headers install-man
-
-install-lib: libruncap.a
- $(MKHIER) $(DESTDIR)$(LIBDIR)
- $(INSTALL) libruncap.a $(DESTDIR)$(LIBDIR)
-
-install-headers: runcap.h
- $(MKHIER) $(DESTDIR)$(INCLUDEDIR)
- $(INSTALL) runcap.h $(DESTDIR)$(INCLUDEDIR)
-
-install-man:;
- $(MKHIER) $(DESTDIR)$(MAN3DIR)
- $(INSTALL) $(MAN3FILES) $(DESTDIR)$(MAN3DIR)
-
-.PHONY: check distdir
-check: all
- $(MAKE) -C t check
-
-DISTDIR=$(PROJECT)-$(VERSION)
-DISTFILES=Makefile $(SOURCES) $(HEADERS) $(MAN3FILES)
-
-distdir:
- test -d $(DISTDIR) || mkdir $(DISTDIR)
- cp $(DISTFILES) $(DISTDIR)
- $(MAKE) -C t distdir TOPDISTDIR=`cd $(DISTDIR); pwd`
-
-dist: distdir
- tar hzcf $(DISTDIR).tar.gz $(DISTDIR)
- rm -rf $(DISTDIR)
-
-distcheck: dist
- @mkdir _build _inst; \
- cd _build; \
- tar xzf ../$(DISTDIR).tar.gz; \
- if $(MAKE) -C $(DISTDIR) check \
- && $(MAKE) -C $(DISTDIR) install DESTDIR=`cd ../_inst; pwd`; then \
- cd ..; \
- rm -rf _build _inst; \
- echo "$(DISTDIR).tar.gz is ready for distribution";\
- else \
- echo "Please, inspect " `pwd`;\
- fi
-
-
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..365a128
--- a/dev/null
+++ b/configure.ac
@@ -0,0 +1,15 @@
+AC_PREREQ(2.63)
+AC_INIT([libruncap], [1.0], [gray+runcap@gnu.org.ua])
+AC_CONFIG_SRCDIR([runcap.c])
+AM_INIT_AUTOMAKE([1.11 foreign tar-ustar silent-rules])
+
+# Enable silent rules by default:
+AM_SILENT_RULES([yes])
+
+# Checks for programs.
+AC_PROG_CC
+
+RUNCAP_SETUP([.],[install])
+
+# Generate files
+AC_OUTPUT
diff --git a/install.am b/install.am
new file mode 100644
index 0000000..3426aee
--- a/dev/null
+++ b/install.am
@@ -0,0 +1,7 @@
+# Automake settings for a standalone installable build of runcap.
+# See Make.am for details.
+include Make.am
+lib_LTLIBRARIES=libruncap.la
+libruncap_la_SOURCES = $(RUNCAP_SRC)
+include_HEADERS=runcap.h
+dist_man_MANS=runcap.3
diff --git a/runcap.3 b/runcap.3
index 61e7337..0a5a89c 100644
--- a/runcap.3
+++ b/runcap.3
@@ -1,5 +1,5 @@
.\" This file is part of runcap -*- nroff -*-
-.\" Copyright (C) 2016 Sergey Poznyakoff
+.\" Copyright (C) 2017 Sergey Poznyakoff
.\"
.\" Runcap is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with runcap. If not, see <http://www.gnu.org/licenses/>.
-.TH RUNCAP 2 "July 24, 2017" "RUNCAP" "User Commands"
+.TH RUNCAP 2 "August 19, 2017" "RUNCAP" "User Commands"
.SH NAME
runcap \- run external process and capture its stdout and stderr
.SH SYNOPSIS
diff --git a/runcap.m4 b/runcap.m4
new file mode 100644
index 0000000..cd4c234
--- a/dev/null
+++ b/runcap.m4
@@ -0,0 +1,39 @@
+# This file is part of runcap -*- autoconf -*-
+# Copyright (C) 2017 Sergey Poznyakoff
+#
+# Runcap is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Runcap is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Runcap. If not, see <http://www.gnu.org/licenses/>.
+AC_DEFUN([RUNCAP_SETUP],[
+ m4_pushdef([runcapdir],m4_if($1,[.],,$1,,[runcap/],$1/))
+ AC_SUBST([RUNCAP_INC],['-I$(top_srcdir)/]runcapdir')
+ AC_SUBST([RUNCAP_BUILD_TYPE])
+ m4_if($2,[install],[
+ LT_INIT
+ RUNCAP_BUILD_TYPE=install
+ RUNCAP_LDADD=['$(top_builddir)/]runcapdir[libruncap.la']
+ AC_CONFIG_FILES(runcapdir[Makefile]:runcapdir[install.in])
+ ],[shared],[
+ LT_INIT
+ RUNCAP_BUILD_TYPE=shared
+ RUNCAP_LDADD=['$(top_builddir)/]runcapdir[libruncap.la']
+ AC_CONFIG_FILES(runcapdir[Makefile]:runcapdir[shared.in])
+ ],[
+ AC_PROG_RANLIB
+ RUNCAP_BUILD_TYPE=static
+ RUNCAP_LDADD=['$(top_builddir)/]runcapdir[libruncap.a']
+ AC_CONFIG_FILES(runcapdir[Makefile]:runcapdir[static.in])
+ ])
+ AC_CONFIG_FILES(runcapdir[t/Makefile])
+ m4_popdef([runcapdir])
+])
+
diff --git a/shared.am b/shared.am
new file mode 100644
index 0000000..81d5f02
--- a/dev/null
+++ b/shared.am
@@ -0,0 +1,6 @@
+# Automake settings to build runcap as a shared convenience library.
+# See Make.am for details.
+include Make.am
+noinst_LTLIBRARIES=libruncap.la
+libruncap_la_SOURCES = $(RUNCAP_SRC)
+noinst_HEADER=runcap.h
diff --git a/static.am b/static.am
new file mode 100644
index 0000000..d42fce4
--- a/dev/null
+++ b/static.am
@@ -0,0 +1,6 @@
+# Automake settings to build runcap as a static convenience library (default).
+# See Make.am for details.
+include Make.am
+noinst_LIBRARIES=libruncap.a
+libruncap_a_SOURCES = $(RUNCAP_SRC)
+noinst_HEADER=runcap.h
diff --git a/t/Makefile b/t/Makefile.am
index 7a3bb62..681184f 100644
--- a/t/Makefile
+++ b/t/Makefile.am
@@ -16,19 +16,15 @@
TESTPROGS=genout rt
check: $(TESTPROGS)
- @./testsuite
+ @$(srcdir)/testsuite
-CPPFLAGS=-I..
-CFLAGS = -ggdb -Wall
+AM_CPPFLAGS=@RUNCAP_INC@
-.c.o:
- $(CC) -c -o$@ $(CPPFLAGS) $(CFLAGS) $<
+noinst_PROGRAMS = rt genout
+rt_SOURCES=rt.c
+rt_LDADD=../libruncap.a
-RT_DEPS=rt.o ../libruncap.a
-rt: $(RT_DEPS)
- cc $(CFLAGS) -ort $(RT_DEPS)
-
-genout: genout.o
+genout_SOURCES = genout.c
TESTSUITE =\
testsuite\
@@ -42,13 +38,4 @@ TESTSUITE =\
08seek.t\
09seek.t
-
-DISTDIR = $(TOPDISTDIR)/t
-DISTFILES = Makefile rt.c genout.c $(TESTSUITE) INPUT
-.PHONY: distdir clean
-distdir:
- test -d $(DISTDIR) || mkdir $(DISTDIR)
- cp $(DISTFILES) $(DISTDIR)
-
-clean:
- rm -rf $(TESTPROGS) testsuite.log testsuite.dir
+EXTRA_DIST = $(TESTSUITE) INPUT
diff --git a/t/testsuite b/t/testsuite
index 84d4c9d..bd870ce 100755
--- a/t/testsuite
+++ b/t/testsuite
@@ -18,7 +18,8 @@
testdir=$(cd $(dirname $0); pwd)
progname=$(basename $0)
-workdir=$testdir/testsuite.dir
+topworkdir=$(pwd)
+workdir=$topworkdir/testsuite.dir
if [ ! -d $workdir ]; then
mkdir $workdir
fi
@@ -42,8 +43,8 @@ $3
EOF
}
-PATH=$testdir:$PATH
-
+PATH=$topworkdir:$PATH
+echo $PATH
TC_EXPECT() {
cat > exp$1
}
@@ -54,7 +55,7 @@ TC_TITLE() {
numtests=0
numfail=0
cd $testdir
-exec 3>testsuite.log
+exec 3>$topworkdir/testsuite.log
if [ $# -gt 0 ]; then
testlist=$(ls $*) || exit 1
@@ -81,9 +82,9 @@ do
fi
cd $dirname
- descr=$(sed -n '/TC_TITLE /s///p' ../../$tc)
+ descr=$(sed -n '/TC_TITLE /s///p' $testdir/$tc)
printheader $numtests $tc "$descr"
- ( . ../../$tc ) >out 2>err
+ ( . $testdir/$tc ) >out 2>err
retcode=$?
numtests=$(( $numtests + 1 ))
cd $workdir
@@ -123,9 +124,10 @@ do
echo "OK"
rm -rf $dirname
fi
+ rm templog
done
-cd $testdir
+cd $topworkdir
if [ $numfail -ne 0 ]; then
echo >&2 "# $numfail out of $numtests tests failed"

Return to:

Send suggestions and report system problems to the System administrator.