clean more on distclean
[mediagoblin.git] / Makefile.in
index a532d861a649afc60472f0006370ea9164112226..a79d6cbcc3807ed6b3c0c8ffb7df321d5623dcd3 100644 (file)
@@ -1,14 +1,31 @@
+# Makefile.in
+#
+# Copyright © 2012, 2013 Brandon Invergo <brandon@invergo.net>
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.  This file is offered as-is,
+# without any warranty.
+
+# List whatever files you want to include in your source distribution here.
+# You can include whole directories but note that *everything* under that 
+# directory will be included
+DISTFILES = PKG-INFO Makefile.in configure setup.py install-sh
+
+DESTDIR = 
 VPATH = @srcdir@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_STRING = @PACKAGE_STRING@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_DISTNAME = ${PACKAGE_NAME}-${PACKAGE_VERSION}
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 PYTHON = @PYTHON@
 VIRTUALENV = @VIRTUALENV@
 SPHINXBUILD = @SPHINXBUILD@
+POSTGRES = @POSTGRES@
 SHELL = @SHELL@
 MKDIR_P = @MKDIR_P@
 INSTALL = @INSTALL@
@@ -23,6 +40,7 @@ includedir = @includedir@
 infodir = @infodir@
 prefix = @prefix@
 srcdir = @srcdir@
+abs_srcdir = @abs_srcdir@
 datadir = @datadir@
 datarootdir = @datarootdir@
 pythondir = @pythondir@
@@ -33,56 +51,125 @@ pkgpythondir = @pkgpythondir@
 pkgpyexecdir = @pkgpyexecdir@
 PYTHONPATH = $(pythondir)$(PATH_SEPARATOR)$(DESTDIR)$(pythondir)
 
-INSTALL_TARGET = develop
-
 all: install
 
+.PHONY: all install develop uninstall distclean info install-html html \
+install-pdf pdf install-dvi dvi install-ps ps clean dist check \
+installdirs postgresql update
 
-.PHONY: all install uninstall distclean info install-html html install-pdf pdf install-dvi dvi install-ps ps clean dist check installdirs
-
-
+# Since installing to a virtualenv is all the rage these days, support
+# it here. If the VIRTUALENV variable is set to anything other than
+# "no", set up a new virtualenv and install there, otherwise install
+# as usual from setup.py
 install: installdirs
        $(NORMAL_INSTALL)
 ifneq ($(VIRTUALENV),no)
-       $(VIRTUALENV) $(VIRTUALENV_FLAGS) $(DESTDIR)$(prefix) || $(VIRTUALENV) $(DESTDIR)$(prefix)
-       $(DESTDIR)$(prefix)/bin/python $(srcdir)/setup.py $(INSTALL_TARGET) --prefix=$(DESTDIR)$(prefix)
+       $(VIRTUALENV) $(VIRTUALENV_FLAGS) --python=$(PYTHON) \
+               --system-site-packages $(DESTDIR)$(prefix) || \
+               $(VIRTUALENV) $(DESTDIR)$(prefix)
+       $(DESTDIR)$(prefix)/bin/python $(srcdir)/setup.py install \
+               --prefix=$(DESTDIR)$(prefix)
+else
+       $(PYTHON) $(srcdir)/setup.py install --prefix=$(DESTDIR)$(prefix)
+endif
+       if [[ $(DESTDIR)$(prefix) != $(abs_srcdir) ]]; then \
+               $(INSTALL_DATA) $(srcdir)/Makefile $(DESTDIR)$(prefix)/Makefile; \
+               $(INSTALL_DATA) $(srcdir)/lazycelery.sh $(DESTDIR)$(prefix)/lazycelery.sh; \
+               $(INSTALL_DATA) $(srcdir)/lazyserver.sh $(DESTDIR)$(prefix)/lazyserver.sh; \
+       fi
+
+# The same as "install", except use the "develop" setup.py target
+develop: installdirs
+       $(NORMAL_INSTALL)
+ifneq ($(VIRTUALENV),no)
+       $(VIRTUALENV) $(VIRTUALENV_FLAGS) --python=$(PYTHON) \
+               --system-site-packages $(DESTDIR)$(prefix) || \
+               $(VIRTUALENV) $(DESTDIR)$(prefix)
+       $(DESTDIR)$(prefix)/bin/python $(srcdir)/setup.py develop \
+               --prefix=$(DESTDIR)$(prefix)
 else
