add jquery-ui.css in the mix for nicer hazelnut rendering - although not perfect yet
[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 # likewise
34 THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery/js/jquery.js)
35 THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery/css/jquery-ui.css)
36 # spin comes in plain or min, + the jquery plugin, and our own settings
37 THIRD-PARTY-RESOURCES += $(shell ls third-party/spin/*.js)
38
39 thirdparty-js:
40         @find $(THIRD-PARTY-RESOURCES) -name '*.js'
41 thirdparty-css:
42         @find $(THIRD-PARTY-RESOURCES) -name '*.css'
43 thirdparty-img:
44         @find $(THIRD-PARTY-RESOURCES) -name '*.png' -o -name '*.ico'
45
46 # we might have any of these as templates - e.g. ./unfold/templates/plugin-init.js
47 # so if there's a /templates/ in the path ignore the file
48 local-js: force
49         @find . -type f -name '*.js' | egrep -v '/all-(static|templates)/|/third-party/|/templates/'
50 local-css: force
51         @find . -type f -name '*.css' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
52 local-img: force
53         @find . -type f -name '*.png' -o -name '*.ico' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
54
55 list-js: thirdparty-js local-js
56 list-css: thirdparty-css local-css
57 list-img: thirdparty-img local-img
58
59 # having templates in a templates/ subdir is fine most of the time except for plugins
60 plugins-templates: force
61         @find plugins -type f -name '*.html' 
62 local-templates: force
63         @$(foreach tmpl,$(shell find . -name templates),ls -1 $(tmpl)/*;)
64
65 list-templates: plugins-templates local-templates
66
67 #################### manage static contents (extract from all the modules into the single all-static location)
68 static run-static static-run: force
69         mkdir -p ./all-static/js all-static/css all-static/img
70         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-js),../../$(x)) ./all-static/js
71         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-css),../../$(x)) ./all-static/css
72         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-img),../../$(x)) ./all-static/img
73
74 clean-static static-clean: force
75         rm -rf ./all-static
76
77 all-static: clean-static run-static
78
79 #################### manage templates for the plugin area
80 templates run-templates templates-run: force
81         mkdir -p all-templates
82         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-templates),../$(x)) ./all-templates
83
84 clean-templates templates-clean: force
85         rm -rf ./all-templates
86
87 all-templates: clean-templates run-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/|play/'
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 #################### sync : push current code on a (devel) box running myslice
106 SSHURL:=root@$(MYSLICEBOX):/
107 SSHCOMMAND:=ssh root@$(MYSLICEBOX)
108
109 ### rsync options
110 # the config file should probably not be overridden ??
111 # --exclude settings.py 
112 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' --exclude config.py --exclude all-static --exclude all-templates --exclude '*.sqlite3'  --exclude play/ 
113 # usual excludes
114 RSYNC_EXCLUDES          := --exclude .git --exclude '*~' --exclude TAGS --exclude .DS_Store $(LOCAL_RSYNC_EXCLUDES) 
115 # make -n will propagate as rsync -n 
116 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
117 # putting it together
118 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
119
120 # xxx until we come up with a packaging this is going to be a wild guess
121 # on debian04 I have stuff in /usr/share/myslice and a symlink in /root/myslice
122 #INSTALLED=/usr/share/myslice
123 INSTALLED=/root/myslice
124
125 sync:
126 ifeq (,$(MYSLICEBOX))
127         @echo "you need to set MYSLICEBOX, like in e.g."
128         @echo "  $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@""
129         @exit 1
130 else
131         +$(RSYNC) ./ $(SSHURL)/$(INSTALLED)/
132 endif
133
134 # xxx likewise until we run this under apache it's probably hard to restart from here
135 restart:
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         @echo "$@" target not yet implemented - for an apache based depl it would read ...; exit; @$(SSHCOMMAND) /etc/init.d/apache2 restart
142 endif