From 919671c89bb9c875bdf5cdcc31e9f3e1b4214a10 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 22 Jan 2022 12:02:00 +0100 Subject: CI: build automake based example project Add automake based example project using libgphoto2 to have the CI builds ensure that building a libgphoto2 frontend with this libgphoto2 is possible. --- examples/ambs-lgp2-frontend/.gitignore | 19 ++++++++++++++++ examples/ambs-lgp2-frontend/Makefile.am | 6 ++++++ examples/ambs-lgp2-frontend/README.md | 11 ++++++++++ examples/ambs-lgp2-frontend/auto-m4/.gitignore | 0 examples/ambs-lgp2-frontend/configure.ac | 30 ++++++++++++++++++++++++++ examples/ambs-lgp2-frontend/main.c | 29 +++++++++++++++++++++++++ 6 files changed, 95 insertions(+) create mode 100644 examples/ambs-lgp2-frontend/.gitignore create mode 100644 examples/ambs-lgp2-frontend/Makefile.am create mode 100644 examples/ambs-lgp2-frontend/README.md create mode 100644 examples/ambs-lgp2-frontend/auto-m4/.gitignore create mode 100644 examples/ambs-lgp2-frontend/configure.ac create mode 100644 examples/ambs-lgp2-frontend/main.c (limited to 'examples') diff --git a/examples/ambs-lgp2-frontend/.gitignore b/examples/ambs-lgp2-frontend/.gitignore new file mode 100644 index 000000000..f5a737c8b --- /dev/null +++ b/examples/ambs-lgp2-frontend/.gitignore @@ -0,0 +1,19 @@ +# autoreconf +/aclocal.m4 +/auto-aux/ +/auto-config.h.in +/autom4te.cache/ +/configure + +# ./configure +/auto-config.h +/config.log +/config.status +/stamp-h1 + +# make +/ambs-lgp2-frontend +/ambs-lgp2-frontend.exe + +# make dist +/ambs-lgp2-frontend-*.tar.gz diff --git a/examples/ambs-lgp2-frontend/Makefile.am b/examples/ambs-lgp2-frontend/Makefile.am new file mode 100644 index 000000000..57d21ee69 --- /dev/null +++ b/examples/ambs-lgp2-frontend/Makefile.am @@ -0,0 +1,6 @@ +ACLOCAL_AMFLAGS = -I auto-m4 + +bin_PROGRAMS = ambs-lgp2-frontend +ambs_lgp2_frontend_SOURCES = main.c +ambs_lgp2_frontend_LDADD = $(LIBGPHOTO2_LIBS) +ambs_lgp2_frontend_CFLAGS = $(LIBGPHOTO2_CFLAGS) diff --git a/examples/ambs-lgp2-frontend/README.md b/examples/ambs-lgp2-frontend/README.md new file mode 100644 index 000000000..c06f15b4a --- /dev/null +++ b/examples/ambs-lgp2-frontend/README.md @@ -0,0 +1,11 @@ +automake buildsystem based example libgphoto2 frontend +==================================================== + +This is an example libgphoto2 frontend project using an automake base +build system. + +Its main purpose is to allow libgphoto2 CI builds to test building a +libgphoto2 frontend against the built libgphoto2 without needing to +clone and build the complete gphoto2 command line interface frontend. + +Additionally, it may serve as a bit of documentation by example. diff --git a/examples/ambs-lgp2-frontend/auto-m4/.gitignore b/examples/ambs-lgp2-frontend/auto-m4/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/examples/ambs-lgp2-frontend/configure.ac b/examples/ambs-lgp2-frontend/configure.ac new file mode 100644 index 000000000..79f105f8d --- /dev/null +++ b/examples/ambs-lgp2-frontend/configure.ac @@ -0,0 +1,30 @@ +AC_PREREQ([2.69]) +AC_INIT([automake buildsystem libgphoto2 frontend], + [0.0.1], + [https://github.com/gphoto/libgphoto2], + [ambs-lgp2-frontend]) +AC_CONFIG_SRCDIR([main.c]) +AC_CONFIG_HEADERS([auto-config.h]) +AC_CONFIG_AUX_DIR([auto-aux]) +AC_CONFIG_MACRO_DIR([auto-m4]) + +AM_INIT_AUTOMAKE([ + -Wall + foreign + 1.16 + subdir-objects +]) + +AM_SILENT_RULES([no]) + +AC_PROG_CC + + +m4_pattern_forbid([^PKG_CHECK_MODULES])dnl +PKG_CHECK_MODULES([LIBGPHOTO2], [libgphoto2]) + + +AC_CONFIG_FILES([ + Makefile +]) +AC_OUTPUT diff --git a/examples/ambs-lgp2-frontend/main.c b/examples/ambs-lgp2-frontend/main.c new file mode 100644 index 000000000..cc3c9f13a --- /dev/null +++ b/examples/ambs-lgp2-frontend/main.c @@ -0,0 +1,29 @@ +#include + +#include + +/* The purpose of this code is to use things defined in gphoto2 header + * files and then link to libgphoto2. */ + +static +struct { + const char *const title; + GPVersionFunc version_func; +} versions[] = { + {"libgphoto2_port", gp_port_library_version}, + {"libgphoto2", gp_library_version} +}; + +int main() +{ + for (size_t i=0; i<(sizeof(versions)/sizeof(versions[0])); i++) { + const char *const title = versions[i].title; + const GPVersionFunc version_func = versions[i].version_func; + const char **version_data = version_func(GP_VERSION_VERBOSE); + printf("%s\n", title); + for (size_t j=0; version_data[j]; j++) { + printf(" %s\n", version_data[j]); + } + } + return 0; +} -- cgit v1.2.1