clean up
authorArjan van de Ven <arjan@linux.intel.com>
Tue, 20 Jan 2009 15:48:11 +0000 (07:48 -0800)
committerArjan van de Ven <arjan@linux.intel.com>
Tue, 20 Jan 2009 15:48:11 +0000 (07:48 -0800)
Makefile
coredumper.h [deleted file]
dbus.c [deleted file]
webinterface.c [deleted file]

index aac2759..d811cd8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,19 +1,90 @@
-all: corewatcher corewatcher-applet
 
-CFLAGS := -O2 -g -Wall -W -D_FORTIFY_SOURCE=2 -fstack-protector
+#
+# to build this package, you need to have the following components installed:
+# dbus-glib-devel libnotify-devel gtk2-devel curl-devel
+#
 
-CFLAGS += `pkg-config --cflags glib-2.0 gtk+-2.0 dbus-glib-1`  -fno-common
+BINDIR=/usr/bin
+SBINDIR=/usr/sbin
+LOCALESDIR=/usr/share/locale
+MANDIR=/usr/share/man/man8
+CC?=gcc
 
-LINKFLAGS += `pkg-config --libs glib-2.0 dbus-glib-1` `curl-config --libs` -fno-common
+CFLAGS := -O2 -g -fstack-protector -D_FORTIFY_SOURCE=2 -Wall -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 gtk+-2.0`
+#
+# 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,
+# and that makes the applet load faster and use less memory.
+#
+LDF_A := -Wl,--as-needed `pkg-config --libs libnotify gtk+-2.0`
+LDF_D := -Wl,--as-needed `pkg-config --libs glib-2.0 dbus-glib-1` `curl-config --libs` -Wl,"-z relro" -Wl,"-z now" 
+
+all:   corewatcher corewatcher-applet corewatcher.8.gz
+
+noui:  corewatcher corewatcher.8.gz
+
+.c.o:
+       $(CC) $(CFLAGS) $(MY_CFLAGS) -c -o $@ $<
+
+corewatcher:   corewatcher.o submit.o dmesg.o configfile.o corewatcher.h
+       gcc corewatcher.o submit.o dmesg.o configfile.o $(LDF_D) -o corewatcher
+       @(cd po/ && $(MAKE))
+
+corewatcher-applet: corewatcher-applet.o
+       gcc corewatcher-applet.o $(LDF_A)-o corewatcher-applet
+
+corewatcher.8.gz: corewatcher.8
+       gzip -9 -c $< > $@
 
-LIBS = corewatcher.o find_file.o webinterface.o dbus.o configfile.o
-corewatcher: $(LIBS) coredumper.h Makefile
-       gcc $(CFLAGS) $(LIBS) $(LINKFLAGS) -o corewatcher
-       
-corewatcher-applet:
-       gcc $(CFLAGS) $(LINKFLAGS)  `pkg-config --libs gtk+-2.0` corewatcher-applet.c -o corewatcher-applet -lnotify
-       
 clean:
-       rm -f *.o extract_core DEADJOE corewatcher *~
+       rm -f *~ *.o *.ko DEADJOE corewatcher corewatcher-applet *.out */*~ corewatcher.8.gz
+       @(cd po/ && $(MAKE) $@)
+
+dist: clean
+       rm -rf .git .gitignore push.sh .*~  */*~ test/*dbg
+
+install-system: corewatcher.8.gz
+       -mkdir -p $(DESTDIR)$(MANDIR)
+       -mkdir -p $(DESTDIR)/etc/dbus-1/system.d/
+       install -m 0644 corewatcher.conf $(DESTDIR)/etc/corewatcher.conf
+       install -m 0644 corewatcher.dbus $(DESTDIR)/etc/dbus-1/system.d/
+       install -m 0644 corewatcher.8.gz $(DESTDIR)$(MANDIR)/
+       @(cd po/ && env LOCALESDIR=$(LOCALESDIR) DESTDIR=$(DESTDIR) $(MAKE) install)
+
+install-corewatcher: corewatcher
+       -mkdir -p $(DESTDIR)$(SBINDIR)
+       install -m 0755 corewatcher $(DESTDIR)$(SBINDIR)/
+
+install-applet: corewatcher-applet
+       -mkdir -p $(DESTDIR)$(BINDIR)
+       -mkdir -p $(DESTDIR)/etc/xdg/autostart
+       -mkdir -p $(DESTDIR)/usr/share/corewatcher
+       install -m 0755 corewatcher-applet $(DESTDIR)$(BINDIR)/
+       desktop-file-install --mode 0644 --dir=$(DESTDIR)/etc/xdg/autostart/ corewatcher-applet.desktop
+       install -m 0644 icon.png $(DESTDIR)/usr/share/corewatcher/icon.png
+
+install: install-system install-corewatcher install-applet
+
+install-noui: install-system install-corewatcher
+
+
+# This is for translators. To update your po with new strings, do :
+# svn up ; make uptrans LG=fr # or de, ru, hu, it, ...
+uptrans:
+       xgettext -C -s -k_ -o po/corewatcher.pot *.c *.h
+       @(cd po/ && env LG=$(LG) $(MAKE) $@)
+
        
-       
\ No newline at end of file
+
+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
+
+
diff --git a/coredumper.h b/coredumper.h
deleted file mode 100644 (file)
index 55641ba..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Core dump watcher & collector
- *
- * (C) 2009 Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 3 of the License.
- */
-
-#ifndef __INCLUDE_GUARD_COREDUMPER_H__
-#define __INCLUDE_GUARD_COREDUMPER_H__
-
-#include <glib.h>
-
-#define __unused  __attribute__ ((__unused__))
-
-
-extern char *find_executable(char *fragment);
-extern char *find_coredump(char *corefile);
-extern void dbus_say_thanks(void);
-extern GList *coredumps;
-extern void submit_queue(void);
-extern void clear_queue(void);
-extern void read_config_file(char *filename);
-
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-extern DBusConnection *bus; 
-extern DBusHandlerResult got_message(
-                DBusConnection __unused *conn,
-                DBusMessage *message,
-                void __unused *user_data);
-
-#endif
diff --git a/dbus.c b/dbus.c
deleted file mode 100644 (file)
index 337a6e2..0000000
--- a/dbus.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Core dump watcher & collector
- *
- * (C) 2009 Intel Corporation
- *
- * Authors:
- *     Arjan van de Ven <arjan@linux.intel.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 3 of the License.
- */
-
-#define _BSD_SOURCE
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h> 
-#include <glib.h>
-#include <asm/unistd.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "coredumper.h"
-
-DBusConnection *bus;
-
-int pinged;
-extern int opted_in;
-
-DBusHandlerResult got_message(
-               DBusConnection __unused *conn,
-               DBusMessage *message,
-               void __unused *user_data)
-{
-       if (dbus_message_is_signal(message,
-               "org.moblin.coredump.ping", "ping")) {
-               pinged = 1;
-               return DBUS_HANDLER_RESULT_HANDLED;
-       }
-
-       if (dbus_message_is_signal(message,
-               "org.moblin.coredump.permission", "yes")) {
-               submit_queue();
-               return DBUS_HANDLER_RESULT_HANDLED;
-       }
-       if (dbus_message_is_signal(message,
-               "org.moblin.coredump.permission", "always")) {
-               submit_queue();
-               opted_in = 2;
-               return DBUS_HANDLER_RESULT_HANDLED;
-       }
-       if (dbus_message_is_signal(message,
-               "org.moblin.coredump.permission", "never")) {
-               clear_queue();
-               opted_in = 0;
-               return DBUS_HANDLER_RESULT_HANDLED;
-       }
-       if (dbus_message_is_signal(message,
-               "org.moblin.coredump.permission", "no")) {
-               clear_queue();
-               return DBUS_HANDLER_RESULT_HANDLED;
-       }
-
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-void dbus_ask_permission(char * detail_file_name)
-{
-       DBusMessage *message;
-       if (!bus)
-               return;
-       message = dbus_message_new_signal("/org/moblin/coredump/permission",
-                       "org.moblin.coredump.permission", "ask");
-       if (detail_file_name) {
-               dbus_message_append_args(message,
-                       DBUS_TYPE_STRING, &detail_file_name,
-                       DBUS_TYPE_INVALID);
-       }
-       dbus_connection_send(bus, message, NULL);
-       dbus_message_unref(message);
-}
-
-void dbus_say_thanks(void)
-{
-       DBusMessage *message;
-       if (!bus)
-               return;
-
-       message = dbus_message_new_signal("/org/moblin/coredump/sent",
-                       "org.moblin.coredump.sent", "sent");
-       dbus_connection_send(bus, message, NULL);
-       dbus_message_unref(message);
-}
-
diff --git a/webinterface.c b/webinterface.c
deleted file mode 100644 (file)
index 5ea89fb..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Core dump watcher & collector
- *
- * (C) 2009 Intel Corporation
- *
- * Authors:
- *     Arjan van de Ven <arjan@linux.intel.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 3 of the License.
- */
-
-#define _BSD_SOURCE
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h> 
-#include <glib.h>
-#include <asm/unistd.h>
-
-#include <curl/curl.h>
-
-#include "coredumper.h"
-
-extern char *submit_url;
-
-void submit_queue(void)
-{
-       int result;
-       int count = 0;
-       GList *entry, *next;
-
-       entry = g_list_first(coredumps);
-
-       while (entry) {
-               char *backtrace;
-               CURL *handle;
-
-               backtrace = entry->data;
-               next = g_list_next(entry);
-
-               coredumps = g_list_delete_link(coredumps, entry);
-               entry = next;
-
-               struct curl_httppost *post = NULL;
-               struct curl_httppost *last = NULL;
-
-               handle = curl_easy_init();
-
-               printf("DEBUG SUBMIT URL is %s \n", submit_url);
-               curl_easy_setopt(handle, CURLOPT_URL, submit_url);
-
-               /* set up the POST data */
-               curl_formadd(&post, &last,
-                       CURLFORM_COPYNAME, "backtrace",
-                       CURLFORM_COPYCONTENTS, backtrace, CURLFORM_END);
-
-               curl_easy_setopt(handle, CURLOPT_HTTPPOST, post);
-               result = curl_easy_perform(handle);
-
-               curl_formfree(post);
-               curl_easy_cleanup(handle);
-               free(backtrace);
-               count++;
-       }
-
-       if (count)
-               dbus_say_thanks();
-}
-
-void clear_queue(void)
-{
-       GList *entry, *next;
-
-       entry = g_list_first(coredumps);
-
-       while (entry) {
-               next = g_list_next(entry);
-               coredumps = g_list_delete_link(coredumps, entry);
-               entry = next;
-       }
-}
-