- gkrellmd: use new logging system and add syslog-handler for logging to syslog or windows event log

- gkrellmd: redo argv parsing, the old one could have read one item too far
- gkrellmd win32: search plugins in installation directory
- gkrellmd win32: print helpful messages on service install/uninstall
- gkrellmd win32: added install target for gkrellmd.conf
This commit is contained in:
Stefan Gehn 2008-09-28 15:51:42 +00:00
parent d22da7e24e
commit c994994734
4 changed files with 418 additions and 270 deletions

View File

@ -18,6 +18,10 @@ INCLUDEDIRMODE ?= 755
LIBDIR ?= $(INSTALLROOT)/lib LIBDIR ?= $(INSTALLROOT)/lib
LIBDIRMODE ?= 755 LIBDIRMODE ?= 755
CFGDIR ?= $(INSTALLROOT)/etc
CFGDIRMODE ?= 755
CFGMODE ?= 644
SMANDIR ?= $(INSTALLROOT)/share/man/man1 SMANDIR ?= $(INSTALLROOT)/share/man/man1
MANMODE ?= 644 MANMODE ?= 644
MANDIRMODE ?= 755 MANDIRMODE ?= 755
@ -25,6 +29,9 @@ INSTALL ?= install
LINK_FLAGS ?= -Wl,-E LINK_FLAGS ?= -Wl,-E
EXTRAOBJS = EXTRAOBJS =
SHARED_PATH = ../shared
# Make GNU Make search for sources somewhere else as well
VPATH = $(SHARED_PATH)
ifeq ($(without-libsensors),yes) ifeq ($(without-libsensors),yes)
CONFIGURE_ARGS += --without-libsensors CONFIGURE_ARGS += --without-libsensors
@ -44,7 +51,7 @@ endif
CC ?= gcc CC ?= gcc
STRIP ?= -s STRIP ?= -s
GKRELLMD_INCLUDES = gkrellmd.h GKRELLMD_INCLUDES = gkrellmd.h $(SHARED_PATH)/log.h
PKG_INCLUDE = `$(PKG_CONFIG) --cflags glib-2.0 gthread-2.0` PKG_INCLUDE = `$(PKG_CONFIG) --cflags glib-2.0 gthread-2.0`
PKG_LIB = `$(PKG_CONFIG) --libs glib-2.0 gmodule-2.0 gthread-2.0` PKG_LIB = `$(PKG_CONFIG) --libs glib-2.0 gmodule-2.0 gthread-2.0`
@ -52,24 +59,24 @@ PKG_LIB = `$(PKG_CONFIG) --libs glib-2.0 gmodule-2.0 gthread-2.0`
GLIB12_INCLUDE = `glib-config --cflags` GLIB12_INCLUDE = `glib-config --cflags`
GLIB12_LIB = `glib-config --libs glib gmodule` GLIB12_LIB = `glib-config --libs glib gmodule`
FLAGS = -O2 -I.. $(PKG_INCLUDE) $(GTOP_INCLUDE) FLAGS = -O2 $(PKG_INCLUDE)
ifeq ($(glib12),1)
FLAGS = -O2 -I.. $(GLIB12_INCLUDE) $(GTOP_INCLUDE)
endif
ifeq ($(glib12),yes)
FLAGS = -O2 -I.. $(GLIB12_INCLUDE) $(GTOP_INCLUDE)
endif
FLAGS+= $(PTHREAD_INC)
LIBS = $(PKG_LIB) $(GTOP_LIBS_D) $(SYS_LIBS) $(SENSORS_LIBS)
ifeq ($(glib12),1) ifeq ($(glib12),1)
LIBS = $(GLIB12_LIB) $(GTOP_LIBS_D) $(SYS_LIBS) $(SENSORS_LIBS) FLAGS = -O2 $(GLIB12_INCLUDE)
endif endif
ifeq ($(glib12),yes) ifeq ($(glib12),yes)
LIBS = $(GLIB12_LIB) $(GTOP_LIBS_D) $(SYS_LIBS) $(SENSORS_LIBS) FLAGS = -O2 $(GLIB12_INCLUDE)
endif endif
FLAGS += $(GTOP_INCLUDE) $(PTHREAD_INC) -I.. -I$(SHARED_PATH) -DGKRELLM_SERVER
LIBS = $(PKG_LIB)
ifeq ($(glib12),1)
LIBS = $(GLIB12_LIB)
endif
ifeq ($(glib12),yes)
LIBS = $(GLIB12_LIB)
endif
LIBS += $(GTOP_LIBS_D) $(SYS_LIBS) $(SENSORS_LIBS)
ifeq ($(debug),1) ifeq ($(debug),1)
FLAGS += -g FLAGS += -g
@ -93,22 +100,19 @@ ifeq ($(enable_nls),yes)
endif endif
ifneq ($(PACKAGE_D),gkrellmd) ifneq ($(PACKAGE_D),gkrellmd)
FLAGS += -DPACKAGE_D=\"$(PACKAGE_D)\" FLAGS += -DPACKAGE_D=\"$(PACKAGE_D)\"
endif endif
ifeq ($(HAVE_GETADDRINFO),1) ifeq ($(HAVE_GETADDRINFO),1)
FLAGS += -DHAVE_GETADDRINFO FLAGS += -DHAVE_GETADDRINFO
endif endif
override CC += -Wall $(FLAGS) override CC += -Wall $(FLAGS)
OS_NAME=$(shell uname -s) OS_NAME=$(shell uname -s)
OS_RELEASE=$(shell uname -r) OS_RELEASE=$(shell uname -r)
OBJS = main.o monitor.o mail.o plugins.o glib.o utils.o sysdeps-unix.o OBJS = main.o monitor.o mail.o plugins.o glib.o utils.o sysdeps-unix.o log.o
EXTRAOBJS =
all: gkrellmd all: gkrellmd
@ -160,11 +164,11 @@ endif
windows: libgkrellmd.a windows: libgkrellmd.a
$(MAKE) \ $(MAKE) \
CFLAGS="${CFLAGS} -D_WIN32_WINNT=0x0500 -DWINVER=0x0500" \ CFLAGS="${CFLAGS} -D_WIN32_WINNT=0x0500 -DWINVER=0x0500" \
LINK_FLAGS="${LINK_FLAGS} -mconsole" \ LINK_FLAGS="${LINK_FLAGS} -mconsole" \
EXTRAOBJS="win32-resource.o win32-plugin.o" \ EXTRAOBJS="win32-resource.o win32-plugin.o" \
SYS_LIBS=" -llargeint -lws2_32 -lpdh -lnetapi32 -liphlpapi -lntdll -lintl" \ SYS_LIBS=" -llargeint -lws2_32 -lpdh -lnetapi32 -liphlpapi -lntdll -lintl" \
gkrellmd gkrellmd
install: install_bin install_inc install_man install: install_bin install_inc install_man
@ -180,6 +184,10 @@ install_man:
$(INSTALL) -d -m $(MANDIRMODE) $(SMANDIR) $(INSTALL) -d -m $(MANDIRMODE) $(SMANDIR)
$(INSTALL) -c -m $(MANMODE) ../gkrellmd.1 $(SMANDIR)/$(PACKAGE_D).1 $(INSTALL) -c -m $(MANMODE) ../gkrellmd.1 $(SMANDIR)/$(PACKAGE_D).1
install_cfg:
$(INSTALL) -d -m $(CFGDIRMODE) $(CFGDIR)
$(INSTALL) -c -m $(CFGMODE) gkrellmd.conf $(CFGDIR)/gkrellmd.conf
uninstall: uninstall:
rm -f $(SINSTALLDIR)/$(PACKAGE_D) rm -f $(SINSTALLDIR)/$(PACKAGE_D)
rm -f $(SMANDIR)/$(PACKAGE_D).1 rm -f $(SMANDIR)/$(PACKAGE_D).1
@ -205,8 +213,8 @@ install_solaris:
chgrp sys $(SINSTALLDIR)/$(PACKAGE_D) chgrp sys $(SINSTALLDIR)/$(PACKAGE_D)
chmod g+s $(SINSTALLDIR)/$(PACKAGE_D) chmod g+s $(SINSTALLDIR)/$(PACKAGE_D)
install_windows: install_windows: install_inc install_cfg
$(MAKE) BINEXT=".exe" install_bin install_inc $(MAKE) BINEXT=".exe" install_bin
$(INSTALL) -d -m $(LIBDIRMODE) $(LIBDIR) $(INSTALL) -d -m $(LIBDIRMODE) $(LIBDIR)
$(INSTALL) -c -m $(BINMODE) libgkrellmd.a $(LIBDIR) $(INSTALL) -c -m $(BINMODE) libgkrellmd.a $(LIBDIR)
@ -221,19 +229,20 @@ SYSDEPS = ../src/sysdeps/bsd-common.c ../src/sysdeps/bsd-net-open.c \
../src/sysdeps/openbsd.c ../src/sysdeps/sensors-common.c \ ../src/sysdeps/openbsd.c ../src/sysdeps/sensors-common.c \
../src/sysdeps/solaris.c ../src/sysdeps/win32.c ../src/sysdeps/solaris.c ../src/sysdeps/win32.c
main.o: main.c gkrellmd.h GKRELLMD_H = gkrellmd.h gkrellmd-private.h
monitor.o: monitor.c gkrellmd.h
mail.o: mail.c gkrellmd.h main.o: main.c $(GKRELLMD_H)
plugins.o: plugins.c gkrellmd.h monitor.o: monitor.c $(GKRELLMD_H)
glib.o: glib.c gkrellmd.h mail.o: mail.c $(GKRELLMD_H)
utils.o: utils.c gkrellmd.h plugins.o: plugins.c $(GKRELLMD_H)
sysdeps-unix.o: sysdeps-unix.c gkrellmd.h ../src/gkrellm-sysdeps.h $(SYSDEPS) glib.o: glib.c $(GKRELLMD_H)
utils.o: utils.c $(GKRELLMD_H)
sysdeps-unix.o: sysdeps-unix.c ../src/gkrellm-sysdeps.h $(SYSDEPS) $(GKRELLMD_H)
log.o: $(SHARED_PATH)/log.c $(SHARED_PATH)/log.h $(GKRELLMD_H)
win32-gui.o: win32-gui.c win32-gui.o: win32-gui.c
win32-plugin.o: win32-plugin.c win32-plugin.h gkrellmd.h win32-plugin.o: win32-plugin.c win32-plugin.h $(GKRELLMD_H)
win32-resource.o: win32-resource.rc win32-resource.h
win32-libgkrellmd.o: win32-libgkrellmd.c win32-plugin.h gkrellmd.h
libgkrellmd.a: win32-libgkrellmd.o
ar -cr libgkrellmd.a win32-libgkrellmd.o
win32-resource.o: win32-resource.rc win32-resource.h
windres -I.. -o win32-resource.o win32-resource.rc windres -I.. -o win32-resource.o win32-resource.rc
win32-libgkrellmd.o: win32-libgkrellmd.c win32-plugin.h $(GKRELLMD_H)
libgkrellmd.a: win32-libgkrellmd.o
ar -cr libgkrellmd.a win32-libgkrellmd.o

