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