aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaranm@exherbo.org> 2008-01-18 23:42:16 +0000
committerAvatar Ciaran McCreesh <ciaranm@exherbo.org> 2008-01-18 23:42:16 +0000
commitf9710761e84cdfd525d4d463dc3cf946c35d9d60 (patch)
treecba2951cffb745291adffd6da137d0ef4a291ed2
parentcf5ba5870387c1c28880848260a4312fee4f4888 (diff)
downloadannie-f9710761e84cdfd525d4d463dc3cf946c35d9d60.tar.gz
annie-f9710761e84cdfd525d4d463dc3cf946c35d9d60.tar.xz
Might as well use C++ and autotools...
-rw-r--r--AUTHORS0
-rw-r--r--ChangeLog0
-rw-r--r--Makefile11
-rw-r--r--Makefile.am24
-rw-r--r--NEWS0
-rw-r--r--README0
-rwxr-xr-xautogen.bash40
-rw-r--r--configure.ac179
-rw-r--r--src/Makefile.am38
-rw-r--r--src/annie.cc4
-rw-r--r--src/annie.hh7
-rw-r--r--src/kill_everyone_and_reboot.cc (renamed from halt.c)2
-rw-r--r--src/mount_and_fsck.cc9
13 files changed, 302 insertions, 12 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/AUTHORS
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ChangeLog
diff --git a/Makefile b/Makefile
deleted file mode 100644
index ef45702..0000000
--- a/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-all : halt
-
-halt.o : halt.c
- $(CC) $(CFLAGS) -c -std=c99 -W -Wall -D_GNU_SOURCE halt.c -o halt.o
-
-halt : halt.o
- $(CC) $(CFLAGS) -o halt halt.o
-
-clean :
- rm -f *~ halt *.o
-
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..b8b06c6
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,24 @@
+CLEANFILES = *~ done-check gmon.out *.gcov *.gcno *.gcda
+MAINTAINERCLEANFILES = Makefile.in configure config/* aclocal.m4 \
+ config.h config.h.in INSTALL COPYING
+AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip std-options
+EXTRA_DIST = autogen.bash automake-deps-dist-hack.tmp
+SUBDIRS = src
+
+DISTCHECK_CONFIGURE_FLAGS = --enable-visibility
+
+check-local :
+ touch $(top_builddir)/done-check
+
+install-data-local :
+ @[ -f $(top_builddir)/done-check ] || echo || true
+ @[ -f $(top_builddir)/done-check ] || echo "**************************************" || true
+ @[ -f $(top_builddir)/done-check ] || echo "Looks like you didn't run 'make check'" || true
+ @[ -f $(top_builddir)/done-check ] || echo " No cookies for you today. " || true
+ @[ -f $(top_builddir)/done-check ] || echo "**************************************" || true
+ @[ -f $(top_builddir)/done-check ] || echo || true
+
+all-then-check :
+ $(MAKE) all
+ $(MAKE) check
+
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README
diff --git a/autogen.bash b/autogen.bash
new file mode 100755
index 0000000..c64c0fd
--- /dev/null
+++ b/autogen.bash
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+# vim: set sw=4 sts=4 et tw=80 :
+
+if test "xyes" = x"${BASH_VERSION}" ; then
+ echo "This is not bash!"
+ exit 127
+fi
+
+trap 'echo "exiting." ; exit 250' 15
+KILL_PID=$$
+
+run() {
+ echo ">>> $@" 1>&2
+ if ! $@ ; then
+ echo "oops!" 1>&2
+ exit 127
+ fi
+}
+
+get() {
+ local p=${1} v=
+ shift
+
+ for v in ${@} ; do
+ type ${p}-${v} &>/dev/null && echo ${p}-${v} && return
+ type ${p}${v//.} &>/dev/null && echo ${p}${v//.} && return
+ done
+ type ${p} &>/dev/null && echo ${p} && return
+ echo "Could not find ${p}" 1>&2
+ kill $KILL_PID
+}
+
+run mkdir -p config
+run $(get libtoolize 1.5 ) --copy --force --automake
+rm -f config.cache
+run $(get aclocal 1.10 1.9 )
+run $(get autoheader 2.61 2.60 2.59 )
+run $(get autoconf 2.61 2.60 2.59 )
+run $(get automake 1.10 1.9 ) -a --copy
+
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..d7f9593
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,179 @@
+dnl vim: set sw=4 sts=4 ts=4 noet ft=config foldmethod=marker foldmarker={{{,}}} :
+
+dnl {{{ program, version
+AC_PREREQ(2.59)
+AC_INIT([src/annie.hh])
+AC_CONFIG_AUX_DIR(config)
+
+VERSION_MAJOR=0
+VERSION_MINOR=2
+VERSION_MICRO=0
+VERSION_SUFFIX=
+VERSION_FULL="$VERSION_MAJOR.$VERSION_MINOR.$VERSION_MICRO$VERSION_SUFFIX"
+VERSION="$VERSION_FULL"
+VERSION_LIB_CURRENT=`expr 100 '*' $VERSION_MAJOR + $VERSION_MINOR`
+VERSION_LIB_REVISION="$VERSION_MICRO"
+
+AC_SUBST([VERSION_MAJOR])
+AC_SUBST([VERSION_MINOR])
+AC_SUBST([VERSION_MICRO])
+AC_SUBST([VERSION_FULL])
+AC_SUBST([VERSION_SUFFIX])
+AC_SUBST([VERSION_LIB_CURRENT])
+AC_SUBST([VERSION_LIB_REVISION])
+
+AM_INIT_AUTOMAKE(annie, [$VERSION_FULL])
+AC_LANG([C++])
+
+ANNIE_CXXFLAGS=
+dnl }}}
+
+dnl {{{ basic toolchain checks
+AC_PROG_CXX
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_RANLIB
+AC_PROG_MAKE_SET
+dnl }}}
+
+dnl {{{ check for cxxflags
+if test x = x"$LET_ME_RICE"
+then
+ AC_MSG_CHECKING([for go faster stripes])
+ for x in "enforce-eh" "fast-math" "rtti" "visibility"
+ do
+ if echo "${LDFLAGS} ${CFLAGS} ${CXXFLAGS}" | grep "$x" >/dev/null ; then
+ flag=`echo "${LDFLAGS} ${CFLAGS} ${CXXFLAGS}" | tr ' ' '\n' | grep $x | tr '\n' ' '`
+ AC_MSG_RESULT([$flag])
+ AC_MSG_ERROR([Bad ricer. No bagel. Try again with non-broken compiler flags.])
+ fi
+ done
+ AC_MSG_RESULT([no])
+fi
+
+AC_MSG_CHECKING([whether our compiler is iccy])
+AC_COMPILE_IFELSE([
+#ifndef __ICC
+#error nope
+#endif
+],
+ [cxx_compiler_icc=yes],
+ [cxx_compiler_icc=no])
+AC_MSG_RESULT([${cxx_compiler_icc}])
+AC_DEFUN([CHECK_CXXFLAG], [
+ save_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS="$CXXFLAGS $ANNIE_CXXFLAGS $1 -Werror"
+ AC_COMPILE_IFELSE([
+#include <string>
+#include <iostream>
+int main(int, char **)
+{
+ std::string s("test");
+ std::cout << s << std::endl;
+}
+ ],
+ [cxxflag_success=yes],
+ [cxxflag_success=no])
+ CXXFLAGS="$save_CXXFLAGS"
+ if test "x$cxxflag_success" = "xyes" ; then
+ ANNIE_CXXFLAGS="$ANNIE_CXXFLAGS $1"
+ cxxflags_message="${cxxflags_message} $1"
+ fi
+ ])
+AC_MSG_CHECKING([for appropriate compiler flags])
+if test "x${cxx_compiler_icc}" = "xyes" ; then
+ CHECK_CXXFLAG([-Wall])
+ CHECK_CXXFLAG([-wd279])
+ CHECK_CXXFLAG([-wd304])
+ CHECK_CXXFLAG([-wd383])
+ CHECK_CXXFLAG([-wd444])
+ CHECK_CXXFLAG([-wd488])
+ CHECK_CXXFLAG([-wd810])
+ CHECK_CXXFLAG([-wd981])
+ CHECK_CXXFLAG([-wd1125])
+ CHECK_CXXFLAG([-wd1418])
+elif test "x${ac_cv_cxx_compiler_gnu}" = "xyes" ; then
+ CHECK_CXXFLAG([-Wall])
+ CHECK_CXXFLAG([-Wextra])
+ if ! test "x$cxxflag_success" = "xyes" ; then
+ CHECK_CXXFLAG([-W])
+ fi
+ CHECK_CXXFLAG([-Wold-style-cast])
+ CHECK_CXXFLAG([-Wredundant-decls])
+ CHECK_CXXFLAG([-Wstrict-null-sentinel])
+ CHECK_CXXFLAG([-Wmissing-noreturn])
+ CHECK_CXXFLAG([-Woverloaded-virtual])
+ CHECK_CXXFLAG([-Winit-self])
+ CHECK_CXXFLAG([-Wunreachable-code])
+ CHECK_CXXFLAG([-Wunused])
+ CHECK_CXXFLAG([-Wunused-function])
+ CHECK_CXXFLAG([-Wshadow])
+ CHECK_CXXFLAG([-Wlogical-op])
+ CHECK_CXXFLAG([-Wvla])
+ CHECK_CXXFLAG([-Wwrite-strings])
+ CHECK_CXXFLAG([-Wsignature-shadow])
+ CHECK_CXXFLAG([-Wfloat-equal])
+ CHECK_CXXFLAG([-pedantic])
+else
+ CHECK_CXXFLAG([-Wall])
+fi
+AC_MSG_RESULT([${cxxflags_message}])
+AC_SUBST([ANNIE_CXXFLAGS])
+
+AC_MSG_CHECKING([whether to enable visibility])
+AC_ARG_ENABLE([visibility],
+ AS_HELP_STRING([--enable-visibility], [Enable visibility (g++-4.1)]),
+ [ENABLE_VISIBILITY=$enableval],
+ [ENABLE_VISIBILITY=no])
+AC_MSG_RESULT([$ENABLE_VISIBILITY])
+AC_SUBST([ENABLE_VISIBILITY])
+if test "x$ENABLE_VISIBILITY" = "xyes" ; then
+ AC_MSG_CHECKING([for appropriate compiler visibility flags])
+ old_ANNIE_CXXFLAGS=$ANNIE_CXXFLAGS
+ ANNIE_CXXFLAGS=
+ CHECK_CXXFLAG([-fvisibility-inlines-hidden])
+ CHECK_CXXFLAG([-fvisibility=hidden])
+ AC_MSG_RESULT([$ANNIE_CXXFLAGS])
+ ANNIE_CXXFLAGS_VISIBILITY="$ANNIE_CXXFLAGS -DANNIE_ENABLE_VISIBILITY=1"
+ ANNIE_CXXFLAGS=$old_ANNIE_CXXFLAGS
+ ANNIE_ENABLE_VISIBILITY=1
+else
+ ANNIE_ENABLE_VISIBILITY=0
+fi
+AC_SUBST([ANNIE_ENABLE_VISIBILITY])
+AC_SUBST([ANNIE_CXXFLAGS_VISIBILITY])
+dnl }}}
+
+dnl {{{ built sources
+GENERATED_FILE=misc/generated-file.txt
+AC_SUBST_FILE(GENERATED_FILE)
+
+BUILDUSER=`whoami`
+AC_SUBST([BUILDUSER])
+BUILDHOST=`hostname`
+AC_SUBST([BUILDHOST])
+BUILDDATE=`date +%Y-%m-%dT%H:%M:%S%z`
+AC_SUBST([BUILDDATE])
+
+if test -d "${ac_top_srcdir:-./}/.svn" ; then
+ SVNVERSION=`svnversion "${ac_top_srcdir:-./}"`
+else
+ SVNVERSION=
+fi
+AC_MSG_CHECKING([for svn revision])
+AC_ARG_WITH([svn-revision],
+ AS_HELP_STRING([--with-svn-revision], [Specify svn revision]),
+ SVNVERSION=`eval echo $withval`,
+ SVNVERSION=`eval echo $SVNVERSION`)
+AC_MSG_RESULT([$SVNVERSION])
+AC_SUBST([SVNVERSION])
+dnl }}}
+
+dnl {{{ output
+AM_CONFIG_HEADER(config.h)
+AC_OUTPUT(
+ Makefile
+ src/Makefile
+ )
+dnl }}}
+
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..3e9a802
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,38 @@
+AM_CXXFLAGS = -I$(top_srcdir) @ANNIE_CXXFLAGS@ @ANNIE_CXXFLAGS_VISIBILITY@
+DEFS= \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DLIBDIR=\"$(libdir)\"
+
+SUBDIRS = .
+
+libexecanniedir=$(libexecdir)/annie
+
+libexecannie_PROGRAMS = \
+ kill_everyone_and_reboot \
+ mount_and_fsck
+
+kill_everyone_and_reboot_SOURCES = \
+ kill_everyone_and_reboot.cc
+
+kill_everyone_and_reboot_LDADD = \
+ libannie.a
+
+mount_and_fsck_SOURCES = \
+ mount_and_fsck.cc
+
+mount_and_fsck_LDADD = \
+ libannie.a
+
+noinst_LIBRARIES = libannie.a
+
+libannie_a_SOURCES = \
+ annie.cc annie.hh
+
+TESTS =
+
+CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
+DISTCLEANFILES =
+MAINTAINERCLEANFILES = Makefile.in
+
diff --git a/src/annie.cc b/src/annie.cc
new file mode 100644
index 0000000..5f5f470
--- /dev/null
+++ b/src/annie.cc
@@ -0,0 +1,4 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#include "annie.hh"
+
diff --git a/src/annie.hh b/src/annie.hh
new file mode 100644
index 0000000..15dbd4f
--- /dev/null
+++ b/src/annie.hh
@@ -0,0 +1,7 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#ifndef ANNIE_GUARD_SRC_ANNIE_HH
+#define ANNIE_GUARD_SRC_ANNIE_HH 1
+
+
+#endif
diff --git a/halt.c b/src/kill_everyone_and_reboot.cc
index da2fa06..8b67f89 100644
--- a/halt.c
+++ b/src/kill_everyone_and_reboot.cc
@@ -77,7 +77,7 @@ void power_off()
}
}
-int main(int argc __attribute__((unused)), char * argv [] __attribute__((unused)))
+int main(int, char *[])
{
kill_everybody(SIGTERM);
sleep(1);
diff --git a/src/mount_and_fsck.cc b/src/mount_and_fsck.cc
new file mode 100644
index 0000000..26f57ff
--- /dev/null
+++ b/src/mount_and_fsck.cc
@@ -0,0 +1,9 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#include <cstdlib>
+
+int main(int, char *[])
+{
+ return EXIT_SUCCESS;
+}
+