Build infrastructure support

The infrastructure to build libintel_dbus.so.

This was all copied from ibm-dbus-interfaces.

Change-Id: I19fb26d4bf1f9bd170fc05015296743cf1a76b73
Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d270d59
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,54 @@
+# Template from:
+# https://github.com/github/gitignore/blob/master/Autotools.gitignore
+
+# http://www.gnu.org/software/automake
+
+Makefile.in
+/ar-lib
+/mdate-sh
+/py-compile
+/test-driver
+/ylwrap
+
+# http://www.gnu.org/software/autoconf
+
+/autom4te.cache
+/autoscan.log
+/autoscan-*.log
+/aclocal.m4
+/compile
+/config.guess
+/config.h.in
+/config.sub
+/configure
+/configure.scan
+/depcomp
+/install-sh
+/missing
+/stamp-h1
+
+# https://www.gnu.org/software/libtool/
+
+/ltmain.sh
+
+# http://www.gnu.org/software/texinfo
+
+/texinfo.tex
+
+# Repo Specific Items
+Makefile.interfaces
+Makefile.yaml
+*.pc
+.deps
+*.o
+*.la
+*.lo
+*.log
+/config.h
+/config.h.in~
+/config.status
+Makefile
+*-libtool
+.libs
+*.hpp
+*.cpp
diff --git a/MAINTAINERS b/MAINTAINERS
new file mode 100644
index 0000000..63f6bbf
--- /dev/null
+++ b/MAINTAINERS
@@ -0,0 +1,46 @@
+How to use this list:
+    Find the most specific section entry (described below) that matches where
+    your change lives and add the reviewers (R) and maintainers (M) as
+    reviewers. You can use the same method to track down who knows a particular
+    code base best.
+
+    Your change/query may span multiple entries; that is okay.
+
+    If you do not find an entry that describes your request at all, someone
+    forgot to update this list; please at least file an issue or send an email
+    to a maintainer, but preferably you should just update this document.
+
+Description of section entries:
+
+    Section entries are structured according to the following scheme:
+
+    X:  NAME <EMAIL_USERNAME@DOMAIN> <IRC_USERNAME!>
+    X:  ...
+    .
+    .
+    .
+
+    Where REPO_NAME is the name of the repository within the OpenBMC GitHub
+    organization; FILE_PATH is a file path within the repository, possibly with
+    wildcards; X is a tag of one of the following types:
+
+    M:  Denotes maintainer; has fields NAME <EMAIL_USERNAME@DOMAIN> <IRC_USERNAME!>;
+        if omitted from an entry, assume one of the maintainers from the
+        MAINTAINERS entry.
+    R:  Denotes reviewer; has fields NAME <EMAIL_USERNAME@DOMAIN> <IRC_USERNAME!>;
+        these people are to be added as reviewers for a change matching the repo
+        path.
+    F:  Denotes forked from an external repository; has fields URL.
+
+    Line comments are to be denoted "# SOME COMMENT" (typical shell style
+    comment); it is important to follow the correct syntax and semantics as we
+    may want to use automated tools with this file in the future.
+
+    A change cannot be added to an OpenBMC repository without a MAINTAINER's
+    approval; thus, a MAINTAINER should always be listed as a reviewer.
+
+START OF MAINTAINERS LIST
+-------------------------
+
+M:  Yong Li <yong.b.li@linux.intel.com> <yongli!>
+M:  James Feist <james.feist@intel.com> <jfei!>
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..8598a0c
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,26 @@
+AM_DEFAULT_SOURCE_EXT = .cpp
+
+if WANT_LIBINTEL_DBUS
+nobase_include_HEADERS = ## These get filled in by Makefile.interfaces
+
+libintel_dbusdir = ${libdir}
+libintel_dbus_LTLIBRARIES = libintel_dbus.la
+libintel_dbus_la_LDFLAGS = $(SYSTEMD_LIBS) $(SDBUSPLUS_LIBS) -version-info 0:0:0 -shared
+libintel_dbus_la_CXXFLAGS = $(SYSTEMD_CFLAGS) $(SDBUSPLUS_CFLAGS) -flto
+
+BUILT_SOURCES = libintel_dbus.cpp
+CLEANFILES = libintel_dbus.cpp
+
+pkgconfiglibdir = ${libdir}/pkgconfig
+pkgconfiglib_DATA = intel-dbus-interfaces.pc
+
+clean-local: clean-dbus
+
+-include Makefile.interfaces
+endif
+
+yamldir = ${datadir}/intel-dbus-yaml/yaml
+nobase_yaml_DATA = ## Filled in by Makefile.yaml
+
+-include Makefile.yaml
+
diff --git a/Makefile.interfaces.in b/Makefile.interfaces.in
new file mode 100644
index 0000000..714e6d0
--- /dev/null
+++ b/Makefile.interfaces.in
@@ -0,0 +1 @@
+# Empty file so that 'configure' attempts to generate Makefile.interfaces.
diff --git a/Makefile.yaml.in b/Makefile.yaml.in
new file mode 100644
index 0000000..964f971
--- /dev/null
+++ b/Makefile.yaml.in
@@ -0,0 +1 @@
+# Empty file so that 'configure' attempts to generate Makefile.yaml
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..ff74658
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# intel-dbus-interfaces
+YAML descriptors of Intel specific D-Bus interfaces
diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755
index 0000000..50b75b7
--- /dev/null
+++ b/bootstrap.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+AUTOCONF_FILES="Makefile.in aclocal.m4 ar-lib autom4te.cache compile \
+        config.guess config.h.in config.sub configure depcomp install-sh \
+        ltmain.sh missing *libtool test-driver"
+
+case $1 in
+    clean)
+        test -f Makefile && make maintainer-clean
+        for file in ${AUTOCONF_FILES}; do
+            find -name "$file" | xargs -r rm -rf
+        done
+        exit 0
+        ;;
+esac
+
+autoreconf -i
+echo 'Run "./configure ${CONFIGURE_FLAGS} && make"'
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..3056a7b
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,58 @@
+# Initialization
+AC_PREREQ([2.69])
+AC_INIT([intel-dbus-interfaces], [1.0], [https://github.com/openbmc/intel-dbus-interfaces])
+AC_CONFIG_HEADERS([config.h])
+AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
+AM_SILENT_RULES([yes])
+AC_LANG([C++])
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+AC_PROG_SED
+AC_CHECK_PROG([FIND], find, find)
+AC_CHECK_PROG([BASENAME], basename, basename)
+AC_CHECK_PROG([DIRNAME], dirname, dirname)
+
+AC_ARG_ENABLE([libintel_dbus],
+    AS_HELP_STRING([--disable-libintel_dbus], [Disable libintel_dbus]))
+
+AM_CONDITIONAL([WANT_LIBINTEL_DBUS], [test "x$enable_libintel_dbus" != "xno"])
+
+AS_IF([test "x$enable_libintel_dbus" != "xno"], [
+    AC_PATH_PROG([SDBUSPLUSPLUS], [sdbus++])
+    AS_IF([test "x$SDBUSPLUSPLUS" == "x"],
+        AC_MSG_ERROR([Cannot find sdbus++]))
+
+    # Checks for libraries.
+    AX_PKG_CHECK_MODULES([SYSTEMD], [], [libsystemd >= 221], [], [AC_MSG_ERROR(["systemd required and not found."])])
+    AX_PKG_CHECK_MODULES([SDBUSPLUS], [], [sdbusplus], [], [AC_MSG_ERROR(["sdbusplus required and not found."])])
+
+    # Checks for typedefs, structures, and compiler characteristics.
+    AX_CXX_COMPILE_STDCXX_17([noext])
+    AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CFLAGS])
+    AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
+
+    # Checks for header files.
+    old_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$SDBUSPLUS_CFLAGS $CPPFLAGS"
+    AC_CHECK_HEADER(sdbusplus/server.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server.hpp...sdbusplus package required])])
+    CPPFLAGS="$old_CPPFLAGS"
+
+    # Checks for library functions.
+    LT_INIT([dlopen disable-static shared])
+    LT_LIB_DLLOAD
+
+    # Create configured output
+    AC_CONFIG_FILES([Makefile.interfaces],
+        [${srcdir}/generate_makefile.sh ${srcdir} > Makefile.interfaces])
+    AC_CONFIG_FILES([intel-dbus-interfaces.pc])
+])
+AC_CONFIG_FILES([Makefile.yaml],
+    [${srcdir}/generate_yaml_makefile.sh ${srcdir} > Makefile.yaml])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/generate_makefile.sh b/generate_makefile.sh
new file mode 100755
index 0000000..2507c04
--- /dev/null
+++ b/generate_makefile.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+cd $1
+
+toplevel_dirs=com
+interfaces=`find $toplevel_dirs -name "*.interface.yaml"`
+
+for i in ${interfaces};
+do
+    iface_path=`dirname $i`/`basename $i .interface.yaml`
+    iface=`echo $iface_path | sed 's/\//./g'`
+    cat <<MAKEFILE
+
+${i%.interface.yaml}/server.cpp: ${i} ${i%.interface.yaml}/server.hpp
+	@mkdir -p \`dirname \$@\`
+	\$(SDBUSPLUSPLUS) -r \$(srcdir) interface server-cpp ${iface} > \$@
+
+${i%.interface.yaml}/server.hpp: ${i}
+	@mkdir -p \`dirname \$@\`
+	\$(SDBUSPLUSPLUS) -r \$(srcdir) interface server-header ${iface} > \$@
+
+MAKEFILE
+
+done
+
+errors=`find $toplevel_dirs -name "*.errors.yaml"`
+
+for e in ${errors};
+do
+    iface_path=`dirname $e`/`basename $e .errors.yaml`
+    iface=`echo $iface_path | sed 's/\//./g'`
+    cat <<MAKEFILE
+
+${e%.errors.yaml}/error.cpp: ${e} ${e%.errors.yaml}/error.hpp
+	@mkdir -p \`dirname \$@\`
+	\$(SDBUSPLUSPLUS) -r \$(srcdir) error exception-cpp ${iface} > \$@
+
+${e%.errors.yaml}/error.hpp: ${e}
+	@mkdir -p \`dirname \$@\`
+	\$(SDBUSPLUSPLUS) -r \$(srcdir) error exception-header ${iface} > \$@
+
+MAKEFILE
+
+done
+
+echo "libintel_dbus_cpp_SOURCES = \\"
+for i in ${interfaces};
+do
+    echo "	${i%.interface.yaml}/server.cpp \\"
+done
+for e in ${errors};
+do
+    echo "	${e%.errors.yaml}/error.cpp \\"
+done
+echo
+
+echo "libintel_dbus_hpp_SOURCES = \\"
+for i in ${interfaces};
+do
+    echo "	${i%.interface.yaml}/server.hpp \\"
+done
+for e in ${errors};
+do
+    echo "	${e%.errors.yaml}/error.hpp\\"
+done
+
+echo
+
+cat << MAKEFILE
+libintel_dbus.cpp: \$(libintel_dbus_cpp_SOURCES)
+	cat \$^ > \$@
+
+nobase_include_HEADERS = \$(libintel_dbus_hpp_SOURCES)
+
+.PHONY: clean-dbus
+clean-dbus:
+	for i in \$(libintel_dbus_cpp_SOURCES) \\
+	         \$(libintel_dbus_hpp_SOURCES); \\
+	do \\
+	    test -e \$\$i && rm \$\$i ; \\
+	    test -d \`dirname \$\$i\` && rmdir -p \`dirname \$\$i\` ; \\
+	    true; \\
+	done
+MAKEFILE
diff --git a/generate_yaml_makefile.sh b/generate_yaml_makefile.sh
new file mode 100755
index 0000000..a157d55
--- /dev/null
+++ b/generate_yaml_makefile.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+cd $1
+
+toplevel_dirs=com
+all_yaml=`find $toplevel_dirs -name "*.yaml"`
+
+echo "nobase_yaml_DATA = \\"
+for i in ${all_yaml};
+do
+    echo "	${i} \\"
+done
+echo
diff --git a/intel-dbus-interfaces.pc.in b/intel-dbus-interfaces.pc.in
new file mode 100644
index 0000000..d66d61e
--- /dev/null
+++ b/intel-dbus-interfaces.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: intel-dbus-interfaces
+Description: Generated sdbusplus bindings for intel-dbus-interfaces.
+URL: https://github.com/openbmc/intel-dbus-interfaces
+Version: @VERSION@
+Libs: -L@libdir@ -lintel_dbus
+Cflags: -I@includedir@