summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2022-01-22 12:02:00 +0100
committerHans Ulrich Niedermann <hun@n-dimensional.de>2022-01-23 15:41:05 +0100
commit919671c89bb9c875bdf5cdcc31e9f3e1b4214a10 (patch)
treebcde921b42ec3f1ae06303eaeae8a74957390939 /examples
parentbd5aec38d1ef2320b41d8f5404bbfaf80444936b (diff)
downloadlibgphoto2-919671c89bb9c875bdf5cdcc31e9f3e1b4214a10.tar.gz
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.
Diffstat (limited to 'examples')
-rw-r--r--examples/ambs-lgp2-frontend/.gitignore19
-rw-r--r--examples/ambs-lgp2-frontend/Makefile.am6
-rw-r--r--examples/ambs-lgp2-frontend/README.md11
-rw-r--r--examples/ambs-lgp2-frontend/auto-m4/.gitignore0
-rw-r--r--examples/ambs-lgp2-frontend/configure.ac30
-rw-r--r--examples/ambs-lgp2-frontend/main.c29
6 files changed, 95 insertions, 0 deletions
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
--- /dev/null
+++ b/examples/ambs-lgp2-frontend/auto-m4/.gitignore
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 <stdio.h>
+
+#include <gphoto2/gphoto2-version.h>
+
+/* 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;
+}