Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
[myslice.git] / Makefile
1 SHELL = /bin/bash
2
3 MAKE-SILENT = $(MAKE) --no-print-directory
4
5 all: static templates
6
7 # clean up and recompute
8 redo: clean-oldies redo-static redo-templates 
9
10 clean-oldies:
11         rm -rf all-static all-templates django-static 
12
13 force:
14
15 DESTDIR := /
16 datadir := /usr/share
17 bindir := /usr/bin
18
19 PWD := $(shell pwd)
20
21
22 build: static templates force
23         python setup.py build
24
25 install: 
26         python setup.py install \
27             --install-purelib=$(DESTDIR)/$(datadir)/unfold \
28             --install-scripts=$(DESTDIR)/$(datadir)/unfold \
29             --install-data=$(DESTDIR)/$(datadir)/unfold
30
31 #################### third-party layout is managed as part of collectstatic
32 static: force
33         ./manage.py collectstatic --noinput
34
35 clean-static:
36         rm -rf static/
37
38 redo-static: clean-static static
39
40 ####################
41 # general stuff
42 DATE=$(shell date -u +"%a, %d %b %Y %T")
43
44 # This is called from the build with the following variables set 
45 # (see build/Makefile and target_debian)
46 # (.) RPMTARBALL
47 # (.) RPMVERSION
48 # (.) RPMRELEASE
49 # (.) RPMNAME
50 DEBVERSION=$(RPMVERSION).$(RPMRELEASE)
51 DEBTARBALL=../$(RPMNAME)_$(DEBVERSION).orig.tar.bz2
52
53 debian: static templates debian/changelog debian.source debian.package
54
55 debian/changelog: debian/changelog.in
56         sed -e "s|@VERSION@|$(DEBVERSION)|" -e "s|@DATE@|$(DATE)|" debian/changelog.in > debian/changelog
57
58 debian.source: force 
59         rsync -a $(RPMTARBALL) $(DEBTARBALL)
60
61 debian.package:
62         debuild --set-envvar PREFIX=/usr -uc -us -b
63
64 debian.clean:
65         $(MAKE) -f debian/rules clean
66         rm -rf build/ MANIFEST ../*.tar.gz ../*.dsc ../*.build
67         find . -name '*.pyc' -delete
68
69
70 # having templates in a templates/ subdir is fine most of the time except for plugins
71 plugins-templates: force
72         @find plugins -type f -name '*.html' 
73 local-templates: force
74         @$(foreach tmpl,$(shell find . -name templates | grep -v '^\./templates$$'),find $(tmpl) -maxdepth 1 -type f -name *.html;)
75
76
77 list-templates: plugins-templates local-templates
78
79 #################### manage templates for the plugin area
80 templates: force
81         @mkdir -p templates
82         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-templates),../$(x)) ./templates
83
84 clean-templates templates-clean: force
85         rm -rf ./templates
86
87 redo-templates: clean-templates templates
88
89 ####################
90 ### list-all list-resources: list-templates list-js list-css list-img
91
92 #################### compute emacs tags
93 # list files under git but exclude third-party stuff like bootstrap and jquery
94 myfiles: force
95         @git ls-files | egrep -v 'insert(_|-)above|third-party/|to-be-integrated/'
96
97 # in general it's right to rely on the contents as reported by git
98 tags: force
99         $(MAKE-SILENT) myfiles | xargs etags
100
101 # however sometimes we have stuff not yet added, so in this case
102 ftags: force
103         find . -type f | fgrep -v '/.git/' | xargs etags
104
105 ########################################
106 ### devel-oriented
107 ########################################
108
109 #################### sync : push current code on a box running myslice
110 # this for now targets deployments based on the debian packaging
111 SSHURL:=root@$(MYSLICEBOX):/
112 SSHCOMMAND:=ssh root@$(MYSLICEBOX)
113
114 ### rsync options
115 # the config file should probably not be overridden ??
116 # --exclude settings.py 
117 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc'
118 LOCAL_RSYNC_EXCLUDES    += --exclude '*.sqlite3' --exclude myslice.ini
119 LOCAL_RSYNC_EXCLUDES    += --exclude static --exclude templates --exclude build
120 LOCAL_RSYNC_EXCLUDES    += --exclude to-be-integrated --exclude third-party 
121 # usual excludes
122 RSYNC_EXCLUDES          := --exclude .git --exclude '*~' --exclude TAGS --exclude .DS_Store $(LOCAL_RSYNC_EXCLUDES) 
123 # make -n will propagate as rsync -n 
124 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
125 # putting it together
126 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
127
128 #################### minimal convenience for pushing work-in-progress in an apache-based depl.
129 # xxx until we come up with a packaging this is going to be a wild guess
130 # on debian04 I have stuff in /usr/share/myslice and a symlink in /root/myslice
131 INSTALLED_MAIN          =/usr/share/pyshared
132 # this is for a debian box
133 INSTALLED_APACHE        =/etc/apache2/sites-available/
134
135 sync: sync-main sync-apache
136
137 sync-main:
138 ifeq (,$(MYSLICEBOX))
139         @echo "you need to set MYSLICEBOX, like in e.g."
140         @echo "  $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@""
141         @exit 1
142 else
143         +$(RSYNC) ./ $(SSHURL)/$(INSTALLED_MAIN)/
144 endif
145
146 sync-apache:
147 ifeq (,$(MYSLICEBOX))
148         @echo "you need to set MYSLICEBOX, like in e.g."
149         @echo "  $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@""
150         @exit 1
151 else
152         +$(RSYNC) ./apache/unfold.conf $(SSHURL)/$(INSTALLED_APACHE)/
153         +$(RSYNC) ./apache/unfold-init-ssl.sh $(SSHURL)/$(bindir)/
154 endif
155
156 restart:
157 ifeq (,$(MYSLICEBOX))
158         @echo "you need to set MYSLICEBOX, like in e.g."
159         @echo "  $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@""
160         @exit 1
161 else
162         +$(SSHCOMMAND) apachectl restart
163 endif