From 004d7d3950c30686502652db8ff8b64def216fe6 Mon Sep 17 00:00:00 2001
From: Divya Theja <divyathe@codeaurora.org>
Date: Tue, 10 Apr 2018 14:24:22 +0530
Subject: [PATCH] Add GNU Autotool build files

---
 Makefile.am                     | 41 +++++++++++++++++++++++++++++++++++++
 configure.ac                    | 45 +++++++++++++++++++++++++++++++++++++++++
 lib/crypto/crypto_scrypt-neon.c |  2 +-
 libscrypt.pc.in                 | 11 ++++++++++
 4 files changed, 98 insertions(+), 1 deletion(-)
 create mode 100644 Makefile.am
 create mode 100644 configure.ac
 create mode 100644 libscrypt.pc.in

diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..5c89e2c
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,41 @@
+ACLOCAL_AMFLAGS = -I m4
+
+libscrypt_la_SOURCES :=
+
+if BUILD_HOST
+libscrypt_la_SOURCES += $(srcdir)/lib/crypto/crypto_scrypt-sse.c
+endif
+
+#if NEON support is available on the ARM architecture
+if ARMNEON
+libscrypt_la_SOURCES += $(srcdir)/lib/crypto/crypto_scrypt-neon.c
+endif
+
+if !ARMNEON
+#for ARM architecture
+if ARM
+libscrypt_la_SOURCES += $(srcdir)/lib/crypto/crypto_scrypt-ref.c
+endif
+
+if ARM64
+libscrypt_la_SOURCES += $(srcdir)/lib/crypto/crypto_scrypt-ref.c
+endif
+
+endif 
+
+libscrypt_la_CFLAGS := -I$(srcdir)/lib/crypto \
+                       -I$(srcdir)/lib/util \
+                       -DUSE_OPENSSL_PBKDF2
+
+if ARMNEON
+libscrypt_la_CFLAGS += -flax-vector-conversions
+endif
+
+libscrypt_la_LDFLAGS := -llog -lcrypto
+
+
+lib_LTLIBRARIES = libscrypt.la
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libscrypt.pc
+EXTRA_DIST = $(pkgconfig_DATA)
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..bd83829
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,45 @@
+  AC_PREREQ(2.61)
+  AC_INIT([libscrypt],1.1.6)
+  AM_INIT_AUTOMAKE([foreign])
+  AM_MAINTAINER_MODE
+  AC_CONFIG_HEADER([config.h])
+  AC_CONFIG_MACRO_DIR([m4])
+
+  # Checks for programs.
+  AM_PROG_AS
+  AC_PROG_CC
+  AM_PROG_CC_C_O
+  AC_PROG_LIBTOOL
+  AC_PROG_AWK
+  AC_PROG_CPP
+  AC_PROG_CXX
+  AC_PROG_INSTALL
+  AC_PROG_LN_S
+  AC_PROG_MAKE_SET
+
+  PKG_CHECK_MODULES([LOGLIB],[liblog],,[AC_MSG_ERROR([the requested liblog is not found on the system])])
+
+  AS_CASE([$host],
+        [arm*], [ARM=yes],
+        [ARM=no]
+        )
+  AM_CONDITIONAL(ARM, [test "x$ARM" = "xyes"])
+  AS_CASE([$host],
+        [aarch64*], [ARM64=yes],
+        [ARM64=no]
+        )
+  AM_CONDITIONAL(ARM64, [test "x$ARM64" = "xyes"])
+  AS_CASE([$host],
+        [x86_64*], [X86_64=yes],
+        [X86_64=no]
+         )
+  AM_CONDITIONAL(X86_64, [test "x$X86_64" = "xyes"])
+  AM_CONDITIONAL(BUILD_HOST, [test "x$X86_64" = "xyes"])
+
+  AC_ARG_WITH([arm_neon],AC_HELP_STRING([--with-arm-neon],[enable Neon specific source code compilation]),[with_arm_neon=yes],[with_arm_neon=no])
+  AM_CONDITIONAL(ARMNEON, [test "x$with_arm_neon" != "xno"])
+
+  AC_OUTPUT([ \
+          Makefile \
+          libscrypt.pc
+  ])
diff --git a/lib/crypto/crypto_scrypt-neon.c b/lib/crypto/crypto_scrypt-neon.c
index a3bf052..da8de1e 100644
--- a/lib/crypto/crypto_scrypt-neon.c
+++ b/lib/crypto/crypto_scrypt-neon.c
@@ -28,7 +28,7 @@
  */
 #include "scrypt_platform.h"
 
-#include <machine/cpu-features.h>
+//#include <machine/cpu-features.h>
 #include <arm_neon.h>
 
 #include <errno.h>
diff --git a/libscrypt.pc.in b/libscrypt.pc.in
new file mode 100644
index 0000000..a26683b
--- /dev/null
+++ b/libscrypt.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: scrypt
+Description: scrypt library
+Version: @VERSION@
+Libs: -L${libdir} -lscrypt
+Cflags: -I${includedir}/scrypt
+
-- 
1.9.1

