Add rpm and Debian makefile targets 09/3709/6
authorTimo Tietavainen <timo.tietavainen@nokia.com>
Fri, 15 May 2020 08:10:54 +0000 (11:10 +0300)
committerTimo Tietavainen <timo.tietavainen@nokia.com>
Fri, 15 May 2020 15:45:21 +0000 (18:45 +0300)
Add configuration options to enable rpm or Debian package building and
to specify the output directory where to create package files:
  configure --with-rpm-dir=DIR
  configure --with-deb-dir=DIR

Add makefile targets to build rpm and Debian packages:
  make build_rpm
  make build_deb

Signed-off-by: Timo Tietavainen <timo.tietavainen@nokia.com>
Change-Id: If40ee4b0a78e2b77e6980103a0b1f94dcb76db6d

Makefile.am
README.md
configure.ac
debian/control

index 499b862..5421f28 100644 (file)
@@ -400,6 +400,21 @@ test_gcov: test
        ls -la @GCOV_REPORT_DIR@
 endif
 
+if ENABLE_RPM_BUILD
+build_rpm:
+       rpmbuild --nodeps --nocheck -bb rpm/sdl.spec --define="_sourcedir $(top_srcdir)" --define="_builddir $(top_srcdir)" --define="_rpmdir .."
+       mkdir -p @RPM_DIR@
+       cp ../x86_64/*.rpm @RPM_DIR@
+endif
+
+
+if ENABLE_DEB_BUILD
+build_deb:
+       DEB_BUILD_OPTIONS='nocheck noddebs' debuild -b -us -uc
+       mkdir -p @DEB_DIR@
+       cp ../*.deb @DEB_DIR@
+endif
+
 clean-local:
        rm -f libsdl.pc
 if ENABLE_GCOV
index 9f43ec6..4c76fd9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -37,20 +37,31 @@ directory named `shareddatalayer`.
 
 Build-time dependencies:
 
-    boost
+    libboost (system, filesystem, program-options)
     hiredis
+    rpm
+    valgrind
+    autoconf-archive
     doxygen (optional)
 
 Commands to install dependent packages in Fedora:
 
     sudo dnf install boost-devel
     sudo dnf install hiredis-devel
+    sudo dnf install rpm
+    sudo dnf install valgrind
+    sudo dnf install autoconf-archive
     sudo dnf install doxygen
 
 Commands to install dependent packages in Debian/Ubuntu:
 
-    sudo apt install libboost-all-dev
+    sudo apt install libboost-filesystem-dev
+    sudo apt install libboost-program-options-dev
+    sudo apt install libboost-system-dev
     sudo apt install libhiredis-dev
+    sudo apt install rpm
+    sudo apt install valgrind
+    sudo apt install autoconf-archive
     sudo apt install doxygen
 
 ### Compilation in the source directory
index 6d073c6..494b179 100644 (file)
@@ -72,6 +72,68 @@ AM_CONDITIONAL([HIREDIS], [test xtrue])
 AC_DEFINE(HAVE_HIREDIS_VIP, [0], [Have hiredis-vip])
 AM_CONDITIONAL([HIREDIS_VIP], [test "xyes" = "xno"])
 
+#
+# Configuration option --with-rpm-dir=DIR
+#   If this option is given, rpm packages building is enabled and ready rpms are
+#   copied to the directory.
+#
+AC_ARG_WITH([rpm-dir],
+    AS_HELP_STRING([--with-rpm-dir=DIR],
+        [Directory for build rpm packages]),
+    [AC_CHECK_PROG(RPMBUILD, rpmbuild, "yes", "no")
+     AC_CHECK_PROG(RPM, rpm, "yes", "no")
+     AS_IF([test "x$RPMBUILD" != xyes],
+         [AC_MSG_ERROR([rpmbuild needs to be installed])],
+     [test "x$RPM" != xyes],
+         [AC_MSG_ERROR([rpm is needs to be installed])])],
+    [with_rpm_dir=no])
+
+AC_MSG_CHECKING([rpm package])
+if test "x$with_rpm_dir" = "xno"; then
+    AC_MSG_RESULT([no])
+    RPM_DIR="/tmp"
+else
+    AC_MSG_RESULT([yes])
+    AC_MSG_NOTICE([rpm directory: $with_rpm_dir])
+    RPM_DIR="$with_rpm_dir"
+fi
+AC_SUBST(RPM_DIR)
+AM_CONDITIONAL([ENABLE_RPM_BUILD],[test "x$with_rpm_dir" != "xno"])
+
+
+#
+# Configuration option --with-deb-dir=DIR
+#   If this option is given, Debian packages packages building is enabled and ready
+#   packages are copied to the directory.
+#
+AC_ARG_WITH([deb-dir],
+    AS_HELP_STRING([--with-deb-dir=DIR],
+        [Directory for build Debian packages]),
+    [AC_CHECK_PROG(DEBUILD, dpkg-buildpackage, "yes", "no")
+     AS_IF([test "x$DEBUILD" != xyes],
+         [AC_MSG_ERROR([dpkg-buildpackage needs to be installed])],
+             [test "x$with_rpm_dir" != "xno"],
+                            [AC_MSG_ERROR([--with-deb-dir and --with-rpm-dir are mutually exclusive])])],
+    [with_deb_dir=no])
+
+AC_MSG_CHECKING([deb package])
+if test "x$with_deb_dir" = "xno"; then
+    AC_MSG_RESULT([no])
+    DEB_DIR="/tmp"
+else
+    AC_MSG_RESULT([yes])
+    AC_MSG_NOTICE([deb directory: $with_deb_dir])
+    DEB_DIR="$with_deb_dir"
+fi
+AC_SUBST(DEB_DIR)
+AM_CONDITIONAL([ENABLE_DEB_BUILD],[test "x$with_deb_dir" != "xno"])
+
+
+#
+# Configuration option --with-gcov-report-dir=DIR
+#   If this option is given, gcov unit test coverage analysis is enabled and
+#   results are copied to the directory.
+#
 AC_ARG_WITH([gcov-report-dir],
     AS_HELP_STRING([--with-gcov-report-dir=DIR],
         [Directory for GCOV report files]),
index 1db652e..a96bebe 100644 (file)
@@ -1,7 +1,7 @@
 Source: sdl
 Priority: optional
 Maintainer: Rolf Badorek <rolf.badorek@nokia.com>
-Build-Depends: debhelper (>= 10), pkg-config, libtool, automake, gawk, autoconf, automake, autoconf-archive, make, gcc, libboost-all-dev, libhiredis-dev
+Build-Depends: debhelper (>= 10), pkg-config, libtool, automake, gawk, autoconf, automake, autoconf-archive, make, gcc, libboost-filesystem-dev, libboost-program-options-dev, libboost-system-dev, libhiredis-dev
 Standards-Version: 4.1.2
 Section: libs