Update corewatcher to use autotools.
authorWilliam Douglas <william.douglas@intel.com>
Wed, 27 Jul 2011 00:04:42 +0000 (17:04 -0700)
committerWilliam Douglas <william.douglas@intel.com>
Thu, 28 Jul 2011 21:09:13 +0000 (14:09 -0700)
This involves major source restructuring and in the process
some files have been renamed as well as moved.  This was
done to ease the use of autotooling the package though
it shouldn't impair clarity of purpose for the files.

At this point there are further opportunities to improve
the packaging such as introducing #defines for some
file locations in the code.

Signed-off-by: William Douglas <william.douglas@intel.com>
14 files changed:
Makefile [deleted file]
Makefile.am [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
corewatcher-core.conf [moved from corewatcher.sysctl with 100% similarity]
src/Makefile.am [new file with mode: 0644]
src/configfile.c [moved from configfile.c with 100% similarity]
src/coredump.c [moved from coredump.c with 100% similarity]
src/corewatcher-config.c [moved from corewatcher-config.c with 100% similarity]
src/corewatcher.c [moved from corewatcher.c with 100% similarity]
src/corewatcher.h [moved from corewatcher.h with 100% similarity]
src/find_file.c [moved from find_file.c with 100% similarity]
src/segfault.c [moved from segfault.c with 100% similarity]
src/submit.c [moved from submit.c with 100% similarity]

diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 88adb00..0000000
--- a/Makefile
+++ /dev/null
@@ -1,71 +0,0 @@
-VERSION = 0.27
-#
-# to build this package, you need to have the following components installed:
-# dbus-glib-devel libnotify-devel curl-devel
-#
-PREFIX    ?= /usr
-BINDIR     = $(PREFIX)/bin
-SBINDIR    = $(PREFIX)/sbin
-MANDIR     = $(PREFIX)/share/man/man8
-CC ?= gcc
-
-CFLAGS := -g -fstack-protector -D_FORTIFY_SOURCE=2 -Wall -pedantic -W -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wdeclaration-after-statement -Wformat -Wformat-security -Werror=format-security
-
-MY_CFLAGS := `pkg-config --cflags libnotify libproxy-1.0 glib-2.0 dbus-1`
-#
-# pkg-config tends to make programs pull in a ton of libraries, not all
-# are needed. -Wl,--as-needed tells the linker to just drop unused ones.
-#
-LDF_C := -Wl,--as-needed `pkg-config --libs glib-2.0`
-LDF_D := -Wl,--as-needed `pkg-config --libs glib-2.0 dbus-glib-1 libproxy-1.0 dbus-1` `curl-config --libs` -Wl,"-z relro" -Wl,"-z now"
-
-all:   corewatcher corewatcher-config corewatcher.8.gz
-
-.c.o:
-       $(CC) $(CFLAGS) $(MY_CFLAGS) -c -o $@ $<
-
-
-corewatcher:   corewatcher.o submit.o coredump.o configfile.o find_file.o corewatcher.h
-       gcc corewatcher.o submit.o coredump.o configfile.o find_file.o $(LDF_D) -o corewatcher
-
-corewatcher-config: corewatcher-config.o
-       gcc corewatcher-config.o $(LDF_C)-o corewatcher-config
-
-corewatcher.8.gz: corewatcher.8
-       gzip -9 -c $< > $@
-
-clean:
-       rm -f *~ *.o *.ko DEADJOE corewatcher corewatcher-config *.out */*~ corewatcher.8.gz
-
-install-system: corewatcher.8.gz
-       -mkdir -p $(DESTDIR)$(MANDIR)
-       -mkdir -p $(DESTDIR)/var/lib/corewatcher
-       -mkdir -p $(DESTDIR)/etc/security/limits.d/
-       -mkdir -p $(DESTDIR)/etc/dbus-1/system.d/
-       -mkdir -p $(DESTDIR)/etc/sysctl.d/
-       install -m 0644 95-core.conf $(DESTDIR)/etc/security/limits.d/95-core.conf
-       if [ ! -f $(DESTDIR)/etc/corewatcher.conf ] ; then install -m 0644 corewatcher.conf $(DESTDIR)/etc/corewatcher.conf ; fi
-       install -m 0644 corewatcher.dbus $(DESTDIR)/etc/dbus-1/system.d/
-       install -m 0644 corewatcher.8.gz $(DESTDIR)$(MANDIR)/
-       install -m 0644 gdb.command  $(DESTDIR)/var/lib/corewatcher/
-       install -m 0644 corewatcher.sysctl  $(DESTDIR)/etc/sysctl.d/corewatcher.conf
-
-install-corewatcher: corewatcher
-       -mkdir -p $(DESTDIR)$(SBINDIR)
-       install -m 0755 corewatcher $(DESTDIR)$(SBINDIR)/
-       install -m 0755 corewatcher-config $(DESTDIR)$(SBINDIR)/
-
-install: install-system install-corewatcher
-
-tests: corewatcher
-       desktop-file-validate *.desktop
-       for i in test/*txt ; do echo -n . ; ./corewatcher --debug $$i > $$i.dbg ; diff -u $$i.out $$i.dbg ; done ; echo
-       [ -e /usr/bin/valgrind ] && for i in test/*txt ; do echo -n . ; valgrind -q --leak-check=full ./corewatcher --debug $$i > $$i.dbg ; diff -u $$i.out $$i.dbg ; done ; echo
-
-valgrind: corewatcher tests
-       valgrind -q --leak-check=full ./corewatcher --debug test/*.txt
-
-dist:
-       git tag v$(VERSION)
-       git archive --format=tar --prefix="corewatcher-$(VERSION)/" v$(VERSION) | \
-               gzip > corewatcher-$(VERSION).tar.gz
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..87e5848
--- /dev/null
@@ -0,0 +1,26 @@
+SUBDIRS = \
+       src
+
+man_MANS = \
+       corewatcher.8
+
+corewatcherconfdir = $(sysconfdir)/corewatcher
+dist_corewatcherconf_DATA = \
+       gdb.command \
+       corewatcher.conf
+
+EXTRA_DIST = \
+       corewatcher.supp \
+       $(man_MANS)
+
+sysctldir = $(sysconfdir)/sysctl.d
+dist_sysctl_DATA = \
+       corewatcher-core.conf
+
+dbusdir = $(sysconfdir)/dbus-1/system.d
+dist_dbus_DATA = \
+       corewatcher.dbus
+
+corefileconfdir = $(sysconfdir)/security/limits.d
+dist_corefileconf_DATA = \
+       95-core.conf
\ No newline at end of file
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..3538370
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+autoreconf --install
+
+args="--prefix=/usr \
+--sysconfdir=/etc"
+
+./configure $args $@
\ No newline at end of file
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..132f70b
--- /dev/null
@@ -0,0 +1,50 @@
+AC_PREREQ([2.68])
+AC_INIT([corewatcher],[0.27],[william.douglas@intel.com])
+AM_INIT_AUTOMAKE([foreign -Wall -Werror])
+AC_CONFIG_FILES([Makefile src/Makefile])
+AC_CONFIG_SRCDIR([src/corewatcher.c])
+AC_CONFIG_HEADERS([config.h])
+
+# Checks for programs.
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_INSTALL
+
+# Checks for libraries.
+AC_CHECK_LIB([pthread], [pthread_mutex_unlock], , AC_MSG_ERROR([libpthread is required but was not found]))
+
+# PkgConfig tests
+PKG_CHECK_MODULES([DBUS], [dbus-1])
+PKG_CHECK_MODULES([DBUSGLIB], [dbus-glib-1])
+PKG_CHECK_MODULES([GLIB2], [glib-2.0])
+PKG_CHECK_MODULES([LIBPROXY], [libproxy-1.0])
+PKG_CHECK_MODULES([LIBNOTIFY], [libnotify])
+PKG_CHECK_MODULES([LIBCURL], [libcurl])
+
+# Checks for header files.
+AC_CHECK_HEADERS([stdio.h assert.h sys/types.h sys/stat.h dirent.h signal.h errno.h sched.h fcntl.h stdlib.h string.h sys/time.h syslog.h unistd.h asm/unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+
+AC_OUTPUT
+AC_MSG_RESULT([
+       corewatcher $VERSION
+       ========
+
+       prefix:                 ${prefix}
+       sysconfdir:             ${sysconfdir}
+       exec_prefix:            ${exec_prefix}
+       bindir:                 ${bindir}
+       sbindir:                ${sbindir}
+       datarootdir:            ${datarootdir}
+       mandir:                 ${mandir}
+
+       compiler:               ${CC}
+       cflags:                 ${CFLAGS}
+       ldflags:                ${LDFLAGS}
+])
similarity index 100%
rename from corewatcher.sysctl
rename to corewatcher-core.conf
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..2cae526
--- /dev/null
@@ -0,0 +1,37 @@
+sbin_PROGRAMS = \
+       corewatcher \
+       corewatcher-config
+
+corewatcher_SOURCES = \
+       configfile.c \
+       coredump.c \
+       corewatcher.c \
+       find_file.c \
+       submit.c
+
+corewatcher_config_SOURCES = \
+       corewatcher-config.c
+
+corewatcher_CFLAGS = \
+       $(DBUS_CFLAGS) \
+       $(DBUSGLIB_CFLAGS) \
+       $(GLIB2_CFLAGS) \
+       $(LIBPROXY_CFLAGS) \
+       $(LIBNOTIFY_CFLAGS) \
+       $(LIBCURL_CFLAGS)
+
+corewatcher_LDADD = \
+       $(DBUS_LIBS) \
+       $(DBUSGLIB_LIBS) \
+       $(GLIB2_LIBS) \
+       $(LIBPROXY_LIBS) \
+       $(LIBNOTIFY_LIBS) \
+       $(LIBCURL_LIBS)
+
+corewatcher_config_CFLAGS = \
+       $(GLIB2_CFLAGS)
+corewatcher_config_LDADD = \
+       $(GLIB2_LIBS)
+
+noinst_HEADERS = \
+       corewatcher.h
\ No newline at end of file
similarity index 100%
rename from configfile.c
rename to src/configfile.c
similarity index 100%
rename from coredump.c
rename to src/coredump.c
similarity index 100%
rename from corewatcher.c
rename to src/corewatcher.c
similarity index 100%
rename from corewatcher.h
rename to src/corewatcher.h
similarity index 100%
rename from find_file.c
rename to src/find_file.c
similarity index 100%
rename from segfault.c
rename to src/segfault.c
similarity index 100%
rename from submit.c
rename to src/submit.c