Merge pull request #64 from graysky2/master

fixes to Makefile to support other distros
This commit is contained in:
Jordi Sanfeliu 2014-08-23 19:19:36 +02:00
commit 2fe19df4ed
1 changed files with 36 additions and 23 deletions

View File

@ -2,9 +2,12 @@ PN = monitorix
PREFIX ?= /usr PREFIX ?= /usr
CONFDIR = /etc CONFDIR = /etc
BASEDIR = /var/lib/monitorix/www BASEDIR = /var/lib/monitorix
WWWDIR = $(BASEDIR)/www
DBDIR = /var/lib/monitorix
LIBDIR = /usr/lib/monitorix LIBDIR = /usr/lib/monitorix
INITDIR_SYSTEMD = $(PREFIX)/lib/systemd/system INITDIR_SYSTEMD = $(PREFIX)/lib/systemd/system
INITDIR_RHEL = $(CONFDIR)/rc.d/init.d
INITDIR_OTHER = $(CONFDIR)/init.d INITDIR_OTHER = $(CONFDIR)/init.d
BINDIR = $(PREFIX)/bin BINDIR = $(PREFIX)/bin
DOCDIR = $(PREFIX)/share/doc/$(PN) DOCDIR = $(PREFIX)/share/doc/$(PN)
@ -16,9 +19,9 @@ RMD = rmdir
SED = sed SED = sed
INSTALL = install -p INSTALL = install -p
INSTALL_PROGRAM = $(INSTALL) -m755 INSTALL_PROGRAM = $(INSTALL) -m755
INSTALL_SCRIPT = $(INSTALL) -m755
INSTALL_DATA = $(INSTALL) -m644 INSTALL_DATA = $(INSTALL) -m644
INSTALL_DIR = $(INSTALL) -d INSTALL_DIR = $(INSTALL) -d
INSTALL_WORLDDIR = $(INSTALL) -dm777
Q = @ Q = @
@ -39,21 +42,26 @@ install-bin:
$(INSTALL_DIR) "$(DESTDIR)$(BINDIR)" $(INSTALL_DIR) "$(DESTDIR)$(BINDIR)"
$(INSTALL_PROGRAM) $(PN) "$(DESTDIR)$(BINDIR)/$(PN)" $(INSTALL_PROGRAM) $(PN) "$(DESTDIR)$(BINDIR)/$(PN)"
$(INSTALL_DIR) "$(DESTDIR)$(BASEDIR)/cgi" $(INSTALL_DIR) "$(DESTDIR)$(DBDIR)"
$(INSTALL_DIR) "$(DESTDIR)$(BASEDIR)/imgs"
$(INSTALL_PROGRAM) $(PN).cgi "$(DESTDIR)$(BASEDIR)/cgi/$(PN).cgi" $(INSTALL_DIR) "$(DESTDIR)$(BASEDIR)"
$(INSTALL_DATA) logo_bot.png "$(DESTDIR)$(BASEDIR)/logo_bot.png" $(INSTALL_DIR) "$(DESTDIR)$(WWWDIR)"
$(INSTALL_DATA) logo_top.png "$(DESTDIR)$(BASEDIR)/logo_top.png" $(INSTALL_DIR) "$(DESTDIR)$(WWWDIR)/cgi"
$(INSTALL_DATA) monitorixico.png "$(DESTDIR)$(BASEDIR)/monitorixico.png" $(INSTALL_WORLDDIR) "$(DESTDIR)$(WWWDIR)/imgs"
$(INSTALL_PROGRAM) $(PN).cgi "$(DESTDIR)$(WWWDIR)/cgi/$(PN).cgi"
$(INSTALL_DATA) logo_bot.png "$(DESTDIR)$(WWWDIR)/logo_bot.png"
$(INSTALL_DATA) logo_top.png "$(DESTDIR)$(WWWDIR)/logo_top.png"
$(INSTALL_DATA) monitorixico.png "$(DESTDIR)$(WWWDIR)/monitorixico.png"
$(INSTALL_DIR) "$(DESTDIR)$(CONFDIR)/$(PN)" $(INSTALL_DIR) "$(DESTDIR)$(CONFDIR)/$(PN)"
$(INSTALL_DATA) $(PN).conf "$(DESTDIR)$(CONFDIR)/$(PN)/$(PN).conf" $(INSTALL_DATA) $(PN).conf "$(DESTDIR)$(CONFDIR)/$(PN)/$(PN).conf"
$(INSTALL_DIR) "$(DESTDIR)$(CONFDIR)/$(PN)/conf.d"
$(INSTALL_DIR) "$(DESTDIR)$(CONFDIR)/logrotate.d/" $(INSTALL_DIR) "$(DESTDIR)$(CONFDIR)/logrotate.d/"
$(INSTALL_DATA) docs/$(PN).logrotate "$(DESTDIR)$(CONFDIR)/logrotate.d/$(PN).logrotate" $(INSTALL_DATA) docs/$(PN).logrotate "$(DESTDIR)$(CONFDIR)/logrotate.d/$(PN)"
$(INSTALL_DIR) "$(DESTDIR)$(CONFDIR)/sysconfig" $(INSTALL_DIR) "$(DESTDIR)$(CONFDIR)/sysconfig"
$(INSTALL_DATA) docs/$(PN).sysconfig "$(DESTDIR)$(CONFDIR)/sysconfig//$(PN).sysconfig" $(INSTALL_DATA) docs/$(PN).sysconfig "$(DESTDIR)$(CONFDIR)/sysconfig/$(PN)"
$(INSTALL_DIR) "$(DESTDIR)$(LIBDIR)" $(INSTALL_DIR) "$(DESTDIR)$(LIBDIR)"
$(INSTALL_DATA) lib/apache.pm "$(DESTDIR)$(LIBDIR)/apache.pm" $(INSTALL_DATA) lib/apache.pm "$(DESTDIR)$(LIBDIR)/apache.pm"
@ -100,6 +108,7 @@ install-bin:
$(INSTALL_DATA) reports/de.html "$(DESTDIR)$(BASEDIR)/reports/de.html" $(INSTALL_DATA) reports/de.html "$(DESTDIR)$(BASEDIR)/reports/de.html"
$(INSTALL_DATA) reports/en.html "$(DESTDIR)$(BASEDIR)/reports/en.html" $(INSTALL_DATA) reports/en.html "$(DESTDIR)$(BASEDIR)/reports/en.html"
$(INSTALL_DATA) reports/it.html "$(DESTDIR)$(BASEDIR)/reports/it.html" $(INSTALL_DATA) reports/it.html "$(DESTDIR)$(BASEDIR)/reports/it.html"
$(INSTALL_DATA) reports/pl.html "$(DESTDIR)$(BASEDIR)/reports/pl.html"
$(INSTALL_DATA) reports/zh_CN.html "$(DESTDIR)$(BASEDIR)/reports/zh_CN.html" $(INSTALL_DATA) reports/zh_CN.html "$(DESTDIR)$(BASEDIR)/reports/zh_CN.html"
$(INSTALL_DIR) "$(DESTDIR)$(BASEDIR)/usage" $(INSTALL_DIR) "$(DESTDIR)$(BASEDIR)/usage"
@ -125,7 +134,9 @@ install-man:
$(INSTALL_DATA) man/man5/$(PN).conf.5 "$(DESTDIR)$(MAN5DIR)/$(PN).conf.5" $(INSTALL_DATA) man/man5/$(PN).conf.5 "$(DESTDIR)$(MAN5DIR)/$(PN).conf.5"
$(INSTALL_DIR) "$(DESTDIR)$(MAN8DIR)" $(INSTALL_DIR) "$(DESTDIR)$(MAN8DIR)"
gzip -9 "$(DESTDIR)$(MAN5DIR)/$(PN).conf.5"
$(INSTALL_DATA) man/man8/$(PN).8 "$(DESTDIR)$(MAN8DIR)/$(PN).8" $(INSTALL_DATA) man/man8/$(PN).8 "$(DESTDIR)$(MAN8DIR)/$(PN).8"
gzip -9 "$(DESTDIR)$(MAN8DIR)/$(PN).8"
install-systemd: install-systemd:
$(Q)echo -e '\033[1;32mInstalling systemd service...\033[0m' $(Q)echo -e '\033[1;32mInstalling systemd service...\033[0m'
@ -136,7 +147,7 @@ install-systemd:
install-upstart: install-upstart:
$(Q)echo -e '\033[1;32mInstalling upstart service...\033[0m' $(Q)echo -e '\033[1;32mInstalling upstart service...\033[0m'
$(INSTALL_DIR) "$(DESTDIR)$(INITDIR_OTHER)" $(INSTALL_DIR) "$(DESTDIR)$(INITDIR_OTHER)"
$(INSTALL_PROGRAM) docs/$(PN).upstart "$(DESTDIR)$(INITDIR_UPSTART)/$(PN)" $(INSTALL_PROGRAM) docs/$(PN).upstart "$(DESTDIR)$(INITDIR_OTHER)/$(PN)"
install-debian: install-debian:
$(Q)echo -e '\033[1;32mInstalling debian sysv service...\033[0m' $(Q)echo -e '\033[1;32mInstalling debian sysv service...\033[0m'
@ -145,8 +156,8 @@ install-debian:
install-redhat: install-redhat:
$(Q)echo -e '\033[1;32mInstalling redhat sysv service...\033[0m' $(Q)echo -e '\033[1;32mInstalling redhat sysv service...\033[0m'
$(INSTALL_DIR) "$(DESTDIR)$(INITDIR_OTHER)" $(INSTALL_DIR) "$(DESTDIR)$(INITDIR_RHEL)"
$(INSTALL_PROGRAM) docs/$(PN).init "$(DESTDIR)$(INITDIR_OTHER)/$(PN)" $(INSTALL_PROGRAM) docs/$(PN).init "$(DESTDIR)$(INITDIR_RHEL)/$(PN)"
install-systemd-all: install-bin install-man install-docs install-systemd install-systemd-all: install-bin install-man install-docs install-systemd
@ -158,17 +169,17 @@ install-redhat-all: install-bin install-man install-docs install-redhat
uninstall-bin: uninstall-bin:
$(RM) "$(DESTDIR)$(BINDIR)/$(PN)" $(RM) "$(DESTDIR)$(BINDIR)/$(PN)"
$(RM) "$(DESTDIR)$(BASEDIR)/cgi/$(PN).cgi" $(RM) "$(DESTDIR)$(WWWDIR)/cgi/$(PN).cgi"
$(RM) "$(DESTDIR)$(BASEDIR)/logo_bot.png" $(RM) "$(DESTDIR)$(WWWDIR)/logo_bot.png"
$(RM) "$(DESTDIR)$(BASEDIR)/logo_top.png" $(RM) "$(DESTDIR)$(WWWDIR)/logo_top.png"
$(RM) "$(DESTDIR)$(BASEDIR)/monitorixico.png" $(RM) "$(DESTDIR)$(WWWDIR)/monitorixico.png"
$(RM) "$(DESTDIR)$(CONFDIR)/$(PN)/$(PN).conf" $(RM) "$(DESTDIR)$(CONFDIR)/$(PN)/$(PN).conf"
$(RM) "$(DESTDIR)$(CONFDIR)/logrotate.d/$(PN).logrotate" $(RM) "$(DESTDIR)$(CONFDIR)/logrotate.d/$(PN)"
$(RM) "$(DESTDIR)$(CONFDIR)/sysconfig//$(PN).sysconfig" $(RM) "$(DESTDIR)$(CONFDIR)/sysconfig/$(PN)"
$(RM) "$(DESTDIR)$(LIBDIR)/"*.pm $(RM) "$(DESTDIR)$(LIBDIR)/"*.pm
$(RM) "$(DESTDIR)$(BASEDIR)/reports/"*.html $(RM) "$(DESTDIR)$(BASEDIR)/reports/"*.html
$(RMD) "$(DESTDIR)$(LIBDIR)/" $(RMD) "$(DESTDIR)$(LIBDIR)/"
$(RMD) "$(DESTDIR)$(BASEDIR)/cgi" $(RMD) "$(DESTDIR)$(WWWDIR)/cgi"
uninstall-docs: uninstall-docs:
$(RM) "$(DESTDIR)$(DOCDIR)/$(PN)-alert.sh" $(RM) "$(DESTDIR)$(DOCDIR)/$(PN)-alert.sh"
@ -179,8 +190,8 @@ uninstall-docs:
$(RM) "$(DESTDIR)$(DOCDIR)/"*.conf $(RM) "$(DESTDIR)$(DOCDIR)/"*.conf
uninstall-man: uninstall-man:
$(RM) "$(DESTDIR)$(MAN5DIR)/$(PN).conf.5" $(RM) "$(DESTDIR)$(MAN5DIR)/$(PN).conf.5.gz"
$(RM) "$(DESTDIR)$(MAN8DIR)/$(PN).8" $(RM) "$(DESTDIR)$(MAN8DIR)/$(PN).8.gz"
uninstall-systemd: uninstall-systemd:
$(RM) "$(DESTDIR)$(INITDIR_SYSTEMD)/$(PN).service" $(RM) "$(DESTDIR)$(INITDIR_SYSTEMD)/$(PN).service"
@ -192,7 +203,7 @@ uninstall-debian:
$(RM) "$(DESTDIR)$(INITDIR_OTHER)/$(PN)" $(RM) "$(DESTDIR)$(INITDIR_OTHER)/$(PN)"
uninstall-redhat: uninstall-redhat:
$(RM) "$(DESTDIR)$(INITDIR_OTHER)/$(PN)" $(RM) "$(DESTDIR)$(INITDIR_RHEL)/$(PN)"
uninstall-systemd-all: uninstall-bin uninstall-man uninstall-docs uninstall-systemd uninstall-systemd-all: uninstall-bin uninstall-man uninstall-docs uninstall-systemd
@ -206,6 +217,8 @@ uninstall:
$(Q)echo "run one of the following:" $(Q)echo "run one of the following:"
$(Q)echo " make uninstall-systemd-all (systemd based systems)" $(Q)echo " make uninstall-systemd-all (systemd based systems)"
$(Q)echo " make uninstall-upstart-all (upstart based systems)" $(Q)echo " make uninstall-upstart-all (upstart based systems)"
$(Q)echo " make uninstall-debian-all (debian sysv based systems)"
$(Q)echo " make uninstall-redhat-all (redhat sysv based systems)"
$(Q)echo $(Q)echo
$(Q)echo "or check out the Makefile for specific rules" $(Q)echo "or check out the Makefile for specific rules"