this release uses bootstrap style for datatables instead of jquery-ui
[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/DT_bootstrap.js)
34 # likewise
35 THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery/js/jquery{,.min}.js)
36 # for storing the visible status of plugins
37 THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery-html5storage/jquery.html5storage{,.min}.js)
38 # xxx we have jquery-ui in our codebase but we've now moved to using bootstrap instead 
39 # so jquery-ui can probably be git removed altogether
40 #THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery-ui/themes/base/jquery-ui.css)
41 # spin comes in plain or min, + the jquery plugin, and our own settings
42 THIRD-PARTY-RESOURCES += $(shell ls third-party/spin/*.js)
43 # used in QueryCode
44 THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/scripts/sh{Core,Autoloader,BrushPython,BrushRuby}.js)
45 THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/styles/sh{Core,CoreDefault,ThemeDefault}.css)
46
47
48 thirdparty-js:
49         @find $(THIRD-PARTY-RESOURCES) -name '*.js'
50 thirdparty-css:
51         @find $(THIRD-PARTY-RESOURCES) -name '*.css'
52 thirdparty-img:
53         @find $(THIRD-PARTY-RESOURCES) -name '*.png' -o -name '*.ico'
54
55 # we might have any of these as templates - e.g. ./unfold/templates/plugin-init.js
56 # so if there's a /templates/ in the path ignore the file
57 local-js: force
58         @find . -type f -name '*.js' | egrep -v '/all-(static|templates)/|/third-party/|/templates/'
59 local-css: force
60         @find . -type f -name '*.css' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
61 local-img: force
62         @find . -type f -name '*.png' -o -name '*.ico' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
63
64 list-js: thirdparty-js local-js
65 list-css: thirdparty-css local-css
66 list-img: thirdparty-img local-img
67
68 # having templates in a templates/ subdir is fine most of the time except for plugins
69 plugins-templates: force
70         @find plugins -type f -name '*.html' 
71 local-templates: force
72         @$(foreach tmpl,$(shell find . -name templates),ls -1 $(tmpl)/*;)
73
74 list-templates: plugins-templates local-templates
75
76 #################### manage static contents (extract from all the modules into the single all-static location)
77 static run-static static-run: force
78         mkdir -p ./all-static/js all-static/css all-static/img
79         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-js),../../$(x)) ./all-static/js
80         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-css),../../$(x)) ./all-static/css
81         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-img),../../$(x)) ./all-static/img
82
83 clean-static static-clean: force
84         rm -rf ./all-static
85
86 all-static: clean-static run-static
87
88 #################### manage templates for the plugin area
89 templates run-templates templates-run: force
90         mkdir -p all-templates
91         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-templates),../$(x)) ./all-templates
92
93 clean-templates templates-clean: force
94         rm -rf ./all-templates
95
96 all-templates: clean-templates run-templates
97
98 ####################
99 list-all list-resources: list-templates list-js list-css list-img
100
101 #################### compute emacs tags
102 # list files under git but exclude third-party stuff like bootstrap and jquery
103 myfiles: force
104         @git ls-files | egrep -v 'insert(_|-)above|third-party/|play/'
105
106 # in general it's right to rely on the contents as reported by git
107 tags: force
108         $(MAKE-SILENT) myfiles | xargs etags
109
110 # however sometimes we have stuff not yet added, so in this case
111 ftags: force
112         find . -type f | fgrep -v '/.git/' | xargs etags
113
114 #################### sync : push current code on a (devel) box running myslice
115 SSHURL:=root@$(MYSLICEBOX):/
116 SSHCOMMAND:=ssh root@$(MYSLICEBOX)
117
118 ### rsync options
119 # the config file should probably not be overridden ??
120 # --exclude settings.py 
121 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' --exclude config.py --exclude all-static --exclude all-templates --exclude '*.sqlite3'  --exclude play/ 
122 # usual excludes
123 RSYNC_EXCLUDES          := --exclude .git --exclude '*~' --exclude TAGS --exclude .DS_Store $(LOCAL_RSYNC_EXCLUDES) 
124 # make -n will propagate as rsync -n 
125 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
126 # putting it together
127 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
128
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=/usr/share/myslice
132 INSTALLED=/root/myslice
133
134 sync:
135 ifeq (,$(MYSLICEBOX))
136         @echo "you need to set MYSLICEBOX, like in e.g."
137         @echo "  $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@""
138         @exit 1
139 else
140         +$(RSYNC) ./ $(SSHURL)/$(INSTALLED)/
141 endif
142
143 # xxx likewise until we run this under apache it's probably hard to restart from here
144 restart:
145 ifeq (,$(MYSLICEBOX))
146         @echo "you need to set MYSLICEBOX, like in e.g."
147         @echo "  $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@""
148         @exit 1
149 else
150         @echo "$@" target not yet implemented - for an apache based depl it would read ...; exit; @$(SSHCOMMAND) /etc/init.d/apache2 restart
151 endif