-       $(PYTHON) $(srcdir)/setup.py $(INSTALL_TARGET) --prefix=$(DESTDIR)$(prefix)
+       $(PYTHON) $(srcdir)/setup.py develop --prefix=$(DESTDIR)$(prefix)
 endif
-       $(INSTALL_SCRIPT) $(srcdir)/lazyserver.sh $(DESTDIR)$(pkgdatadir)
-       $(INSTALL_SCRIPT) $(srcdir)/lazycelery.sh $(DESTDIR)$(pkgdatadir)
-       $(INSTALL_SCRIPT) $(srcdir)/lazystarter.sh $(DESTDIR)$(pkgdatadir)
-       $(INSTALL_DATA) $(srcdir)/mediagoblin.ini $(DESTDIR)$(pkgdatadir)
-       $(INSTALL_DATA) $(srcdir)/paste.ini $(DESTDIR)$(pkgdatadir)
+       if [ "$(DESTDIR)$(prefix)" != "$(abs_srcdir)" ]; then \
+               $(INSTALL_DATA) $(srcdir)/Makefile $(DESTDIR)$(prefix)/Makefile; \
+               $(INSTALL_DATA) $(srcdir)/lazycelery.sh $(DESTDIR)$(prefix)/lazycelery.sh; \
+               $(INSTALL_DATA) $(srcdir)/lazyserver.sh $(DESTDIR)$(prefix)/lazyserver.sh; \
+       fi
+
+
+# setup.py doesn't (yet) support an uninstall command, so until it does, you 
+# must manually remove everything that was installed here. The following example
+# should remove a basic package installed via setup.py, but please double- and 
+# triple-check it so that you don't remove something you shouldn't!
+# Be sure to remove any extra files you install, such as binaries or documentation!
+# uninstall: 
+#      case $(prefix) in
+#              /usr|/usr/local )
+#                      exit 1 ;;
+#              /www/*|/srv/* )
+#                      rm -rvf $(prefix) ;;
+#      esac
+
+# Just use the usual setup.py clean command
+clean:
+       $(PYTHON) setup.py clean
 
 
-uninstall: $(wildcard $(srcdir)/docs/source/*)
-       rm -rf $(DESTDIR)$(pkgdatadir)
-       rm -rf $(DESTDIR)$(htmldir)
-       rm -rf $(DESTDIR)$(pdfdir)
+# Clean up the output of configure
+distclean: 
+       rm -v $(srcdir)/config.log
+       rm -v $(srcdir)/config.status
+       rm -rvf $(srcdir)/autom4te.cache
+       rm -v $(srcdir)/aclocal.m4
+       rm -v $(srcdir)/Makefile
 
+# You can either use the setup.py sdist command or you can roll your own here
+dist:
+#      $(PYTHON) setup.py sdist
+       mkdir $(PACKAGE_DISTNAME)
+       cp -r $(DISTFILES) $(PACKAGE_DISTNAME)
+       tar -czf $(PACKAGE_DISTNAME).tar.gz $(PACKAGE_DISTNAME)
+       rm -rf $(PACKAGE_DISTNAME)
 
-clean:
-       $(PYTHON) setup.py clean
+# Use the setup.py check command
+check:
+       $(PYTHON) setup.py check
+
+# setup.py might complain if a directory doesn't exist so just in case, make the directory
+# here
+installdirs:
+       $(MKDIR_P) $(DESTDIR)$(prefix)
 
+# Set up PostgreSQL
+postgresql:
+       sudo -u $(POSTGRES) createuser mediagoblin
+       sudo -u $(POSTGRES) createdb -E UNICODE -O mediagoblin mediagoblin
 
-distclean: $(wildcard $(srcdir)/docs/source/*)
-       rm $(srcdir)/config.log
-       rm $(srcdir)/config.status
+update:
+ifneq ($(VIRTUALENV),no)
+       $(prefix)/bin/python $(srcdir)/setup.py develop --prefix=$(prefix) --upgrade
+else
+       $(PYTHON) $(srcdir)/setup.py develop --prefix=$(prefix) --upgrade
+endif  
+       $(prefix)/bin/gmg dbupdate
 
+# The following show how to install documentation. In this example,
+# docs are built from a separate Makefile contained in the docs
+# directory which uses the SPHINXBUILD variable to store the location
+# of the sphinx-build (Python doc tool) binary to use.
 
-$(DESTDIR)$(infodir)/gnumediagoblin.info: docs/build/texinfo/gnumediagoblin.info
+$(DESTDIR)$(infodir)/mediagoblin.info: docs/build/texinfo/mediagoblin.info
        $(POST_INSTALL)
        $(INSTALL_DATA) @< $(DESTDIR)$@
        if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then
                install-info --dir-file=$(DESTDIR)$(infodir)/dir \
-                               $(DESTDIR)$(infodir)/gnumediagoblin.info;
+                               $(DESTDIR)$(infodir)/foo.info;
        else true; fi
 
-info: docs/build/texinfo/gnumediagoblin.info
+info: docs/build/texinfo/mediagoblin.info
 
-docs/build/texinfo/gnumediagoblin.info: $(wildcard docs/source/*)
-ifneq ($(SPHINX_BUILD),no)
+docs/build/texinfo/mediagoblin.info: $(wildcard docs/source/*)
+ifneq ($(SPHINXBUILD),no)
        $(MAKE) -C docs info SPHINXBUILD=$(SPHINXBUILD)
 endif
 
@@ -93,18 +180,18 @@ install-html: html installdirs
 html: docs/build/html/index.html
 
 docs/build/html/index.html: $(wildcard $(srcdir)/docs/source/*)
-ifneq ($(SPHINX_BUILD),no)
+ifneq ($(SPHINXBUILD),no)
        $(MAKE) -C docs html SPHINXBUILD=$(SPHINXBUILD)
 endif
 
 
 install-pdf: pdf installdirs
-       $(INSTALL_DATA) docs/build/latex/GNUMediaGoblin.pdf $(DESTDIR)$(pdfdir)
+       $(INSTALL_DATA) docs/build/latex/mediagoblin.pdf $(DESTDIR)$(pdfdir)
 
-pdf: docs/build/latex/GNUMediaGoblin.pdf
+pdf: docs/build/latex/mediagoblin.pdf
 
-docs/build/latex/GNUMediaGoblin.pdf: $(wildcard $(srcdir)/docs/source/*)
-ifneq ($(SPHINX_BUILD),no)
+docs/build/latex/mediagoblin.pdf: $(wildcard $(srcdir)/docs/source/*)
+ifneq ($(SPHINXBUILD),no)
        $(MAKE) -C docs latexpdf SPHINXBUILD=$(SPHINXBUILD)
 endif
 
@@ -118,15 +205,3 @@ install-ps:
 ps:
 
 
-dist:
-       $(PYTHON) setup.py sdist
-
-check:
-       $(PYTHON) setup.py check
-
-installdirs:
-       $(MKDIR_P) \
-               $(DESTDIR)$(pkgpythondir) \
-               $(DESTDIR)$(pkgdatadir) \
-               $(DESTDIR)$(htmldir) \
-               $(DESTDIR)$(pdfdir)