# this is # ---------------------------------------------------------------------------- # $Id$ # Copyright (c) 2012 by Daniel Armbruster # ---- # This file is part of csback. # # csback is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # csback is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with csback. If not, see . # ---- # Daniel Armbruster 15/01/2012 # # REVISIONS and CHANGES # 15/01/2012 V0.1 Daniel Armbruster # 16/01/2012 V0.2 added package rule # 28/02/2012 V0.3 smaller modifications - added csbackobs.py # ---------------------------------------------------------------------------- PROGRAMS=csback2cron.py csbackntfy.py csbackgen.py csbackchk.py csbackobs.py .PHONY: all all: install doc .PHONY: install install: installscripts .PHONY: doc doc: pdfdoc # ---------------------------------------------------------------------------- LOCBINDIR=~/bin RSYNC=$(shell env which rsync) CRON=$(shell ps -ef | grep -v grep | grep -cw cron) SYSLOGNG=$(shell ps -ef | grep -v grep | grep -cw syslog) LOGROTATE=$(shell if [ -d /etc/logrotate.d/ ]; then echo logrotate; fi) PYTHON=$(shell env which python) # ---------------------------------------------------------------------------- .PHONY: clean clean: /bin/rm -rvf $(addprefix $(LOCBINDIR)/,$(patsubst %.py,%,$(PROGRAMS))) $(MAKE) -C doc clean # ---------------------------------------------------------------------------- CHECKVAR=$(if $($(1)),,$(error ERROR: missing variable $(1))) CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var))) CHECKPROG=$(if $($(1)),,$(error ERROR: missing program $(1))) CHECKPROGS=$(foreach prog,$(1),$(call CHECKPROG,$(prog))) $(call CHECKVARS, LOCBINDIR) $(call CHECKPROGS, RSYNC CRON SYSLOGNG LOGROTATE PYTHON) # ---------------------------------------------------------------------------- PWD=$(shell env pwd) $(addprefix $(LOCBINDIR)/, $(PROGRAMS)): $(addprefix $(PWD)/, $(PROGRAMS)) $(LOCBINDIR)/%: %.py mkdir -pv $(LOCBINDIR) ln -fs $(addprefix $(PWD)/,$<) $@ chmod +x $(addprefix $(PWD)/,$<) installscripts: $(addprefix $(LOCBINDIR)/, $(patsubst %.py,%,$(PROGRAMS))) # ---------------------------------------------------------------------------- pdfdoc: $(MAKE) -C doc pdf # ============================================================================ # create package # -------------- # version code based on current date VERSIONCODE=$(shell date +'%Y%m%d') # name of the package (including version code) THEPACKAGE=csback$(VERSIONCODE) # directory to place temporary files in TMPDIR=$(HOME)/tmp # path where the package will be created TMPPATH=$(TMPDIR)/$(THEPACKAGE) # tar file PACKAGETARFILE=$(THEPACKAGE).tar # gzipped tar file PACKAGEGZIPFILE=$(PACKAGETARFILE).gz # bzipped tar file PACKAGEBZIPFILE=$(PACKAGETARFILE).bz2 # list of README files to be obtained from the subversion repository INFOFILESFROMSVNWITHPATH=src/LICENSE.GPL # list of files to be created INFOFILESFROMSVN=$(notdir $(INFOFILESFROMSVNWITHPATH)) DIRFROMSVNWITHPATH=src/python/csback # list of files to be created DIRFROMSVN=$(notdir $(DIRFROMSVNWITHPATH)) # rule for the creation of README files from the repository $(addprefix $(TMPPATH)/,$(INFOFILESFROMSVN)): mkdir -pv $(dir $@) svn export \ $(SVNTF)/trunk/$(filter %$(notdir $@),$(INFOFILESFROMSVNWITHPATH)) $@ # rule for the creation of csback files from the repository $(addprefix $(TMPPATH)/,$(DIRFROMSVN)): mkdir -pv $(dir $@) svn export $(SVNTF)/trunk/$(filter %$(notdir $@),$(DIRFROMSVNWITHPATH)) $@ # create package tar archive $(TMPDIR)/$(PACKAGETARFILE): $(TMPPATH) /bin/rm -fv $@ cd $