autoconf 2.59c has introduced docdir, htmldir, so we do not need to
have --with-doc-dir= and --with-html-dir= any more. --docdir= and
--htmldir= will do the job.
This rewrites the variadic macro PTP_CNT_INIT() and the ptp_init_container()
function such that they compile with the strictest compiler available:
clang -std=c99 -pedantic -Wall -Wextra -Weverything
This is achieved by moving the code argument to be the first of the
variable arguments, and adapting the parameter counting and argument
handling inside ptp_init_container() accordingly.
As the code in ptp_init_container() which handles the va_args and puts
them into PTPContainer Param<N> fields relies on a particular memory
layout of the PTPContainer struct, this adds compile time assertions
which check the memory layout is the one the code expects.
Closes: https://github.com/gphoto/libgphoto2/pull/740
C11 has added static_assert(EXPR, MSG) to assert.h, but C99
only knows runtime assertions using assert(EXPR). This
defines the COMPILETIME_ASSERT(EXPR) macro which works with
both C11 and later using static_assert(), and another way
if compiling using a pre-C11 language standard.
Only use a single gphoto-m4/ subdir - namely that in
libgphoto2_port/gphoto-m4/. This prevents us from
needing to synchronize the contents of the gphoto-m4/
and the libgphoto2_port/gphoto-m4/ directories.
We can do that by switching from recursive make for the
gphoto-m4 subdirectories to using
include path/to/gphoto-m4/Makefile-files
from both the top-level Makefile.am and libgphoto2_port/Makefile.am
using %reldir% (introduced in automake 1.14).
This gives us a few more features, and a few less conditionals
conditionally reimplementing features added to automake
before automake 1.14.
automake 1.14 is almost the same automake version requirement
as libexif uses (libexif requires 1.14.1).
automake 1.14 has been released 2013-06-20. If you ever
need to build a post 2021 libgphoto2 from git on a
system with pre 1.14 automake, you can can always
prepare a tarball using "make dist" on a system with
automake 1.14 or later, and build that tarball on the
older machine.
This gives us a few more features and bug fixes and fewer workarounds.
autoconf 2.69 is the same autoconf version requirement as libexif
uses.
autoconf 2.69 has been released 2012-04-25. If you ever need to build a
post 2021 libgphoto2 from git on a system with pre 2.69 autoconf, you
can always prepare a tarball using "make dist" on a system with autoconf
2.69 or later, and build that tarball on the older machine.
This adds a list of tool releases with their respective release
dates and why they are important for libgphoto2 (libexif
requirements, notable bug fixes and features).
The "localedir" variable has been introduced by autoconf-2.59c.
We are requiring at least autoconf-2.62, so we do not need to
define and AC_SUBST "localedir" any more.
This puts AM_PO_SUBDIRS before AM_GNU_GETTEXT to fix the
error: `po-directories' is already registered with AC_CONFIG_COMMANDS.
and puts the -DLOCALEDIR definition close to the gettext
setup.
Use the same checks for asm .symver and -Wl,--version-script
support for both libgphoto2.la and libgphoto2_port.la.
This also reorganizes the Makefile.am files for libgphoto2.la
and libgphoto2_port.la so that things belonging together are
actually grouped together, so that inconsistencies can become
more visible.
This does not change what actually happens with when linking
the libraries:
* libgphoto2.la is still linked with just a
--export-symbols libgphoto2.sym
list of exported symbols.
* libgphoto2_port.la is still linked with a
-Wl,--version-script=libgphoto2_port.ver
version script.
However, the two library Makefile.am are now organized
in such a way that you can actually see that.
We should examine what those two symbol export methods actually
do on Linux/ELF (complete support for version script semantics),
and on non-ELF systems such as MacOSX dylib or Windows DLL.
Update the checks for libjpeg to try libjpeg.pc with
PKG_CHECK_MODULES first, and also to allow explicitly
set LIBJPEG_CFLAGS and LIBJPEG_LIBS.
The old detection logic did not allow specifying the location
of libjpeg at all. It only allowed either disabling libjpeg
or using libjpeg from the default include and linker paths.
So this also changes the places in the Makefiles where we
used to add @LIBJPEG@ to the linker to both link with
$(LIBJPEG_LIBS) and compile with $(LIBJPEG_CFLAGS).
The new configure logic keeps --without-jpeg to force-
disable libjpeg, but updates the detection of libjpeg
to first try the LIBJPEG_* variables if given, otherwise
try PKG_CHECK_MODULES for libjpeg, and only then falls
back to the old way of just trying the default include
and link locations for libjpeg.
This mentions more information in the configure summary
if not building with libjpeg.
This is the first time we make it possible to build with
libjpeg from e.g. FreeBSD ports' or MacOS homebrew's
jpeg-turbo packages.
We still do not use LTDL_INIT() as LTDL_INIT insists on
us shipping libltdl sources in our release tarballs and
we still do not like shipping third party sources.
This now checks locations other than the default include
and linker paths, so that configure should find libltdl
by itself now on e.g. FreeBSD or OSX/homebrew.
Make the compiler warnings work with clang in addition to gcc by
test compiling all warning options before actually using them.
This came up when the pedantic build tests failed on FreeBSD 13.
To achieve this, we add -Werror=unknown-warning-option to
the CFLAGS for clang to abort immediately on encountering
an unknown warning option. This means we now only add warnings
which the compiler (clang, gcc, or whatever) actually supports.
As running configure now checks whether compiling is possible
for each warning flag, this should not introduce compatibility
issues where builds which used to work now fail to build.
However, you can always opt to not use the generated CFLAGS
by setting CFLAGS to empty or whatever else you want when
running your build, e.g. like
make all check CFLAGS=
Add a pedantic C compile test for c2x in addition to
the existing ones for c90, c99, and c11.
Add a pedantic C++ compile test for c++20 in addition to
the existing ones for c++98, c++11, c++14, and c++17.
Always define the test programs, but only conditionally test them.
This makes certain that they can be build, that the sources are
added to the dist tarball, etc.
These did not work with C++ on FreeBSD 13 anyway, due to
c++98 not working there, which the old pedantic compilation
just assumed was working without testing it in configure.
The new pedantic compilation tests offer a multitude of
language standards including c++98, but only tries building
the pedantic compilation tests for those language standards
for which configure has shown that building programs is
possible at all.
Fix the GP_SLEEP invocation in the Gentoo hack warning which
adds the ptp2 camlib if the only camlib requested is canon, as
modern Canon cameras use the ptp2 camlib, not the canon camlib.
Also syncs gphoto-m4/gp-camlibs.m4 to libgphoto2-port/gphoto-m4/.
The printf(3) format string character "%m" is available on
Linux/glibc and FreeBSD, but not on MacOSX. So using "%m"
should be limited to system specific code.