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