home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / xbmc-9.11.exe / system / python / spyce / makefile < prev    next >
Encoding:
Makefile  |  2009-12-23  |  6.3 KB  |  161 lines

  1. PYTHON := $(shell which python)
  2. SPYCE_VERSION = $(shell $(PYTHON) -c "import spyce; print spyce.__version__")
  3. SPYCE_RELEASE = $(shell $(PYTHON) -c "import spyce; print spyce.__release__")
  4.  
  5. SRC := $(wildcard *.py) $(wildcard modules/*.py) $(wildcard tags/*.py)
  6. OTHER := CHANGES LICENCE README THANKS spyceApache.conf spyce.conf.eg spyce.mime
  7. DOC_SRC := $(wildcard docs/*.spy) docs/*.gif docs/examples/*.gif
  8. DOC = $(wildcard docs/*.html) docs/*.gif
  9. EXAMPLES := $(wildcard docs/examples/*.spy) $(wildcard docs/examples/*.spi) $(wildcard docs/examples/*.tmpl) $(wildcard docs/examples/*.py) $(wildcard docs/examples/*.gif)
  10.  
  11. SFUSER := batripler
  12. SFCVSanon := :pserver:anonymous@cvs1.sourceforge.net:/cvsroot/spyce
  13. SFCVSdev := :ext:$(SFUSER)@cvs1.sourceforge.net:/cvsroot/spyce
  14. SFCVS := $(SFCVSdev)
  15. SF_SPYCE_DIR := /home/groups/s/sp/spyce
  16.  
  17. ssh := ssh -1 -x
  18. scp := scp -o Protocol=1
  19.  
  20. COMPILED = $(SRC:.py=.pyc) $(SRC:.py=.pyo)
  21.  
  22. # install paths
  23. DESTDIR := /
  24. INSTALL_ROOT := $(DESTDIR)
  25. INSTALL_CODE := $(INSTALL_ROOT)/usr/share
  26.  
  27. RPMROOT := /home/barr/misc/rpm
  28.  
  29. .PHONY: all compile clean remake tgz rpm www
  30.  
  31. all: compile docs
  32.  
  33. # make this a dependency every time you use $PYTHON or $SPYCE_VERSION
  34. versionchk: $(PYTHON)
  35.     $(PYTHON) verchk.py
  36.     touch versionchk
  37.  
  38. clean: versionchk
  39.     -rm versionchk
  40.     -rm -f spyce.spec spyce.nsi
  41.     -rm -f *.pyc modules/*.pyc tags/*.pyc
  42.     -rm -f *.pyo modules/*.pyo tags/*.pyo
  43.     -rm -f spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).tgz
  44.     -rm -f spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).noarch.rpm
  45.     -rm -f $(RPMROOT)/SOURCES/spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).tgz
  46.     -rm -f $(RPMROOT)/SRPMS/spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).src.rpm
  47.     -rm -f $(RPMROOT)/RPMS/noarch/spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).noarch.rpm
  48.     -rm -rf $(RPMROOT)/BUILD/spyce-$(SPYCE_VERSION)
  49.     -$(MAKE) -C docs clean
  50.  
  51. perm:
  52.     chmod a+r -R .
  53.     chmod a+rx . `find . -type d`
  54.     chmod a+x run_*.py verchk.py
  55.     chmod a+x spyce.py spyceCGI.py
  56.  
  57. remake: clean all
  58.  
  59. compile: $(COMPILED)
  60.  
  61. # make documentation
  62. docs: compile
  63.     @$(MAKE) -C docs
  64.  
  65. # make source tarball
  66. tgz: versionchk
  67.     @echo "Making clean source tarball: spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).tgz"
  68.     -rm -rf spyce-$(SPYCE_VERSION)
  69.     cvs -d $(SFCVS) export -d spyce-$(SPYCE_VERSION) -D now spyce
  70.     chmod a+r -R spyce-$(SPYCE_VERSION)
  71.     chmod a+x `find spyce-$(SPYCE_VERSION) -type d`
  72.     chmod a+x spyce-$(SPYCE_VERSION)/run_*.py spyce-$(SPYCE_VERSION)/verchk.py
  73.     chmod a+x spyce-$(SPYCE_VERSION)/spyce.py spyce-$(SPYCE_VERSION)/spyceCGI.py
  74.     # process .nsi.in so that we can just use .tgz to make .exe installer
  75.     cd spyce-$(SPYCE_VERSION); make spyce.nsi; rm -f *.pyc *.pyo; cd ..
  76.     tar --totals -czf spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).tgz spyce-$(SPYCE_VERSION)
  77.     rm -rf spyce-$(SPYCE_VERSION)
  78.  
  79. # make rpm
  80. rpm: versionchk tgz spyce.spec
  81.     cp spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).tgz $(RPMROOT)/SOURCES
  82.     rpmbuild -ba spyce.spec
  83.     cp $(RPMROOT)/RPMS/noarch/spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).noarch.rpm .
  84.  
  85. # install Spyce (used for manual install and by rpm scripts)
  86. install: compile docs
  87.     @echo "Installing Spyce python module in: $(INSTALL_CODE)/spyce"
  88.     @for f in `find . -type d`; do \
  89.         mkdir -p $(INSTALL_CODE)/spyce/$$f; \
  90.         chmod a+rx $(INSTALL_CODE)/spyce/$$f; \
  91.     done
  92.     @for f in $(SRC) $(COMPILED) $(OTHER) $(DOC) $(EXAMPLES); do \
  93.         install -m 644 $$f $(INSTALL_CODE)/spyce/$$f; \
  94.     done
  95.     @chmod a+rx $(INSTALL_CODE)/spyce/run_*.py $(INSTALL_CODE)/spyce/verchk.py
  96.     @chmod a+rx $(INSTALL_CODE)/spyce/spyce.py $(INSTALL_CODE)/spyce/spyceCGI.py
  97.  
  98. # uninstall Spyce (used for manual install and by rpm scripts)
  99. uninstall:
  100.     @echo "Removing main Spyce directory: $(INSTALL_CODE)/spyce"
  101.     @-rm -rf $(INSTALL_CODE)/spyce
  102.  
  103. # generate python compiled (bytecode) files
  104. $(COMPILED): $(SRC)
  105.     $(PYTHON) -c "exec '''import py_compile,string,os\nfor i in string.split('$+', ' '):\n  print 'Compiling .pyc: '+i; py_compile.compile(i)\n'''"
  106.     $(PYTHON) -OO -c "exec '''import py_compile,string,os\nfor i in string.split('$+', ' '):\n  print 'Compiling .pyo: '+i; py_compile.compile(i)\n'''"
  107.     chmod a+r $(COMPILED)
  108.  
  109. %.pyc: %.py versionchk
  110.     $(PYTHON) -c "import py_compile; py_compile.compile('$<')"
  111.     chmod a+r $<
  112.  
  113. %.pyo: %.py versionchk
  114.     $(PYTHON) -O -c "import py_compile; py_compile.compile('$<')"
  115.     chmod a+r $<
  116.  
  117. spyce.spec: spyce.spec.in spyce.py
  118.     cat spyce.spec.in | sed "s/__VERSION__/${SPYCE_VERSION}/" | sed "s/__RELEASE__/${SPYCE_RELEASE}/" > spyce.spec
  119.  
  120. spyce.nsi: spyce.nsi.in spyce.py
  121.     cat spyce.nsi.in | sed "s/__VERSION__/${SPYCE_VERSION}/" | sed "s/__RELEASE__/${SPYCE_RELEASE}/" > spyce.nsi
  122.  
  123.  
  124. # update sourceforge
  125. sf: clean tgz compile
  126.     -rm -r www
  127.     mkdir www; mkdir www/htdocs; mkdir www/htdocs/examples; mkdir www/cgi-bin; mkdir www/cgi-bin/eg
  128.     # docs
  129.     @$(MAKE) -C docs sf
  130.     cp docs/*.html docs/*.gif docs/*.ico www/htdocs
  131.     # examples
  132.     cp docs/examples/*.spy docs/examples/*.spi docs/examples/*.tmpl www/htdocs/examples
  133.     # exec
  134.     cp spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).tgz www
  135.     cd www; tar -xzf spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).tgz; mv spyce-$(SPYCE_VERSION) spyce; rm spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).tgz; cd spyce; make compile; cd ../..
  136.     # cgi
  137.     cp docs/examples/*.spy docs/examples/*.spi docs/examples/*.py docs/examples/*.tmpl docs/examples/*.gif www/cgi-bin/eg
  138.     cd www; for f in cgi-bin/eg/*.spy; do spyce/misc/addfirstline.sh $$f '#!/usr/bin/python ../../spyce/run_spyceCGI.py'; done; cd ..
  139.     # package it all up
  140.     tar -czvf www.tgz www/
  141.     -rm -r www
  142.     # send it over
  143.     $(scp) www.tgz $(SFUSER)@shell.sourceforge.net:.
  144.     -rm www.tgz
  145.     make clean
  146.     # unpackage it there
  147.     $(ssh) $(SFUSER)@shell.sourceforge.net 'tar -xzf www.tgz; rm www.tgz; cd www; chmod -R a+r .; chmod a+x `find . -type d`; chmod a+x cgi-bin/eg/*.spy; cd spyce; make perm; cd ../..; chown -R :spyce www; chmod -R g+rw .; chmod g+x `find www -type d`'
  148.     # out with the old and in with the new
  149.     $(ssh) $(SFUSER)@shell.sourceforge.net 'pushd $(SF_SPYCE_DIR); rm -rf cgi-bin htdocs spyce; popd; mv www/* $(SF_SPYCE_DIR); rmdir www'
  150.  
  151. sfcontrib:
  152.     # contribs
  153.     python run_spyceCmd.py -O contrib/*.spy
  154.     $(scp) -r contrib $(SFUSER)@shell.sourceforge.net:$(SF_SPYCE_DIR)/htdocs
  155.  
  156. # upload files to sourceforge file release system
  157. upload: versionchk rpm
  158.     ncftpput upload.sourceforge.net incoming spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).tgz spyce-$(SPYCE_VERSION)-$(SPYCE_RELEASE).noarch.rpm
  159.     make clean
  160.  
  161.