forked from paixaop/node-sodium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
157 lines (135 loc) · 4.05 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
MOCHA_OPTS= --check-leaks
REPORTER = tap
BINDIR = ./node_modules/.bin
LIBSODIUM_DIR = ./deps/libsodium
INSTALL_DIR = $(CURDIR)/deps/build
SODIUM_LIB = ${INSTALL_DIR}/lib/libsodium
.DEFAULT_GOAL := sodium
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
CCFLAGS += -fPIC
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}
# If a static libsodium is found then compile against it
# instead of trying to compile from source
libsodium:
ifeq (,$(wildcard ${SODIUM_LIB}.*))
@echo Static libsodium was not found at ${SODIUM_LIB} so compiling libsodium from source.
@cd $(LIBSODIUM_DIR)/ && ./autogen.sh
@cd $(LIBSODIUM_DIR)/ && ./configure --enable-static \
--enable-shared --with-pic --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
echo Build node-sodium module
node-gyp rebuild
nodesodium:
echo Build node-sodium module
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 *.lo
-rm -fr *.o
-rm -fr ${INSTALL_DIR}
cd ${LIBSODIUM_DIR} && $(MAKE) clean
-find ${LIBSODIUM_DIR} -name Makefile -delete
-rm -fr ${LIBSODIUM_DIR}/autom4te.cache
-rm -fr ${LIBSODIUM_DIR}/build-aux
-rm -fr ${LIBSODIUM_DIR}/.dirstamp
-rm -fr ${LIBSODIUM_DIR}/**/.dirstamp
-find ${LIBSODIUM_DIR} -name .dirstamp -delete
-find deps/libsodium/ -name .deps -exec rm -fr {} \;
-find ${LIBSODIUM_DIR} -name *.res -delete
-find ${LIBSODIUM_DIR} -name Makefile.in -delete
-find ${LIBSODIUM_DIR} -name *.log -delete
-rm ${LIBSODIUM_DIR}/aclocal.m4
-rm ${LIBSODIUM_DIR}/config.status
-rm ${LIBSODIUM_DIR}/configure
-rm ${LIBSODIUM_DIR}/libsodium-uninstalled.pc
-rm ${LIBSODIUM_DIR}/libsodium.pc
-rm ${LIBSODIUM_DIR}/libtool
-rm ${LIBSODIUM_DIR}/m4/libtool.m4
-rm ${LIBSODIUM_DIR}/m4/ltoptions.m4
-rm ${LIBSODIUM_DIR}/m4/ltsugar.m4
-rm ${LIBSODIUM_DIR}/m4/ltversion.m4
-rm ${LIBSODIUM_DIR}/m4/lt~obsolete.m4
-rm ${LIBSODIUM_DIR}/src/libsodium/include/sodium/version.h
cleanbuild: clean
-rm -fr ./build
cleanall: cleanbuild
-rm -fr ./node_modules
publish: cleanall
npm version patch
npm publish
all:
sodium
.PHONY: all test-cov site docs test docclean