forked from paixaop/node-sodium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (96 loc) · 2.78 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
MOCHA_OPTS= --check-leaks
REPORTER = tap
BINDIR = ./node_modules/.bin
LIBSODIUM_DIR = ./deps/libsodium
INSTALL_DIR = $(CURDIR)/deps/build
STATIC_LIB = ${INSTALL_DIR}/lib/libsodium
PLATFORM = ''
THIS_OS = ''
ifeq ($(OS),Windows_NT)
CCFLAGS += -D WIN32
THIS_OS = Windows
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
CCFLAGS += -D AMD64
PLATFORM = x86_64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
CCFLAGS += -D IA32
PLATFORM = i386
endif
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
THIS_OS = Linux
CCFLAGS += -D LINUX
endif
ifeq ($(UNAME_S),Darwin)
THIS_OS = OSX
OSX_VERSION_MIN = $(shell sw_vers -productVersion ) | awk -F '.' '{print $$1 "." $$2}'
CFLAGS="-arch x86_64 -mmacosx-version-min=${OSX_VERSION_MIN} -O2 -g -flto"
LDFLAGS="-arch x86_64 -mmacosx-version-min=${OSX_VERSION_MIN} -flto"
endif
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
PLATFORM = x86_64
CCFLAGS += -D AMD64
endif
ifneq ($(filter %86,$(UNAME_P)),)
CCFLAGS += -D IA32
PLATFORM = i386
endif
ifneq ($(filter arm%,$(UNAME_P)),)
PLATFORM = ARM
CCFLAGS += -D ARM
endif
endif
ec:
@echo ${OSX_VERSION_MIN}
all: sodium
# If a static libsodium is found then compile against it
# instead of trying to compile from source
libsodium:
ifeq (,$(wildcard ${STATIC_LIB}.*))
@echo Static libsodium was not found at ${STATIC_LIB} so compiling libsodium from source.
@cd $(LIBSODIUM_DIR)/ && ./configure \
--enable-static --prefix="$(INSTALL_DIR)"
@cd $(LIBSODIUM_DIR)/ && make clean > /dev/null
@cd $(LIBSODIUM_DIR)/ && make -j3 check
@cd $(LIBSODIUM_DIR)/ && make -j3 install
else
@echo Found a compiled lib in ${INSTALL_DIR}. Make sure this library that was compiled for this platform.
@echo Use make clean to remove the static lib and force recompilation
@echo Operating System: ${OS} THIS_OS = ${THIS_OS}, Platform = ${PLATFORM}
endif
sodium: libsodium
$(BINDIR)/node-gyp rebuild
test: test-unit
test-unit:
@NODE_ENV=test $(BINDIR)/mocha \
--reporter $(REPORTER) \
--globals setImmediate,clearImmediate
instrument: clean
$(BINDIR)/istanbul instrument --output lib-cov --no-compact \
--variable global.__coverage__ lib
test-cov: clean instrument
@echo Run make test for simple tests with no coverage reports
@COVERAGE=1 NODE_ENV=test $(BINDIR)/mocha \
-R mocha-istanbul \
--globals setImmediate,clearImmediate
@$(BINDIR)/istanbul report
@rm -rf lib-cov
@echo
@echo Open html-report/index.html file in your browser
git-pull:
git pull
git submodule init
git submodule update
git submodule status
clean:
-rm -fr lib-cov
-rm -fr covershot
-rm -fr html-report
-rm -fr coverage
-rm -fr coverage.html
-rm -fr *.o
-rm -fr ${INSTALL_DIR}
.PHONY: test-cov site docs test docclean