summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@gmail.com>2009-02-17 10:48:47 +0000
committerDamien Lespiau <damien.lespiau@gmail.com>2009-02-18 12:19:07 +0000
commit11c87f5814982a0daf47ce4dfcab65853555f555 (patch)
tree241710a62dbe5105b5b909c8e760eb0bbafa464f
First import
Signed-off-by: Damien Lespiau <damien.lespiau@gmail.com>
-rw-r--r--.gitignore23
-rw-r--r--README6
-rw-r--r--shave/.gitignore7
-rw-r--r--shave/shave-libtool.in70
-rw-r--r--shave/shave.in70
-rw-r--r--shave/shave.m436
-rw-r--r--test-flat-lt/.gitignore1
-rw-r--r--test-flat-lt/Makefile.am9
-rw-r--r--test-flat-lt/configure.ac9
-rw-r--r--test-flat-lt/lib-file0.c6
-rw-r--r--test-flat-lt/lib-file0.h1
-rw-r--r--test-flat-lt/lib-file1.c6
-rw-r--r--test-flat-lt/lib-file1.h1
-rw-r--r--test-flat-lt/tool0.c9
-rw-r--r--test-flat-nolt/Makefile.am6
-rw-r--r--test-flat-nolt/configure.ac6
-rw-r--r--test-flat-nolt/no-libtool.c8
-rw-r--r--test/.gitignore1
-rw-r--r--test/Makefile.am3
-rw-r--r--test/configure.ac16
-rw-r--r--test/foo/Makefile.am6
-rw-r--r--test/foo/internal/Makefile.am3
-rw-r--r--test/foo/internal/internal-file0.c11
-rw-r--r--test/foo/internal/internal-file0.h1
-rw-r--r--test/foo/lib-file0.c6
-rw-r--r--test/foo/lib-file0.h1
-rw-r--r--test/foo/lib-file1.c6
-rw-r--r--test/foo/lib-file1.h1
-rw-r--r--test/tools/Makefile.am5
-rw-r--r--test/tools/tool0.c9
30 files changed, 343 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..747bb5c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,23 @@
+.deps
+.libs/
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+libtool
+ltmain.sh
+missing
+stamp-*
+*.o
+*.lo
+*.la
+.*.sw?
diff --git a/README b/README
new file mode 100644
index 0000000..deda930
--- /dev/null
+++ b/README
@@ -0,0 +1,6 @@
+shave transforms the messy ouput of autotools into a pretty Kbuild-like one.
+
+shave : the actual thing
+test-flat-nolt: flat layout, no use of litool (broken!)
+test-flat-lt : flat layout, use of libtool
+test-lt : common layout, libtooled, with noinst libs
diff --git a/shave/.gitignore b/shave/.gitignore
new file mode 100644
index 0000000..67fa56e
--- /dev/null
+++ b/shave/.gitignore
@@ -0,0 +1,7 @@
+libtool.m4
+ltoptions.m4
+ltsugar.m4
+ltversion.m4
+lt~obsolete.m4
+shave-libtool
+shave
diff --git a/shave/shave-libtool.in b/shave/shave-libtool.in
new file mode 100644
index 0000000..02de5ad
--- /dev/null
+++ b/shave/shave-libtool.in
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+# we need sed
+SED=@SED@
+if test -z "$SED" ; then
+SED=sed
+fi
+Xsed="$SED -e s/^X//"
+
+lt_unmangle ()
+{
+ last_result=`echo -n X$1 | $Xsed -e 's#.libs/##' -e 's#[^0-9a-zA-Z_]\+_la##'`
+}
+
+# the real libtool to use
+LIBTOOL="$1"
+shift
+
+# if 1, don't print anything, the underlaying wrapper will do it
+pass_though=0
+
+# scan the arguments, keep the right ones for libtool, and discover the mode
+preserved_args=
+while test "$#" -gt 0; do
+ opt="$1"
+ shift
+
+ case $opt in
+ --mode=*)
+ mode=`echo "X$opt" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'`
+ preserved_args="$preserved_args $opt"
+ ;;
+ -o)
+ lt_output="$1"
+ preserved_args="$preserved_args $opt"
+ ;;
+ *)
+ preserved_args="$preserved_args $opt"
+ ;;
+ esac
+done
+
+case "$mode" in
+compile)
+ # shave will be called and print the actual CC/CXX/LINK line
+ preserved_args="$preserved_args --shave-mode=$mode"
+ pass_though=1
+ ;;
+link)
+ preserved_args="$preserved_args --shave-mode=$mode"
+ Q=" LINK "
+ ;;
+*)
+ # let's u
+ # echo "*** libtool: Unimplemented mode: $mode, fill a bug report"
+ ;;
+esac
+
+lt_unmangle "$lt_output"
+output=$last_result
+
+if test -z $V; then
+ if test $pass_though -eq 0; then
+ echo "$Q$output"
+ fi
+ $LIBTOOL --silent $preserved_args
+else
+ echo $LIBTOOL $preserved_args
+ $LIBTOOL $preserved_args
+fi
diff --git a/shave/shave.in b/shave/shave.in
new file mode 100644
index 0000000..c989989
--- /dev/null
+++ b/shave/shave.in
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+# we need sed
+SED=@SED@
+if test -z "$SED" ; then
+SED=sed
+fi
+Xsed="$SED -e s/^X//"
+
+lt_unmangle ()
+{
+ last_result=`echo -n X$1 | $Xsed -e 's#.libs/##' -e 's#[^0-9a-zA-Z_]\+_la##'`
+}
+
+# the tool to wrap (cc, cxx, ar, ranlib, ..)
+tool="$1"
+shift
+
+# the reel tool (to call)
+REEL_TOOL="$1"
+shift
+
+pass_through=0
+preserved_args=
+while test "$#" -gt 0; do
+ opt="$1"
+ shift
+
+ case $opt in
+ --shave-mode=*)
+ mode=`echo "X$opt" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'`
+ ;;
+ -o)
+ lt_output="$1"
+ preserved_args="$preserved_args $opt"
+ ;;
+ *)
+ preserved_args="$preserved_args $opt"
+ ;;
+ esac
+done
+
+# mode=link is handled in the libtool wrapper
+case "$mode" in
+compile)
+ Q=" CC "
+ ;;
+link)
+ pass_through=1
+ ;;
+*)
+ # no "libtool" mode has been given, we are called by the Makefile:
+ # -> assume compilation
+ mode=compile
+ Q=" CC "
+ ;;
+esac
+
+lt_unmangle "$lt_output"
+output=$last_result
+
+if test -z $V; then
+ if test $pass_through -eq 0; then
+ echo "$Q$output"
+ fi
+ $REEL_TOOL $preserved_args
+else
+ echo $REEL_TOOL $preserved_args
+ $REEL_TOOL $preserved_args
+fi
diff --git a/shave/shave.m4 b/shave/shave.m4
new file mode 100644
index 0000000..b5835f9
--- /dev/null
+++ b/shave/shave.m4
@@ -0,0 +1,36 @@
+dnl Make automake/libtool output more friendly to humans
+dnl
+dnl SHAVE_INIT([shavedir])
+dnl
+dnl shavedir: the directory where the shave script is, it defaults to
+dnl $(top_builddir)
+dnl
+dnl * SHAVE_INIT should be called late in your configure.(ac|in) file (just
+dnl before AC_CONFIG_FILE/AC_OUTPUT is perfect. This macro rewrite CC and
+dnl LIBTOOL, you don't want the configure tests to have these variables
+dnl re-defined.
+dnl * This macro requires GNU make's -s option.
+
+AC_DEFUN([SHAVE_INIT], [
+dnl where can we find the shave scripts?
+m4_if([$1],,
+ [shavedir='$(top_builddir)'],
+ [shavedir='$(top_builddir)'/$1])
+AC_SUBST(shavedir)
+dnl make is now quiet
+AC_SUBST([MAKEFLAGS], [-s])
+AC_SUBST([AM_MAKEFLAGS], ['`test -z $V && echo -s`'])
+dnl we need sed
+AC_CHECK_PROG(SED,sed,sed,false)
+dnl substitute libtool
+SHAVE_SAVED_LIBTOOL=$LIBTOOL
+AC_SUBST(SHAVE_SAVED_LIBTOOL)
+LIBTOOL='$(SHELL) $(shavedir)/shave-libtool "$(SHAVE_SAVED_LIBTOOL)"'
+AC_SUBST(LIBTOOL)
+dnl substitute cc
+SHAVE_SAVED_CC=$CC
+AC_SUBST(SHAVE_SAVED_CC)
+CC='$(SHELL) $(shavedir)/shave cc "$(SHAVE_SAVED_CC)"'
+AC_SUBST(CC)
+])
+
diff --git a/test-flat-lt/.gitignore b/test-flat-lt/.gitignore
new file mode 100644
index 0000000..02362c7
--- /dev/null
+++ b/test-flat-lt/.gitignore
@@ -0,0 +1 @@
+tool0
diff --git a/test-flat-lt/Makefile.am b/test-flat-lt/Makefile.am
new file mode 100644
index 0000000..cd064b1
--- /dev/null
+++ b/test-flat-lt/Makefile.am
@@ -0,0 +1,9 @@
+ACLOCAL_AMFLAGS = -I ../shave
+
+lib_LTLIBRARIES = libfoo.la
+bin_PROGRAMS = tool0
+
+libfoo_la_SOURCES = lib-file0.c lib.file0.h lib-file1.c lib-file1.h
+
+tool0_SOURCES = tool0.c
+tool0_LDADD = $(top_builddir)/libfoo.la
diff --git a/test-flat-lt/configure.ac b/test-flat-lt/configure.ac
new file mode 100644
index 0000000..2199a83
--- /dev/null
+++ b/test-flat-lt/configure.ac
@@ -0,0 +1,9 @@
+AC_INIT([testflat], [1.0], [damien.lespiauAgmailDcom])
+AM_INIT_AUTOMAKE([foreign])
+AC_CONFIG_MACRO_DIR([../shave])
+AC_CONFIG_HEADERS([config.h])
+AC_PROG_LIBTOOL
+AC_PROG_CC
+SHAVE_INIT([../shave])
+AC_CONFIG_FILES([Makefile ../shave/shave ../shave/shave-libtool])
+AC_OUTPUT
diff --git a/test-flat-lt/lib-file0.c b/test-flat-lt/lib-file0.c
new file mode 100644
index 0000000..6ec81e2
--- /dev/null
+++ b/test-flat-lt/lib-file0.c
@@ -0,0 +1,6 @@
+#include "lib-file0.h"
+
+int ns_add(const int a, const int b)
+{
+ return a + b;
+}
diff --git a/test-flat-lt/lib-file0.h b/test-flat-lt/lib-file0.h
new file mode 100644
index 0000000..2893a94
--- /dev/null
+++ b/test-flat-lt/lib-file0.h
@@ -0,0 +1 @@
+int ns_add(const int a, const int b);
diff --git a/test-flat-lt/lib-file1.c b/test-flat-lt/lib-file1.c
new file mode 100644
index 0000000..61eb437
--- /dev/null
+++ b/test-flat-lt/lib-file1.c
@@ -0,0 +1,6 @@
+#include "lib-file1.h"
+
+int ns_sub(const int a, const int b)
+{
+ return a - b;
+}
diff --git a/test-flat-lt/lib-file1.h b/test-flat-lt/lib-file1.h
new file mode 100644
index 0000000..98922c2
--- /dev/null
+++ b/test-flat-lt/lib-file1.h
@@ -0,0 +1 @@
+int ns_sub(const int a, const int b);
diff --git a/test-flat-lt/tool0.c b/test-flat-lt/tool0.c
new file mode 100644
index 0000000..f616154
--- /dev/null
+++ b/test-flat-lt/tool0.c
@@ -0,0 +1,9 @@
+
+#include <lib-file0.h>
+#include <lib-file1.h>
+
+int main(int argc, char **argv)
+{
+ return ns_add(1, 2);
+}
+
diff --git a/test-flat-nolt/Makefile.am b/test-flat-nolt/Makefile.am
new file mode 100644
index 0000000..51871de
--- /dev/null
+++ b/test-flat-nolt/Makefile.am
@@ -0,0 +1,6 @@
+ACLOCAL_AMFLAGS = -I ../shave
+
+bin_PROGRAMS = no-libtool
+
+no_libtool = no-libtool.c
+
diff --git a/test-flat-nolt/configure.ac b/test-flat-nolt/configure.ac
new file mode 100644
index 0000000..fcea7e0
--- /dev/null
+++ b/test-flat-nolt/configure.ac
@@ -0,0 +1,6 @@
+AC_INIT([testflat], [1.0], [damien.lespiauAgmailDcom])
+AM_INIT_AUTOMAKE([foreign])
+AC_PROG_CC
+SHAVE_INIT([../shave])
+AC_CONFIG_FILES([Makefile ../shave/shave-cc])
+AC_OUTPUT
diff --git a/test-flat-nolt/no-libtool.c b/test-flat-nolt/no-libtool.c
new file mode 100644
index 0000000..a9d62cc
--- /dev/null
+++ b/test-flat-nolt/no-libtool.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ printf("No libtool needed to compile this program!\n");
+ return 0;
+}
+
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 0000000..02362c7
--- /dev/null
+++ b/test/.gitignore
@@ -0,0 +1 @@
+tool0
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..29250cc
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,3 @@
+ACLOCAL_AMFLAGS = -I ../shave
+
+SUBDIRS = foo tools
diff --git a/test/configure.ac b/test/configure.ac
new file mode 100644
index 0000000..c58762b
--- /dev/null
+++ b/test/configure.ac
@@ -0,0 +1,16 @@
+AC_INIT([testflat], [1.0], [damien.lespiauAgmailDcom])
+AM_INIT_AUTOMAKE([foreign])
+AC_CONFIG_MACRO_DIR([../shave])
+AC_CONFIG_HEADERS([config.h])
+AC_PROG_LIBTOOL
+AC_PROG_CC
+SHAVE_INIT([../shave])
+AC_CONFIG_FILES([
+ ../shave/shave
+ ../shave/shave-libtool
+ Makefile
+ tools/Makefile
+ foo/Makefile
+ foo/internal/Makefile
+])
+AC_OUTPUT
diff --git a/test/foo/Makefile.am b/test/foo/Makefile.am
new file mode 100644
index 0000000..df71393
--- /dev/null
+++ b/test/foo/Makefile.am
@@ -0,0 +1,6 @@
+lib_LTLIBRARIES = libfoo.la
+
+SUBDIRS = internal
+
+libfoo_la_SOURCES = lib-file0.c lib.file0.h lib-file1.c lib-file1.h
+libfoo_la_LIBADD = internal/libinternal.la
diff --git a/test/foo/internal/Makefile.am b/test/foo/internal/Makefile.am
new file mode 100644
index 0000000..8e29a2b
--- /dev/null
+++ b/test/foo/internal/Makefile.am
@@ -0,0 +1,3 @@
+noinst_LTLIBRARIES = libinternal.la
+
+libinternal_la_SOURCES = internal-file0.c internal-file0.h
diff --git a/test/foo/internal/internal-file0.c b/test/foo/internal/internal-file0.c
new file mode 100644
index 0000000..a3bf9ad
--- /dev/null
+++ b/test/foo/internal/internal-file0.c
@@ -0,0 +1,11 @@
+
+#include "internal-file0.h"
+
+void ns_yet_another_symbol(void)
+{
+ int i;
+
+ for (i = 0; i < 100;)
+ i++;
+}
+
diff --git a/test/foo/internal/internal-file0.h b/test/foo/internal/internal-file0.h
new file mode 100644
index 0000000..c333b3f
--- /dev/null
+++ b/test/foo/internal/internal-file0.h
@@ -0,0 +1 @@
+void ns_yet_another_symbol(void);
diff --git a/test/foo/lib-file0.c b/test/foo/lib-file0.c
new file mode 100644
index 0000000..6ec81e2
--- /dev/null
+++ b/test/foo/lib-file0.c
@@ -0,0 +1,6 @@
+#include "lib-file0.h"
+
+int ns_add(const int a, const int b)
+{
+ return a + b;
+}
diff --git a/test/foo/lib-file0.h b/test/foo/lib-file0.h
new file mode 100644
index 0000000..2893a94
--- /dev/null
+++ b/test/foo/lib-file0.h
@@ -0,0 +1 @@
+int ns_add(const int a, const int b);
diff --git a/test/foo/lib-file1.c b/test/foo/lib-file1.c
new file mode 100644
index 0000000..61eb437
--- /dev/null
+++ b/test/foo/lib-file1.c
@@ -0,0 +1,6 @@
+#include "lib-file1.h"
+
+int ns_sub(const int a, const int b)
+{
+ return a - b;
+}
diff --git a/test/foo/lib-file1.h b/test/foo/lib-file1.h
new file mode 100644
index 0000000..98922c2
--- /dev/null
+++ b/test/foo/lib-file1.h
@@ -0,0 +1 @@
+int ns_sub(const int a, const int b);
diff --git a/test/tools/Makefile.am b/test/tools/Makefile.am
new file mode 100644
index 0000000..3e0378f
--- /dev/null
+++ b/test/tools/Makefile.am
@@ -0,0 +1,5 @@
+bin_PROGRAMS = tool0
+
+tool0_SOURCES = tool0.c
+tool0_CFLAGS = -I$(top_srcdir)/foo
+tool0_LDADD = $(top_builddir)/foo/libfoo.la
diff --git a/test/tools/tool0.c b/test/tools/tool0.c
new file mode 100644
index 0000000..f616154
--- /dev/null
+++ b/test/tools/tool0.c
@@ -0,0 +1,9 @@
+
+#include <lib-file0.h>
+#include <lib-file1.h>
+
+int main(int argc, char **argv)
+{
+ return ns_add(1, 2);
+}
+