summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richardipsum@fastmail.co.uk>2017-06-06 21:33:25 +0100
committerRichard Ipsum <richardipsum@fastmail.co.uk>2017-06-17 14:10:33 +0100
commit10abc615fae65f23ec0dbe03591e32b06fa8ff5e (patch)
treeee997197c0cfec303bb17fd95042f65829c3cf1a
parent9c319bdb4e2614878aa6392bee788cf597591c1d (diff)
downloadlua-scrypt-10abc615fae65f23ec0dbe03591e32b06fa8ff5e.tar.bz2
Replace find lua rules with luxio cargo
Take the findlua.mk file from luxio and use it for this project.
-rw-r--r--Makefile99
-rw-r--r--findlua.mk80
2 files changed, 82 insertions, 97 deletions
diff --git a/Makefile b/Makefile
index e32ab37..401808a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,100 +1,3 @@
-ifeq ($(strip $(shell which pkg-config > /dev/null || echo NONE)),NONE)
- $(error This makefile requires pkg-config)
-endif
-
-ifeq ($(strip $(shell which $(CC) > /dev/null || echo NONE)),NONE)
- $(info lua-scrypt: Hmm, CC make variable contains nonsense. Overriding to gcc.)
- CC := gcc
-endif
-
-NAKED_LUA_VER := $(shell (pkg-config --exists lua && \
- pkg-config --modversion lua || \
- pkg-config --variable V lua) | cut -d. -f1-2)
-
-# fine appropriate Lua interpreter
-LUA_REPL := $(shell (which lua5.1 > /dev/null 2>&1 && echo lua5.1) || \
- (which lua-5.1 > /dev/null 2>&1 && echo lua-5.1) || \
- (which lua51 > /dev/null 2>&1 && echo lua51) || \
- (lua -e"print(_VERSION)" | grep -q 5.1 && echo lua) || \
- (which lua-5.2 > /dev/null 2>&1 && echo lua-5.2) || \
- (which lua52 > /dev/null 2>&1 && echo lua52))
-
-# find appropriate Lua libraries
-LUA51_PKG := $(shell (pkg-config --exists lua5.1 && echo lua5.1) || \
- (pkg-config --exists lua-5.1 && echo lua-5.1) || \
- (pkg-config --exists lua51 && echo lua51) || \
- (echo "NONE"))
-
-
-LUA51_PKG := $(strip $(LUA51_PKG))
-
-ifeq ($(LUA51_PKG),NONE)
- ifeq ($(NAKED_LUA_VER),5.1)
- LUA51_PKG := lua
- endif
-endif
-
-ifneq ($(LUA51_PKG),NONE)
- $(info lua-scrypt: Lua 5.1 package name on this system is $(LUA51_PKG))
- LUA51_HAS_MODINST := $(shell test x`pkg-config --variable INSTALL_LMOD $(LUA51_PKG)` != x && echo YES)
- LUA51_INC := $(shell pkg-config --cflags $(LUA51_PKG))
- LUA51_LIB := $(shell pkg-config --libs $(LUA51_PKG))
- ifeq ($(LUA51_HAS_MODINST),)
- LOCAL := YES
- endif
- ifeq ($(LOCAL),)
- LUA51_LMOD_INST := $(shell pkg-config --variable=INSTALL_LMOD $(LUA51_PKG))
- LUA51_CMOD_INST := $(shell pkg-config --variable=INSTALL_CMOD $(LUA51_PKG))
- else
- LUA51_LMOD_INST := /usr/local/share/lua/5.1
- LUA51_CMOD_INST := /usr/local/lib/lua/5.1
- endif
- lua-5.1-try: lua-5.1
- lua-5.1-try-install: lua-5.1-install
-else
-lua-5.1-try:
- @echo lua-scrypt: Lua 5.1 could not be found, so lua-scrypt was not built for it.
-lua-5.1-try-install:
- @echo lua-scrypt: Lua 5.1 could not be found, so lua-scrypt was not installed for it.
-endif
-
-LUA52_PKG := $(shell (pkg-config --exists lua5.2 && echo lua5.2) || \
- (pkg-config --exists lua-5.2 && echo lua-5.2) || \
- (pkg-config --exists lua52 && echo lua52) || \
- (echo "NONE"))
-
-LUA52_PKG := $(strip $(LUA52_PKG))
-
-ifeq ($(LUA52_PKG),NONE)
- ifeq ($(NAKED_LUA_VER),5.2)
- LUA52_PKG := lua
- endif
-endif
-
-ifneq ($(LUA52_PKG),NONE)
- $(info lua-scrypt: Lua 5.2 package name on this system is $(LUA52_PKG))
- LUA52_HAS_MODINST := $(shell test x`pkg-config --variable INSTALL_LMOD $(LUA52_PKG)` != x && echo YES)
- LUA52_INC := $(shell pkg-config --cflags $(LUA52_PKG))
- LUA52_LIB := $(shell pkg-config --libs $(LUA52_PKG))
- ifeq ($(LUA52_HAS_MODINST),)
- LOCAL := YES
- endif
- ifeq ($(LOCAL),)
- LUA52_LMOD_INST := $(shell pkg-config --variable=INSTALL_LMOD $(LUA52_PKG))
- LUA52_CMOD_INST := $(shell pkg-config --variable=INSTALL_CMOD $(LUA52_PKG))
- else
- LUA52_LMOD_INST := /usr/local/share/lua/5.2
- LUA52_CMOD_INST := /usr/local/lib/lua/5.2
- endif
- lua-5.2-try: lua-5.2
- lua-5.2-try-install: lua-5.2-install
-else
-lua-5.2-try:
- @echo lua-scrypt: Lua 5.2 could not be found, so lua-scrypt was not built for it.
-lua-5.2-try-install:
- @echo lua-scrypt: Lua 5.2 could not be found, so lua-scrypt was not installed for it.
-endif
-
LIBCRYPT_C := lib/crypto/crypto_aesctr.c \
lib/crypto/crypto_scrypt-nosse.c \
lib/crypto/crypto_scrypt-ref.c \
@@ -107,6 +10,8 @@ override CFLAGS := $(CFLAGS) -O2 -Wall -fPIC
all: lua-5.1-try lua-5.2-try
+include findlua.mk
+
clean:
$(RM) scrypt-5.1.so scrypt-5.2.so scrypt.so
$(RM) luascrypt.o
diff --git a/findlua.mk b/findlua.mk
new file mode 100644
index 0000000..45012b7
--- /dev/null
+++ b/findlua.mk
@@ -0,0 +1,80 @@
+ifeq ($(strip $(shell which pkg-config > /dev/null || echo NONE)),NONE)
+ $(error This makefile requires pkg-config)
+endif
+
+ifeq ($(strip $(shell which $(CC) > /dev/null || echo NONE)),NONE)
+ $(info Luxio: Hmm, CC make variable contains nonsense. Overriding to gcc.)
+ CC := gcc
+endif
+
+# This isn't nice. Find a nice way.
+HOST_OS := $(shell uname -s)
+
+ifneq ($(findstring $(HOST_OS),Linux NetBSD GNU/kFreeBSD),)
+ # These operating systems require a seperate Real Time library
+ EXTRA_LIBS := -lrt
+else
+ EXTRA_LIBS :=
+endif
+
+NAKED_LUA_VER := $(shell (pkg-config --exists lua && \
+ pkg-config --modversion lua || \
+ pkg-config --variable V lua) | cut -d. -f1-2)
+
+# find appropriate Lua interpreter
+LUA_REPL := $(shell (which lua5.1 > /dev/null 2>&1 && echo lua5.1) || \
+ (which lua-5.1 > /dev/null 2>&1 && echo lua-5.1) || \
+ (which lua51 > /dev/null 2>&1 && echo lua51) || \
+ (lua -e"print(_VERSION)" | grep -q 5.1 && echo lua) || \
+ (which lua-5.2 > /dev/null 2>&1 && echo lua-5.2) || \
+ (which lua52 > /dev/null 2>&1 && echo lua52))
+
+# find appropriate Lua libraries
+define find_lua_libs
+LUA$(1)_PKG := $$(shell (pkg-config --exists lua$(2) && echo lua$(2)) || \
+ (pkg-config --exists lua-$(2) && echo lua-$(2)) || \
+ (pkg-config --exists lua$(1) && echo lua$(1)) || \
+ (echo "NONE"))
+
+LUA$(1)_PKG := $$(strip $$(LUA$(1)_PKG))
+
+ifeq ($$(LUA$(1)_PKG),NONE)
+ ifeq ($$(NAKED_LUA_VER),$(2))
+ LUA$(1)_PKG := lua
+ endif
+endif
+
+ifneq ($$(LUA$(1)_PKG),NONE)
+ $$(info Luxio: Lua $(2) package name on this system is $$(LUA$(1)_PKG))
+ LUA$(1)_HAS_MODINST := $$(shell test x`pkg-config --variable INSTALL_LMOD $$(LUA$(1)_PKG)` != x && echo YES)
+ LUA$(1)_INC := $$(shell pkg-config --cflags $$(LUA$(1)_PKG))
+ LUA$(1)_LIB := $$(shell pkg-config --libs $$(LUA$(1)_PKG))
+ ifeq ($$(LUA$(1)_HAS_MODINST),)
+ LOCAL := YES
+ endif
+ ifeq ($$(LOCAL),)
+ LUA$(1)_LMOD_INST := $$(shell pkg-config --variable=INSTALL_LMOD $$(LUA$(1)_PKG))
+ LUA$(1)_CMOD_INST := $$(shell pkg-config --variable=INSTALL_CMOD $$(LUA$(1)_PKG))
+ else
+ LUA$(1)_LMOD_INST := /usr/local/share/lua/$(2)
+ LUA$(1)_CMOD_INST := /usr/local/lib/lua/$(2)
+ endif
+
+ .PHONY: lua-$(2)-try
+ lua-$(2)-try: lua-$(2)
+
+ .PHONY: lua-$(2)-try-install
+ lua-$(2)-try-install: lua-$(2)-install
+else
+.PHONY: lua-$(2)-try
+lua-$(2)-try:
+ @echo Luxio: Lua $(2) could not be found, so luxio was not built for it.
+
+.PHONY: lua-$(2)-try-install
+lua-$(2)-try-install:
+ @echo Luxio: Lua $(2) could not be found, so luxio was not installed for it.
+endif
+endef
+
+$(eval $(call find_lua_libs,51,5.1))
+$(eval $(call find_lua_libs,52,5.2))