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