commit 7eaf997f527107beac3379da6b814ac7b783ebc0 from: Anna via: Omar Polo date: Thu Aug 19 09:10:26 2021 UTC configure: add --with-libimsg option commit - 8671caea20ee6eb43a2b4005a0429cddf9266d4a commit + 7eaf997f527107beac3379da6b814ac7b783ebc0 blob - 5efad90e9ec8a5e4ddd9ca4ba66d2491dfa1f060 blob + ea03666a0ed569fc992b5d10526381f43a9bf5bf --- README.md +++ README.md @@ -83,6 +83,12 @@ To build from a release tarball just execute: make sudo make install +The configure script has optional support for building with libraries +provided by your distribution instead of internal compatibility funcs: + + - `--with-libimsg`: link with the + [imsg-compat](https://github.com/bsd-ac/imsg-compat) library + If you want to build from the git checkout, something that's discouraged for users that don't intend to hack on telescope blob - b8f98cb5c6e5fe7790cea23b8d7520b9b71db12e blob + 50a4c8463e720db999afd8a7439dadf1d102a913 --- compat.h +++ compat.h @@ -45,12 +45,16 @@ # include "compat/queue.h" #endif -#ifdef HAVE_LIBUTIL +#ifdef HAVE_IMSG # include +#else +# include "compat/imsg.h" +#endif + +#ifdef HAVE_LIBUTIL # include # include #else -# include "compat/imsg.h" # include "compat/ohash.h" # define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */ int fmt_scaled(long long, char *); blob - 734736d5102fb46b8da50d9ada97a803119cf7aa blob + dd2c97f2053529099aeed212f71d8b28769559db --- configure.ac +++ configure.ac @@ -8,6 +8,10 @@ AC_PROG_YACC PKG_PROG_PKG_CONFIG +AC_ARG_WITH([libimsg], + AS_HELP_STRING([--with-libimsg], + [Build with imsg-compat library (default: disabled)])) + AC_REPLACE_FUNCS([ asprintf \ err \ @@ -74,9 +78,23 @@ case "$host_os" in ;; esac -AC_CHECK_LIB(util, imsg_init, [], [ - AC_LIBOBJ(imsg) - AC_LIBOBJ(imsg-buffer) +AS_IF([test "x$with_libimsg" = "xyes"], [ + PKG_CHECK_MODULES([libimsg], [libimsg], [ + CFLAGS="$libimsg_CFLAGS $CFLAGS" + LIBS="$libimsg_LIBS $LIBS" + ]) +]) + +AC_SEARCH_LIBS([imsg_init], [util], [ + AC_DEFINE([HAVE_IMSG], 1, + [Define to 1 if you have imsg functions (-lutil or -limsg).]) + ], [ + AC_LIBOBJ(imsg) + AC_LIBOBJ(imsg-buffer) + ] +) + +AC_CHECK_LIB(util, ohash_init, [], [ AC_LIBOBJ(ohash) AC_LIBOBJ(fmt_scaled) ])