spell them out one by one as {} won't work on debian for some reason
[myslice.git] / Makefile
1 SHELL = /bin/bash
2
3 MAKE-SILENT = $(MAKE) --no-print-directory
4
5 ### first purpose, build and install from the specfile
6 all: build
7
8 force:
9
10 DESTDIR := /
11 datadir := /usr/share
12 bindir := /usr/bin
13
14 PWD := $(shell pwd)
15
16 build: static templates
17         python setup.py build
18
19 install: 
20         python setup.py install \
21             --install-purelib=$(DESTDIR)/$(datadir)/myslice \
22             --install-scripts=$(DESTDIR)/$(datadir)/myslice \
23             --install-data=$(DESTDIR)/$(datadir)/myslice
24
25
26 #################### third-party layout is kind of special 
27 # because we have differents versions, and also we 
28 # try to preserve the file structure from upstream
29 # so let's handle this manually
30 THIRD-PARTY-RESOURCES =
31 # ignore variants, use the main symlink third-party/bootstrap
32 THIRD-PARTY-RESOURCES += $(shell ls third-party/bootstrap/*/*)
33 # just the single js as identified with a symlink
34 THIRD-PARTY-RESOURCES += $(shell ls third-party/datatables/js/dataTables.js)
35 THIRD-PARTY-RESOURCES += $(shell ls third-party/datatables/js/dataTables.bootstrap.js)
36 THIRD-PARTY-RESOURCES += $(shell ls third-party/datatables/css/dataTables.bootstrap.css)
37 # likewise
38 THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery/js/jquery.js)
39 THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery/js/jquery.min.js)
40 # for storing the visible status of plugins
41 THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery-html5storage/jquery.html5storage.js)
42 THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery-html5storage/jquery.html5storage.min.js)
43 # spin comes in plain or min, + the jquery plugin, and our own settings
44 THIRD-PARTY-RESOURCES += $(shell ls third-party/spin/*.js)
45 # used in QueryCode
46 THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/scripts/shCore.js)
47 THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/scripts/shAutoloader.js)
48 THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/scripts/shBrushPython.js)
49 THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/scripts/shBrushRuby.js)
50 THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/styles/shCore.css)
51 THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/styles/shCoreDefault.css)
52 THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/styles/shThemeDefault.css)
53
54
55 thirdparty-js:
56         @find $(THIRD-PARTY-RESOURCES) -name '*.js'
57 thirdparty-css:
58         @find $(THIRD-PARTY-RESOURCES) -name '*.css'
59 thirdparty-img:
60         @find $(THIRD-PARTY-RESOURCES) -name '*.png' -o -name '*.ico'
61
62 # we might have any of these as templates - e.g. ./unfold/templates/plugin-init.js
63 # so if there's a /templates/ in the path ignore the file
64 local-js: force
65         @find . -type f -name '*.js' | egrep -v '/all-(static|templates)/|/third-party/|/templates/'
66 local-css: force
67         @find . -type f -name '*.css' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
68 local-img: force
69         @find . -type f -name '*.png' -o -name '*.ico' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
70
71 list-js: thirdparty-js local-js
72 list-css: thirdparty-css local-css
73 list-img: thirdparty-img local-img
74
75 # having templates in a templates/ subdir is fine most of the time except for plugins
76 plugins-templates: force
77         @find plugins -type f -name '*.html' 
78 local-templates: force
79         @$(foreach tmpl,$(shell find . -name templates),ls -1 $(tmpl)/*;)
80
81 list-templates: plugins-templates local-templates
82
83 #################### manage static contents (extract from all the modules into the single all-static location)
84 static run-static static-run: force
85         mkdir -p ./all-static/js all-static/css all-static/img
86         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-js),../../$(x)) ./all-static/js
87         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-css),../../$(x)) ./all-static/css
88         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-img),../../$(x)) ./all-static/img
89
90 clean-static static-clean: force
91         rm -rf ./all-static
92
93 all-static: clean-static run-static
94
95 #################### manage templates for the plugin area
96 templates run-templates templates-run: force
97         mkdir -p all-templates
98         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-templates),../$(x)) ./all-templates
99
100 clean-templates templates-clean: force
101         rm -rf ./all-templates
102
103 all-templates: clean-templates run-templates
104
105 ####################
106 list-all list-resources: list-templates list-js list-css list-img
107
108 #################### compute emacs tags
109 # list files under git but exclude third-party stuff like bootstrap and jquery
110 myfiles: force
111         @git ls-files | egrep -v 'insert(_|-)above|third-party/|play/'
112
113 # in general it's right to rely on the contents as reported by git
114 tags: force
115         $(MAKE-SILENT) myfiles | xargs etags
116
117 # however sometimes we have stuff not yet added, so in this case
118 ftags: force
119         find . -type f | fgrep -v '/.git/' | xargs etags
120
121 #################### sync : push current code on a (devel) box running myslice
122 SSHURL:=root@$(MYSLICEBOX):/
123 SSHCOMMAND:=ssh root@$(MYSLICEBOX)
124
125 ### rsync options
126 # the config file should probably not be overridden ??
127 # --exclude settings.py 
128 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' --exclude config.py --exclude all-static --exclude all-templates --exclude '*.sqlite3'  --exclude play/ 
129 # usual excludes
130 RSYNC_EXCLUDES          := --exclude .git --exclude '*~' --exclude TAGS --exclude .DS_Store $(LOCAL_RSYNC_EXCLUDES) 
131 # make -n will propagate as rsync -n 
132 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
133 # putting it together
134 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
135
136 # xxx until we come up with a packaging this is going to be a wild guess
137 # on debian04 I have stuff in /usr/share/myslice and a symlink in /root/myslice
138 #INSTALLED=/usr/share/myslice
139 INSTALLED=/root/myslice
140
141 sync:
142 ifeq (,$(MYSLICEBOX))
143         @echo "you need to set MYSLICEBOX, like in e.g."
144         @echo "  $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@""
145         @exit 1
146 else
147         +$(RSYNC) ./ $(SSHURL)/$(INSTALLED)/
148 endif
149
150 # xxx likewise until we run this under apache it's probably hard to restart from here
151 restart:
152 ifeq (,$(MYSLICEBOX))
153         @echo "you need to set MYSLICEBOX, like in e.g."
154         @echo "  $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@""
155         @exit 1
156 else
157         @echo "$@" target not yet implemented - for an apache based depl it would read ...; exit; @$(SSHCOMMAND) /etc/init.d/apache2 restart
158 endif