[vlmc-devel] [PATCH] Initialized autotools build system.

Hugo Beauzée-Luyssen hugo at beauzee.fr
Sat Apr 30 19:02:44 CEST 2016


On 04/28/2016 06:07 PM, Paweł Wegner wrote:
> ---
>  Makefile.am           |  2 ++
>  configure.ac          | 15 +++++++++++++++
>  src/ICloudStorage.cpp | 15 +++++++++++++++
>  src/ICloudStorage.h   | 16 ++++++++++++++++
>  src/Makefile.am       |  6 ++++++
>  test/Makefile.am      |  5 +++++
>  test/main.cpp         |  6 ++++++
>  7 files changed, 65 insertions(+)
>  create mode 100644 Makefile.am
>  create mode 100644 configure.ac
>  create mode 100644 src/ICloudStorage.cpp
>  create mode 100644 src/ICloudStorage.h
>  create mode 100644 src/Makefile.am
>  create mode 100644 test/Makefile.am
>  create mode 100644 test/main.cpp
> 
> diff --git a/Makefile.am b/Makefile.am
> new file mode 100644
> index 0000000..a7d191e
> --- /dev/null
> +++ b/Makefile.am
> @@ -0,0 +1,2 @@
> +ACLOCAL_AMFLAGS = -I m4
> +SUBDIRS = src test
> diff --git a/configure.ac b/configure.ac
> new file mode 100644
> index 0000000..290d69f
> --- /dev/null
> +++ b/configure.ac
> @@ -0,0 +1,15 @@
> +AC_INIT([libcloudstorage], [1.0])
> +AM_INIT_AUTOMAKE([foreign subdir-objects])
> +AC_CONFIG_MACRO_DIRS([m4])
> +LT_INIT
> +
> +AC_PROG_CC
> +AC_PROG_CXX
> +

I don't think you need AC_PROG_CC since this is going to be C++ only

> +AC_CONFIG_FILES([
> +  Makefile
> +  src/Makefile
> +  test/Makefile
> +])
> +
> +AC_OUTPUT

I'm not sure it's worth commiting test files.
Granted those are needed to test the build system, but maybe it would be
better to have the basic includes and implementation before linking them
to the build system (as far as the commit go, at least)

> diff --git a/src/ICloudStorage.cpp b/src/ICloudStorage.cpp
> new file mode 100644
> index 0000000..0cb7b46
> --- /dev/null
> +++ b/src/ICloudStorage.cpp
> @@ -0,0 +1,15 @@
> +#include "ICloudStorage.h"
> +
> +#include <cstdio>
> +#include <vector>
> +
> +namespace cloudstorage {
> +
> +ICloudStorage::ICloudStorage() {
> +  for (int t : std::vector<int>(5, 4)) printf("%d\n", t); // C++11 test
> +  printf("ICloudStorage!\n");
> +}
> +
> +ICloudStorage::~ICloudStorage() {}

Please use '= default' instead, for future empty destructors

> +
> +};  //  namespace cloudstorage
> diff --git a/src/ICloudStorage.h b/src/ICloudStorage.h
> new file mode 100644
> index 0000000..d31bd63
> --- /dev/null
> +++ b/src/ICloudStorage.h
> @@ -0,0 +1,16 @@
> +#ifndef ICLOUDSTORAGE_H
> +#define ICLOUDSTORAGE_H
> +
> +namespace cloudstorage {
> +
> +class ICloudStorage {
> + public:
> +  ICloudStorage();
> +  virtual ~ICloudStorage();
> +
> + private:
> +};
> +
> +}  //  namespace cloudstorage
> +
> +#endif  //  ICLOUDSTORAGE_H
> diff --git a/src/Makefile.am b/src/Makefile.am
> new file mode 100644
> index 0000000..d5dd7ac
> --- /dev/null
> +++ b/src/Makefile.am
> @@ -0,0 +1,6 @@
> +ACLOCAL_AMFLAGS = -I m4
> +
> +AM_CXXFLAGS = -std=c++11

Please use
https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
instead

> +
> +lib_LTLIBRARIES = libcloudstorage.la
> +libcloudstorage_la_SOURCES = ICloudStorage.cpp
> diff --git a/test/Makefile.am b/test/Makefile.am
> new file mode 100644
> index 0000000..3be1db5
> --- /dev/null
> +++ b/test/Makefile.am
> @@ -0,0 +1,5 @@
> +AM_LDFLAGS = $(top_srcdir)/src/libcloudstorage.la
> +AM_CXXFLAGS = -I$(top_srcdir)/src -std=c++11
> +
> +bin_PROGRAMS = main
> +main_SOURCES = main.cpp

There are some test specific targets in automake:
https://www.gnu.org/software/automake/manual/html_node/Tests.html

> diff --git a/test/main.cpp b/test/main.cpp
> new file mode 100644
> index 0000000..e75b175
> --- /dev/null
> +++ b/test/main.cpp
> @@ -0,0 +1,6 @@
> +#include <ICloudStorage.h>
> +
> +int main() {
> +  cloudstorage::ICloudStorage obj;
> +  return 0;
> +}
> 

I realize autotools is not the most shiny way, but I trully believe it
will make things easier in the future, once we need to build this
library on "exotic" platforms.

Thanks!

-- 
Hugo Beauzée-Luyssen
www.beauzee.fr


More information about the Vlmc-devel mailing list