From 99d73258a97ba52262236c9cc84d5c675ed9a72c Mon Sep 17 00:00:00 2001 From: Jan Kneschke Date: Wed, 12 Aug 2009 21:25:58 +0200 Subject: [PATCH] added a few more missing files --- Makefile.am | 5 +- autogen.sh | 103 ++++++++++++++++++++++++++++++---- configure.ac | 136 +++++++++++++++++++++++++++++++++++++-------- src/Makefile.am | 22 +++----- src/os/Makefile.am | 12 +++- 5 files changed, 229 insertions(+), 49 deletions(-) diff --git a/Makefile.am b/Makefile.am index 865e8f95..ead17433 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,2 +1,5 @@ -SUBDIRS = src examples +SUBDIRS = include src bindings examples tests +EXTRA_DIST=\ + CMakeLists.txt \ + winbuild.bat diff --git a/autogen.sh b/autogen.sh index a46b735d..e9688bf3 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,15 +1,96 @@ #!/bin/sh -set -x +# Run this to generate all the initial makefiles, etc. -touch INSTALL NEWS AUTHORS -libtoolize="libtoolize" -if which glibtoolize >/dev/null 2>&1 -then - libtoolize=glibtoolize +# LIBTOOLIZE=${LIBTOOLIZE:-libtoolize} +LIBTOOLIZE_FLAGS="--copy --force" +# ACLOCAL=${ACLOCAL:-aclocal} +# AUTOHEADER=${AUTOHEADER:-autoheader} +# AUTOMAKE=${AUTOMAKE:-automake} +AUTOMAKE_FLAGS="--add-missing --copy" +# AUTOCONF=${AUTOCONF:-autoconf} + +ARGV0=$0 +ARGS="$@" + + +run() { + echo "$ARGV0: running \`$@' $ARGS" + $@ $ARGS +} + +## jump out if one of the programs returns 'false' +set -e + +## on macosx glibtoolize, others have libtool +if test x$LIBTOOLIZE = x; then + if test \! "x`which glibtoolize 2> /dev/null | grep -v '^no'`" = x; then + LIBTOOLIZE=glibtoolize + elif test \! "x`which libtoolize-1.5 2> /dev/null | grep -v '^no'`" = x; then + LIBTOOLIZE=libtoolize-1.5 + elif test \! "x`which libtoolize 2> /dev/null | grep -v '^no'`" = x; then + LIBTOOLIZE=libtoolize + else + echo "libtoolize 1.5.x wasn't found, exiting"; exit 0 + fi fi -autoheader \ -&& aclocal \ -&& $libtoolize --copy --force \ -&& automake --add-missing --copy \ -&& autoconf +## suse has aclocal and aclocal-1.9 +if test x$ACLOCAL = x; then + if test \! "x`which aclocal-1.9 2> /dev/null | grep -v '^no'`" = x; then + ACLOCAL=aclocal-1.9 + elif test \! "x`which aclocal19 2> /dev/null | grep -v '^no'`" = x; then + ACLOCAL=aclocal19 + elif test \! "x`which aclocal 2> /dev/null | grep -v '^no'`" = x; then + ACLOCAL=aclocal + else + echo "automake 1.9.x (aclocal) wasn't found, exiting"; exit 0 + fi +fi + +if test x$AUTOMAKE = x; then + if test \! "x`which automake-1.9 2> /dev/null | grep -v '^no'`" = x; then + AUTOMAKE=automake-1.9 + elif test \! "x`which automake19 2> /dev/null | grep -v '^no'`" = x; then + AUTOMAKE=automake19 + elif test \! "x`which automake 2> /dev/null | grep -v '^no'`" = x; then + AUTOMAKE=automake + else + echo "automake 1.9.x wasn't found, exiting"; exit 0 + fi +fi + + +## macosx has autoconf-2.59 and autoconf-2.60 +if test x$AUTOCONF = x; then + if test \! "x`which autoconf-2.59 2> /dev/null | grep -v '^no'`" = x; then + AUTOCONF=autoconf-2.59 + elif test \! "x`which autoconf259 2> /dev/null | grep -v '^no'`" = x; then + AUTOCONF=autoconf259 + elif test \! "x`which autoconf 2> /dev/null | grep -v '^no'`" = x; then + AUTOCONF=autoconf + else + echo "autoconf 2.59+ wasn't found, exiting"; exit 0 + fi +fi + +if test x$AUTOHEADER = x; then + if test \! "x`which autoheader-2.59 2> /dev/null | grep -v '^no'`" = x; then + AUTOHEADER=autoheader-2.59 + elif test \! "x`which autoheader259 2> /dev/null | grep -v '^no'`" = x; then + AUTOHEADER=autoheader259 + elif test \! "x`which autoheader 2> /dev/null | grep -v '^no'`" = x; then + AUTOHEADER=autoheader + else + echo "autoconf 2.59+ (autoheader) wasn't found, exiting"; exit 0 + fi +fi + + +run $LIBTOOLIZE $LIBTOOLIZE_FLAGS +run $ACLOCAL $ACLOCAL_FLAGS +# we don't need autoheader as we don't have a config.h +# run $AUTOHEADER +run $AUTOMAKE $AUTOMAKE_FLAGS +run $AUTOCONF +test "$ARGS" = "" && echo "Now type './configure --enable-maintainer-mode ...' and 'make' to compile." + diff --git a/configure.ac b/configure.ac index 42613400..0c6424a4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,9 +1,21 @@ +dnl ... hmm ... we have to duplicate the data below again AC_INIT(libsigar, 1.6.2) AC_CONFIG_SRCDIR(src/sigar.c) -AC_CONFIG_HEADERS(src/config.h) -AM_INIT_AUTOMAKE +dnl AC_CONFIG_HEADERS(src/config.h) +AM_INIT_AUTOMAKE([foreign]) AC_CANONICAL_HOST +dnl for sigar_version_autoconf.c.in +VERSION_MAJOR=1 +VERSION_MINOR=6 +VERSION_MAINT=2 +VERSION_BUILD=0 + +AC_SUBST(VERSION_MAJOR) +AC_SUBST(VERSION_MINOR) +AC_SUBST(VERSION_MAINT) +AC_SUBST(VERSION_BUILD) + AC_PROG_CC AC_PROG_LN_S AC_PROG_INSTALL @@ -11,57 +23,137 @@ AC_PROG_MAKE_SET AC_PROG_LIBTOOL AC_MSG_CHECKING([for os type ($host_os)]) +FRAMEWORK= case $host_os in *aix*) SRC_OS="aix" + AC_DEFINE(SIGAR_TEST_OS_AIX, [1], [for the tests]) + LIBS="-lodm -lcfg -lperfstat -lpthreads" ;; *darwin*) SRC_OS="darwin" - ;; - *freebsd*) - SRC_OS="darwin" - LIBS="-lkvm" - ;; - *hpux*) - SRC_OS="hpux" - ;; - *linux*) - SRC_OS="linux" - ;; - *openbsd*) - SRC_OS="darwin" - LIBS="-lkvm" + AC_DEFINE(DARWIN,[],[running on MacOS X]) + AC_DEFINE(SIGAR_TEST_OS_DARWIN, [1], [for the tests]) + SIGAR_INCLUDES="-I /Developer/Headers/FlatCarbon/" + SIGAR_LIBS="-framework IOKit -framework CoreServices" ;; *netbsd*) SRC_OS="darwin" - LIBS="-lkvm" + AC_DEFINE(SIGAR_TEST_OS_DARWIN, [1], [for the tests]) + SIGAR_LIBS="-lkvm" + ;; + *openbsd*) + SRC_OS="darwin" + AC_DEFINE(SIGAR_TEST_OS_DARWIN, [1], [for the tests]) + SIGAR_LIBS="-lkvm" + ;; + *freebsd*) + SRC_OS="darwin" + AC_DEFINE(SIGAR_TEST_OS_DARWIN, [1], [for the tests]) + SIGAR_LIBS="-lkvm" + ;; + *hpux*) + AC_DEFINE(SIGAR_HPUX,[],[running on HPUX]) + SRC_OS="hpux" + AC_DEFINE(SIGAR_TEST_OS_HPUX, [1], [for the tests]) + SIGAR_LIBS="-lnm -lnsl" + ;; + *linux*) + SRC_OS="linux" + AC_DEFINE(SIGAR_TEST_OS_LINUX, [1], [for the tests]) ;; *solaris*) + AC_DEFINE(SOLARIS,[],[running on Solaris]) SRC_OS="solaris" - LIBS="-lkstat -lsocket" + AC_DEFINE(SIGAR_TEST_OS_SOLARIS, [1], [for the tests]) + SIGAR_LIBS="-lkstat -lsocket" ;; *) ac_system="unknown" esac -AC_MSG_RESULT([$ac_system]) AC_MSG_RESULT([$SRC_OS]) -INCLUDES="-I\$(top_builddir)/include -I\$(srcdir)/os/$SRC_OS" +AC_CHECK_HEADERS(libproc.h valgrind/valgrind.h) +if test $ac_cv_header_libproc_h = yes; then + AC_DEFINE(DARWIN_HAS_LIBPROC_H, [1], [sigar named them DARWIN_HAS_... instead of HAVE_]) +fi + +INCLUDES="-I\$(top_srcdir)/include -I\$(top_srcdir)/src/os/$SRC_OS $SIGAR_INCLUDES" AC_SUBST(SRC_OS) AC_SUBST(INCLUDES) -AC_SUBST(LIBS) +AC_SUBST(SIGAR_LIBS) + +AM_CONDITIONAL(OS_WIN32, test x$SRC_OS = xwin32) +AM_CONDITIONAL(OS_MACOSX, test x$SRC_OS = xdarwin) +AM_CONDITIONAL(OS_LINUX, test x$SRC_OS = xlinux) +AM_CONDITIONAL(OS_HPUX, test x$SRC_OS = xhpux) +AM_CONDITIONAL(OS_AIX, test x$SRC_OS = xaix) +AM_CONDITIONAL(OS_SOLARIS, test x$SRC_OS = xsolaris) + +AC_ARG_WITH(valgrind, [AC_HELP_STRING( + [--with-valgrind[=binary]], + [run the tests in valgrind to check for mem-leaks] + )], + [], + [with_valgrind=no]) +AS_IF([test "x$with_valgrind" != xno], + [AS_IF([test "x$with_valgrind" = xyes], + [AC_CHECK_PROG(VALGRIND, valgrind) + AS_IF([test "x$VALGRIND" = x], + [AC_MSG_ERROR("--with-valgrind ... but no valgrind found")]) + ], + [VALGRIND="$with_valgrind" + AC_SUBST(VALGRIND)]) + ]) +AM_CONDITIONAL(USE_VALGRIND, test "x$VALGRIND" != x) + +dnl Check for lua +AC_MSG_CHECKING(if with lua) +AC_ARG_WITH(lua, AC_HELP_STRING([--with-lua],[lua]), +[WITH_LUA=$withval],[WITH_LUA=yes]) + +if test "$WITH_LUA" != "no"; then + AC_MSG_RESULT($WITH_LUA) + # try pkgconfig + if test "$WITH_LUA" = "yes"; then + LUAPC=lua + else + LUAPC=$WITH_LUA + fi + + PKG_CHECK_MODULES(LUA, $LUAPC >= 5.1, [ + AC_DEFINE([HAVE_LUA], [1], [liblua]) + AC_DEFINE([HAVE_LUA_H], [1], [lua.h]) + ],[ + PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1, [ + AC_DEFINE([HAVE_LUA], [1], [liblua]) + AC_DEFINE([HAVE_LUA_H], [1], [lua.h]) + ]) + ]) + + AC_SUBST(LUA_CFLAGS) + AC_SUBST(LUA_LIBS) +fi AC_CONFIG_FILES([ Makefile +include/Makefile src/Makefile src/os/Makefile src/os/aix/Makefile src/os/darwin/Makefile -src/os/linux/Makefile +src/os/freebsd/Makefile src/os/hpux/Makefile +src/os/linux/Makefile +src/os/netware/Makefile +src/os/osf1/Makefile src/os/solaris/Makefile +src/os/stub/Makefile +src/os/win32/Makefile examples/Makefile +src/sigar_version_autoconf.c +tests/Makefile ]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index fda8b9d2..b3443789 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,26 +2,15 @@ SUBDIRS = os INCLUDES = @INCLUDES@ -include_HEADERS = \ - $(top_builddir)/include/sigar.h \ - $(top_builddir)/include/sigar_log.h \ - $(top_builddir)/include/sigar_format.h \ - $(top_builddir)/include/sigar_fileinfo.h \ - $(top_builddir)/include/sigar_ptql.h - lib_LTLIBRARIES = libsigar.la -libsigar_la_LDFLAGS = +libsigar_la_LDFLAGS = $(SIGAR_LIBS) libsigar_la_LIBADD = $(top_builddir)/src/os/@SRC_OS@/libsigar_os.la -libsigar_la_CFLAGS = +libsigar_la_CFLAGS = -I$(top_srcdir)/include libsigar_la_SOURCES = \ - $(include_HEADERS) \ - $(top_builddir)/include/sigar_private.h \ - $(top_builddir)/include/sigar_util.h \ - $(top_builddir)/include/sigar_getline.h \ sigar.c \ sigar_cache.c \ sigar_fileinfo.c \ @@ -29,5 +18,10 @@ libsigar_la_SOURCES = \ sigar_getline.c \ sigar_ptql.c \ sigar_signal.c \ - sigar_util.c + sigar_util.c \ + sigar_version_autoconf.c + +EXTRA_DIST=\ + sigar_version.c.in \ + CMakeLists.txt diff --git a/src/os/Makefile.am b/src/os/Makefile.am index ded6dcbf..53363f29 100644 --- a/src/os/Makefile.am +++ b/src/os/Makefile.am @@ -1 +1,11 @@ -SUBDIRS = @SRC_OS@ +SUBDIRS = \ + aix \ + darwin \ + freebsd \ + hpux \ + linux \ + netware \ + osf1 \ + solaris \ + stub \ + win32