Skip to content

Commit

Permalink
use libsodium native compile instead of node-gyp
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Paixao authored and Pedro Paixao committed Mar 28, 2016
1 parent e065739 commit 1c7d123
Show file tree
Hide file tree
Showing 701 changed files with 31,465 additions and 47,783 deletions.
77 changes: 66 additions & 11 deletions Makefile
Expand Up @@ -3,20 +3,73 @@ REPORTER = tap
BINDIR = ./node_modules/.bin

LIBSODIUM_DIR = ./deps/libsodium
INSTALL_DIR = $(CURDIR)/deps/build
STATIC_LIB = ${INSTALL_DIR}/lib/libsodium

configure:
@cd $(LIBSODIUM_DIR)/ && ./autogen.sh
@cd $(LIBSODIUM_DIR)/ && ./configure
@node defines.js

PLATFORM = ''
THIS_OS = ''

sodium:
ifeq (,$(wildcard deps/libsodium.gyp))
@echo Running make configure
@make configure
ifeq ($(OS),Windows_NT)
CCFLAGS += -D WIN32
THIS_OS = Windows
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
CCFLAGS += -D AMD64
PLATFORM = x86_64
endif
$(BINDIR)/node-gyp rebuild
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}

# 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-minimal \
--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:
Expand All @@ -25,7 +78,8 @@ test-unit:
--globals setImmediate,clearImmediate

instrument: clean
$(BINDIR)/istanbul instrument --output lib-cov --no-compact --variable global.__coverage__ lib
$(BINDIR)/istanbul instrument --output lib-cov --no-compact \
--variable global.__coverage__ lib


test-cov: clean instrument
Expand All @@ -51,6 +105,7 @@ clean:
-rm -fr coverage
-rm -fr coverage.html
-rm -fr *.o
-rm -fr ${INSTALL_DIR}

all:
sodium
Expand Down
52 changes: 0 additions & 52 deletions defines.js

This file was deleted.

196 changes: 0 additions & 196 deletions deps/libsodium.gyp.in

This file was deleted.

0 comments on commit 1c7d123

Please sign in to comment.