michaelrsweet / pdfio

PDFio is a simple C library for reading and writing PDF files.
https://www.msweet.org/pdfio
Apache License 2.0
198 stars 44 forks source link

Switch to autoconf/configure #54

Closed michaelrsweet closed 11 months ago

michaelrsweet commented 11 months ago

Based on some feedback (see #53) about issues with the current portable makefile build system, switch to using autoconf to create a configure script that handles generating the makefile. Specific goals:

michaelrsweet commented 11 months ago

Implemented...

eli-schwartz commented 11 months ago

Autoconf provides this:

PKG_CHECK_MODULES([ZLIB], [zlib >= 1.0], , [ZLIB_LIBS=-lz])

which requires pkg-config installed when running autoconf, lets you drop 8 lines from configure.ac, and provides some free additional help text:

$ ./configure --help
 [...]
Some influential environment variables:
[...]
  PKG_CONFIG  path to pkg-config utility
  PKG_CONFIG_PATH
              directories to add to pkg-config's search path
  PKG_CONFIG_LIBDIR
              path overriding pkg-config's built-in search path
  ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config
  ZLIB_LIBS   linker flags for ZLIB, overriding pkg-config
michaelrsweet commented 11 months ago

@eli-schwartz I actually don't have any experience using the PKG_CHECK_MODULES macro, primarily because it isn't part of autoconf. It requires the use of aclocal (or you need to AC_INCLUDE the pkg.m4 file in the aclocal directory), not to mention the pkg.m4 file is provided under the GPLv2 which isn't compatible with PDFio's Apache 2.0 library (sigh...)

eli-schwartz commented 11 months ago

not to mention the pkg.m4 file is provided under the GPLv2 which isn't compatible with PDFio's Apache 2.0 library (sigh...)

This turns out to not be the case. For two reasons.

Autoconf is also GPL software, but GPL 3, which is compatible with Apache 2.

The pkg.m4 is "either version 2 of the License, or (at your option) any later version.", a fairly common way to use the GPL2 that permits projects such as PDFio to accept it under the GPL3 license terms. It is not Apache, but it is compatible.

But also, there is a special exception clause in autoconf itself, which means you don't need to be compatible with the GPL3 either and you can still ship a generated configure script and its config.sub/config.guess and related software: https://github.com/michaelrsweet/pdfio/blob/c992b2ba8900238c3a50f26dcdab34b4ee8296a7/config.guess#L9-L27

And pkg.m4 has the same exception clause. It was part of the initial addition of licensing terms in https://gitlab.freedesktop.org/pkg-config/pkg-config/-/commit/b1584b5aaf9ce396e61599caff2b5e15f01daf91 from 2004.

dnl As a special exception to the GNU General Public License, if you
dnl distribute this file as part of a program that contains a
dnl configuration script generated by Autoconf, you may include it under
dnl the same distribution terms that you use for the rest of that
dnl program.