1 dnl Copyright © 2019 Nick Bowler
3 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 dnl This is free software: you are free to do what the fuck you want to.
5 dnl There is NO WARRANTY, to the extent permitted by law.
7 AT_BANNER([Library tests])
9 dnl TEST_DUMMY_PKGCONFIG([cflags], [libs])
11 dnl Create a hack pkg-config script in the current working directory which
12 dnl responds to --cflags and --libs with the provided values. The macro
13 dnl arguments should each be a single shell word, suitable for the right
14 dnl hand side of a shell assignment.
15 m4_define([TEST_DUMMY_PKGCONFIG],
16 [[cat >pkg-config <<EOF
22 --cflags) cflags=]$1[;;
26 printf '%s %s\n' "\$cflags" "\$libs"
31 AT_SETUP([libdiscid probes])
32 AT_KEYWORDS([libdiscid])
35 AT_DATA([discid/discid.h],
36 [[typedef void DiscId;
37 DiscId *discid_new(void);
38 void discid_free(DiscId *);
39 #ifndef DISCID_VERSION_MAJOR
40 # define DISCID_VERSION_MAJOR 2
50 TEST_CONFIGURE_AC([[DX_LIB_LIBDISCID([1.2.3], [HAVE_LIBDISCID=yes],
52 AC_SUBST([HAVE_LIBDISCID])
53 AC_CONFIG_FILES([test])
57 # Check the search via explicit flags
58 TEST_CONFIGURE([LIBDISCID_CFLAGS=-I. LIBDISCID_LIBS="$builddir/t/libdummy.a"])
59 AT_CHECK_UNQUOTED([cat test], [0], [yes
61 $builddir/t/libdummy.a
64 # Check the search via pkg-config
65 TEST_DUMMY_PKGCONFIG([-I.], [$builddir/t/libdummy.a])
66 TEST_CONFIGURE([PKG_CONFIG=$PWD/pkg-config])
67 AT_CHECK_UNQUOTED([cat test], [0], [yes
69 $builddir/t/libdummy.a
72 # Check the default -ldiscid search
73 cp "$builddir/t/libdummy.a" libdiscid.a
74 TEST_CONFIGURE([PKG_CONFIG=false CFLAGS=-I. LDFLAGS=-L.])
75 AT_CHECK_UNQUOTED([cat test], [0], [yes
80 # Check the failure case
81 TEST_CONFIGURE([PKG_CONFIG=false CFLAGS='-I. -DDISCID_VERSION_MAJOR=0'])
82 AT_CHECK_UNQUOTED([cat test], [0], [no