Stamp version.js @ 640.16
[armadillo.git] / Makefile
1 # Armadillo File Manager
2 # Copyright (c) 2012, Robert Sesek <http://www.bluestatic.org>
3 #
4 # This program is free software: you can redistribute it and/or modify it under
5 # the terms of the GNU General Public License as published by the Free Software
6 # Foundation, either version 3 of the License, or any later version.
7
8 VERSION_MAJOR=0
9 VERSION_MINOR=8
10 VERSION_NAMESPACE=armadillo.Version
11 VERSION_FILE=frontend/version.js.proto
12 VERSION_SOURCE=$(basename $(VERSION_FILE))
13
14 FRONTEND_SOURCES=frontend/jquery-1.7.1.js \
15 frontend/utils.js \
16 $(VERSION_SOURCE) \
17 frontend/tv_renamer.js \
18 frontend/path_control.js \
19 frontend/actor.js \
20 frontend/file.js \
21 frontend/main.js
22 FRONTEND_BIN=frontend/armadillo.js
23
24 # Default target, used to produce the backend and uncompiled frontend.
25 all: backend frontend
26
27 # Creates the compiled frontend code.
28 release: backend compiled
29
30 # Performs a release build and stamps the actual version file.
31 dist: stamp release
32
33 # Compiles the backend server.
34 backend:
35 go build -v .
36
37 # Compiles the frontend code for development.
38 frontend: version $(FRONTEND_BIN)
39
40 $(FRONTEND_BIN): $(FRONTEND_SOURCES)
41 echo $(foreach f,$^,"document.write('<script src="fe/$(notdir $f)"></script>');\n") > $(FRONTEND_BIN)
42
43 # Compiles the frontend code for release.
44 compiled: SOURCES_FLAGS=$(foreach f,$(FRONTEND_SOURCES),--js=$f)
45 compiled:
46 java -jar closure-compiler.jar \
47 $(SOURCES_FLAGS) \
48 --js_output_file=$(FRONTEND_BIN) \
49 --compilation_level=SIMPLE_OPTIMIZATIONS
50
51 .PHONY: $(VERSION_FILE)
52
53 # Builds the version file template.
54 version:
55 if [[ -f $(VERSION_FILE) ]]; then $(MAKE) $(VERSION_FILE); fi
56 $(VERSION_FILE): STAMP=$(shell date +%s)
57 $(VERSION_FILE): BUILD=$(shell gitcrement next)
58 $(VERSION_FILE):
59 @echo "// This file is automatically generated." > $(VERSION_FILE)
60 @echo >> $(VERSION_FILE)
61 @echo "$$.namespace('$(VERSION_NAMESPACE)');" >> $(VERSION_FILE)
62 @echo >> $(VERSION_FILE)
63 echo "$(VERSION_NAMESPACE).MAJOR = $(VERSION_MAJOR);" >> $(VERSION_FILE)
64 echo "$(VERSION_NAMESPACE).MINOR = $(VERSION_MINOR);" >> $(VERSION_FILE)
65 echo "$(VERSION_NAMESPACE).BUILD = $(BUILD);" >> $(VERSION_FILE)
66 echo "$(VERSION_NAMESPACE).STAMP = $(STAMP);" >> $(VERSION_FILE)
67
68 # Copies the version template to the source and commits it.
69 stamp: $(VERSION_FILE)
70 cp $(VERSION_FILE) $(VERSION_SOURCE)
71 git commit $(VERSION_SOURCE) \
72 --author='Armadillo Build Script <armadillo@bluestatic.org>' \
73 -m 'Stamp version.js @ $(shell gitcrement current)'