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