# 
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2007 FON Technology
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 4091 2006-06-27 00:35:46Z mbm $

include $(TOPDIR)/rules.mk

PKG_NAME:=monit
PKG_VERSION:=4.9
PKG_RELEASE:=1

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.tildeslash.com/monit/dist/
PKG_MD5SUM:=bcbaab776a54d1e34e3a057c925de9ca
PKG_CAT:=zcat

PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/

include $(INCLUDE_DIR)/package.mk

define Package/monit-fon
  SECTION:=base
  CATEGORY:=Utilities
  TITLE:=monit - system monitor
  DESCRIPTION:=A lightweight system monitor
  URL:=http://www.tildeslash.com/monit/
endef

define Build/Configure
	(cd $(PKG_BUILD_DIR); \
		rm -rf config.{cache,status} ; \
		$(TARGET_CONFIGURE_OPTS) \
		CFLAGS="$(TARGET_CFLAGS) -s" \
		./configure --host=$(GNU_TARGET_NAME) \
			--prefix=/usr \
			--without-largefiles \
			--without-resource \
			--without-ssl \
	);
endef

define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR) \
		$(TARGET_CONFIGURE_OPTS) \
		CFLAGS="$(TARGET_CFLAGS) -I . \
			-I./device -I./http \
			-I./process -I./protocols"
endef

define Package/monit-fon/install
	$(CP) ./files/* $(1)/
	install -m0755 -d $(1)/sbin
	ln -sf ../init.d/monitd $(1)/etc/rc1.d/S99monit
	ln -sf ../init.d/monitd $(1)/etc/rc2.d/K05monit
	$(CP) $(PKG_INSTALL_DIR)/monit $(1)/sbin/
endef

$(eval $(call BuildPackage,monit-fon))