View File

@ -21,6 +21,8 @@
#ifndef GKRELLMD_H #ifndef GKRELLMD_H
#define GKRELLMD_H #define GKRELLMD_H
#include "log.h"
#include <glib.h> #include <glib.h>
#include <stdio.h> #include <stdio.h>
@ -35,26 +37,27 @@
#endif #endif
#if !defined(WIN32) #if !defined(WIN32)
#include <unistd.h> #include <unistd.h>
#include <utime.h> #include <utime.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/time.h> #include <sys/time.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>
#if defined(__solaris__) #if defined(__solaris__)
#include <sys/filio.h> #include <sys/filio.h>
#endif #endif /* defined(__solaris__) */
#include <sys/select.h> #include <sys/select.h>
#include <sys/wait.h> #include <sys/wait.h>
#else #else
#define ioctl ioctlsocket
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#endif typedef int sa_family_t; // WIN32 uses int for ai_family;
#include <stdint.h> // defines uint32_t
#endif /* !defined(WIN32) */
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
@ -85,7 +88,7 @@
# define gettext(String) (String) # define gettext(String) (String)
# define dgettext(Domain,String) (String) # define dgettext(Domain,String) (String)
# define dcgettext(Domain,String,Type) (String) # define dcgettext(Domain,String,Type) (String)
# define bindtextdomain(Domain,Directory) (Domain) # define bindtextdomain(Domain,Directory) (Domain)
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
/* ------------------------------------------------------------------- /* -------------------------------------------------------------------
@ -108,7 +111,7 @@ GKRELLMD_VERSION_REV >= (rev)))
#else #else
#define GKRELLMD_USER_CONFIG ".gkrellmd.conf" #define GKRELLMD_USER_CONFIG ".gkrellmd.conf"
#endif #endif
#define GKRELLMD_PLUGINS_DIR ".gkrellm2/plugins-gkrellmd" #define GKRELLMD_PLUGINS_DIR ".gkrellm2/plugins-gkrellmd"
#if !defined(WIN32) #if !defined(WIN32)
#define GKRELLMD_LOCAL_PLUGINS_DIR "/usr/local/lib/gkrellm2/plugins-gkrellmd" #define GKRELLMD_LOCAL_PLUGINS_DIR "/usr/local/lib/gkrellm2/plugins-gkrellmd"

File diff suppressed because it is too large Load Diff

View File

@ -76,7 +76,6 @@
#include <sys/utsname.h> #include <sys/utsname.h>
#endif #endif
#if !defined(WIN32)
gchar * gchar *
gkrellm_sys_get_host_name(void) gkrellm_sys_get_host_name(void)
{ {
@ -89,6 +88,7 @@ gkrellm_sys_get_host_name(void)
return buf; return buf;
} }
#if !defined(WIN32)
gchar * gchar *
gkrellm_sys_get_system_name(void) gkrellm_sys_get_system_name(void)
{ {