# $Id$ .PHONY : test log all install clean distclean uninstall encaps rename bcfg2only bcfg2bump .SUFFIXES : .SUFFIXES : .ep .sh .installed .packaged .d export BASEDIR = /usr/local export ENCAPDIR := ${BASEDIR}/encap export EPKG := ${BASEDIR}/bin/epkg export MKENCAP := ${BASEDIR}/bin/mkencap export SHELL = /bin/sh srcdir = . export EP2TARGET := $(srcdir)/ep2target BCFG2 := $(basename $(wildcard bcfg2-[0-9].[0-9]*.ep)) BCFG2_CHEETAH := $(basename $(wildcard bcfg2-cheetah-[0-9].[0-9]*.ep)) BCFG2_CHEETAH_DOC := $(basename $(wildcard bcfg2-cheetah-doc-*.ep)) BCFG2_GAMIN := $(basename $(wildcard bcfg2-gamin-*.ep)) BCFG2_GETTEXT := $(basename $(wildcard bcfg2-gettext-*.ep)) BCFG2_GLIB := $(basename $(wildcard bcfg2-glib-*.ep)) BCFG2_LIBGCC := $(basename $(wildcard bcfg2-libgcc-*.sh)) BCFG2_LIBICONV := $(basename $(wildcard bcfg2-libiconv-*.ep)) BCFG2_LIBSTDCXX := $(basename $(wildcard bcfg2-libstdc++-*.sh)) BCFG2_LIBXML2 := $(basename $(wildcard bcfg2-libxml2-*.ep)) BCFG2_LIBXSLT := $(basename $(wildcard bcfg2-libxslt-*.ep)) BCFG2_LXML := $(basename $(wildcard bcfg2-lxml-*.ep)) BCFG2_OPENSSL := $(basename $(wildcard bcfg2-openssl-*.ep)) BCFG2_PKG_CONFIG := $(basename $(wildcard bcfg2-pkg-config-*.ep)) BCFG2_PYOPENSSL := $(basename $(wildcard bcfg2-pyopenssl-*.ep)) BCFG2_PYREX := $(basename $(wildcard bcfg2-pyrex-*.ep)) BCFG2_PYTHON := $(basename $(wildcard bcfg2-python-[0-9].[0-9]*.ep)) BCFG2_ZLIB := $(basename $(wildcard bcfg2-zlib-*.ep)) DAEMONTOOLS := $(basename $(wildcard daemontools-[0-9].[0-9]*.ep)) DAEMONTOOLS_DOC := $(basename $(wildcard daemontools-doc-*.ep)) M4 := $(basename $(wildcard m4-*.sh)) MAKESELF := $(basename $(wildcard makeself-*.ep)) OSTIARTY := $(basename $(wildcard ostiary-[0-9].[0-9]*.ep)) OSTIARTY_DOC := $(basename $(wildcard ostiary-doc-*.ep)) PATCH := $(basename $(wildcard patch-*.ep)) sources_ep := $(sort $(BCFG2) $(BCFG2_CHEETAH) $(BCFG2_CHEETAH_DOC) $(BCFG2_GETTEXT) $(BCFG2_LIBICONV) $(BCFG2_LIBXML2) $(BCFG2_LIBXSLT) $(BCFG2_LXML) $(BCFG2_OPENSSL) $(BCFG2_PKG_CONFIG) $(BCFG2_PYOPENSSL) $(BCFG2_PYREX) $(BCFG2_PYTHON) $(BCFG2_ZLIB) $(DAEMONTOOLS) $(DAEMONTOOLS_DOC) $(MAKESELF) $(OSTIARTY) $(OSTIARTY_DOC) $(PATCH)) sources_sh := $(sort $(BCFG2_LIBGCC) $(BCFG2_LIBSTDCXX) $(M4)) # Only compile bcfg2-glib and bcfg2-gamin (needed by bcfg2 server) on Linux # (Gamin only supports Linux), and only compile bcfg2-python-apt on known # Debian and Ubuntu systems (as python-apt is distribution-specific) UNAME := $(shell uname) ifeq ($(UNAME),Linux) sources_ep += $(BCFG2_GLIB) $(BCFG2_GAMIN) DISTRO := $(shell cat /etc/issue | head -1) endif ifeq ($(DISTRO),Debian GNU/Linux 3.1 \n \l) BCFG2_PYTHON_APT = bcfg2-python-apt-0.5.10 OS ?= linux_debian_sarge endif ifeq ($(DISTRO),Debian GNU/Linux testing/unstable \n \l) BCFG2_PYTHON_APT = bcfg2-python-apt-0.6.19 OS ?= linux_debian_sid endif ifeq ($(DISTRO),Ubuntu 6.06.1 LTS \n \l) BCFG2_PYTHON_APT = bcfg2-python-apt-0.6.16.2ubuntu8 OS ?= linux_ubuntu_dapper endif ifdef BCFG2_PYTHON_APT sources_ep += $(BCFG2_PYTHON_APT) endif # List of all sources... sources := $(sort $(sources_ep) $(sources_sh)) %.installed : %.ep # Clean, compile and install an encap package @printf "***** START .ep.installed for |$*| ***** \n" -$(EPKG) -q -r $(ENCAPDIR)/$* -rm -rf $(ENCAPDIR)/$* -$(MKENCAP) -m /usr/local/bin/m4 -b -DUP $(srcdir)/$*.ep > ./$*.log 2>&1 -$(MKENCAP) -m /usr/local/bin/m4 -b -T $(srcdir)/$*.ep >> ./$*.log 2>&1 $(MKENCAP) -m /usr/local/bin/m4 -b -CBI $(srcdir)/$*.ep >> ./$*.log 2>&1 $(EPKG) -q -i $(ENCAPDIR)/$* test -h $(BASEDIR)/var/encap/$* touch ./$*.installed @printf "***** STOP .ep.installed for |$*| ***** \n" %.installed : %.sh # Create and install a "fake" encap package @printf "***** START .sh.installed for |$*| ***** \n" -$(EPKG) -q -r $(ENCAPDIR)/$* -rm -rf $(ENCAPDIR)/$* chmod 755 $(srcdir)/$*.sh && $(srcdir)/$*.sh $(EPKG) -q -i $(ENCAPDIR)/$* test -h $(BASEDIR)/var/encap/$* touch ./$*.installed @printf "***** STOP .sh.installed for |$*| ***** \n" %.packaged : %.installed # Create .tar.gz encap packages @printf "***** START .installed.packaged for |$*| ***** \n" -rm $(ENCAPDIR)/$*-*.tar.gz -(cd $(ENCAPDIR) && $(MKENCAP) -e $*) -(cd $(ENCAPDIR) && $(MKENCAP) -c $*) mv $(ENCAPDIR)/$*-encap-*.tar.gz ./ touch ./$*.packaged @printf "***** STOP .installed.packaged for |$*| ***** \n" %.d : %.ep # Create dependancy files from .ep files @printf "***** START .d.ep for |$*| ***** \n" chmod 755 $(EP2TARGET) && $(EP2TARGET) $< > $@ @printf "***** STOP .d.ep for |$*| ***** \n" %.d : %.sh # Create dependancy files from .sh files @printf "***** START .d.sh for |$*| ***** \n" chmod 755 $(EP2TARGET) && $(EP2TARGET) $< > $@ @printf "***** STOP .d.sh for |$*| ***** \n" log : ( $(MAKE) install > ./make.log 2>&1 \ && $(MAKE) encaps >> ./make.log 2>&1 \ && $(MAKE) rename >> ./make.log 2>&1 ) & all : install encaps rename .DELETE_ON_ERROR : # delete the target of a rule if it has changed and its # commands exit with a nonzero exit status install : $(EPKG) $(MKENCAP) $(EP2TARGET) $(M4).installed $(addsuffix .installed,$(sources)) encaps : $(EPKG) $(MKENCAP) $(EP2TARGET) $(addsuffix .packaged,$(sources)) rename : encaps if [ "$(OS)x" != "x" ]; then OS="$(OS)"; fi && \ if [ "$${OS}x" != "x" ]; then \ for OLDNAME in `ls ./*-encap-*.tar.gz`; do \ NEWNAME="`printf "%s\n" "$${OLDNAME}" \ | awk -F- '{$$NF = "OSDIST.tar.gz" ; print}' \ | sed s:\ :-:g | sed s:OSDIST:\$${OS}:g`" ; \ if [ "$${OLDNAME}x" != "$${NEWNAME}x" ]; then \ mv ./$${OLDNAME} ./$${NEWNAME}; \ fi; \ done; \ fi clean : -(rm ./*.log; rm ./*.packaged; rm ./*.gz; rm ./*~) distclean : clean -rm ./*.d uninstall : distclean -(find $(BASEDIR)/lib/bcfg2 | grep "\.pyc" | xargs -n1 rm) -(ENCAPS="m4 patch daemontools makeself ostiary bcfg2"; \ for ENCAP in $${ENCAPS}; do \ $(EPKG) -q -r $(ENCAPDIR)/$${ENCAP}-*; \ rm -rf $(ENCAPDIR)/$${ENCAP}-*; \ rm ./$${ENCAP}-*.installed; \ done) -rm -rf $(BASEDIR)/lib/bcfg2 bcfg2only : $(MAKE) -t; sleep 2; touch $(srcdir)/$(BCFG2).ep; $(MAKE) bcfg2bump : @if [ "$(NEWVERSION)x" != "x" ]; then NEWVERSION="$(NEWVERSION)"; fi && \ if [ "$(FORCE)x" != "x" ]; then FORCE="$(FORCE)"; fi && \ if [ "$${NEWVERSION}x" != "x" ]; then \ if [ "$${FORCE}x" != "yesmamx" ]; then \ printf "About to 'svn mv %s %s'\n" "$(BCFG2).ep" "$$NEWVERSION"; \ printf "\tand edit the later as appropriate.\n"; \ printf "Press 'return' to continue, or 'ctrl-c' to exit. "; \ read THROWAWAY; \ fi; \ svn mv $(BCFG2).ep $${NEWVERSION}; \ NVBASE="`printf "%s\n" "$${NEWVERSION}" | sed 's:\.ep::g'`"; \ sed s:$(BCFG2):$$NVBASE:g $${NEWVERSION} > $${NEWVERSION}.tmp; \ mv $${NEWVERSION}.tmp $${NEWVERSION}; \ printf "Changes to %s are:\n" "$${NEWVERSION}"; \ svn diff $${NEWVERSION}; \ if [ "$${FORCE}x" != "yesmamx" ]; then \ printf "'svn commit %s -m \"EncapPackages: Bumped bcfg2 .ep version to %s\"'? \n" "$${NEWVERSION}" "$${NEWVERSION}"; \ printf "Press 'return' to commit, or 'ctrl-c' to exit. "; \ read THROWAWAY; \ fi; \ svn commit $${NEWVERSION} -m "EncapPackages: Bumped bcfg2 .ep version to $${NVBASE}"; \ else \ printf "Set the NEWVERSION (and optionally FORCE) environment variables\n"; \ printf "Example: 'NEWVERSION=bcfg2-0.8.3.ep $(MAKE) bcfg2bump'\n"; \ fi include $(addsuffix .d,$(sources))