forget about manage.py collectstatic and come up with our own brew
[myslice.git] / Makefile
1 ### 
2 all: 
3         @echo no default target
4
5 force:
6
7 #################### compute emacs tags
8 # list files under git but exclude third-party stuff like bootstrap and jquery
9 myfiles: force
10         @git ls-files | egrep -v 'insert(_|-)above|/third-party/|/play/'
11
12 # in general it's right to rely on the contents as reported by git
13 tags: force
14         $(MAKE) myfiles | xargs etags
15
16 # however sometimes we have stuff not yet added, so in this case
17 ftags: force
18         find . -type f | fgrep -v '/.git/' | xargs etags
19
20 #################### third-party layout is kind of special 
21 # because we have differents versions and all
22 THIRD-PARTY-RESOURCES =
23 # ignore variants, use the main symlink third-party/bootstrap
24 THIRD-PARTY-RESOURCES += $(shell ls third-party/bootstrap/*/*)
25 # just the single js as identified with a symlink
26 THIRD-PARTY-RESOURCES += $(shell ls third-party/datatables/js/dataTables.js)
27 # likewise
28 THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery/js/jquery.js)
29 # spin comes in plain or min, + the jquery plugin, and our own settings
30 THIRD-PARTY-RESOURCES += $(shell ls third-party/spin/*.js)
31
32 thirdparty-js:
33         @find $(THIRD-PARTY-RESOURCES) -name '*.js'
34 thirdparty-css:
35         @find $(THIRD-PARTY-RESOURCES) -name '*.css'
36 thirdparty-img:
37         @find $(THIRD-PARTY-RESOURCES) -name '*.png'
38
39 # we might have any of these as templates - e.g. ./engine/templates/plugin-setenv.js
40 # so if there's a /templates/ in the path ignore the file
41 other-js: force
42         @find . -type f -name '*.js' | egrep -v '/all-(static|templates)/|/third-party/|/templates/'
43 other-css: force
44         @find . -type f -name '*.css' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
45 other-img: force
46         @find . -type f -name '*.png' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
47
48 list-js: thirdparty-js other-js
49 list-css: thirdparty-css other-css
50 list-img: thirdparty-img other-img
51
52 # having templates in a templates/ subdir is fine most of the time except for plugins
53 list-templates: force
54         @find plugins -type f -name '*.html' 
55
56 #################### manage static contents (extract from all the modules into the single all-static location)
57 static run-static static-run: force
58         mkdir -p ./all-static/js all-static/css all-static/img
59         ln -sf $(foreach x,$(shell $(MAKE) list-js),../../$(x)) ./all-static/js
60         ln -sf $(foreach x,$(shell $(MAKE) list-css),../../$(x)) ./all-static/css
61         ln -sf $(foreach x,$(shell $(MAKE) list-img),../../$(x)) ./all-static/img
62 #       rsync -av $(shell $(MAKE) list-js) ./all-static/js
63 #       rsync -av $(shell $(MAKE) list-css) ./all-static/css
64 #       rsync -av $(shell $(MAKE) list-img) ./all-static/img
65
66 clean-static static-clean: force
67         rm -rf ./all-static
68
69 all-static: clean-static run-static
70
71 #################### manage templates for the plugin area
72 templates run-templates templates-run: force
73         mkdir -p all-templates
74         ln -sf $(foreach x,$(shell $(MAKE) list-templates),.../$(x)) ./all-templates
75 #       rsync -av $(shell $(MAKE) list-templates) ./all-templates
76
77 clean-templates templates-clean: force
78         rm -rf ./all-templates
79
80 all-templates: clean-templates run-templates
81
82 ####################
83 list-all list-resources: list-templates list-js list-css list-img
84
85 #################### sync : push current code on a (devel) box running myslice
86 SSHURL:=root@$(MYSLICEBOX):/
87 SSHCOMMAND:=ssh root@$(MYSLICEBOX)
88
89 ### rsync options
90 # the config file should probably not be overridden ??
91 # --exclude settings.py 
92 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' --exclude config.py --exclude all-static --exclude all-templates --exclude '*.sqlite3' 
93 # usual excludes
94 RSYNC_EXCLUDES          := --exclude .git --exclude '*~' --exclude TAGS --exclude .DS_Store $(LOCAL_RSYNC_EXCLUDES) 
95 # make -n will propagate as rsync -n 
96 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
97 # putting it together
98 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
99
100 # xxx until we come up with a packaging this is going to be a wild guess
101 # on debian04 I have stuff in /usr/share/myslice and a symlink in /root/myslice
102 #INSTALLED=/usr/share/myslice
103 INSTALLED=/root/myslice
104
105 sync:
106 ifeq (,$(MYSLICEBOX))
107         @echo "you need to set MYSLICEBOX, like in e.g."
108         @echo "  $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@""
109         @exit 1
110 else
111         +$(RSYNC) ./ $(SSHURL)/$(INSTALLED)/
112 endif
113
114 # xxx likewise until we run this under apache it's probably hard to restart from here
115 restart:
116 ifeq (,$(MYSLICEBOX))
117         @echo "you need to set MYSLICEBOX, like in e.g."
118         @echo "  $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@""
119         @exit 1
120 else
121         @echo "$@" target not yet implemented - for an apache based depl it would read ...; exit; @$(SSHCOMMAND) /etc/init.d/apache2 restart
122 endif