You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.1KB

  1. # import buildflags
  2. CFLAGS += $(shell dpkg-buildflags --get CFLAGS)
  3. CPPFLAGS += $(shell dpkg-buildflags --get CPPFLAGS)
  4. CXXFLAGS += $(shell dpkg-buildflags --get CXXFLAGS)
  5. LDFLAGS += $(shell dpkg-buildflags --get LDFLAGS)
  6. # define common directories
  7. PLUGINDIR := /usr/lib/nagios/plugins
  8. CRONJOBDIR := /usr/lib/nagios/cronjobs
  9. CONFIGDIR := /etc/nagios-plugins/config
  10. PNP4NAGIOSTEMPLATEDIR := /etc/pnp4nagios/templates.d/nagios-plugins-contrib
  11. INIDIR := /etc/nagios-plugins
  12. CONFIGFILES := $(wildcard *.cfg)
  13. # guess the name of the plugin to build if not defined
  14. PLUGINNAME := $(shell basename $(CURDIR))
  15. ifndef PLUGIN
  16. PLUGIN := $(PLUGINNAME)
  17. endif
  18. DOCDIR := /usr/share/doc/nagios-plugins-contrib/$(PLUGINNAME)
  19. # add some default files to clean
  20. # we actually need strip here. make is weird sometimes.
  21. CLEANEXTRAFILES := $(strip $(wildcard *.o) $(wildcard *.a) $(wildcard *.so))
  22. # build the stuff actually
  23. all:: $(PLUGIN) $(MANPAGES) $(INIFILES) $(CRONJOBS)
  24. install::
  25. install -d $(DESTDIR)$(PLUGINDIR)
  26. install -m 755 -o root -g root $(PLUGIN) $(DESTDIR)$(PLUGINDIR)
  27. ifdef CONFIGFILES
  28. install -d $(DESTDIR)$(CONFIGDIR)
  29. install -m 644 -o root -g root $(CONFIGFILES) $(DESTDIR)$(CONFIGDIR)
  30. endif
  31. ifdef MANPAGES
  32. set -e; for m in $(MANPAGES); do \
  33. section=`echo $$m | sed 's,\.gz$$,,;s,.*\.,,'` ;\
  34. mandir="/usr/share/man/man$${section}" ;\
  35. install -d $(DESTDIR)$${mandir} ;\
  36. install -m 644 -o root -g root $${m} $(DESTDIR)$${mandir} ;\
  37. done
  38. endif
  39. ifdef PNP4NAGIOSTEMPLATES
  40. install -d $(DESTDIR)$(PNP4NAGIOSTEMPLATEDIR)
  41. install -m 644 -o root -g root $(PNP4NAGIOSTEMPLATES) $(DESTDIR)$(PNP4NAGIOSTEMPLATEDIR)
  42. endif
  43. ifdef INIFILES
  44. install -d $(DESTDIR)$(INIDIR)
  45. install -m 644 -o root -g root $(INIFILES) $(DESTDIR)$(INIDIR)
  46. endif
  47. ifdef DOCFILES
  48. install -d $(DESTDIR)$(DOCDIR)
  49. install -m 644 -o root -g root $(DOCFILES) $(DESTDIR)$(DOCDIR)
  50. endif
  51. ifdef CRONJOBS
  52. install -d $(DESTDIR)$(CRONJOBDIR)
  53. install -m 755 -o root -g root $(CRONJOBS) $(DESTDIR)$(CRONJOBDIR)
  54. endif
  55. clean::
  56. ifdef CLEANFILES
  57. rm -f $(CLEANFILES)
  58. endif
  59. ifneq (,$(CLEANEXTRAFILES))
  60. rm -f $(CLEANEXTRAFILES)
  61. endif
  62. .PHONY: clean