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