From efe1355563ac28c2f1a1ac689d6f5001bef627b0 Mon Sep 17 00:00:00 2001
From: Adam Wujek <adam.wujek@cern.ch>
Date: Thu, 13 Nov 2014 13:48:13 +0100
Subject: [PATCH] add monit

Commit based on patches from buildroot

Signed-off-by: Adam Wujek <adam.wujek@cern.ch>
---
 package/Config.in                              |  3 ++
 package/monit/Config.in                        | 15 ++++++++++
 package/monit/monit-0001-no-force-static.patch | 20 +++++++++++++
 package/monit/monit.mk                         | 41 ++++++++++++++++++++++++++
 4 files changed, 79 insertions(+)
 create mode 100644 package/monit/Config.in
 create mode 100644 package/monit/monit-0001-no-force-static.patch
 create mode 100644 package/monit/monit.mk

diff --git a/package/Config.in b/package/Config.in
index 4b5e5d8..d767060 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -529,6 +529,9 @@ endif
 source "package/htop/Config.in"
 if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 source "package/module-init-tools/Config.in"
+endif
+source "package/monit/Config.in"
+if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 source "package/procps/Config.in"
 source "package/psmisc/Config.in"
 source "package/rsyslog/Config.in"
diff --git a/package/monit/Config.in b/package/monit/Config.in
new file mode 100644
index 0000000..794ef76
--- /dev/null
+++ b/package/monit/Config.in
@@ -0,0 +1,15 @@
+config BR2_PACKAGE_MONIT
+	bool "monit"
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_USE_MMU # fork()
+	help
+	  Monit is a free open source utility for managing and
+	  monitoring, processes, programs, files, directories and
+	  filesystems on a UNIX system. Monit conducts automatic
+	  maintenance and repair and can execute meaningful causal
+	  actions in error situations.
+
+	  http://mmonit.com/monit/
+
+comment "monit requires a toolchain with threads support"
+       depends on !BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/monit/monit-0001-no-force-static.patch b/package/monit/monit-0001-no-force-static.patch
new file mode 100644
index 0000000..edb619b
--- /dev/null
+++ b/package/monit/monit-0001-no-force-static.patch
@@ -0,0 +1,20 @@
+Do not force building a statically-linked binary
+
+Statically-linked binary do not work well with glibc, because it
+still dlopen()s the NSS libraries.
+
+Reported-by: Peter Kümmel <syntheticpp@gmx.net>
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
+
+diff -durN monit-5.7.orig/Makefile.am monit-5.7/Makefile.am
+--- monit-5.7.orig/Makefile.am	2014-02-20 09:00:42.000000000 +0100
++++ monit-5.7/Makefile.am	2014-09-05 12:49:43.711104001 +0200
+@@ -85,7 +85,7 @@
+ 		  src/process/sysdep_@ARCH@.c
+  
+ monit_LDADD 	= libmonit/libmonit.la
+-monit_LDFLAGS 	= -static $(EXTLDFLAGS)
++monit_LDFLAGS 	= $(EXTLDFLAGS)
+ 
+ man_MANS 	= monit.1
+ 
diff --git a/package/monit/monit.mk b/package/monit/monit.mk
new file mode 100644
index 0000000..ef70a7a
--- /dev/null
+++ b/package/monit/monit.mk
@@ -0,0 +1,41 @@
+#############################################################
+#
+# monit
+#
+#############################################################
+
+MONIT_VERSION = 5.10
+MONIT_SITE = http://mmonit.com/monit/dist/
+MONIT_LICENSE = AGPLv3 with OpenSSL exception
+MONIT_LICENSE_FILES = COPYING
+#
+# Touching Makefile.am:
+MONIT_AUTORECONF = YES
+
+# Missing m4/ directory in the source tree
+define MONIT_M4
+	mkdir -p $(@D)/m4
+endef
+MONIT_POST_PATCH_HOOKS += MONIT_M4
+
+MONIT_CONF_ENV = \
+	libmonit_cv_setjmp_available=yes \
+	libmonit_cv_vsnprintf_c99_conformant=yes
+
+MONIT_CONF_OPT += \
+	--without-pam --enable-optimized
+
+ifeq ($(BR2_PACKAGE_OPENSSL),y)
+MONIT_CONF_OPT += --with-ssl=$(STAGING_DIR)/usr
+MONIT_DEPENDENCIES += openssl
+else
+MONIT_CONF_OPT += --without-ssl
+endif
+
+ifeq ($(BR2_LARGEFILE),y)
+MONIT_CONF_OPT += --with-largefiles
+else
+MONIT_CONF_OPT += --without-largefiles
+endif
+
+$(eval $(call AUTOTARGETS))
-- 
1.9.1

