From a53e1a3863f718282877da6a57c52eb1bdb0561c Mon Sep 17 00:00:00 2001
From: Divya Theja <divyathe@codeaurora.org>
Date: Mon, 5 Feb 2018 18:41:51 +0530
Subject: [PATCH] Add autotool make files for libfec

---
 Makefile.am  | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 libfec.pc.in | 11 +++++++++++
 3 files changed, 114 insertions(+)
 create mode 100644 Makefile.am
 create mode 100644 configure.ac
 create mode 100644 libfec.pc.in

diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..18c1ac6
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,49 @@
+ACLOCAL_AMFLAGS = -I m4
+
+
+AM_CPPFLAGS = -Wall\
+             -O3\
+             -D_LARGEFILE64_SOURCE\
+             -Wno-error=c++0x-compat\
+             -std=c++11
+
+EXTRA_CPPFLAGS := -I.\
+                  -I$(srcdir)/include\
+                  -I@H@\
+                  -I@core_incdir@
+
+#check if we are building for host also
+
+if BUILD_HOST
+AM_CPPFLAGS += -D_GNU_SOURCE\
+             -DFEC_NO_KLOG
+endif
+
+libfec_c_sources := fec_open.cpp\
+                    fec_read.cpp\
+                    fec_verity.cpp\
+                    fec_process.cpp
+
+libfec_h_sources := $(srcdir)/include/fec/io.h\
+                    $(srcdir)/include/fec/ecc.h
+
+libfec_la_CPPFLAGS = $(EXTRA_CPPFLAGS)\
+                     $(AM_CPPFLAGS)
+
+libfec_la_SOURCES = $(libfec_c_sources)
+
+lib_LTLIBRARIES = libfec.la
+
+libfec_la_LIBADD = @CUTILS_LIBS@\
+                   @FECRS_LIBS@\
+                   @CRYPTOUTILS_LIBS@\
+                   @SQUASHFSUTILS_LIBS@
+
+libfec_la_LDFLAGS = -lcrypto -lbase -lext4_utils
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libfec.pc
+EXTRA_DIST = $(pkgconfig_DATA)
+
+fec_includedir = $(includedir)/fec
+fec_include_HEADERS = $(libfec_h_sources)
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..619e572
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,54 @@
+  AC_PREREQ(2.61)
+  AC_INIT([libfec],1.0.0)
+  AM_INIT_AUTOMAKE([-Wall gnu foreign])
+  AC_CONFIG_SRCDIR([Makefile.am])
+  AC_CONFIG_HEADERS([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
+
+#check for various packages.
+
+  PKG_CHECK_MODULES([FECRS],[libfec_rs],,[AC_MSG_ERROR([the requested libfec_rs is not found on the system])])
+  AC_SUBST([FECRS_LIBS])
+
+  PKG_CHECK_MODULES([CRYPTOUTILS],[libcrypto_utils],,[AC_MSG_ERROR([the requested libcrypto_utils is not found on the system])])
+  AC_SUBST([CRYPTOUTILS_LIBS])
+
+  PKG_CHECK_MODULES([CUTILS],[libcutils],,[AC_MSG_ERROR([the requested libcutils is not found on the system])])
+  AC_SUBST([CUTILS_LIBS])
+
+  PKG_CHECK_MODULES([SQUASHFSUTILS],[libsquashfs_utils],,[AC_MSG_ERROR([the requested libsquashfs_utils is not found on the system])])
+  AC_SUBST([SQUASHFSUTILS_LIBS])
+
+  AC_ARG_WITH([header_includes],AC_HELP_STRING([--with-header-includes=@<:@dir@:>@],[Specify the location of the included headers]),[header_incdir=$withval],[with_header_includes=no])
+
+  if test "x$with_header_includes" != "xno"; then
+    AC_SUBST(H,[${header_incdir}])
+  fi
+
+  AC_ARG_WITH([coreheader_includes],AC_HELP_STRING([--with-coreheader-includes=@<:@dir@:>@],[Specify the location of the included headers]),[coreheader_incdir=$withval],[with_coreheader_includes=no])
+  if test "x$with_coreheader_includes" != "xno"; then
+    AC_SUBST(core_incdir,[${coreheader_incdir}])
+  fi
+ 
+ 
+
+  AS_CASE([${host}],[x86_64*],[X86_64=yes],[X86_64=no])
+
+  AM_CONDITIONAL([BUILD_HOST],[test "x$X86_64" = "xyes" ])
+
+  AC_OUTPUT([ \
+          Makefile \
+          libfec.pc
+  ])
diff --git a/libfec.pc.in b/libfec.pc.in
new file mode 100644
index 0000000..a2d47d2
--- /dev/null
+++ b/libfec.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: fec
+Description: fec library
+Version: @VERSION@
+Libs: -L${libdir} -lfec
+Cflags: -I${includedir}/fec
+
-- 
1.9.1

