Autotools: do not include library when doing "make check"

So, I am writing tests for my code, and I want to disable library function calls (make sure that it calls the correct library calls at the right time and that it handles errors accordingly).

I think I am SOL with the standard C library functions, but these are not the only libraries that I use.

When creating my final executable (and not my test executable) I want to use -lfuse, so I included this line in myconfigure.ac

AC_CHECK_LIB([fuse], [fuse_main])

However, it also rushes in -lfusewhen trying to create mine check_PROGRAMS.

Is there a way I can tell autotools that I don't need a library -lfusewhen creating my test executable ( make check)? Then I must be able to fill in the library calls as I want, since nothing will be associated with the same name.

+3
source share
2 answers

I see that libfuse delivers the file fuse.pcto its source distribution, so the right way to check it is to use it pkg-config. You can do

PKG_CHECK_MODULES([APPNAME], [fuse ...and any other libraries to check for...])

in configure.acand then

appname_CFLAGS += @APPNAME_CFLAGS@
appname_LIBS += @APPNAME_LIBS@

c src/Makefile.am. Then just do not add these variables to your test programs.

+1
source

, , . , , , , - - .

/ configure.ac

 AC_SUBST([HAVE_LIBFUSE])
 AC_CHECK_LIB([fuse], [fuse_main], [HAVE_LIBFUSE=1])

-lfuse <appname>_LDADD src/Makefile.am, , , , .

, , , , .

0

Source: https://habr.com/ru/post/1755583/


All Articles