aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2014-10-19 08:20:55 +0000
committerMike Frysinger <vapier@gentoo.org>2014-10-19 08:20:55 +0000
commitb2f345ec3336e42899b9ceb2095c45f1fce380c6 (patch)
tree33c03486a487a211e0614ecf43ef29a3da3ebbe6
parentscanelf: do not use debug syms with runtime strings or vice versa (diff)
downloadpax-utils-b2f345ec3336e42899b9ceb2095c45f1fce380c6.tar.gz
pax-utils-b2f345ec3336e42899b9ceb2095c45f1fce380c6.tar.bz2
pax-utils-b2f345ec3336e42899b9ceb2095c45f1fce380c6.zip
add autotools support
URL: https://bugs.gentoo.org/413967
-rw-r--r--.cvsignore47
-rw-r--r--.gitignore38
-rw-r--r--Makefile39
-rw-r--r--Makefile.am72
-rwxr-xr-xautogen.sh53
-rw-r--r--configure.ac46
-rw-r--r--porting.h6
-rwxr-xr-xtests/source/dotest22
8 files changed, 293 insertions, 30 deletions
diff --git a/.cvsignore b/.cvsignore
index 58ae857..a121e02 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -1,14 +1,43 @@
-.cvsignore
+*bz2
+*~
+*.[adio]
+*.l[ao]
+*.gdb
+*.pyc
+*.deps
+*.libs
+
+*.patch
+*.orig
+*.rej
+*.diff
+pax-utils-*
+contrib
+
+a.out*
+lib*.so*
+core
+.gdb_history
+.gdbinit
+
+aclocal.m4
+autom4te.cache
+build
+config.cache
+config.h
+config.h.in
+config.log
+config.status
+configure
+autotools
+libtool
+Makefile.in
+stamp-h1
+
dumpelf
pspax
scanelf
scanmacho
-*.x
-pax-utils-*.tar.*
-.gdb_history
-.gdbinit
+
.git
-.gitignore
-a.out
-*.gdb
-*.pyc
+*.x
diff --git a/.gitignore b/.gitignore
index c2444f6..394adca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,24 +1,44 @@
-*.o
+*bz2
+*~
+*.[adio]
+*.l[ao]
*.gdb
*.pyc
+*.deps
+*.libs
-a.out
-core
-
-*.diff
*.patch
*.orig
*.rej
+*.diff
+/pax-utils-*
+contrib
+
+a.out*
+lib*.so*
+core
+.gdb_history
+.gdbinit
+
+aclocal.m4
+autom4te.cache
+build
+config.cache
+config.h
+config.h.in
+config.log
+config.status
+configure
+autotools
+libtool
+Makefile.in
+stamp-h1
/dumpelf
/pspax
/scanelf
/scanmacho
-/pax-utils-*.tar.*
/man/*.1
-.gdb_history
-.gdbinit
-
CVS
diff --git a/Makefile b/Makefile
index f80c06d..a065163 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
# Copyright 2003-2006 Ned Ludd <solar@linbsd.net>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/Makefile,v 1.84 2014/08/01 01:39:20 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/Makefile,v 1.85 2014/10/19 08:20:55 vapier Exp $
####################################################################
check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
@@ -131,11 +131,19 @@ dist:
cd $(P) && cvs up
echo "<releaseinfo>$(PV)</releaseinfo>" > $(P)/man/fragment/version
$(MAKE) -C $(P)/man
+ sed -i '/AC_INIT/s:git:$(PV):' $(P)/configure.ac
+ $(MAKE) -C $(P) autotools
tar cf - $(P) --exclude=CVS --exclude=.cvsignore | xz > $(P).tar.xz
@printf "\n ..... Making sure clean cvs build works ..... \n\n"
+ set -e; \
unset CFLAGS; \
- for t in all check clean debug check ; do \
- $(MAKE) -C $(P) $$t || exit $$? ; \
+ for t in all check clean debug check clean; do \
+ $(MAKE) -C $(P) $$t; \
+ done; \
+ cd $(P); \
+ ./configure -C; \
+ for t in all check; do \
+ $(MAKE) $$t; \
done
rm -rf $(P)
du -b $(P).tar.xz
@@ -146,3 +154,28 @@ check test:
$(MAKE) -C tests
.PHONY: all check clean dist install test
+
+#
+# All logic related to autotools is below here
+#
+GEN_MARK_START = \# @@@ GEN START @@@ \#
+GEN_MARK_END = \# @@@ GEN START @@@ \#
+EXTRA_DIST = \
+ $(shell find '(' -name CVS -prune ')' -o '(' -type f -print ')')
+MAKE_MULTI_LINES = $(patsubst %,\\\\\n\t%,$(sort $(1)))
+# 2nd level of indirection here is so the $(find) doesn't pick up
+# files in EXTRA_DIST that get cleaned up ...
+autotools-update: clean
+ $(MAKE) _autotools-update
+_autotools-update:
+ sed -i '/^$(GEN_MARK_START)$$/,/^$(GEN_MARK_END)$$/d' Makefile.am
+ printf '%s\ndist_man_MANS += %b\nEXTRA_DIST += %b\n%s\n' \
+ "$(GEN_MARK_START)" \
+ "$(call MAKE_MULTI_LINES,$(wildcard man/*.1))" \
+ "$(call MAKE_MULTI_LINES,$(EXTRA_DIST))" \
+ "$(GEN_MARK_END)" \
+ >> Makefile.am
+autotools: autotools-update
+ ./autogen.sh --from=make
+
+.PHONY: autotools autotools-update _autotools-update
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..f39bbde
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,72 @@
+ACLOCAL_AMFLAGS = -I autotools/m4
+
+SUBDIRS = autotools/gnulib
+
+AM_CPPFLAGS = \
+ -I$(top_builddir)/autotools/gnulib \
+ -I$(top_srcdir)/autotools/gnulib
+
+noinst_LTLIBRARIES = libpaxutils.la
+libpaxutils_la_LDFLAGS = -no-undefined
+libpaxutils_la_SOURCES = \
+ paxelf.c \
+ paxinc.c \
+ paxmacho.c \
+ xfuncs.c
+LDADD = libpaxutils.la
+
+bin_PROGRAMS = scanelf dumpelf pspax scanmacho
+
+install-exec-hook:
+ cd $(DESTDIR)$(bindir); \
+ for applet in $(APPLETS) ; do \
+ [ ! -e "$$applet" ] && ln -s q $${applet} ; \
+ done
+
+TMAKE = \
+ $(MAKE) -C $(abs_top_srcdir)/tests \
+ AUTOTOOLS=true \
+ abs_top_builddir="$(abs_top_builddir)" \
+ abs_top_srcdir="$(abs_top_srcdir)"
+check-hook:
+ $(TMAKE) check
+clean-local:
+ $(TMAKE) clean
+ -rmdir tests/*/ tests/
+ rm -f $(APPLETS)
+check: check-hook
+
+# Start off with base values which we append below
+dist_man_MANS =
+APPLETS =
+EXTRA_DIST = autotools/m4/gnulib-cache.m4
+
+# @@@ GEN START @@@ #
+dist_man_MANS +=
+EXTRA_DIST += \
+ tests/CVS/Entries \
+ tests/CVS/Repository \
+ tests/CVS/Root \
+ tests/Makefile \
+ tests/lddtree/CVS/Entries \
+ tests/lddtree/CVS/Repository \
+ tests/lddtree/CVS/Root \
+ tests/lddtree/Makefile \
+ tests/lddtree/dotest.cmp \
+ tests/lddtree/dotest.py \
+ tests/lddtree/dotest.sfx \
+ tests/lddtree/dotest.sh \
+ tests/lib.sh \
+ tests/scanelf/CVS/Entries \
+ tests/scanelf/CVS/Repository \
+ tests/scanelf/CVS/Root \
+ tests/scanelf/Makefile \
+ tests/scanelf/dotest \
+ tests/scanelf/scanelf.simple.good \
+ tests/source/CVS/Entries \
+ tests/source/CVS/Repository \
+ tests/source/CVS/Root \
+ tests/source/Makefile \
+ tests/source/dotest \
+ tests/source/space
+# @@@ GEN START @@@ #
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..622ab16
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,53 @@
+#!/bin/bash -e
+
+v() { echo "$@"; "$@"; }
+
+m4dir="autotools/m4"
+
+v rm -rf autotools
+if [[ $1 != "--from=make" ]] ; then
+ v ${MAKE:-make} autotools-update
+fi
+
+# reload the gnulib code if possible
+PATH=/usr/local/src/gnu/gnulib:${PATH}
+mods="
+ alloca
+ faccessat
+ fdopendir
+ fstatat
+ futimens
+ getline
+ getopt-posix
+ mkdirat
+ openat
+ progname
+ readlinkat
+ renameat
+ stat-time
+ strcasestr-simple
+ strncat
+ symlinkat
+ sys_stat
+ unlinkat
+ utimensat
+ vasprintf-posix
+"
+v gnulib-tool \
+ --source-base=autotools/gnulib --m4-base=autotools/m4 \
+ --import \
+ ${mods}
+
+# not everyone has sys-devel/autoconf-archive installed
+for macro in $(grep -o '\<AX[A-Z_]*\>' configure.ac | sort -u) ; do
+ if m4=$(grep -rl "\[${macro}\]" /usr/share/aclocal/) ; then
+ v cp $m4 ${m4dir}/
+ fi
+done
+
+export AUTOMAKE="automake --foreign"
+v autoreconf -i -f
+
+if [[ -x ./test.sh ]] ; then
+ exec ./test.sh "$@"
+fi
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..c241f71
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,46 @@
+AC_PREREQ([2.65])
+AC_INIT([pax-utils], [git])
+AC_CONFIG_AUX_DIR([autotools])
+AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip silent-rules -Wall])
+AM_SILENT_RULES([yes]) # AM_INIT_AUTOMAKE([silent-rules]) is broken atm
+AC_CONFIG_HEADER([config.h])
+AC_CONFIG_MACRO_DIR([autotools/m4])
+
+AC_PROG_CC_C99
+AM_PROG_CC_C_O
+AM_PROG_AR
+AC_USE_SYSTEM_EXTENSIONS
+LT_INIT
+
+gl_EARLY
+gl_INIT
+
+AX_CFLAGS_WARN_ALL
+AC_DEFUN([PT_CHECK_CFLAG],[AX_CHECK_COMPILER_FLAGS([$1],[CFLAGS="$CFLAGS $1"])])
+m4_foreach_w([flag], [
+ -Wunused
+ -Wimplicit
+ -Wshadow
+ -Wformat=2
+ -Wmissing-declarations
+ -Wno-missing-prototypes
+ -Wwrite-strings
+ -Wbad-function-cast
+ -Wnested-externs
+ -Wcomment
+ -Winline
+ -Wchar-subscripts
+ -Wcast-align
+ -Wno-format-nonliteral
+ -Wsequence-point
+ -Wold-style-definition
+ -Wextra
+], [
+ AX_CHECK_COMPILE_FLAG(flag, AS_VAR_APPEND([CFLAGS], " flag"))
+])
+
+AC_CONFIG_FILES([
+ Makefile
+ autotools/gnulib/Makefile
+])
+AC_OUTPUT
diff --git a/porting.h b/porting.h
index f10717f..fcf5ced 100644
--- a/porting.h
+++ b/porting.h
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2012 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/porting.h,v 1.45 2014/01/11 00:29:11 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/porting.h,v 1.46 2014/10/19 08:20:55 vapier Exp $
*
* Copyright 2005-2012 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2012 Mike Frysinger - <vapier@gentoo.org>
@@ -12,6 +12,10 @@
#ifndef _PORTING_H
#define _PORTING_H
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*arr))
#undef __PAX_UTILS_CLEANUP
diff --git a/tests/source/dotest b/tests/source/dotest
index 241c021..b7b3567 100755
--- a/tests/source/dotest
+++ b/tests/source/dotest
@@ -2,11 +2,17 @@
. "${0%/*}"/../lib.sh
+findfiles() {
+ find "${top_srcdir}" \
+ '(' -type d -a '(' -name CVS -o -name .git -o -name autotools ')' -prune ')' \
+ -o '(' '(' -name '*.[ch]' -a ! -name 'config.h' ')' -print0 ')'
+}
+
#
# check for misc common typos
#
find "${top_srcdir}" \
- '(' -type d -a '(' -name CVS -o -name tests ')' -prune ')' \
+ '(' -type d -a '(' -name CVS -o -name .git -o -name tests ')' -prune ')' \
-o '(' -type f -a -print0 ')' | xargs -0 \
grep -n -I \
-e '\<compatability\>' \
@@ -34,7 +40,7 @@ testit src.typos
#
# don't allow obsolete functions
#
-find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
+findfiles | xargs -0 \
grep -n -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utimes)\>[[:space:]]*\(' \
| sed -e "s:^\.\./\.\./::g" > src.obsolete.funcs
testit src.obsolete.funcs
@@ -44,7 +50,7 @@ testit src.obsolete.funcs
#
# make sure people use our constants
#
-find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
+findfiles | xargs -0 \
grep -n -E -e '\<PATH_MAX\>' | grep -v __PAX_UTILS_PATH_MAX \
| sed -e "s:^\.\./\.\./::g" > src.bad.constants
testit src.bad.constants
@@ -54,7 +60,7 @@ testit src.bad.constants
#
# don't allow obsolete headers
#
-find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
+findfiles | xargs -0 \
grep -n -E -e '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' \
| sed -e "s:^\.\./\.\./::g" > src.obsolete.headers
testit src.obsolete.headers
@@ -66,7 +72,7 @@ testit src.obsolete.headers
#
xfuncs=$(printf '%s|' $(sed -n 's:.*x\([^(]*\)(.*:\1:p' "${top_srcdir}"/xfuncs.h))
xfuncs=${xfuncs:0:${#xfuncs}-1}
-find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
+findfiles | xargs -0 \
grep -n -E -e "\<(${xfuncs})[[:space:]]*\(" \
| grep -v xfuncs.c \
| sed -e "s:^\.\./\.\./::g" > src.use.xfuncs
@@ -77,7 +83,7 @@ testit src.use.xfuncs
#
# check for style
#
-find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
+findfiles | xargs -0 \
grep -n -E \
-e '\<(for|if|switch|while)\(' \
-e '\<(for|if|switch|while) \( ' \
@@ -93,7 +99,7 @@ testit src.style
#
# Auto clean up the space issues
#
-for x in $(find ../.. '(' -name '*.c' -o -name '*.h' ')' ); do
+while read -d'\0' x; do
case ${x} in
*/elf.h) continue ;; # Not our files
esac
@@ -103,7 +109,7 @@ for x in $(find ../.. '(' -name '*.c' -o -name '*.h' ')' ); do
else
rm -f "$x~"
fi
-done > src.space
+done > src.space < <(findfiles)
testit src.space