-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
89 lines (68 loc) · 2.34 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Standard things
.SUFFIXES:
.SUFFIXES: .c .o .so
# Defaults
SRC_DIR = Source
BUILD_DIR = Build
PREFIX = .
DIST_DIR = $(PREFIX)/Dist
OUT_NAME = FeatherGL
# Sources
SOURCE_NAMES = FeatherGL Constants Enhancements Matrix Color Mesh Point Vector
SOURCE_NAMES += Framebuffer WebGL Shaders Camera Light Scene View
# Variables
JS_ENGINE ?= `which node nodejs 2>/dev/null`
COMPILER = $(JS_ENGINE) $(BUILD_DIR)/uglify.js --unsafe
COMPILE_POST = $(JS_ENGINE) $(BUILD_DIR)/compile-post.js
COMPILE_SHADER = $(JS_ENGINE) $(BUILD_DIR)/compile-shaders.js
OUT = $(DIST_DIR)/$(OUT_NAME).js
OUT_MIN = $(DIST_DIR)/$(OUT_NAME).min.js
VERSION = sed "s/@VERSION/$(shell cat version.txt)/"
#DATE = $(shell git log -1 --pretty=format:%ad)
SOURCE_FILES = $(addsuffix .js, $(addprefix $(SRC_DIR)/, $(SOURCE_NAMES)))
SIZE = $(shell stat --printf="%s" $(OUT))
SIZE_MIN = $(shell stat --printf="%s" $(OUT_MIN))
SIZE_GZIP = $(shell stat --printf="%s" $(OUT_MIN).gz)
MIN_PERCENT = `echo "scale=2;" $(SIZE_MIN) / $(SIZE) \* 100 | bc`
GZIP_PERCENT = `echo "scale=2;" $(SIZE_GZIP) / $(SIZE) \* 100 | bc`
# Rules
all: clean feathergl min size
feathergl: $(OUT)
@@echo "FeatherGL build complete."
$(OUT): $(SOURCE_FILES) | $(DIST_DIR)
@@echo "Building" $(OUT)
@@tail --lines=+9 -q $(SOURCE_FILES) > $(OUT);
$(SRC_DIR)/Shaders.js:
@@$(COMPILE_SHADER)
min: feathergl $(OUT_MIN)
$(OUT_MIN): $(OUT)
@@if test ! -z $(JS_ENGINE); then \
echo "Minifying FeatherGL" $(OUT_MIN); \
$(COMPILER) $(OUT) > $(OUT_MIN).tmp; \
$(COMPILE_POST) $(OUT_MIN).tmp > $(OUT_MIN); \
rm -f $(OUT_MIN).tmp; \
else \
echo "You must have NodeJS installed in order to minify feather."; \
fi
$(DIST_DIR):
@@mkdir -p $(DIST_DIR)
lint: feathergl
size: feathergl min
ifdef JS_ENGINE
@gzip -c $(OUT_MIN) > $(OUT_MIN).gz
@echo "Original : " $(SIZE) "bytes"
@echo "Minified : " $(SIZE_MIN) "bytes " $(MIN_PERCENT) "%"
@echo "Compressed : " $(SIZE_GZIP) "bytes " $(GZIP_PERCENT) "%"
# @rm $(OUT_MIN).gz
else
@echo "You must have NodeJS installed in order to size FeatherGL.";
endif
docs:
@cd $(DOCDIR)
@doxygen doxygen.config
clean:
@@echo "Removing Distribution directory:" $(DIST_DIR)
@@rm -rf $(DIST_DIR)
@@rm -f $(SRC_DIR)/Shaders.js
distclean: clean
.PHONY: all feathergl lint min clean distclean core