commit 53ea4951a380d7e7c95f8f99db8410fcce94c18f
parent 987109d73ea678d749e473a5210c966aa9598a6b
Author: Michael Savage <mikejsavage@gmail.com>
Date: Thu, 24 Dec 2015 15:27:23 +0000
Fix building on OpenBSD
Diffstat:
3 files changed, 68 insertions(+), 30 deletions(-)
diff --git a/Makefile.mess b/Makefile.mess
@@ -1,10 +1,3 @@
-# This is more or less what libressl does
-# See http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/lib/libssl/src/crypto/mem_clr.c?rev=1.4&content-type=text/x-cvsweb-markup
-CFLAGS += -DOPENSSL_cleanse=explicit_bzero
-
-# GCC whines without this. Assume everyone has strndup anyway
-CFLAGS += -DHAVE_STRNDUP
-
# Let Luarocks point us to the right headers
ifdef LUA_INCDIR
CFLAGS += -I$(LUA_INCDIR)
@@ -13,30 +6,41 @@ endif
# OS detection
uname := $(shell uname -s)
-ifneq ($(uname),Darwin)
+ifeq ($(uname),OpenBSD)
LDFLAGS += -shared
else
- LDFLAGS += -bundle -undefined dynamic_lookup
-endif
-
-CFLAGS += -Iinclude
-
-SRCS += compat/arc4random/arc4random.c
-SRCS += compat/arc4random/arc4random_uniform.c
-SRCS += compat/safebfuns.c
-SRCS += compat/sha/sha512.c
-
-ifeq ($(uname),Linux)
- SRCS += compat/getentropy/getentropy_linux.c
- LDFLAGS += -lrt
-endif
-
-ifeq ($(uname),Darwin)
- SRCS += compat/getentropy/getentropy_osx.c
-endif
-
-ifeq ($(uname),FreeBSD)
- SRCS += compat/getentropy/getentropy_freebsd.c
+ # This is more or less what libressl does
+ # See http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/lib/libssl/src/crypto/mem_clr.c?rev=1.4&content-type=text/x-cvsweb-markup
+ CFLAGS += -DOPENSSL_cleanse=explicit_bzero
+
+ # GCC whines without this. Assume everyone has strndup anyway
+ CFLAGS += -DHAVE_STRNDUP
+
+ ifneq ($(uname),Darwin)
+ LDFLAGS += -shared
+ else
+ LDFLAGS += -bundle -undefined dynamic_lookup
+ endif
+
+ CFLAGS += -Iinclude
+
+ SRCS += compat/arc4random/arc4random.c
+ SRCS += compat/arc4random/arc4random_uniform.c
+ SRCS += compat/safebfuns.c
+ SRCS += compat/sha/sha512.c
+
+ ifeq ($(uname),Linux)
+ SRCS += compat/getentropy/getentropy_linux.c
+ LDFLAGS += -lrt
+ endif
+
+ ifeq ($(uname),Darwin)
+ SRCS += compat/getentropy/getentropy_osx.c
+ endif
+
+ ifeq ($(uname),FreeBSD)
+ SRCS += compat/getentropy/getentropy_freebsd.c
+ endif
endif
compat/safebfuns.o: compat/safebfuns.c
diff --git a/rockspec/arc4random-1.3-2.rockspec b/rockspec/arc4random-1.3-2.rockspec
@@ -0,0 +1,34 @@
+package = "arc4random"
+version = "1.3-2"
+
+source = {
+ url = "git://github.com/mikejsavage/lua-arc4random.git",
+ tag = "v1.3-2",
+}
+
+description = {
+ summary = "A Lua wrapper around OpenBSD's arc4random",
+ homepage = "http://github.com/mikejsavage/lua-arc4random",
+ license = "MIT",
+ maintainer = "Mike Savage",
+}
+
+dependencies = {
+ "lua >= 5.1",
+}
+
+build = {
+ type = "make",
+
+ install_pass = false,
+
+ build_variables = {
+ LUA_INCDIR = "$(LUA_INCDIR)",
+ },
+
+ install = {
+ lib = {
+ [ "arc4random" ] = "arc4random.so",
+ },
+ },
+}
diff --git a/src/main.c b/src/main.c
@@ -15,7 +15,7 @@
*/
#include <stdlib.h>
-#include <sys/types.h>
+#include <stdint.h>
#include <math.h>
#include <lua.h>