tag 0.8.2-rc1
[remotestorage.js] / Makefile
1 NODEJS         = node
2 DOC_BIN        = naturaldocs
3 DOC_DIR        = ./doc/code
4 DOC_CONFIG_DIR = ./doc/config
5 DOC_CUSTOM_CSS = custom-1
6 SOURCE_DIR     = ./src
7 ASSETS_DIR     = ./assets
8 ASSETS_OUT     = $(SOURCE_DIR)/assets.js
9 DOC_INPUTS     = -i $(SOURCE_DIR)
10 SOURCES        = ${shell find $(SOURCE_DIR) -name "*.js"}
11
12 DEFAULT_COMPONENTS = core widget baseclient caching modules debug legacy googledrive dropbox
13 NOCACHE_COMPONENTS = core widget baseclient modules debug legacy googledrive dropbox
14 NODEJS_COMPONENTS = core baseclient caching modules legacy
15
16
17 default: help
18
19 help:
20         @echo "help           - display this text"
21         @echo "all            - build regular, minified AMD and nodejs targets, plus all -nocache targets"
22         @echo "build          - build remotestorage.js"
23         @echo "build-amd      - build remotestorage.js with AMD wrapper"
24         @echo "build-node     - build remotestorage.js suitable for nodejs"
25         @echo "build-nocache  - build remotestorage.js without caching (plus AMD and .min versions of that)"
26         @echo "minify         - minify remotestorage.js -> remotestorage.min.js"
27         @echo "compile-assets - compile $(ASSETS_DIR)/* into $(ASSETS_OUT)"
28         @echo "clean          - remove all builds and editor swapfiles"
29
30 all: build build-amd minify build-nocache build-node doc
31 build-all: all
32 minify: remotestorage.min.js
33 build: remotestorage.js
34 build-amd: remotestorage.amd.js
35 build-node: remotestorage-node.js
36 build-nocache: remotestorage-nocache.js remotestorage-nocache.min.js remotestorage-nocache.amd.js
37 compile-assets: $(ASSETS_OUT)
38
39 .PHONY: help buildserver build-all compile-assets minify build doc clean
40
41 %.min.js: %.js
42 #       uglifyjs $< -o $@ --mangle --wrap --export-all
43         uglifyjs -o $@ $<
44         mv $@ $@.tmp
45         head -n1 $< > $@
46         cat $@.tmp >> $@
47         rm $@.tmp
48
49 remotestorage.js: $(SOURCES)
50         $(NODEJS) build/do-build.js remotestorage.js $(DEFAULT_COMPONENTS)
51
52 remotestorage.amd.js: $(SOURCES)
53         $(NODEJS) build/do-build.js remotestorage.amd.js --amd $(DEFAULT_COMPONENTS)
54
55 remotestorage-node.js: $(SOURCES)
56         $(NODEJS) build/do-build.js remotestorage-node.js --node $(NODEJS_COMPONENTS)
57
58 # remotestorage.min.js: remotestorage.js
59 #       uglifyjs remotestorage.js -o remotestorage.min.js --mangle --wrap --export-all
60 # ## copy version header from original (uglifyjs strips all comments):
61 #       mv remotestorage.min.js remotestorage.min.js.tmp
62 #       head -n1 remotestorage.js > remotestorage.min.js
63 #       cat remotestorage.min.js.tmp >> remotestorage.min.js
64 #       rm remotestorage.min.js.tmp
65
66 remotestorage-nocache.js: $(SOURCES)
67         $(NODEJS) build/do-build.js $@ $(NOCACHE_COMPONENTS)
68
69 remotestorage-nocache.amd.js: $(SOURCES)
70         $(NODEJS) build/do-build.js $@ --amd $(NOCACHE_COMPONENTS)
71
72 $(ASSETS_OUT): $(ASSETS_DIR)/*
73         $(NODEJS) build/compile-assets.js $(ASSETS_DIR) $(ASSETS_OUT)
74
75 doc:
76         mkdir -p $(DOC_DIR) $(DOC_CONFIG_DIR)
77         $(DOC_BIN) $(DOC_INPUTS) -o html $(DOC_DIR) -p $(DOC_CONFIG_DIR) -s Default $(DOC_CUSTOM_CSS)
78
79 clean:
80         rm -f remotestorage.js remotestorage.min.js remotestorage.amd.js remotestorage-nocache.js remotestorage-nocache.amd.js remotestorage-nocache.min.js ${shell find -name "*~"} ${shell find -name "*.swp"}